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

Improve RPM database path in RPM probes #2156

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

jan-cerny
Copy link
Member

Description

The assumption that /var/lib/rpm is always a symlink to /usr/lib/sysimage/rpm was wrong. In bootc images, it isn't the case. As a result, all rules were evaluated as notapplicable when scanning a bootc image or container.

We will fix it the following way: We will first try if the "new" location /usr/lib/sysimage/rpm exists, and use it only if it exists. If it doesn't exist, we will fall back to the "old" location /var/lib/rpm.

Fixes: https://issues.redhat.com/browse/RHEL-55251
Fixes: #2151

Rationale

This would be a first step to get OpenSCAP ready for bootc experience.

Review hints

First, reproduce the problem and verify that we fixed it.
sudo podman pull quay.io/centos-bootc/centos-bootc:stream9
sudo oscap-podman quay.io/centos-bootc/centos-bootc:stream9 oval eval --results /tmp/results.xml oval.xml
sudo oscap-podman --oscap=/home/jcerny/work/git/openscap/build/oscap_wrapper quay.io/centos-bootc/centos-bootc:stream9 oval eval --results /tmp/results.xml oval.xml

Then, verify we haven't broken scanning old systems on example of the ubi8 image.
sudo podman pull ubi8
sudo oscap-podman ubi8 oval eval --results /tmp/results.xml oval.xml
sudo oscap-podman --oscap=/home/jcerny/work/git/openscap/build/oscap_wrapper ubi8 oval eval --results /tmp/results.xml oval.xml

Also, verify that the probes still work locally.
./oscap_wrapper oval eval --results /tmp/local.xml oval.xml

In each command examine the produced OVAL result carefully and check if there is an item matching every test and check if the collected data comes from the scanned target and not form the host or from elsewhere.

@jan-cerny jan-cerny changed the title Improve rpm database path in RPM probes Improve RPM database path in RPM probes Aug 22, 2024
@evgenyz
Copy link
Contributor

evgenyz commented Sep 2, 2024

This fix will make CI more adequate: #2157.

The assumption that /var/lib/rpm is always a symlink to
/usr/lib/sysimage/rpm was wrong. In bootc images, it isn't
the case. As a result, all rules were evaluated as notapplicable
when scanning a bootc image or container.

We will fix it the following way: We will first try if the "new"
location /usr/lib/sysimage/rpm exists, and use it only if it exists.  If
it doesn't exist, we will fall back to the "old" location /var/lib/rpm.

Fixes: https://issues.redhat.com/browse/RHEL-55251
Fixes: OpenSCAP#2151
@jan-cerny
Copy link
Member Author

I have rebased the PR on the top of the latest upstream maint-1.3 branch

@matusmarhefka matusmarhefka self-assigned this Sep 13, 2024
@matusmarhefka matusmarhefka added this to the 1.3.11 milestone Sep 13, 2024
@matusmarhefka matusmarhefka merged commit 8c7ef5d into OpenSCAP:maint-1.3 Sep 13, 2024
10 checks passed
@jan-cerny jan-cerny added the Image Mode Bootable containers and Image Mode RHEL label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Image Mode Bootable containers and Image Mode RHEL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants