mirror of
https://github.com/anchore/syft.git
synced 2026-10-31 06:26:30 +01:00
fix: unknowns, better full vs local path handling
Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
@@ -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}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user