-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
fix(containerd): Use img platform in exporter instead of strict host platform #4477
Conversation
img.Platform()
in exporter instead of strict host platformimg.Platform()
in exporter instead of strict host platform
img.Platform()
in exporter instead of strict host platformThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @AliDatadog
Thanks for your work!
I left a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for work!
LGTM.
@knqyf263 Can you take a look and merge this PR if that's ok for you?
@knqyf263 any update ? |
If I correctly get your point, it still doesn't work in my environment.
Looks like we also need to pass the platform to the client. trivy/pkg/fanal/image/daemon/containerd.go Lines 120 to 123 in cb02f4f
Otherwise, trivy/pkg/fanal/image/daemon/containerd.go Line 212 in cb02f4f
The image platform inherits from the client's platform. Please let me know if I'm missing something. Also, I'm confused about the desired behavior. As shown above, trivy/pkg/fanal/image/daemon/containerd.go Lines 58 to 71 in cb02f4f
As you said, it could bring complex behavior. I want to keep it simple.
In other words, the default value of |
I think my description was a little misleading. For a mono-arch image or a multi-arch image that does not have a version strictly matching the host's platform (for example mono-arch
Also, nice catch! I will push a commit to include the image platform to the client (or the image actually, I think there is a function for that). |
How does |
I think that since
While I think it's great to keep things simple, it could be insecure for users which have both |
I think we can assume people using containerd are familiar with multi-arch images. We don't have to do something different from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM🚀
…platform (aquasecurity#4477) * match with img platform instead of host platform * client matching pull spec * use default platform * pull with platforms default strict * use withplatform to pull and add debug log * looks like we are trying to scan a i386 image * revert changes on test, use the right platform match * try with Config.Platform * use spect.platform * fix function usage * try another way to retrieve the platform * fix compilation * read platforms from config manifest * use platform from RegistryOptions if available, otherwise get the actual platform * goimport * put platform in containerd client * fix panic * use DefaultStrict as default
Description
This PR replaces the platform comparer from
DefaultStrict
to the platform currently available on the host.Motivation
Trivy fails to export
arm
images running onarm64
hosts even though these images are used by running containers.This issue can be reproduced by
ctr
which uses a similar underlying export function.The only way to retrieve the correct platform is to deserialize the image config or the spec.
Additional notes
Scan will most likely fail if a host pulls a compatible version of a multi-arch image if this version is not preferred.
For example, if a
amd64
host pulls thei386
version ofalpine
which support bothamd64
andi386
.Checklist