separate CPE definitions from capabilities

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman 2022-04-02 00:05:25 -04:00
parent 9f60d32369
commit 078dbedfb6
No known key found for this signature in database
GPG Key ID: 5CB45AE22BAB7EA7
292 changed files with 292 additions and 292 deletions

View File

@ -211,13 +211,13 @@ integration-fingerprint:
.PHONY: java-packages-fingerprint .PHONY: java-packages-fingerprint
java-packages-fingerprint: java-packages-fingerprint:
$(call title,Java test fixture fingerprint) $(call title,Java test fixture fingerprint)
cd syft/pkg/cataloger/java/test-fixtures/java-builds && \ cd syft/cataloger/packages/java/test-fixtures/java-builds && \
make packages.fingerprint make packages.fingerprint
.PHONY: fixtures .PHONY: fixtures
fixtures: fixtures:
$(call title,Generating test fixtures) $(call title,Generating test fixtures)
cd syft/pkg/cataloger/java/test-fixtures/java-builds && make cd syft/cataloger/packages/java/test-fixtures/java-builds && make
.PHONY: generate-json-schema .PHONY: generate-json-schema
generate-json-schema: ## Generate a new json schema generate-json-schema: ## Generate a new json schema

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/anchore/syft/syft/cpe"
"github.com/anchore/syft/syft/file" "github.com/anchore/syft/syft/file"
"net/http" "net/http"
"strings" "strings"
@ -23,7 +24,7 @@ import (
"github.com/wagoodman/go-progress" "github.com/wagoodman/go-progress"
) )
func must(c pkg.CPE, e error) pkg.CPE { func must(c cpe.CPE, e error) cpe.CPE {
if e != nil { if e != nil {
panic(e) panic(e)
} }
@ -53,7 +54,7 @@ func (m *mockPackageSBOMImportAPI) ImportImagePackages(ctx context.Context, sess
func sbomFixture() sbom.SBOM { func sbomFixture() sbom.SBOM {
return sbom.SBOM{ return sbom.SBOM{
Artifacts: sbom.Artifacts{ Artifacts: sbom.Artifacts{
PackageCatalog: pkg.NewCatalog(pkg.Package{ PackageCatalog: pkg.NewCollection(pkg.Package{
Name: "name", Name: "name",
Version: "version", Version: "version",
FoundBy: "foundBy", FoundBy: "foundBy",
@ -68,8 +69,8 @@ func sbomFixture() sbom.SBOM {
Licenses: []string{"license"}, Licenses: []string{"license"},
Language: pkg.Python, Language: pkg.Python,
Type: pkg.PythonPkg, Type: pkg.PythonPkg,
CPEs: []pkg.CPE{ CPEs: []cpe.CPE{
must(pkg.NewCPE("cpe:2.3:*:some:package:1:*:*:*:*:*:*:*")), must(cpe.New("cpe:2.3:*:some:package:1:*:*:*:*:*:*:*")),
}, },
PURL: "purl", PURL: "purl",
MetadataType: pkg.PythonPackageMetadataType, MetadataType: pkg.PythonPackageMetadataType,

View File

@ -3,17 +3,16 @@ package config
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/anchore/syft/syft/cataloger/files/fileclassifier"
"path" "path"
"reflect" "reflect"
"strings" "strings"
"github.com/adrg/xdg"
"github.com/anchore/syft/internal"
"github.com/anchore/syft/internal/version" "github.com/anchore/syft/internal/version"
"github.com/anchore/syft/syft" "github.com/anchore/syft/syft"
"github.com/anchore/syft/syft/file" "github.com/anchore/syft/syft/file"
"github.com/anchore/syft/syft/file/cataloger/fileclassifier"
"github.com/adrg/xdg"
"github.com/anchore/syft/internal"
"github.com/mitchellh/go-homedir" "github.com/mitchellh/go-homedir"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/viper" "github.com/spf13/viper"

View File

@ -1,8 +1,8 @@
package config package config
import ( import (
"github.com/anchore/syft/syft/cataloger/files/filecontents"
"github.com/anchore/syft/syft/file" "github.com/anchore/syft/syft/file"
"github.com/anchore/syft/syft/file/cataloger/filecontents"
"github.com/anchore/syft/syft/source" "github.com/anchore/syft/syft/source"
"github.com/spf13/viper" "github.com/spf13/viper"
) )

View File

@ -1,7 +1,7 @@
package config package config
import ( import (
"github.com/anchore/syft/syft/pkg/cataloger/packages" "github.com/anchore/syft/syft/cataloger/packages"
"github.com/spf13/viper" "github.com/spf13/viper"
) )

View File

@ -2,9 +2,9 @@ package config
import ( import (
"fmt" "fmt"
"github.com/anchore/syft/syft/cataloger/files/secrets"
"github.com/anchore/syft/syft/file" "github.com/anchore/syft/syft/file"
"github.com/anchore/syft/syft/file/cataloger/secrets"
"github.com/anchore/syft/syft/source" "github.com/anchore/syft/syft/source"
"github.com/spf13/viper" "github.com/spf13/viper"
) )

View File

@ -2,6 +2,7 @@ package cyclonedxhelpers
import ( import (
"github.com/CycloneDX/cyclonedx-go" "github.com/CycloneDX/cyclonedx-go"
"github.com/anchore/syft/syft/cpe"
"github.com/anchore/syft/internal/log" "github.com/anchore/syft/internal/log"
"github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg"
@ -11,7 +12,7 @@ func encodeSingleCPE(p pkg.Package) string {
// Since the CPEs in a package are sorted by specificity // Since the CPEs in a package are sorted by specificity
// we can extract the first CPE as the one to output in cyclonedx // we can extract the first CPE as the one to output in cyclonedx
if len(p.CPEs) > 0 { if len(p.CPEs) > 0 {
return pkg.CPEString(p.CPEs[0]) return cpe.String(p.CPEs[0])
} }
return "" return ""
} }
@ -24,15 +25,15 @@ func encodeCPEs(p pkg.Package) (out []cyclonedx.Property) {
} }
out = append(out, cyclonedx.Property{ out = append(out, cyclonedx.Property{
Name: "syft:cpe23", Name: "syft:cpe23",
Value: pkg.CPEString(c), Value: cpe.String(c),
}) })
} }
return return
} }
func decodeCPEs(c *cyclonedx.Component) (out []pkg.CPE) { func decodeCPEs(c *cyclonedx.Component) (out []cpe.CPE) {
if c.CPE != "" { if c.CPE != "" {
cp, err := pkg.NewCPE(c.CPE) cp, err := cpe.New(c.CPE)
if err != nil { if err != nil {
log.Warnf("invalid CPE: %s", c.CPE) log.Warnf("invalid CPE: %s", c.CPE)
} else { } else {
@ -43,7 +44,7 @@ func decodeCPEs(c *cyclonedx.Component) (out []pkg.CPE) {
if c.Properties != nil { if c.Properties != nil {
for _, p := range *c.Properties { for _, p := range *c.Properties {
if p.Name == "syft:cpe23" { if p.Name == "syft:cpe23" {
cp, err := pkg.NewCPE(p.Value) cp, err := cpe.New(p.Value)
if err != nil { if err != nil {
log.Warnf("invalid CPE: %s", p.Value) log.Warnf("invalid CPE: %s", p.Value)
} else { } else {

View File

@ -1,6 +1,7 @@
package cyclonedxhelpers package cyclonedxhelpers
import ( import (
"github.com/anchore/syft/syft/cpe"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -9,8 +10,8 @@ import (
) )
func Test_encodeCPE(t *testing.T) { func Test_encodeCPE(t *testing.T) {
testCPE := pkg.MustCPE("cpe:2.3:a:name:name:3.2:*:*:*:*:*:*:*") testCPE := cpe.Must("cpe:2.3:a:name:name:3.2:*:*:*:*:*:*:*")
testCPE2 := pkg.MustCPE("cpe:2.3:a:name:name2:3.2:*:*:*:*:*:*:*") testCPE2 := cpe.Must("cpe:2.3:a:name:name2:3.2:*:*:*:*:*:*:*")
tests := []struct { tests := []struct {
name string name string
input pkg.Package input pkg.Package
@ -20,14 +21,14 @@ func Test_encodeCPE(t *testing.T) {
// note: since this is an optional field, no value is preferred over NONE or NOASSERTION // note: since this is an optional field, no value is preferred over NONE or NOASSERTION
name: "no metadata", name: "no metadata",
input: pkg.Package{ input: pkg.Package{
CPEs: []pkg.CPE{}, CPEs: []cpe.CPE{},
}, },
expected: "", expected: "",
}, },
{ {
name: "single CPE", name: "single CPE",
input: pkg.Package{ input: pkg.Package{
CPEs: []pkg.CPE{ CPEs: []cpe.CPE{
testCPE, testCPE,
}, },
}, },
@ -36,7 +37,7 @@ func Test_encodeCPE(t *testing.T) {
{ {
name: "multiple CPEs", name: "multiple CPEs",
input: pkg.Package{ input: pkg.Package{
CPEs: []pkg.CPE{ CPEs: []cpe.CPE{
testCPE2, testCPE2,
testCPE, testCPE,
}, },

View File

@ -49,7 +49,7 @@ func toSyftModel(bom *cyclonedx.BOM) (*sbom.SBOM, error) {
} }
s := &sbom.SBOM{ s := &sbom.SBOM{
Artifacts: sbom.Artifacts{ Artifacts: sbom.Artifacts{
PackageCatalog: pkg.NewCatalog(), PackageCatalog: pkg.NewCollection(),
LinuxDistribution: linuxReleaseFromComponents(*bom.Components), LinuxDistribution: linuxReleaseFromComponents(*bom.Components),
}, },
Source: meta, Source: meta,

View File

@ -1,6 +1,7 @@
package spdxhelpers package spdxhelpers
import ( import (
"github.com/anchore/syft/syft/cpe"
"github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg"
) )
@ -10,7 +11,7 @@ func ExternalRefs(p pkg.Package) (externalRefs []ExternalRef) {
for _, c := range p.CPEs { for _, c := range p.CPEs {
externalRefs = append(externalRefs, ExternalRef{ externalRefs = append(externalRefs, ExternalRef{
ReferenceCategory: SecurityReferenceCategory, ReferenceCategory: SecurityReferenceCategory,
ReferenceLocator: pkg.CPEString(c), ReferenceLocator: cpe.String(c),
ReferenceType: Cpe23ExternalRefType, ReferenceType: Cpe23ExternalRefType,
}) })
} }

View File

@ -1,6 +1,7 @@
package spdxhelpers package spdxhelpers
import ( import (
"github.com/anchore/syft/syft/cpe"
"testing" "testing"
"github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg"
@ -8,7 +9,7 @@ import (
) )
func Test_ExternalRefs(t *testing.T) { func Test_ExternalRefs(t *testing.T) {
testCPE := pkg.MustCPE("cpe:2.3:a:name:name:3.2:*:*:*:*:*:*:*") testCPE := cpe.Must("cpe:2.3:a:name:name:3.2:*:*:*:*:*:*:*")
tests := []struct { tests := []struct {
name string name string
input pkg.Package input pkg.Package
@ -17,7 +18,7 @@ func Test_ExternalRefs(t *testing.T) {
{ {
name: "cpe + purl", name: "cpe + purl",
input: pkg.Package{ input: pkg.Package{
CPEs: []pkg.CPE{ CPEs: []cpe.CPE{
testCPE, testCPE,
}, },
PURL: "a-purl", PURL: "a-purl",
@ -25,7 +26,7 @@ func Test_ExternalRefs(t *testing.T) {
expected: []ExternalRef{ expected: []ExternalRef{
{ {
ReferenceCategory: SecurityReferenceCategory, ReferenceCategory: SecurityReferenceCategory,
ReferenceLocator: pkg.CPEString(testCPE), ReferenceLocator: cpe.String(testCPE),
ReferenceType: Cpe23ExternalRefType, ReferenceType: Cpe23ExternalRefType,
}, },
{ {

View File

@ -1,6 +1,7 @@
package spdxhelpers package spdxhelpers
import ( import (
"github.com/anchore/syft/syft/cpe"
"strconv" "strconv"
"strings" "strings"
@ -20,7 +21,7 @@ func ToSyftModel(doc *spdx.Document2_2) (*sbom.SBOM, error) {
s := &sbom.SBOM{ s := &sbom.SBOM{
Artifacts: sbom.Artifacts{ Artifacts: sbom.Artifacts{
PackageCatalog: pkg.NewCatalog(), PackageCatalog: pkg.NewCollection(),
FileMetadata: map[file.Coordinates]file.Metadata{}, FileMetadata: map[file.Coordinates]file.Metadata{},
FileDigests: map[file.Coordinates][]file.Digest{}, FileDigests: map[file.Coordinates][]file.Digest{},
LinuxDistribution: findLinuxReleaseByPURL(doc), LinuxDistribution: findLinuxReleaseByPURL(doc),
@ -316,10 +317,10 @@ func findPURLValue(p *spdx.Package2_2) string {
return "" return ""
} }
func extractCPEs(p *spdx.Package2_2) (cpes []pkg.CPE) { func extractCPEs(p *spdx.Package2_2) (cpes []cpe.CPE) {
for _, r := range p.PackageExternalReferences { for _, r := range p.PackageExternalReferences {
if r.RefType == string(Cpe23ExternalRefType) { if r.RefType == string(Cpe23ExternalRefType) {
cpe, err := pkg.NewCPE(r.Locator) cpe, err := cpe.New(r.Locator)
if err != nil { if err != nil {
log.Warnf("unable to extract SPDX CPE=%q: %+v", r.Locator, err) log.Warnf("unable to extract SPDX CPE=%q: %+v", r.Locator, err)
continue continue

View File

@ -2,6 +2,7 @@ package testutils
import ( import (
"bytes" "bytes"
"github.com/anchore/syft/syft/cpe"
"strings" "strings"
"testing" "testing"
@ -99,7 +100,7 @@ func AssertEncoderAgainstGoldenSnapshot(t *testing.T, format sbom.Format, sbom s
func ImageInput(t testing.TB, testImage string, options ...ImageOption) sbom.SBOM { func ImageInput(t testing.TB, testImage string, options ...ImageOption) sbom.SBOM {
t.Helper() t.Helper()
catalog := pkg.NewCatalog() catalog := pkg.NewCollection()
var cfg imageCfg var cfg imageCfg
var img *image.Image var img *image.Image
for _, opt := range options { for _, opt := range options {
@ -151,7 +152,7 @@ func carriageRedactor(s []byte) []byte {
return []byte(msg) return []byte(msg)
} }
func populateImageCatalog(catalog *pkg.Catalog, img *image.Image) { func populateImageCatalog(catalog *pkg.Collection, img *image.Image) {
_, ref1, _ := img.SquashedTree().File("/somefile-1.txt", filetree.FollowBasenameLinks) _, ref1, _ := img.SquashedTree().File("/somefile-1.txt", filetree.FollowBasenameLinks)
_, ref2, _ := img.SquashedTree().File("/somefile-2.txt", filetree.FollowBasenameLinks) _, ref2, _ := img.SquashedTree().File("/somefile-2.txt", filetree.FollowBasenameLinks)
@ -172,8 +173,8 @@ func populateImageCatalog(catalog *pkg.Catalog, img *image.Image) {
Version: "1.0.1", Version: "1.0.1",
}, },
PURL: "a-purl-1", PURL: "a-purl-1",
CPEs: []pkg.CPE{ CPEs: []cpe.CPE{
pkg.MustCPE("cpe:2.3:*:some:package:1:*:*:*:*:*:*:*"), cpe.Must("cpe:2.3:*:some:package:1:*:*:*:*:*:*:*"),
}, },
}) })
catalog.Add(pkg.Package{ catalog.Add(pkg.Package{
@ -190,8 +191,8 @@ func populateImageCatalog(catalog *pkg.Catalog, img *image.Image) {
Version: "2.0.1", Version: "2.0.1",
}, },
PURL: "a-purl-2", PURL: "a-purl-2",
CPEs: []pkg.CPE{ CPEs: []cpe.CPE{
pkg.MustCPE("cpe:2.3:*:some:package:2:*:*:*:*:*:*:*"), cpe.Must("cpe:2.3:*:some:package:2:*:*:*:*:*:*:*"),
}, },
}) })
} }
@ -227,8 +228,8 @@ func DirectoryInput(t testing.TB) sbom.SBOM {
} }
} }
func newDirectoryCatalog() *pkg.Catalog { func newDirectoryCatalog() *pkg.Collection {
catalog := pkg.NewCatalog() catalog := pkg.NewCollection()
// populate catalog with test data // populate catalog with test data
catalog.Add(pkg.Package{ catalog.Add(pkg.Package{
@ -252,8 +253,8 @@ func newDirectoryCatalog() *pkg.Catalog {
}, },
}, },
PURL: "a-purl-2", PURL: "a-purl-2",
CPEs: []pkg.CPE{ CPEs: []cpe.CPE{
pkg.MustCPE("cpe:2.3:*:some:package:2:*:*:*:*:*:*:*"), cpe.Must("cpe:2.3:*:some:package:2:*:*:*:*:*:*:*"),
}, },
}) })
catalog.Add(pkg.Package{ catalog.Add(pkg.Package{
@ -270,8 +271,8 @@ func newDirectoryCatalog() *pkg.Catalog {
Version: "2.0.1", Version: "2.0.1",
}, },
PURL: "a-purl-2", PURL: "a-purl-2",
CPEs: []pkg.CPE{ CPEs: []cpe.CPE{
pkg.MustCPE("cpe:2.3:*:some:package:2:*:*:*:*:*:*:*"), cpe.Must("cpe:2.3:*:some:package:2:*:*:*:*:*:*:*"),
}, },
}) })

View File

@ -48,7 +48,7 @@ func toFormatModel(s sbom.SBOM) (*model.Document, error) {
}, nil }, nil
} }
func toPackages(catalog *pkg.Catalog, relationships []artifact.Relationship) []model.Package { func toPackages(catalog *pkg.Collection, relationships []artifact.Relationship) []model.Package {
packages := make([]model.Package, 0) packages := make([]model.Package, 0)
for _, p := range catalog.Sorted() { for _, p := range catalog.Sorted() {

View File

@ -89,9 +89,9 @@ func toFormatModel(s sbom.SBOM) (*spdx.Document2_2, error) {
}, nil }, nil
} }
// packages populates all Package Information from the package Catalog (see https://spdx.github.io/spdx-spec/3-package-information/) // packages populates all Package Information from the package Collection (see https://spdx.github.io/spdx-spec/3-package-information/)
// nolint: funlen // nolint: funlen
func toFormatPackages(catalog *pkg.Catalog) map[spdx.ElementID]*spdx.Package2_2 { func toFormatPackages(catalog *pkg.Collection) map[spdx.ElementID]*spdx.Package2_2 {
results := make(map[spdx.ElementID]*spdx.Package2_2) results := make(map[spdx.ElementID]*spdx.Package2_2)
for _, p := range catalog.Sorted() { for _, p := range catalog.Sorted() {

View File

@ -2,6 +2,7 @@ package syftjson
import ( import (
"flag" "flag"
"github.com/anchore/syft/syft/cpe"
"testing" "testing"
"github.com/anchore/syft/syft/file" "github.com/anchore/syft/syft/file"
@ -37,7 +38,7 @@ func TestImageEncoder(t *testing.T) {
} }
func TestEncodeFullJSONDocument(t *testing.T) { func TestEncodeFullJSONDocument(t *testing.T) {
catalog := pkg.NewCatalog() catalog := pkg.NewCollection()
p1 := pkg.Package{ p1 := pkg.Package{
Name: "package-1", Name: "package-1",
@ -60,8 +61,8 @@ func TestEncodeFullJSONDocument(t *testing.T) {
Files: []pkg.PythonFileRecord{}, Files: []pkg.PythonFileRecord{},
}, },
PURL: "a-purl-1", PURL: "a-purl-1",
CPEs: []pkg.CPE{ CPEs: []cpe.CPE{
pkg.MustCPE("cpe:2.3:*:some:package:1:*:*:*:*:*:*:*"), cpe.Must("cpe:2.3:*:some:package:1:*:*:*:*:*:*:*"),
}, },
} }
@ -84,8 +85,8 @@ func TestEncodeFullJSONDocument(t *testing.T) {
Files: []pkg.DpkgFileRecord{}, Files: []pkg.DpkgFileRecord{},
}, },
PURL: "a-purl-2", PURL: "a-purl-2",
CPEs: []pkg.CPE{ CPEs: []cpe.CPE{
pkg.MustCPE("cpe:2.3:*:some:package:2:*:*:*:*:*:*:*"), cpe.Must("cpe:2.3:*:some:package:2:*:*:*:*:*:*:*"),
}, },
} }

View File

@ -2,6 +2,7 @@ package syftjson
import ( import (
"fmt" "fmt"
"github.com/anchore/syft/syft/cpe"
"sort" "sort"
"strconv" "strconv"
@ -152,7 +153,7 @@ func toFileMetadataEntry(coordinates file.Coordinates, metadata *file.Metadata)
} }
} }
func toPackageModels(catalog *pkg.Catalog) []model.Package { func toPackageModels(catalog *pkg.Collection) []model.Package {
artifacts := make([]model.Package, 0) artifacts := make([]model.Package, 0)
if catalog == nil { if catalog == nil {
return artifacts return artifacts
@ -167,7 +168,7 @@ func toPackageModels(catalog *pkg.Catalog) []model.Package {
func toPackageModel(p pkg.Package) model.Package { func toPackageModel(p pkg.Package) model.Package {
var cpes = make([]string, len(p.CPEs)) var cpes = make([]string, len(p.CPEs))
for i, c := range p.CPEs { for i, c := range p.CPEs {
cpes[i] = pkg.CPEString(c) cpes[i] = cpe.String(c)
} }
var licenses = make([]string, 0) var licenses = make([]string, 0)

View File

@ -4,6 +4,7 @@ import (
"github.com/anchore/syft/internal/formats/syftjson/model" "github.com/anchore/syft/internal/formats/syftjson/model"
"github.com/anchore/syft/internal/log" "github.com/anchore/syft/internal/log"
"github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/artifact"
"github.com/anchore/syft/syft/cpe"
"github.com/anchore/syft/syft/file" "github.com/anchore/syft/syft/file"
"github.com/anchore/syft/syft/linux" "github.com/anchore/syft/syft/linux"
"github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg"
@ -47,7 +48,7 @@ func toSyftLinuxRelease(d model.LinuxRelease) *linux.Release {
} }
} }
func toSyftRelationships(doc *model.Document, catalog *pkg.Catalog, relationships []model.Relationship) []artifact.Relationship { func toSyftRelationships(doc *model.Document, catalog *pkg.Collection, relationships []model.Relationship) []artifact.Relationship {
idMap := make(map[string]interface{}) idMap := make(map[string]interface{})
for _, p := range catalog.Sorted() { for _, p := range catalog.Sorted() {
@ -129,8 +130,8 @@ func toSyftSourceData(s model.Source) *source.Metadata {
return nil return nil
} }
func toSyftCatalog(pkgs []model.Package) *pkg.Catalog { func toSyftCatalog(pkgs []model.Package) *pkg.Collection {
catalog := pkg.NewCatalog() catalog := pkg.NewCollection()
for _, p := range pkgs { for _, p := range pkgs {
catalog.Add(toSyftPackage(p)) catalog.Add(toSyftPackage(p))
} }
@ -138,9 +139,9 @@ func toSyftCatalog(pkgs []model.Package) *pkg.Catalog {
} }
func toSyftPackage(p model.Package) pkg.Package { func toSyftPackage(p model.Package) pkg.Package {
var cpes []pkg.CPE var cpes []cpe.CPE
for _, c := range p.CPEs { for _, c := range p.CPEs {
value, err := pkg.NewCPE(c) value, err := cpe.New(c)
if err != nil { if err != nil {
log.Warnf("excluding invalid CPE %q: %v", c, err) log.Warnf("excluding invalid CPE %q: %v", c, err)
continue continue

View File

@ -4,8 +4,8 @@ Package apkdb provides a concrete Cataloger implementation for Alpine DB files.
package apkdb package apkdb
import ( import (
"github.com/anchore/syft/syft/cataloger/packages/generic"
"github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/pkg/cataloger/generic"
) )
// NewApkdbCataloger returns a new Alpine DB cataloger object. // NewApkdbCataloger returns a new Alpine DB cataloger object.

View File

@ -8,7 +8,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/anchore/syft/syft/pkg/cataloger/generic" "github.com/anchore/syft/syft/cataloger/packages/generic"
"github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/artifact"

View File

@ -2,16 +2,16 @@ package packages
import ( import (
"fmt" "fmt"
"github.com/anchore/syft/syft/file" "github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/internal/bus" "github.com/anchore/syft/internal/bus"
"github.com/anchore/syft/internal/log" "github.com/anchore/syft/internal/log"
"github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/artifact"
"github.com/anchore/syft/syft/cpe"
"github.com/anchore/syft/syft/event" "github.com/anchore/syft/syft/event"
"github.com/anchore/syft/syft/event/monitor" "github.com/anchore/syft/syft/event/monitor"
"github.com/anchore/syft/syft/file"
"github.com/anchore/syft/syft/linux" "github.com/anchore/syft/syft/linux"
"github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/speculate/cpes"
"github.com/hashicorp/go-multierror" "github.com/hashicorp/go-multierror"
"github.com/wagoodman/go-partybus" "github.com/wagoodman/go-partybus"
"github.com/wagoodman/go-progress" "github.com/wagoodman/go-progress"
@ -21,8 +21,8 @@ import (
// In order to efficiently retrieve contents from an underlying container image the content fetch requests are // In order to efficiently retrieve contents from an underlying container image the content fetch requests are
// done in bulk. Specifically, all files of interest are collected from each cataloger and accumulated into a single // done in bulk. Specifically, all files of interest are collected from each cataloger and accumulated into a single
// request. // request.
func Catalog(resolver file.Resolver, release *linux.Release, catalogers ...pkg.Cataloger) (*pkg.Catalog, []artifact.Relationship, error) { func Catalog(resolver file.Resolver, release *linux.Release, catalogers ...pkg.Cataloger) (*pkg.Collection, []artifact.Relationship, error) {
catalog := pkg.NewCatalog() catalog := pkg.NewCollection()
var allRelationships []artifact.Relationship var allRelationships []artifact.Relationship
filesProcessed, packagesDiscovered := newPackageCatalogerMonitor() filesProcessed, packagesDiscovered := newPackageCatalogerMonitor()
@ -45,7 +45,7 @@ func Catalog(resolver file.Resolver, release *linux.Release, catalogers ...pkg.C
for _, p := range packages { for _, p := range packages {
// generate CPEs (note: this is excluded from package ID, so is safe to mutate) // generate CPEs (note: this is excluded from package ID, so is safe to mutate)
p.CPEs = cpe.Generate(p) p.CPEs = cpes.Generate(p)
// generate PURL (note: this is excluded from package ID, so is safe to mutate) // generate PURL (note: this is excluded from package ID, so is safe to mutate)
p.PURL = pkg.URL(p, release) p.PURL = pkg.URL(p, release)

View File

@ -1,17 +1,17 @@
package packages package packages
import ( import (
"github.com/anchore/syft/syft/cataloger/packages/apkdb"
"github.com/anchore/syft/syft/cataloger/packages/deb"
"github.com/anchore/syft/syft/cataloger/packages/golang"
"github.com/anchore/syft/syft/cataloger/packages/java"
"github.com/anchore/syft/syft/cataloger/packages/javascript"
"github.com/anchore/syft/syft/cataloger/packages/php"
"github.com/anchore/syft/syft/cataloger/packages/python"
"github.com/anchore/syft/syft/cataloger/packages/rpmdb"
"github.com/anchore/syft/syft/cataloger/packages/ruby"
"github.com/anchore/syft/syft/cataloger/packages/rust"
"github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/pkg/cataloger/apkdb"
"github.com/anchore/syft/syft/pkg/cataloger/deb"
"github.com/anchore/syft/syft/pkg/cataloger/golang"
"github.com/anchore/syft/syft/pkg/cataloger/java"
"github.com/anchore/syft/syft/pkg/cataloger/javascript"
"github.com/anchore/syft/syft/pkg/cataloger/php"
"github.com/anchore/syft/syft/pkg/cataloger/python"
"github.com/anchore/syft/syft/pkg/cataloger/rpmdb"
"github.com/anchore/syft/syft/pkg/cataloger/ruby"
"github.com/anchore/syft/syft/pkg/cataloger/rust"
"github.com/anchore/syft/syft/source" "github.com/anchore/syft/syft/source"
) )

Some files were not shown because too many files have changed in this diff Show More