mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
fix: use filepath.EvalSymlinks if os.Readlink fails to evaluate the link (#1884)
Signed-off-by: DD (Devdatta) Deshpande <dd@codewits.in> Co-authored-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
parent
cfbb9f703b
commit
a00a3df10c
@ -332,7 +332,19 @@ func (r directoryIndexer) addFileToIndex(p string, info os.FileInfo) error {
|
||||
func (r directoryIndexer) addSymlinkToIndex(p string, info os.FileInfo) (string, error) {
|
||||
linkTarget, err := os.Readlink(p)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to readlink for path=%q: %w", p, err)
|
||||
if runtime.GOOS == WindowsOS {
|
||||
p = posixToWindows(p)
|
||||
}
|
||||
|
||||
linkTarget, err = filepath.EvalSymlinks(p)
|
||||
|
||||
if runtime.GOOS == WindowsOS {
|
||||
p = windowsToPosix(p)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to readlink for path=%q: %w", p, err)
|
||||
}
|
||||
}
|
||||
|
||||
if filepath.IsAbs(linkTarget) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user