mirror of
https://github.com/anchore/syft
synced 2024-11-10 06:14:16 +00:00
fix: handle invalid symlinks (#1861)
Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
parent
c560ffd811
commit
1764e1c3f6
1 changed files with 7 additions and 0 deletions
|
@ -370,6 +370,13 @@ func (r directoryIndexer) addSymlinkToIndex(p string, info os.FileInfo) (string,
|
|||
metadata.LinkDestination = linkTarget
|
||||
r.index.Add(*ref, metadata)
|
||||
|
||||
// if the target path does not exist, then do not report it as a new root, or try to send
|
||||
// syft parsing there.
|
||||
if _, err := os.Stat(targetAbsPath); err != nil && errors.Is(err, os.ErrNotExist) {
|
||||
log.Debugf("link %s points to unresolved path %s, ignoring target as new root", p, targetAbsPath)
|
||||
targetAbsPath = ""
|
||||
}
|
||||
|
||||
return targetAbsPath, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue