From b280414eedf34d32ca252db605e25a854b040a2c Mon Sep 17 00:00:00 2001 From: Bob Gendler Date: Tue, 10 May 2022 16:44:41 -0400 Subject: [PATCH] many schema fixes --- scripts/generate_scap.py | 121 ++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 58 deletions(-) diff --git a/scripts/generate_scap.py b/scripts/generate_scap.py index 85e3f433..d5f95065 100755 --- a/scripts/generate_scap.py +++ b/scripts/generate_scap.py @@ -45,25 +45,27 @@ def generate_scap(all_rules, all_baselines): scapPrefix = ''' - - + + - + - + - + - + + - - + + + @@ -79,18 +81,16 @@ def generate_scap(all_rules, all_baselines): Security Content Automation Protocol National Institute of Standards and Technology - platform-cpe-dictionary - platform-cpe-oval + platform-cpe-dictionary + platform-cpe-oval - {3} + {3} National Institute of Standards and Technology National Institute of Standards and Technology - https://github.com/usnistgov/macos_security/releases/latest - Bob Gendler - National Institute of Standards and -Technology - Dan Brodjieski - National Aeronautics and Space -Administration + https://github.com/usnistgov/macOS_security/releases/latest + Bob Gendler - National Institute of Standards and Technology + Dan Brodjieski - National Aeronautics and Space Administration Allen Golbig - Jamf '''.format(date_time_string, version_yaml['os'], version_yaml['cpe'], version_yaml['version'],date_time_string.split("T")[0] + "Z") @@ -184,12 +184,14 @@ Administration else: severity = "unknown" check = str() - if "inherent" not in rule_yaml['tags'] or "n_a" in rule_yaml['tags'] or "permenant" in rule_yaml['tags']: + if "inherent" in rule_yaml['tags'] or "n_a" in rule_yaml['tags'] or "permenant" in rule_yaml['tags']: check = ''' - '''.format(x) + ''' else: - check = "" + check = ''' + + '''.format(x) references = str() if "800-53r5" in rule_yaml['references'] and rule_yaml['references']['800-53r5'][0] != "N/A": @@ -236,8 +238,11 @@ Administration {3} {4} -{5}{9}{6} - {7}{8} +{5}{9} +{6} + {7} + {8} + '''.format(rule_yaml['id'] + "_" + odv_label, severity, rule_yaml['title'], rule_yaml['discussion'].replace("<","<").replace(">",">").replace("&","&"), rule_yaml['check'].replace("<","<").replace(">",">").replace("&","&"), result, cce,rule_yaml['fix'].replace("<","<").replace(">",">").replace("&","&"), check, references) @@ -301,7 +306,7 @@ Administration {} - + {} @@ -367,7 +372,7 @@ Administration {} - + {} @@ -415,7 +420,7 @@ Administration {} - + {} @@ -483,7 +488,7 @@ Administration {} - + {} @@ -521,7 +526,7 @@ Administration {} - + {} @@ -572,7 +577,7 @@ Administration {} - + {} @@ -638,7 +643,7 @@ Administration {} - + {} @@ -703,7 +708,7 @@ Administration {} - + {} @@ -769,7 +774,7 @@ Administration {} - + {} @@ -833,7 +838,7 @@ Administration {} - + {} @@ -898,7 +903,7 @@ Administration {} - + {} @@ -943,7 +948,7 @@ Administration {} - + {} @@ -1005,7 +1010,7 @@ Administration {} - + {} @@ -1116,7 +1121,7 @@ Administration {} - + {} @@ -1156,7 +1161,7 @@ Administration {} - + {} @@ -1198,7 +1203,7 @@ Administration {} - + {} @@ -1250,7 +1255,7 @@ Administration {} - + {} @@ -1347,7 +1352,7 @@ Administration {} - + {} @@ -1472,7 +1477,7 @@ Administration {} - + {} @@ -1679,7 +1684,7 @@ Administration {} - + {} @@ -1713,7 +1718,7 @@ Administration {} - + {} @@ -1745,7 +1750,7 @@ Administration {} - + {} @@ -1778,7 +1783,7 @@ Administration {} - + {} @@ -1853,7 +1858,7 @@ Administration {} - + {} @@ -2059,7 +2064,7 @@ Administration {} - + {} @@ -2132,7 +2137,7 @@ Administration {} - + {} @@ -2166,7 +2171,7 @@ Administration {} - + {} @@ -2211,7 +2216,7 @@ Administration {} - + {} @@ -2241,7 +2246,7 @@ Administration {} - + {} @@ -2293,7 +2298,7 @@ Administration {} - + {} @@ -2327,7 +2332,7 @@ Administration {} - + {} @@ -2367,7 +2372,7 @@ Administration total_scap = scapPrefix + scap_profiles + ''' - + All rules All the rules @@ -2378,7 +2383,7 @@ must be run with elevated privileges. ''' + xccdf_rules + ''' - + 5.11.2 @@ -2386,7 +2391,7 @@ must be run with elevated privileges. Copyright (c) 2020, NIST. macOS Security Compliance Project -'''.format(date_time_string) +'''.format(date_time_string,version_yaml['os']) total_oval = "\n\n" + oval_definition + "\n\n\n" + oval_test + "\n\n\n" + oval_object + "\n\n" # total_oval = ovalPrefix + "\n\n" + oval_definition + "\n\n\n" + oval_test + "\n\n\n" + oval_object + "\n\n" if oval_state != "": @@ -2433,7 +2438,7 @@ must be run with elevated privileges. - + @@ -2446,12 +2451,12 @@ must be run with elevated privileges. This CPE Name represents macOS {2} - oval:gov.nist.mscp.content.cpe.oval:def:1 + oval:gov.nist.mscp.content.cpe.oval:def:1 - + macOS Security Compliance Project