Fix bugs in SBOM layer comment generation#3594
Merged
Merged
Conversation
tonistiigi
reviewed
Feb 10, 2023
| // | ||
| // 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) |
Member
There was a problem hiding this comment.
isn't this supposed to be filepath.Join("/", filename)
Member
There was a problem hiding this comment.
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
tonistiigi
approved these changes
Feb 10, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.