summaryrefslogtreecommitdiffstats
path: root/meta-security-compliance
diff options
context:
space:
mode:
authorYi Zhao <yi.zhao@windriver.com>2020-11-05 14:04:58 +0800
committerArmin Kuster <akuster808@gmail.com>2020-11-15 11:03:39 -0800
commit080778ca97bd3b246237d8927d6e0ea96a738e04 (patch)
treeb23c2d4a9605cc51e111b27c5cb1aff3d1025ae9 /meta-security-compliance
parentc40e8f8d9dbdd7e2052033d9d50ebf8e4d883c69 (diff)
downloadmeta-security-080778ca97bd3b246237d8927d6e0ea96a738e04.tar.gz
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 <yi.zhao@windriver.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-security-compliance')
-rw-r--r--meta-security-compliance/recipes-openscap/scap-security-guide/files/0001-fix-deprecated-instance-of-element.getchildren.patch43
-rw-r--r--meta-security-compliance/recipes-openscap/scap-security-guide/files/0002-fix-deprecated-getiterator-function.patch58
-rw-r--r--meta-security-compliance/recipes-openscap/scap-security-guide/files/0003-fix-remaining-getchildren-and-getiterator-functions.patch57
-rw-r--r--meta-security-compliance/recipes-openscap/scap-security-guide/scap-security-guide_git.bb3
4 files changed, 161 insertions, 0 deletions
diff --git a/meta-security-compliance/recipes-openscap/scap-security-guide/files/0001-fix-deprecated-instance-of-element.getchildren.patch b/meta-security-compliance/recipes-openscap/scap-security-guide/files/0001-fix-deprecated-instance-of-element.getchildren.patch
new file mode 100644
index 0000000..01e3dd6
--- /dev/null
+++ b/meta-security-compliance/recipes-openscap/scap-security-guide/files/0001-fix-deprecated-instance-of-element.getchildren.patch
@@ -0,0 +1,43 @@
1From e435bf2dc59d652710104a1c59332e410b12bb64 Mon Sep 17 00:00:00 2001
2From: Vojtech Polasek <vpolasek@redhat.com>
3Date: Mon, 8 Jun 2020 12:33:48 +0200
4Subject: [PATCH] fix deprecated instance of element.getchildren
5
6Upstream-Status: Backport
7[https://github.com/ComplianceAsCode/content/commit/e435bf2dc59d652710104a1c59332e410b12bb64]
8
9Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
10---
11 ssg/build_remediations.py | 2 +-
12 ssg/build_stig.py | 2 +-
13 2 files changed, 2 insertions(+), 2 deletions(-)
14
15diff --git a/ssg/build_remediations.py b/ssg/build_remediations.py
16index fdde0f268..c18d6bd54 100644
17--- a/ssg/build_remediations.py
18+++ b/ssg/build_remediations.py
19@@ -735,7 +735,7 @@ def expand_xccdf_subs(fix, remediation_type, remediation_functions):
20 # First concat output form of modified fix text (including text appended
21 # to all children of the fix)
22 modfix = [fix.text]
23- for child in fix.getchildren():
24+ for child in list(fix):
25 if child is not None and child.text is not None:
26 modfix.append(child.text)
27 modfixtext = "".join(modfix)
28diff --git a/ssg/build_stig.py b/ssg/build_stig.py
29index 528285f3d..6122981fc 100644
30--- a/ssg/build_stig.py
31+++ b/ssg/build_stig.py
32@@ -38,7 +38,7 @@ def add_references(reference, destination):
33 for ref in refs:
34 if (ref.get('href').startswith(stig_refs) and
35 ref.text in dictionary):
36- index = rule.getchildren().index(ref)
37+ index = list(rule).index(ref)
38 new_ref = ET.Element(
39 '{%s}reference' % XCCDF11_NS, {'href': stig_ns})
40 new_ref.text = dictionary[ref.text]
41--
422.17.1
43
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 @@
1From b0adc1d53780def4a95e310b6d26bb91ee97177e Mon Sep 17 00:00:00 2001
2From: Vojtech Polasek <vpolasek@redhat.com>
3Date: Mon, 8 Jun 2020 13:27:41 +0200
4Subject: [PATCH] fix deprecated getiterator function
5
6Upstream-Status: Backport
7[https://github.com/ComplianceAsCode/content/commit/b0adc1d53780def4a95e310b6d26bb91ee97177e]
8
9Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
10---
11 ssg/build_cpe.py | 6 +++---
12 ssg/id_translate.py | 2 +-
13 2 files changed, 4 insertions(+), 4 deletions(-)
14
15diff --git a/ssg/build_cpe.py b/ssg/build_cpe.py
16index 2e5d24a5d..8c046777a 100644
17--- a/ssg/build_cpe.py
18+++ b/ssg/build_cpe.py
19@@ -17,7 +17,7 @@ def extract_subelement(objects, sub_elem_type):
20 """
21
22 for obj in objects:
23- for subelement in obj.getiterator():
24+ for subelement in obj.iter():
25 if subelement.get(sub_elem_type):
26 sub_element = subelement.get(sub_elem_type)
27 return sub_element
28@@ -44,12 +44,12 @@ def extract_referred_nodes(tree_with_refs, tree_with_ids, attrname):
29 reflist = []
30 elementlist = []
31
32- for element in tree_with_refs.getiterator():
33+ for element in tree_with_refs.iter():
34 value = element.get(attrname)
35 if value is not None:
36 reflist.append(value)
37
38- for element in tree_with_ids.getiterator():
39+ for element in tree_with_ids.iter():
40 if element.get("id") in reflist:
41 elementlist.append(element)
42
43diff --git a/ssg/id_translate.py b/ssg/id_translate.py
44index 72b07be18..ba9225904 100644
45--- a/ssg/id_translate.py
46+++ b/ssg/id_translate.py
47@@ -64,7 +64,7 @@ class IDTranslator(object):
48 )
49
50 def translate(self, tree, store_defname=False):
51- for element in tree.getiterator():
52+ for element in tree.iter():
53 idname = element.get("id")
54 if idname:
55 # store the old name if requested (for OVAL definitions)
56--
572.17.1
58
diff --git a/meta-security-compliance/recipes-openscap/scap-security-guide/files/0003-fix-remaining-getchildren-and-getiterator-functions.patch b/meta-security-compliance/recipes-openscap/scap-security-guide/files/0003-fix-remaining-getchildren-and-getiterator-functions.patch
new file mode 100644
index 0000000..8162292
--- /dev/null
+++ b/meta-security-compliance/recipes-openscap/scap-security-guide/files/0003-fix-remaining-getchildren-and-getiterator-functions.patch
@@ -0,0 +1,57 @@
1From a0da16c5eeb9a7414f7f2a37a6b270c8d04b2ddf Mon Sep 17 00:00:00 2001
2From: Vojtech Polasek <vpolasek@redhat.com>
3Date: Mon, 8 Jun 2020 14:01:55 +0200
4Subject: [PATCH] fix remaining getchildren and getiterator functions
5
6Upstream-Status: Backport
7[https://github.com/ComplianceAsCode/content/commit/a0da16c5eeb9a7414f7f2a37a6b270c8d04b2ddf]
8
9Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
10---
11 build-scripts/sds_move_ocil_to_checks.py | 2 +-
12 build-scripts/verify_references.py | 2 +-
13 shared/transforms/pcidss/transform_benchmark_to_pcidss.py | 2 +-
14 3 files changed, 3 insertions(+), 3 deletions(-)
15
16diff --git a/build-scripts/sds_move_ocil_to_checks.py b/build-scripts/sds_move_ocil_to_checks.py
17index 5f5139659..64dc19084 100755
18--- a/build-scripts/sds_move_ocil_to_checks.py
19+++ b/build-scripts/sds_move_ocil_to_checks.py
20@@ -106,7 +106,7 @@ def move_ocil_content_from_ds_extended_component_to_ds_component(datastreamtree,
21 timestamp = extendedcomp.get('timestamp')
22
23 # Get children elements of <ds:extended-component> containing OCIL content
24- extchildren = extendedcomp.getchildren()
25+ extchildren = list(extendedcomp)
26 # There should be just one OCIL subcomponent in <ds:extended-component>
27 if len(extchildren) != 1:
28 sys.stderr.write("ds:extended-component contains more than one element!"
29diff --git a/build-scripts/verify_references.py b/build-scripts/verify_references.py
30index 69b3e2d1f..95d387f46 100755
31--- a/build-scripts/verify_references.py
32+++ b/build-scripts/verify_references.py
33@@ -179,7 +179,7 @@ def main():
34 check_content_refs = xccdftree.findall(".//{%s}check-content-ref"
35 % xccdf_ns)
36
37- xccdf_parent_map = dict((c, p) for p in xccdftree.getiterator() for c in p)
38+ xccdf_parent_map = dict((c, p) for p in xccdftree.iter() for c in p)
39 # now we can actually do the verification work here
40 if options.rules_with_invalid_checks or options.all_checks:
41 for check_content_ref in check_content_refs:
42diff --git a/shared/transforms/pcidss/transform_benchmark_to_pcidss.py b/shared/transforms/pcidss/transform_benchmark_to_pcidss.py
43index 0ceaf727d..c94b12c45 100755
44--- a/shared/transforms/pcidss/transform_benchmark_to_pcidss.py
45+++ b/shared/transforms/pcidss/transform_benchmark_to_pcidss.py
46@@ -111,7 +111,7 @@ def main():
47 benchmark.findall(".//{%s}Value" % (XCCDF_NAMESPACE)):
48 values.append(value)
49
50- parent_map = dict((c, p) for p in benchmark.getiterator() for c in p)
51+ parent_map = dict((c, p) for p in benchmark.iter() for c in p)
52 for rule in \
53 benchmark.findall(".//{%s}Rule" % (XCCDF_NAMESPACE)):
54 parent_map[rule].remove(rule)
55--
562.17.1
57
diff --git a/meta-security-compliance/recipes-openscap/scap-security-guide/scap-security-guide_git.bb b/meta-security-compliance/recipes-openscap/scap-security-guide/scap-security-guide_git.bb
index f35d769..6e7180f 100644
--- a/meta-security-compliance/recipes-openscap/scap-security-guide/scap-security-guide_git.bb
+++ b/meta-security-compliance/recipes-openscap/scap-security-guide/scap-security-guide_git.bb
@@ -4,6 +4,9 @@ SRCREV = "5fdfdcb2e95afbd86ace555beca5d20cbf1043ed"
4SRC_URI = "git://github.com/akuster/scap-security-guide.git;branch=oe-0.1.44; \ 4SRC_URI = "git://github.com/akuster/scap-security-guide.git;branch=oe-0.1.44; \
5 file://0001-Fix-XML-parsing-of-the-remediation-functions-file.patch \ 5 file://0001-Fix-XML-parsing-of-the-remediation-functions-file.patch \
6 file://0002-Fixed-the-broken-fix-when-greedy-regex-ate-the-whole.patch \ 6 file://0002-Fixed-the-broken-fix-when-greedy-regex-ate-the-whole.patch \
7 file://0001-fix-deprecated-instance-of-element.getchildren.patch \
8 file://0002-fix-deprecated-getiterator-function.patch \
9 file://0003-fix-remaining-getchildren-and-getiterator-functions.patch \
7 " 10 "
8PV = "0.1.44+git${SRCPV}" 11PV = "0.1.44+git${SRCPV}"
9 12