Fix loading of files with jinja

This commit is contained in:
Watson Sato 2021-12-01 18:51:18 +01:00
parent 500fdac831
commit 9321395849
2 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,85 @@
From 396fb9029e74b38ea09236c6cd1a7cb38f545afe Mon Sep 17 00:00:00 2001
From: Gabriel Becker <ggasparb@redhat.com>
Date: Wed, 1 Dec 2021 13:20:47 +0100
Subject: [PATCH] Fix jinja issue on fedora rawhide.
---
tests/unit/ssg-module/test_playbook_builder.py | 4 ++--
utils/duplicated_prodtypes.py | 4 ++--
utils/fix_file_ocilclause.py | 4 ++--
utils/move_rules.py | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tests/unit/ssg-module/test_playbook_builder.py b/tests/unit/ssg-module/test_playbook_builder.py
index 6692c54dfab..38b6f1f52e2 100644
--- a/tests/unit/ssg-module/test_playbook_builder.py
+++ b/tests/unit/ssg-module/test_playbook_builder.py
@@ -34,9 +34,9 @@ def test_build_rule_playbook():
assert os.path.exists(real_output_filepath)
with open(real_output_filepath, "r") as real_output:
- real_output_yaml = yaml.load(real_output)
+ real_output_yaml = yaml.load(real_output, Loader=yaml.Loader)
with open(expected_output_filepath, "r") as expected_output:
- expected_output_yaml = yaml.load(expected_output)
+ expected_output_yaml = yaml.load(expected_output, Loader=yaml.Loader)
real_play = real_output_yaml.pop()
expected_play = expected_output_yaml.pop()
diff --git a/utils/duplicated_prodtypes.py b/utils/duplicated_prodtypes.py
index 4cb2c16fef8..25c36c58d81 100755
--- a/utils/duplicated_prodtypes.py
+++ b/utils/duplicated_prodtypes.py
@@ -23,7 +23,7 @@ def _create_profile_cache(ssg_root):
files.sort()
for filename in files:
profile_path = os.path.join(prod_profiles_dir, filename)
- parsed_profile = yaml.load(open(profile_path, 'r'))
+ parsed_profile = yaml.load(open(profile_path, 'r'), Loader=yaml.Loader)
for _obj in parsed_profile['selections']:
obj = _obj
if '=' in obj:
@@ -210,7 +210,7 @@ def find_profiles(ssg_root, path, obj_name):
def parse_from_yaml(file_contents, lines):
new_file_arr = file_contents[lines[0]:lines[1] + 1]
new_file = "\n".join(new_file_arr)
- return yaml.load(new_file)
+ return yaml.load(new_file, Loader=yaml.Loader)
def print_file(file_contents):
diff --git a/utils/fix_file_ocilclause.py b/utils/fix_file_ocilclause.py
index 462d2b37c15..d79bb8c51e0 100755
--- a/utils/fix_file_ocilclause.py
+++ b/utils/fix_file_ocilclause.py
@@ -23,7 +23,7 @@ def _create_profile_cache(ssg_root):
files.sort()
for filename in files:
profile_path = os.path.join(prod_profiles_dir, filename)
- parsed_profile = yaml.load(open(profile_path, 'r'))
+ parsed_profile = yaml.load(open(profile_path, 'r'), Loader=yaml.Loader)
for _obj in parsed_profile['selections']:
obj = _obj
if '=' in obj:
@@ -205,7 +205,7 @@ def fix_ocil_clause(ssg_root, path, obj_name):
def parse_from_yaml(file_contents, lines):
new_file_arr = file_contents[lines[0]:lines[1] + 1]
new_file = "\n".join(new_file_arr)
- return yaml.load(new_file)
+ return yaml.load(new_file, Loader=yaml.Loader)
def print_file(file_contents):
diff --git a/utils/move_rules.py b/utils/move_rules.py
index 2deb62b488a..e91a661be85 100755
--- a/utils/move_rules.py
+++ b/utils/move_rules.py
@@ -340,7 +340,7 @@ def fix_ocil_clause(ssg_root, path, obj_name):
def parse_from_yaml(file_contents, lines):
new_file_arr = file_contents[lines[0]:lines[1] + 1]
new_file = "\n".join(new_file_arr)
- return yaml.load(new_file)
+ return yaml.load(new_file, Loader=yaml.Loader)
def print_file(file_contents):

View File

@ -12,6 +12,8 @@ URL: https://github.com/ComplianceAsCode/content/
Source0: https://github.com/ComplianceAsCode/content/releases/download/v%{version}/scap-security-guide-%{version}.tar.bz2
BuildArch: noarch
Patch0: scap-security-guide-0.1.60-fix-jinja-loading-PR_7944.patch
BuildRequires: libxslt
BuildRequires: expat
BuildRequires: openscap-scanner >= 1.2.5
@ -101,6 +103,7 @@ rm %{buildroot}/%{_docdir}/%{name}/Contributors.md
* Wed Dec 01 2021 Watson Sato <wsato@redhat.com> - 0.1.59-1
- Update to latest upstream SCAP-Security-Guide-0.1.59 release:
https://github.com/ComplianceAsCode/content/releases/tag/v0.1.59
- Fix loading of jinja files
* Thu Sep 30 2021 Watson Sato <wsato@redhat.com> - 0.1.58-1
- Update to latest upstream SCAP-Security-Guide-0.1.58 release: