Skip to content

Commit

Permalink
fix: do not double-prefix symlink paths that already contain volume n…
Browse files Browse the repository at this point in the history
…ames (#2051)

Signed-off-by: Joseph Palermo <[email protected]>
Signed-off-by: Chris Selzo <[email protected]>
Co-authored-by: Joseph Palermo <[email protected]>
  • Loading branch information
selzoc and jpalermo authored Aug 24, 2023
1 parent 1848aa2 commit 5ceef48
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 5ceef48

Please sign in to comment.