-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 bugs in SBOM layer comment generation #3594
Conversation
@@ -172,6 +176,8 @@ func newFileLayerFinder(target cache.ImmutableRef, remote *solver.Remote) (fileL | |||
// | |||
// find is not concurrency-safe. | |||
func (c *fileLayerFinder) find(ctx context.Context, s session.Group, filename string) (cache.ImmutableRef, *ocispecs.Descriptor, error) { | |||
filename = filepath.Clean("/" + filename) |
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.
isn't this supposed to be filepath.Join("/", filename)
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.
Thinking about the use of filepath
as well. I think these paths should be unix normalized, but that can be follow-up when wcow becomes more realistic.
Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
64a79e1
to
1c55dc2
Compare
BuildKit should generate comments for each file indicating what layer the file can be found in. However, when buildkit-syft-scanner switched to using chroot as a temporary hack (see docker/buildkit-syft-scanner#13), all paths in the SBOM were prefixed with
/
. This minor format change meant that the exporter's layer finder would not find this file, as they would be discovered without the/
prefix.To fix this, we just need to canonicalize the file paths, both on entry to the function, and for each file discovered.
Additionally, I also noticed a bug in the whiteout detection - we should only be checking the final path component for whiteouts, not the entire path... and also a panic with a scratch layer, and an issue with checking the core SBOM metadata field. Not quite sure why the code is so bug-full, I'm kinda surprised I wrote it in the first place 😢
I've added a test to check the file comment behavior doesn't break again.