From 6a06016327014be1204016fa48a74c0ae6dc87dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= Date: Tue, 30 Jul 2024 09:21:45 +0200 Subject: [PATCH] Hide some remediation types This change will cause that Anaconda and Kickstart remediation types will not be shown in the HTML report. Anaconda remediations are consumed only by OSCAP Anaconda Addon. Kickstart remediations are consumed by OpenSCAP to generate a kickstart. It isn't useful to the user at all to see or copy these remediation types, they don't have any use for them. To reduce the unnecessary information in the report, we won't include them in the report. --- .../scap_results_parser/data_structures/remediation.py | 5 +++++ openscap_report/scap_results_parser/parsers/rule_parser.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/openscap_report/scap_results_parser/data_structures/remediation.py b/openscap_report/scap_results_parser/data_structures/remediation.py index d8a4f0a2..fc7b3c31 100644 --- a/openscap_report/scap_results_parser/data_structures/remediation.py +++ b/openscap_report/scap_results_parser/data_structures/remediation.py @@ -12,6 +12,10 @@ "fix", ] +HIDDEN_REMEDIATION_TYPES = [ + "urn:redhat:anaconda:pre", + "urn:xccdf:fix:script:kickstart", +] @dataclass class Remediation: @@ -33,5 +37,6 @@ def get_type(self): "urn:redhat:anaconda:pre": "Anaconda snippet", "urn:xccdf:fix:script:kubernetes": "Kubernetes snippet", "urn:redhat:osbuild:blueprint": "OSBuild Blueprint snippet", + "urn:xccdf:fix:script:kickstart": "Kickstart snippet", } return script_types.get(self.system, "script") diff --git a/openscap_report/scap_results_parser/parsers/rule_parser.py b/openscap_report/scap_results_parser/parsers/rule_parser.py index 318fbbed..c8ade9ff 100644 --- a/openscap_report/scap_results_parser/parsers/rule_parser.py +++ b/openscap_report/scap_results_parser/parsers/rule_parser.py @@ -4,6 +4,7 @@ import collections from openscap_report.dataclasses import replace +from ..data_structures.remediation import HIDDEN_REMEDIATION_TYPES from ..data_structures import Identifier, Reference, Rule, RuleWarning from ..namespaces import NAMESPACES @@ -58,6 +59,8 @@ def _get_remediations(self, rule): output = [] for fix in rule.findall(".//xccdf:fix", NAMESPACES): remediation = self.remediation_parser.get_remediation(fix) + if remediation.system in HIDDEN_REMEDIATION_TYPES: + continue output.append(remediation) return output