scap-security-guide/scap-security-guide-0.1.61-delta_tailoring_fix-PR_8262.patch

51 lines
2.3 KiB
Diff

From cd544b1ceec3cfc799faf24fc83e99f950d1c9c9 Mon Sep 17 00:00:00 2001
From: Matthew Burket <mburket@redhat.com>
Date: Wed, 23 Feb 2022 12:21:17 -0600
Subject: [PATCH] Ensure that get_implemented_stigs in
utils/create_scap_delta_tailoring.py works for all case
Before this commit using resolved_rules_dir would deselect all rules
---
utils/create_scap_delta_tailoring.py | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/utils/create_scap_delta_tailoring.py b/utils/create_scap_delta_tailoring.py
index 90e131cd01a..b1a44858a0f 100755
--- a/utils/create_scap_delta_tailoring.py
+++ b/utils/create_scap_delta_tailoring.py
@@ -103,24 +103,22 @@ def get_implemented_stigs(product, root_path, build_config_yaml_path,
build_root):
platform_rules = get_platform_rules(product, json_path, resolved_rules_dir, build_root)
- if resolved_rules_dir:
- platform_rules_dict = dict()
- for rule in platform_rules:
- platform_rules_dict[rule['id']] = rule
- return platform_rules_dict
product_dir = os.path.join(root_path, "products", product)
product_yaml_path = os.path.join(product_dir, "product.yml")
env_yaml = ssg.environment.open_environment(build_config_yaml_path, str(product_yaml_path))
known_rules = dict()
for rule in platform_rules:
- try:
- rule_obj = handle_rule_yaml(product, rule['id'],
- rule['dir'], rule['guide'], env_yaml)
- except ssg.yaml.DocumentationNotComplete:
- sys.stderr.write('Rule %s throw DocumentationNotComplete' % rule['id'])
- # Happens on non-debug build when a rule is "documentation-incomplete"
- continue
+ if resolved_rules_dir:
+ rule_obj = rule
+ else:
+ try:
+ rule_obj = handle_rule_yaml(product, rule['id'],
+ rule['dir'], rule['guide'], env_yaml)
+ except ssg.yaml.DocumentationNotComplete:
+ sys.stderr.write('Rule %s throw DocumentationNotComplete' % rule['id'])
+ # Happens on non-debug build when a rule is "documentation-incomplete"
+ continue
if reference_str in rule_obj['references'].keys():
ref = rule_obj['references'][reference_str]