Skip to content

Commit

Permalink
fixed odv issue, sync branches
Browse files Browse the repository at this point in the history
  • Loading branch information
robertgendler committed Sep 11, 2024
1 parent 862a14a commit 11f29f1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
10 changes: 6 additions & 4 deletions scripts/generate_guidance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1522,9 +1522,10 @@ def fill_in_odv(resulting_yaml, parent_values):
if "$ODV" in resulting_yaml[field]:
resulting_yaml[field] = resulting_yaml[field].replace("$ODV", str(odv))

for result_value in resulting_yaml["result"]:
if "$ODV" in str(resulting_yaml["result"][result_value]):
resulting_yaml["result"][result_value] = odv
if "result" in resulting_yaml.keys():
for result_value in resulting_yaml["result"]:
if "$ODV" in str(resulting_yaml["result"][result_value]):
resulting_yaml["result"][result_value] = odv

if resulting_yaml["mobileconfig_info"]:
for mobileconfig_type in resulting_yaml["mobileconfig_info"]:
Expand Down Expand Up @@ -2560,7 +2561,8 @@ def main():
rule_srg=srg,
)
else:
if version_yaml['platform'] == "iOS/iPadOS":
#using the same rule template for ios/ipados/visionos
if version_yaml['platform'] == "iOS/iPadOS" or version_yaml['platform'] == "visionOS":
rule_adoc = adoc_rule_ios_template.substitute(
rule_title=rule_yaml['title'].replace('|', r'\|'),
rule_id=rule_yaml['id'].replace('|', r'\|'),
Expand Down
9 changes: 9 additions & 0 deletions scripts/generate_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,15 @@ def dir_path(string):
full_baseline = full_baseline + '''
- {}'''.format(rule)

if len(os_section) != 0 and version_yaml['platform'] == "visionOS":
full_baseline = full_baseline + '''
- section: "visionOS"
rules:'''
os_section.sort()
for rule in os_section:
full_baseline = full_baseline + '''
- {}'''.format(rule)

if len(os_section) != 0 and version_yaml['platform'] == "macOS":
full_baseline = full_baseline + '''
- section: "macOS"
Expand Down
15 changes: 12 additions & 3 deletions scripts/generate_scap.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,18 @@ def generate_scap(all_rules, all_baselines, args):
if "ios" in version_yaml['cpe']:
print("OVAL generation is not available on iOS")
exit()

if "visionOS" in version_yaml['cpe']:
print("OVAL generation is not available on visionOS")
exit()

if args.oval == None and args.xccdf == None:
export_as = "scap"
if "ios" in version_yaml['cpe']:
print("iOS will only export as XCCDF")
export_as = "xccdf"
if "visionos" in version_yaml['cpe']:
print("visionOS will only export as XCCDF")
export_as = "xccdf"

now = datetime.now()
date_time_string = now.strftime("%Y-%m-%dT%H:%M:%S")
Expand All @@ -135,7 +140,8 @@ def generate_scap(all_rules, all_baselines, args):
output = "../build/macOS_{0}_Security_Compliance_Benchmark-{1}".format(version_yaml['os'],filenameversion)
if "ios" in version_yaml['cpe']:
output = "../build/iOS_{0}_Security_Compliance_Benchmark-{1}".format(version_yaml['os'],filenameversion)

if "visionos" in version_yaml['cpe']:
output = "../build/iOS_{0}_Security_Compliance_Benchmark-{1}".format(version_yaml['os'],filenameversion)
if export_as == "xccdf":
output = output + "_xccdf.xml"

Expand Down Expand Up @@ -167,8 +173,11 @@ def generate_scap(all_rules, all_baselines, args):
</generator>'''.format(date_time_string)

ostype = "macOS"
if "ios" in version_yaml['cpe']:
if "ios" in version_yaml['cpe'] or "visionos" in version_yaml['cpe']:
ostype = "iOS/iPadOS"
if "visionos" in version_yaml['cpe']:
ostype = "visionOS"

xccdfPrefix = '''<?xml version="1.0" encoding="UTF-8"?>
<Benchmark xmlns="http://checklists.nist.gov/xccdf/1.2" id="xccdf_gov.nist.mscp.content_benchmark_macOS_{1}" style="SCAP_1.3" resolved="true" xml:lang="en">
<status date="{3}">draft</status>
Expand Down

0 comments on commit 11f29f1

Please sign in to comment.