Skip to content

Commit

Permalink
fix: handle invalid symlinks (#1861)
Browse files Browse the repository at this point in the history
Signed-off-by: Avi Deitcher <[email protected]>
  • Loading branch information
deitch authored Jun 5, 2023
1 parent c560ffd commit 1764e1c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions syft/internal/fileresolver/directory_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 1764e1c

Please sign in to comment.