chore: migrate syft to use mholt/archives instead of anchore fork#4029
chore: migrate syft to use mholt/archives instead of anchore fork#4029spiffcs merged 16 commits intoanchore:mainfrom
Conversation
| cleanupFn := func() error { | ||
| return os.RemoveAll(tempDir) | ||
| visitor := func(_ context.Context, file archives.FileInfo) error { | ||
| destPath, err := intFile.SafeJoin(tempDir, file.NameInArchive) |
There was a problem hiding this comment.
I updated this to use the same kind of SafeJoin functionality so we don't escape the tmpDir like we do in other parts of syft. If the archives library already handles this internally apologies I just couldn't find it on a quick inspection.
|
@wagoodman I've looked at this one and added a small protection. The visitor now uses a path aware directory join and cannot write outside the temp directory. Also, I don't know what Static Analysis is on about here. I've checked out this branch even on a different machine and it's told me the go.mod and go.sum are tidy locally |
spiffcs
left a comment
There was a problem hiding this comment.
This one now looks good to me after a first pass review. I identified a section in the visitor where we might be able to escape and write files to paths outside the temp directory so added a fix for this. I'd like additional 👀 from someone on @anchore/tools to check my work.
one more change is needed here where we also protect against symlink attacks
Signed-off-by: Kudryavcev Nikolay <kydry.nikolau@gmail.com>
Signed-off-by: Kudryavcev Nikolay <kydry.nikolau@gmail.com>
Signed-off-by: Kudryavcev Nikolay <kydry.nikolau@gmail.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Phillips <spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Phillips <spiffcs@users.noreply.github.com>
923d9a8 to
cfad5bb
Compare
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Angelo Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
kzantow
left a comment
There was a problem hiding this comment.
Overall LGTM the SafeJoin usage I think is good 👍 main things I think we should update:
- don't ever need to log.Error close problems, there's a CloseAndLogError utility to simplify a bunch of those calls anyway
- the tests don't seem to be actually testing the function we want to verify: UnzipToDir
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Angelo Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
…chore#4029) --------- Signed-off-by: Kudryavcev Nikolay <kydry.nikolau@gmail.com> Signed-off-by: Christopher Phillips <spiffcs@users.noreply.github.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
* chore: migrate syft to use mholt/archives instead of anchore fork (anchore#4029) --------- Signed-off-by: Kudryavcev Nikolay <kydry.nikolau@gmail.com> Signed-off-by: Christopher Phillips <spiffcs@users.noreply.github.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix(java): initialize license scanner in archive parser This commit addresses a potential vulnerability where the license scanner was not properly initialized before use in the Java archive parser, which could lead to nil pointer dereference. Additionally, updates test fixtures and assertions to reflect: - Updated package versions in Rocky Linux (curl-minimal, httpd) - Refactored deduplication tests to index by package name for better resilience to version changes - Added comprehensive test documentation --------- Signed-off-by: Kudryavcev Nikolay <kydry.nikolau@gmail.com> Signed-off-by: Christopher Phillips <spiffcs@users.noreply.github.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> Co-authored-by: Kudryavcev Nikolay <35200428+Rupikz@users.noreply.github.com>
Description
Rewritten deprecated fork github.com/anchore/archiver to github.com/mholt/archives
Type of change
Checklist: