diff --git a/syft/internal/fileresolver/directory_indexer.go b/syft/internal/fileresolver/directory_indexer.go index b4383d75d..6bdbae0c7 100644 --- a/syft/internal/fileresolver/directory_indexer.go +++ b/syft/internal/fileresolver/directory_indexer.go @@ -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 }