Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed solution for RHEL8 and RHEL9 in system detection to avoid false positives #12334

Merged

Conversation

mrkanon
Copy link
Contributor

@mrkanon mrkanon commented Aug 23, 2024

Description:

Updated

installed_OS_is_rhel9
installed_OS_is_rhel8

Rationale:

We have a false positive from RHEL9 to OL9, we also have a false positive from RHEL8 to OL8, this is because OL9 and OL8 have redhat-release package present.

When we check the rule installed_OS_is_vendor_supported we have the following oval results:
OL9

<definition definition_id="oval:ssg-installed_OS_is_vendor_supported:def:1" result="true" version="1">
                  <criteria operator="OR" result="true">
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_rhel8:def:1" version="1" result="false"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_rhel9:def:1" version="1" result="true"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_ol7:def:1" version="1" result="false"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_ol8:def:1" version="1" result="false"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_ol9:def:1" version="1" result="true"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_sle12:def:1" version="1" result="false"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_sle15:def:1" version="1" result="false"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_slmicro5:def:1" version="1" result="false"/>
                  </criteria>
                </definition>

OL8

<definition definition_id="oval:ssg-installed_OS_is_vendor_supported:def:1" result="true" version="1">
                  <criteria operator="OR" result="true">
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_rhel8:def:1" version="1" result="true"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_rhel9:def:1" version="1" result="false"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_ol7:def:1" version="1" result="false"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_ol8:def:1" version="1" result="true"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_ol9:def:1" version="1" result="false"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_sle12:def:1" version="1" result="false"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_sle15:def:1" version="1" result="false"/>
                    <extend_definition definition_ref="oval:ssg-installed_OS_is_slmicro5:def:1" version="1" result="false"/>
                  </criteria>
                </definition>

Copy link

openshift-ci bot commented Aug 23, 2024

Hi @mrkanon. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Aug 23, 2024
Copy link

Start a new ephemeral environment with changes proposed in this pull request:

Fedora Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

Copy link

github-actions bot commented Aug 23, 2024

🤖 A k8s content image for this PR is available at:
ghcr.io/complianceascode/k8scontent:12334
This image was built from commit: 2c06075

Click here to see how to deploy it

If you alread have Compliance Operator deployed:
utils/build_ds_container.py -i ghcr.io/complianceascode/k8scontent:12334

Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and:
CONTENT_IMAGE=ghcr.io/complianceascode/k8scontent:12334 make deploy-local

@jan-cerny jan-cerny self-assigned this Aug 26, 2024
@jan-cerny
Copy link
Collaborator

@mrkanon Can you please rebase this PR on the top of the latest upstream master branch to try if it would help the failing CI.

To prevent false positive RHEL9 in OL9
because OL9 has redhat-release package present

Signed-off-by: Armando Acosta <armando.acosta@oracle.com>
To prevent false positive RHEL8 in OL8
because OL8 has redhat-release package present

Signed-off-by: Armando Acosta <armando.acosta@oracle.com>
@mrkanon mrkanon force-pushed the installed_vendor_supported_rhel branch from 956547e to 593fda8 Compare August 26, 2024 18:16
@jan-cerny
Copy link
Collaborator

Unfortunately, the rebase didn't hlep. I will try to find out what is wrong

The specific error from the build is

OpenSCAP Error: File '/builddir/build/BUILD/scap-security-guide-0.1.75/build/ssg-cs9-ds.xml' line 65535: Element '{http://oval.mitre.org/XMLSchema/oval-definitions-5}definition': Duplicate key-sequence ['oval:ssg-installed_OS_is_part_of_Unix_family:def:1'] in key identity-constraint '{http://oval.mitre.org/XMLSchema/oval-definitions-5}definitionKey'.
 [/builddir/build/BUILD/openscap-1.3.10/src/XCCDF/xccdf_session.c:761]
File '/builddir/build/BUILD/scap-security-guide-0.1.75/build/ssg-cs9-ds.xml' line 65535: Element '{http://oval.mitre.org/XMLSchema/oval-definitions-5#independent}family_test': Duplicate key-sequence ['oval:ssg-test_unix_family:tst:1'] in key identity-constraint '{http://oval.mitre.org/XMLSchema/oval-definitions-5}testKey'.
 [/builddir/build/BUILD/openscap-1.3.10/src/XCCDF/xccdf_session.c:761]
File '/builddir/build/BUILD/scap-security-guide-0.1.75/build/ssg-cs9-ds.xml' line 65535: Element '{http://oval.mitre.org/XMLSchema/oval-definitions-5#independent}family_object': Duplicate key-sequence ['oval:ssg-object_unix_family:obj:1'] in key identity-constraint '{http://oval.mitre.org/XMLSchema/oval-definitions-5}objectKey'.
 [/builddir/build/BUILD/openscap-1.3.10/src/XCCDF/xccdf_session.c:761]
File '/builddir/build/BUILD/scap-security-guide-0.1.75/build/ssg-cs9-ds.xml' line 65535: Element '{http://oval.mitre.org/XMLSchema/oval-definitions-5#independent}family_state': Duplicate key-sequence ['oval:ssg-state_unix_family:ste:1'] in key identity-constraint '{http://oval.mitre.org/XMLSchema/oval-definitions-5}stateKey'.
 [/builddir/build/BUILD/openscap-1.3.10/src/XCCDF/xccdf_session.c:761]

so I would like to find what caused this "duplication" of the definition.

@jan-cerny
Copy link
Collaborator

Hi @mrkanon

The following patch helps me:

diff --git a/ssg/build_derivatives.py b/ssg/build_derivatives.py
index 79fc3eb308..e090b71063 100644
--- a/ssg/build_derivatives.py
+++ b/ssg/build_derivatives.py
@@ -76,7 +76,8 @@ def add_element_to(oval_root, tag_name, component_element):
     if xml_el is None:
         xml_el = ElementTree.Element("{%s}%s" % (oval_namespace, tag_name))
         oval_root.append(xml_el)
-    xml_el.append(component_element)
+    if xml_el.find("%s[@id='%s']" % (component_element.tag, component_element.get("id"))) is None:
+        xml_el.append(component_element)
 
 
 def add_oval_components_to_oval_xml(oval_root, tag_name, component_dict):

Can you try it?

Signed-off-by: Armando Acosta <armando.acosta@oracle.com>
Copy link

codeclimate bot commented Sep 3, 2024

Code Climate has analyzed commit 2c06075 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 0.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 59.5% (0.1% change).

View more on Code Climate.

@jan-cerny jan-cerny added this to the 0.1.75 milestone Sep 5, 2024
@jan-cerny jan-cerny merged commit 076df49 into ComplianceAsCode:master Sep 5, 2024
92 of 93 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ok-to-test Used by openshift-ci bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants