From 080778ca97bd3b246237d8927d6e0ea96a738e04 Mon Sep 17 00:00:00 2001 From: Yi Zhao Date: Thu, 5 Nov 2020 14:04:58 +0800 Subject: scap-security-guide: fix build with Python 3.9 The getchildren and getiterator functions are deprecated in Python 3.9. Backport 3 patches to fix the build issue. Fixes: File "/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/scap-security-guide/0.1.44+gitAUTOINC+5fdfdcb2e9-r0/git/ssg/build_stig.py", line 41, in add_references index = rule.getchildren().index(ref) AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren' Signed-off-by: Yi Zhao Signed-off-by: Armin Kuster --- .../0002-fix-deprecated-getiterator-function.patch | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 meta-security-compliance/recipes-openscap/scap-security-guide/files/0002-fix-deprecated-getiterator-function.patch (limited to 'meta-security-compliance/recipes-openscap/scap-security-guide/files/0002-fix-deprecated-getiterator-function.patch') diff --git a/meta-security-compliance/recipes-openscap/scap-security-guide/files/0002-fix-deprecated-getiterator-function.patch b/meta-security-compliance/recipes-openscap/scap-security-guide/files/0002-fix-deprecated-getiterator-function.patch new file mode 100644 index 0000000..84271c4 --- /dev/null +++ b/meta-security-compliance/recipes-openscap/scap-security-guide/files/0002-fix-deprecated-getiterator-function.patch @@ -0,0 +1,58 @@ +From b0adc1d53780def4a95e310b6d26bb91ee97177e Mon Sep 17 00:00:00 2001 +From: Vojtech Polasek +Date: Mon, 8 Jun 2020 13:27:41 +0200 +Subject: [PATCH] fix deprecated getiterator function + +Upstream-Status: Backport +[https://github.com/ComplianceAsCode/content/commit/b0adc1d53780def4a95e310b6d26bb91ee97177e] + +Signed-off-by: Yi Zhao +--- + ssg/build_cpe.py | 6 +++--- + ssg/id_translate.py | 2 +- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/ssg/build_cpe.py b/ssg/build_cpe.py +index 2e5d24a5d..8c046777a 100644 +--- a/ssg/build_cpe.py ++++ b/ssg/build_cpe.py +@@ -17,7 +17,7 @@ def extract_subelement(objects, sub_elem_type): + """ + + for obj in objects: +- for subelement in obj.getiterator(): ++ for subelement in obj.iter(): + if subelement.get(sub_elem_type): + sub_element = subelement.get(sub_elem_type) + return sub_element +@@ -44,12 +44,12 @@ def extract_referred_nodes(tree_with_refs, tree_with_ids, attrname): + reflist = [] + elementlist = [] + +- for element in tree_with_refs.getiterator(): ++ for element in tree_with_refs.iter(): + value = element.get(attrname) + if value is not None: + reflist.append(value) + +- for element in tree_with_ids.getiterator(): ++ for element in tree_with_ids.iter(): + if element.get("id") in reflist: + elementlist.append(element) + +diff --git a/ssg/id_translate.py b/ssg/id_translate.py +index 72b07be18..ba9225904 100644 +--- a/ssg/id_translate.py ++++ b/ssg/id_translate.py +@@ -64,7 +64,7 @@ class IDTranslator(object): + ) + + def translate(self, tree, store_defname=False): +- for element in tree.getiterator(): ++ for element in tree.iter(): + idname = element.get("id") + if idname: + # store the old name if requested (for OVAL definitions) +-- +2.17.1 + -- cgit v1.2.3-54-g00ecf