-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(redhat): Also try to find buildinfo in root layer (layer 0) #8924
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
Conversation
This is what Red Hat shared for the scanner certification. The first layer must not have any buildinfo. If RHEL 10 has buildinfo in the first layer, it's probably their mistake, or they've added a breaking change without notice. |
However, if that is indeed the case in reality, I think we need to make the correction as you suggested. @DmitriyLewen Could you double-check it? |
Independantly of Red Hat plans, as a RHEL client myself, I do deliver to folks in my company a RHEL base image, which is configured to target our own private mirror of RHEL rpm packages (so it can work without internet access). When I do that, I do build an OCI image which squashes all layers (Red Hat ones + the ones of my company to change the rpm configuration) into a single one. So if you consider this use case legit, this pull request will also "make it work". For me so far it was not seen with RHEL 9 as RHEL 9 had this concept of "default content set" which was actually hidding the problem. Technically the latest RHEL 9 image do have the same layout as the latest RHEL 10 images. |
hm... I didn't find diagram from #8924 (comment). But i checked some images:
Also i checked test-harness images:
So looks like we need to check |
Hmm... That differs from the explanation I received with the diagram. Nevertheless, if that is indeed the actual situation, then we will need to conform to it. We also need to update the following logic. We may want to share the content set with the second layer only when the first layer doesn't have content set. trivy/pkg/fanal/applier/docker.go Lines 63 to 70 in deefd67
|
It's not clear the way it's coded right now, but it's already the case. The first thing done in this function is to return the layer build info if it exists. So on recent RHEL images, since layer 0 build info exists, we return it immediately, without trying to use layer 1 build info. |
I was thinking about this too and trying to find an image for this case. Since we have confirmation (unlike the case when layer 0 contains set content) that there may be cases when we should take set content for layer 0 from >=layer 2 - I think it is worth sticking to the information you received from RedHat the worst case that can happen is that we don't return the content for layer 0 (because layer 1 doesn't contain content sets either) |
It seems some authoritative Red Hat folks would need to clarify what are the garantees scanners can expect wrt the Red Hat managed images. FYI, yesterday I asked one of my contact point at Red Hat involved in podman & bootc to see if someone at Red Hat can read this discussion and provide more up to date guidelines on what you shall do. |
Ah, you're right. It already works as desired. trivy/pkg/fanal/applier/docker.go Lines 59 to 61 in deefd67
|
This may be the ideal approach, but if in reality we need to use the buildinfo from the first layer, I think it's acceptable to make this change while we wait for a response from Red Hat. |
I don't mind |
Description
This is a followup of #8910 where @knqyf263 rightfully pointed out that we shall not need a default content set for recent RHEL. Indeed there was another bug. This is required for future RHEL 10 support, yet RHEL 10 support is still partial.
Let's consider this Dockerfile:
We can build it, and look at the history of this image like this:
We can see the resulting image has 2 "real" layers:
procps
(actuallyprocps-ng
) package. This layer has no "build info".In the logic of
lookupBuildInfo
inpkg/fanal/applier/docker.go
we currently assume that the layer 0 never has any build info, but that layer 1 has. Maybe it was true in the past, but it no longer is the case now. Looking at the logic, in the fina loop trying to find build info for the customer layer, it's ok to try to look for build info in layer 0. At best it will find a valid build info. At worst it will benil
and the loop will exit, returningnil
in the final statement. So I believe this change is valid both for new RHEL 10 images and also "old" RHEL images which didn't have any build info in layer 0.Before the change:
After the change:
Checklist