diff --git a/validation/src/validator.rs b/validation/src/validator.rs index a6618b5..1b59afe 100644 --- a/validation/src/validator.rs +++ b/validation/src/validator.rs @@ -17,9 +17,14 @@ struct NamePolicy{ policy:Policy, } +fn source_has_illegal_keywords(source:&str)->bool{ + source.find("getfenv").is_some()||source.find("require").is_some() +} + #[allow(dead_code)] #[derive(Debug)] pub enum ValidateError{ + Flagged, Blocked, NotAllowed, Get(rbx_asset::cookie::GetError), @@ -96,6 +101,13 @@ impl Validator{ for &script_ref in &script_refs{ if let Some(script)=dom.get_by_ref(script_ref){ if let Some(rbx_dom_weak::types::Variant::String(source))=script.properties.get("Source"){ + // check the source for illegal keywords + if source_has_illegal_keywords(source){ + // immediately abort + return Err(ValidateError::Flagged); + } + // associate a name and policy with the source code + // policy will be fetched from the database to replace the default policy script_map.insert(source.clone(),NamePolicy{ name:script.name.clone(), policy:Policy::None,