-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
in directory indexer, handle outside symlinks #1861
Conversation
Signed-off-by: Avi Deitcher <avi@deitcher.net>
// 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 = "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking how this is used, what if this was moved above, to line 337 and behaved similar to when os.ReadLink
fails? e.g.:
if _, err := os.Stat(targetAbsPath); err != nil && errors.Is(err, os.ErrNotExist) {
return "", fmt.Errorf("link %s points to unresolved path %s", p, targetAbsPath)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. In that case, it would return an error, when that isn't actually what we want. A symlink might be invalid now, but the file could appear later. Think of a link to a mount in a container, or to a log file that will be created later.
The symlink itself not existing, or being unreadable, is an error; the target not existing is a hanging symlink, which is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good as it is 👍
Signed-off-by: Avi Deitcher <avi@deitcher.net>
Fixes #1860
Ensures that if a symlink in a directory points to something that does not exist, it logs a debug message and continues, rather than adding a new root which does not exist, which would cause a fatal error.