Fix symlink validation for canonical project roots - #177
Open
Akimbo92i wants to merge 1 commit into
Open
Conversation
Akimbo92i
marked this pull request as ready for review
September 7, 2026 21:17
abhinavgautam01
left a comment
Contributor
There was a problem hiding this comment.
Reviewed and tested locally. This correctly fixes #175 for both absolute and relative symlinked roots while preserving rejection of external targets. The regression tests fail before the fix and pass afterward.
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.
Summary
Allow
safeReadFileto read internal file symlinks when the project root path itself contains symlinks, while preserving rejection of targets outside the project root.Changes
filepath.Relpath semantics for the containment check and propagate path-resolution errors.Testing
Verified during the approved review:
go test -run '^TestSafeReadFileSymlinks$' -count=1 -v ./detectgo test -race -count=1 ./...go build ./...go vet ./...golangci-lint rungit diff --check origin/mainRelated Issue
Fixes #175