mirror of
https://github.com/anchore/syft.git
synced 2026-11-05 00:46:38 +01:00
Infer the package type from ELF package notes (#3008)
* fix ELF package types to be honored Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * prefer OS packages over binary packages when there are duplicates Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
@@ -13,7 +13,7 @@ func newELFPackage(metadata elfBinaryPackageNotes, locations file.LocationSet) p
|
||||
Version: metadata.Version,
|
||||
Licenses: pkg.NewLicenseSet(pkg.NewLicense(metadata.License)),
|
||||
PURL: packageURL(metadata),
|
||||
Type: pkg.BinaryPkg,
|
||||
Type: pkgType(metadata.Type),
|
||||
Locations: locations,
|
||||
Metadata: metadata.ELFBinaryPackageNoteJSONPayload,
|
||||
}
|
||||
@@ -67,6 +67,8 @@ func packageURL(metadata elfBinaryPackageNotes) string {
|
||||
).ToString()
|
||||
}
|
||||
|
||||
const alpmType = "alpm"
|
||||
|
||||
func purlDistroType(ty string) string {
|
||||
switch ty {
|
||||
case "rpm":
|
||||
@@ -75,8 +77,22 @@ func purlDistroType(ty string) string {
|
||||
return packageurl.TypeDebian
|
||||
case "apk":
|
||||
return packageurl.TypeAlpine
|
||||
case "alpm":
|
||||
return "alpm"
|
||||
case alpmType:
|
||||
return alpmType
|
||||
}
|
||||
return packageurl.TypeGeneric
|
||||
}
|
||||
|
||||
func pkgType(ty string) pkg.Type {
|
||||
switch ty {
|
||||
case "rpm":
|
||||
return pkg.RpmPkg
|
||||
case "deb":
|
||||
return pkg.DebPkg
|
||||
case "apk":
|
||||
return pkg.ApkPkg
|
||||
case alpmType:
|
||||
return pkg.AlpmPkg
|
||||
}
|
||||
return pkg.BinaryPkg
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user