Skip to content

Commit

Permalink
Do not double-prefix symlink paths that already contain volume names
Browse files Browse the repository at this point in the history
Fixes #1950

Co-authored-by: Joseph Palermo <[email protected]>
Signed-off-by: Joseph Palermo <[email protected]>
Signed-off-by: Chris Selzo <[email protected]>
Co-authored-by: Chris Selzo <[email protected]>
  • Loading branch information
selzoc and jpalermo committed Aug 23, 2023
1 parent ee121cf commit 0e5a0c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions syft/internal/fileresolver/directory_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,13 @@ func (r directoryIndexer) addSymlinkToIndex(p string, info os.FileInfo) (string,
}

if filepath.IsAbs(linkTarget) {
linkTarget = filepath.Clean(linkTarget)
// if the link is absolute (e.g, /bin/ls -> /bin/busybox) we need to
// resolve relative to the root of the base directory
linkTarget = filepath.Join(r.base, filepath.Clean(linkTarget))
// resolve relative to the root of the base directory, if it is not already
// prefixed with a volume name
if filepath.VolumeName(linkTarget) == "" {
linkTarget = filepath.Join(r.base, filepath.Clean(linkTarget))
}
} else {
// if the link is not absolute (e.g, /dev/stderr -> fd/2 ) we need to
// resolve it relative to the directory in question (e.g. resolve to
Expand Down

0 comments on commit 0e5a0c6

Please sign in to comment.