Skip to content

Commit

Permalink
Use CPE lang ns from variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Honny1 committed Mar 5, 2024
1 parent 5811520 commit 5e6c799
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions build-scripts/cpe_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

oval_ns = "http://oval.mitre.org/XMLSchema/oval-definitions-5"
cpe_ns = "http://cpe.mitre.org/dictionary/2.0"
cpe_lang_ns = ssg.constants.PREFIX_TO_NS["cpe-lang"]


def parse_args():
Expand Down Expand Up @@ -115,9 +116,7 @@ def get_benchmark_cpe_names(shorthand_tree):
continue
benchmark_cpe_names.add(cpe_name)
# add CPE names used by factref elements in CPEAL platforms
for fact_ref in shorthand_tree.findall(
".//{%s}fact-ref" % ssg.constants.PREFIX_TO_NS["cpe-lang"]
):
for fact_ref in shorthand_tree.findall(".//{%s}fact-ref" % cpe_lang_ns):
cpe_fact_ref_name = fact_ref.get("name")
benchmark_cpe_names.add(cpe_fact_ref_name)
return benchmark_cpe_names
Expand All @@ -141,9 +140,7 @@ def get_all_cpe_oval_def_ids(shorthand_tree, cpe_dict, benchmark_cpe_names):
if cpe_item.name in benchmark_cpe_names:
out.add(cpe_item.check_id)

for check_fact_ref in shorthand_tree.findall(
".//{%s}check-fact-ref" % ssg.constants.PREFIX_TO_NS["cpe-lang"]
):
for check_fact_ref in shorthand_tree.findall(".//{%s}check-fact-ref" % cpe_lang_ns):
out.add(check_fact_ref.get("id-ref"))
return out

Expand All @@ -157,9 +154,7 @@ def _save_minimal_cpe_oval(oval_document, path, oval_def_ids):


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"]
):
for check_fact_ref in shorthand_tree.findall(".//{%s}check-fact-ref" % cpe_lang_ns):
check_fact_ref.set("href", file_name)


Expand Down

0 comments on commit 5e6c799

Please sign in to comment.