usnistgov / macos_security

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

SyntaxWarning: invalid escape sequence '\|' #400

Closed mswer0 closed 1 week ago

mswer0 commented 5 months ago

Summary

Lines 135-140 in generate_baseline.py generate "SyntaxWarning: invalid escape sequence '|'" errors

Steps to reproduce

./scripts/generate_baseline.py -l

Operating System version

macOS 14.5

Intel or Apple Silicon

Apple Silicon

What is the current bug behavior?


/Users/Matt/Downloads/MSCP_Sonoma_Rev_2.0/macos_security-sonoma_rev2/scripts/generate_baseline.py:135: SyntaxWarning: invalid escape sequence '\|'
  all_rules.append(MacSecurityRule(rule_yaml['title'].replace('|', '\|'),
/Users/Matt/Downloads/MSCP_Sonoma_Rev_2.0/macos_security-sonoma_rev2/scripts/generate_baseline.py:136: SyntaxWarning: invalid escape sequence '\|'
  rule_yaml['id'].replace('|', '\|'),
/Users/Matt/Downloads/MSCP_Sonoma_Rev_2.0/macos_security-sonoma_rev2/scripts/generate_baseline.py:137: SyntaxWarning: invalid escape sequence '\|'
  rule_yaml['severity'].replace('|', '\|'),
/Users/Matt/Downloads/MSCP_Sonoma_Rev_2.0/macos_security-sonoma_rev2/scripts/generate_baseline.py:138: SyntaxWarning: invalid escape sequence '\|'
  rule_yaml['discussion'].replace('|', '\|'),
/Users/Matt/Downloads/MSCP_Sonoma_Rev_2.0/macos_security-sonoma_rev2/scripts/generate_baseline.py:139: SyntaxWarning: invalid escape sequence '\|'
  rule_yaml['check'].replace('|', '\|'),
/Users/Matt/Downloads/MSCP_Sonoma_Rev_2.0/macos_security-sonoma_rev2/scripts/generate_baseline.py:140: SyntaxWarning: invalid escape sequence '\|'
  rule_yaml['fix'].replace('|', '\|'),```

### What is the expected *correct* behavior?

These errors do not occur

### Relevant logs and/or screenshots

See above in What is the current *bug* behavior

### Output of checks

See above in What is the current *bug* behavior

### Possible fixes

Fix escape method starting on line 135
https://github.com/usnistgov/macos_security/blob/main/scripts/generate_baseline.py#L135
MHHK89 commented 5 months ago

I have the same issue.