usnistgov / macos_security

macOS Security Compliance Project
Other
1.79k stars 202 forks source link

"check" script in system_settings_screensaver_ask_for_password_delay_enforce.yaml throws a syntax error #449

Open maniqui opened 5 days ago

maniqui commented 5 days ago

https://github.com/usnistgov/macos_security/blob/e22bb0bc02290c54cb968bc3749942fa37ad752b/rules/system_settings/system_settings_screensaver_ask_for_password_delay_enforce.yaml#L7-L18

This "check" script throws the following error

152:174: syntax error: Error on line 3: SyntaxError: Unexpected token ')' (-2700)

The version below (taken from here), which looks exactly the same, does not throw the error:

/usr/bin/osascript -l JavaScript << EOS
function run() {
let delay = ObjC.unwrap($.NSUserDefaults.alloc.initWithSuiteName('com.apple.screensaver')\
.objectForKey('askForPasswordDelay'))
if ( delay <= 5 ) {
return("true")
} else {
return("false")
}
}
EOS
brodjieski commented 5 days ago

Hello! If you copy/paste the check code as-is from the .yaml file for this rule, it will still have the $ODV placeholder that gets filled in during the generation processes. This value needs to be an integer for the check to work. Notice that in the example you provided that worked contains the value of 5 where $ODV is in the code. Leaving the $ODV placeholder in will generate the syntax error you are seeing.