Skip to content

Commit

Permalink
Fix CPE OVAL references
Browse files Browse the repository at this point in the history
  • Loading branch information
Honny1 committed Mar 5, 2024
1 parent 7db8f8b commit 5811520
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion build-scripts/cpe_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ def _save_minimal_cpe_oval(oval_document, path, oval_def_ids):
oval_document.save_as_xml(path, references_to_keep)


def _update_oval_href_in_xccdf(shorthand_tree, file_name):
for check_fact_ref in shorthand_tree.findall(
".//{%s}check-fact-ref" % ssg.constants.PREFIX_TO_NS["cpe-lang"]
):
check_fact_ref.set("href", file_name)


def _generate_cpe_for_thin_xccdf(args, oval_document, cpe_dict):
for xccdf_path in glob.glob("{}/xccdf*.xml".format(args.thin_ds_components_dir)):
cpe_oval_path = xccdf_path.replace("xccdf_", "cpe_oval_")
Expand All @@ -166,8 +173,10 @@ def _generate_cpe_for_thin_xccdf(args, oval_document, cpe_dict):
used_cpe_oval_def_ids = get_all_cpe_oval_def_ids(
shorthand_tree, cpe_dict, benchmark_cpe_names
)
cpe_dict.to_file(cpe_dict_path, cpe_oval_path, benchmark_cpe_names)
cpe_dict.to_file(cpe_dict_path, os.path.basename(cpe_oval_path), benchmark_cpe_names)
_save_minimal_cpe_oval(oval_document, cpe_oval_path, used_cpe_oval_def_ids)
_update_oval_href_in_xccdf(shorthand_tree, os.path.basename(cpe_oval_path))
ssg.xml.ElementTree.ElementTree(shorthand_tree).write(xccdf_path, encoding="utf-8")


def main():
Expand Down

0 comments on commit 5811520

Please sign in to comment.