test: add symlink-escape tests for go.sum and npm-shrinkwrap.json#2324
Open
ZeroX-404 wants to merge 2 commits into
Open
test: add symlink-escape tests for go.sum and npm-shrinkwrap.json#2324ZeroX-404 wants to merge 2 commits into
ZeroX-404 wants to merge 2 commits into
Conversation
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.
This PR adds two integration tests that demonstrate symlink escape via
os.DirFSin thego.sumandnpm-shrinkwrap.jsonextractors.These tests follow the same pattern as the confirmed bug in
requirements.txt(issue #2323): a symlink placed inside the scanned directory, pointing to a file outside the scan root, is followed byos.DirFS.Open(), causing the scanner to read and parse a file that should be out of scope.TestGoSumSymlinkEscape: createsgo.sumas a symlink to a file outside the root. The scanner reads it and the package appears in the JSON output.TestNpmShrinkwrapSymlinkEscape: same approach withnpm-shrinkwrap.jsonand a validpackage-lock.jsonstub.These tests will fail until a fix (such as the
os.Rootapproach in PR #2028) is applied to all file-opening paths in the extractors.Ref: #2323, #2028, #2003