Skip to content

Commit 1271274

Browse files
author
Dan Brodjieski
committed
feat: added build number to all docs
1 parent d4f562d commit 1271274

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

VERSION.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ platform: macOS
33
version: "Sonoma Guidance, Revision 2.0"
44
cpe: o:apple:macos:14.0
55
date: "2024-04-24"
6-
build: 1
6+
build: 2

scripts/generate_guidance.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,8 @@ def default_audit_plist(baseline_name, build_path, baseline_yaml):
581581
def generate_script(baseline_name, audit_name, build_path, baseline_yaml, reference, version_yaml):
582582
"""Generates the zsh script from the rules in the baseline YAML
583583
"""
584-
version = version_yaml["version"]
585-
build = version_yaml["build"]
586-
mscp_version = f'{version.split()[-1]}.{build}'
584+
version = version_yaml['version']
585+
mscp_version = version_yaml["mscp_version"]
587586
compliance_script_file = open(f'{build_path}/{baseline_name}_compliance_v{mscp_version}.sh', 'w')
588587

589588
check_function_string = ""
@@ -1346,7 +1345,7 @@ def get_rule_yaml(rule_file, baseline_yaml, custom=False,):
13461345
return resulting_yaml
13471346

13481347

1349-
def generate_xls(baseline_name, build_path, baseline_yaml):
1348+
def generate_xls(baseline_name, build_path, baseline_yaml, version_yaml):
13501349
"""Using the baseline yaml file, create an XLS document containing the YAML fields
13511350
"""
13521351

@@ -1357,7 +1356,7 @@ def generate_xls(baseline_name, build_path, baseline_yaml):
13571356
parent_dir = os.path.dirname(file_dir)
13581357

13591358
# Output files
1360-
xls_output_file = f"{build_path}/{baseline_name}.xls"
1359+
xls_output_file = f"{build_path}/{baseline_name}_v{version_yaml['mscp_version']}.xls"
13611360

13621361

13631362
wb = Workbook()
@@ -1745,9 +1744,6 @@ def main():
17451744
os.makedirs(build_path)
17461745
except OSError:
17471746
print(f"Creation of the directory {build_path} failed")
1748-
adoc_output_file = open(f"{build_path}/{output_filename}.adoc", 'w')
1749-
print('Profile YAML:', args.baseline.name)
1750-
print('Output path:', adoc_output_file.name)
17511747

17521748
if args.hash:
17531749
signing = True
@@ -1771,6 +1767,15 @@ def main():
17711767
version_file = os.path.join(parent_dir, "VERSION.yaml")
17721768
with open(version_file) as r:
17731769
version_yaml = yaml.load(r, Loader=yaml.SafeLoader)
1770+
1771+
if version_yaml["build"] == 0:
1772+
version_yaml["mscp_version"] = f"{version_yaml['version'].split()[-1]}"
1773+
else:
1774+
version_yaml["mscp_version"] = f"{version_yaml['version'].split()[-1]}.{version_yaml['build']}"
1775+
1776+
adoc_output_file = open(f'{build_path}/{output_filename}_v{version_yaml["mscp_version"]}.adoc', 'w')
1777+
print('Profile YAML:', args.baseline.name)
1778+
print('Output path:', adoc_output_file.name)
17741779

17751780
adoc_templates = [ "adoc_rule_ios",
17761781
"adoc_rule",
@@ -1886,7 +1891,11 @@ def main():
18861891
adoc_html_subtitle=baseline_yaml['title'].split(':')[1]
18871892
adoc_document_subtitle2 = ':document-subtitle2:'
18881893

1889-
# Create header
1894+
# Create header
1895+
if version_yaml['build'] == 0:
1896+
header_version = version_yaml['version']
1897+
else:
1898+
header_version = f'{version_yaml["version"]}.{version_yaml["build"]}'
18901899
header_adoc = adoc_header_template.substitute(
18911900
description=baseline_yaml['description'],
18921901
html_header_title=baseline_yaml['title'],
@@ -1901,7 +1910,7 @@ def main():
19011910
stig_attribute=adoc_STIG_show,
19021911
cis_attribute=adoc_cis_show,
19031912
cmmc_attribute=adoc_cmmc_show,
1904-
version=version_yaml['version'],
1913+
version=header_version,
19051914
os_version=version_yaml['os'],
19061915
release_date=version_yaml['date']
19071916
)
@@ -2214,7 +2223,7 @@ def main():
22142223

22152224
if args.xls:
22162225
print('Generating excel document...')
2217-
generate_xls(baseline_name, build_path, baseline_yaml)
2226+
generate_xls(baseline_name, build_path, baseline_yaml, version_yaml)
22182227

22192228
asciidoctor_path = is_asciidoctor_installed()
22202229
if asciidoctor_path != "":

0 commit comments

Comments
 (0)