From 5e6c7998d9fa6b17abd8ff09a69e8472bcf5363a Mon Sep 17 00:00:00 2001 From: Jan Rodak Date: Tue, 5 Mar 2024 11:55:26 +0100 Subject: [PATCH] Use CPE lang ns from variable --- build-scripts/cpe_generate.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/build-scripts/cpe_generate.py b/build-scripts/cpe_generate.py index d07b8c8a759d..735b8f544eef 100755 --- a/build-scripts/cpe_generate.py +++ b/build-scripts/cpe_generate.py @@ -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(): @@ -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 @@ -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 @@ -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)