beautified oval and lowercased file name

This commit is contained in:
Bob Gendler
2021-12-08 11:30:34 -05:00
parent 422b2055d1
commit badf9847a3
2 changed files with 16 additions and 4 deletions

View File

@@ -40,7 +40,7 @@ XCCDF:
SCAP-version=1.3 \
id-namespace=content.mscp.nist.gov \
benchmark-id-suffix=macOS_${OS} \
OVAL-URI=${DIR}/All_rules.xml \
OVAL-URI=${DIR}/all_rules.xml \
include-CPE=1
# the input OVAL document will be copied to a companion of the XCCDF document named 'oval.xml'
# a gratuitous OCIL document is provided

View File

@@ -9,6 +9,7 @@ import re
import warnings
from pathlib import Path
from datetime import datetime
import shutil
warnings.filterwarnings("ignore", category=DeprecationWarning)
@@ -38,7 +39,7 @@ def main():
except OSError:
print(f"Creation of the directory {build_path} failed")
print('Profile YAML:', results.baseline.name)
print('Output path:', output)
print('Output path:', output.lower())
@@ -1600,10 +1601,21 @@ def main():
final_oval = re.sub('(?=\n\[NOTE\])(?s)(.*)\=\n$.*', '<', total_oval)
# final_oval = re.sub('(?=\n\[NOTE\])(?s)(.*)\=\n<', '<', total_oval)
oval_file = output
oval_file = output.lower()
with open(oval_file,'w') as rite:
with open(oval_file + "temp",'w') as rite:
rite.write(final_oval)
cmd = shutil.which('xmllint')
if cmd == None:
try:
os.rename(oval_file + "temp", oval_file)
except:
print("Error writing Oval file.")
else:
cmd = cmd + " " + oval_file + "temp --format --output " + oval_file
os.popen(cmd).read()
if os.path.exists(oval_file):
os.remove(oval_file + "temp")
if __name__ == "__main__":
main()