mirror of
https://github.com/anchore/syft.git
synced 2026-11-02 07:26:34 +01:00
* add second generation of generic cataloger Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * upgrade aplm cataloger to use generic.Cataloger Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove pacakge found-by attribute from the definition of a package ID Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package alpm
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/anchore/packageurl-go"
|
|
"github.com/anchore/syft/syft/linux"
|
|
"github.com/anchore/syft/syft/pkg"
|
|
"github.com/anchore/syft/syft/source"
|
|
)
|
|
|
|
func newPackage(m pkg.AlpmMetadata, release *linux.Release, locations ...source.Location) pkg.Package {
|
|
p := pkg.Package{
|
|
Name: m.Package,
|
|
Version: m.Version,
|
|
Locations: source.NewLocationSet(locations...),
|
|
Type: pkg.AlpmPkg,
|
|
Licenses: strings.Split(m.License, " "),
|
|
PURL: packageURL(m, release),
|
|
MetadataType: pkg.AlpmMetadataType,
|
|
Metadata: m,
|
|
}
|
|
p.SetID()
|
|
return p
|
|
}
|
|
|
|
func packageURL(m pkg.AlpmMetadata, distro *linux.Release) string {
|
|
if distro == nil || distro.ID != "arch" {
|
|
// note: there is no namespace variation (like with debian ID_LIKE for ubuntu ID, for example)
|
|
return ""
|
|
}
|
|
|
|
qualifiers := map[string]string{
|
|
pkg.PURLQualifierArch: m.Architecture,
|
|
}
|
|
|
|
if m.BasePackage != "" {
|
|
qualifiers[pkg.PURLQualifierUpstream] = m.BasePackage
|
|
}
|
|
|
|
return packageurl.NewPackageURL(
|
|
"alpm", // `alpm` for Arch Linux and other users of the libalpm/pacman package manager. (see https://github.com/package-url/purl-spec/pull/164)
|
|
distro.ID,
|
|
m.Package,
|
|
m.Version,
|
|
pkg.PURLQualifiers(
|
|
qualifiers,
|
|
distro,
|
|
),
|
|
"",
|
|
).ToString()
|
|
}
|