fix: unknowns, better full vs local path handling

Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
Keith Zantow
2026-10-20 11:15:17 -04:00
parent 3cdf97ebad
commit a1f7c52d89
25 changed files with 619 additions and 225 deletions
+12 -1
View File
@@ -2,6 +2,7 @@ package unknown
import (
"regexp"
"strings"
"github.com/anchore/syft/internal/log"
"github.com/anchore/syft/syft/file"
@@ -19,7 +20,7 @@ func ProcessPathErrors(err error) error {
if pathErrorRegex.MatchString(errText) {
foundPath := pathErrorRegex.ReplaceAllString(err.Error(), "$1")
if foundPath != "" {
return New(file.NewLocation(foundPath), err)
return New(file.NewLocationFromCoordinates(pathCoordinates(foundPath)), err)
}
}
unknowns, remainingErrors := ExtractCoordinateErrors(err)
@@ -31,3 +32,13 @@ func ProcessPathErrors(err error) error {
}
return Join(out...)
}
// pathCoordinates names the file at a path from a resolver error, which for a file within an archive is
// a full path: the real path is what precedes the first archive separator.
func pathCoordinates(p string) file.Coordinates {
realPath, _, nested := strings.Cut(p, file.ArchivePathSeparator)
if !nested {
return file.NewCoordinates(p, "")
}
return file.Coordinates{RealPath: realPath, FullPath: p}
}