Follow convention for naming catalogers (#2277)

* follow convention for naming catalogers

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix cataloger name example

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:
Alex Goodman 2023-11-02 08:39:42 -04:00 committed by GitHub
parent 6c41f15975
commit b2f4d7eda2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
144 changed files with 294 additions and 273 deletions

View file

@ -45,8 +45,8 @@ jobs:
- name: Restore RPM test-fixture cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
with:
path: syft/pkg/cataloger/rpm/test-fixtures/rpms
key: ${{ runner.os }}-unit-rpm-cache-${{ hashFiles( 'syft/pkg/cataloger/rpm/test-fixtures/rpms.fingerprint' ) }}
path: syft/pkg/cataloger/redhat/test-fixtures/rpms
key: ${{ runner.os }}-unit-rpm-cache-${{ hashFiles( 'syft/pkg/cataloger/redhat/test-fixtures/rpms.fingerprint' ) }}
- name: Restore go binary test-fixture cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2

View file

@ -202,6 +202,14 @@ From a high level catalogers have the following properties:
- _Packages created by the cataloger should not be mutated after they are created_. There is one exception made for adding CPEs to a package after the cataloging phase, but that will most likely be moved back into the cataloger in the future.
Cataloger names should be unique and named with the following rules of thumb in mind:
- Must end with `-cataloger`
- Use lowercase letters, numbers, and hyphens only
- Use hyphens to separate words
- Catalogers for language ecosystems should start with the language name (e.g. `python-` for a cataloger that raises up python packages)
- Distinct between when the cataloger is searching for evidence of installed packages vs declared packages. For example, there are currently two different gemspec-based catalogers, the `ruby-gemspec-cataloger` and `ruby-installed-gemspec-cataloger`, where the latter requires that the gemspec is found within a `specifications` directory (which means it was installed, not just at the root of a source repo).
#### Building a new Cataloger
Catalogers must fulfill the [`pkg.Cataloger` interface](https://github.com/anchore/syft/tree/v0.70.0/syft/pkg/cataloger.go) in order to add packages to the SBOM.

View file

@ -494,7 +494,7 @@ platform: ""
# set the list of package catalogers to use when generating the SBOM
# default = empty (cataloger set determined automatically by the source type [image or file/directory])
# catalogers:
# - alpmdb-cataloger
# - alpm-db-cataloger
# - apkdb-cataloger
# - binary-cataloger
# - cargo-auditable-binary-cataloger
@ -502,10 +502,10 @@ platform: ""
# - conan-cataloger
# - dartlang-lock-cataloger
# - dotnet-deps-cataloger
# - dpkgdb-cataloger
# - dpkg-db-cataloger
# - elixir-mix-lock-cataloger
# - erlang-rebar-lock-cataloger
# - go-mod-file-cataloger
# - go-module-file-cataloger
# - go-module-binary-cataloger
# - graalvm-native-image-cataloger
# - haskell-cataloger
@ -519,12 +519,12 @@ platform: ""
# - php-composer-installed-cataloger
# - php-composer-lock-cataloger
# - portage-cataloger
# - python-index-cataloger
# - python-package-cataloger
# - python-installed-package-cataloger
# - rpm-db-cataloger
# - rpm-file-cataloger
# - rpm-archive-cataloger
# - ruby-gemfile-cataloger
# - ruby-gemspec-cataloger
# - ruby-installed-gemspec-cataloger
# - rust-cargo-lock-cataloger
# - sbom-cataloger
# - spm-cataloger

View file

@ -174,7 +174,9 @@ tasks:
unit:
desc: Run unit tests
deps: [tmpdir]
deps:
- tmpdir
- fixtures
vars:
TEST_PKGS:
sh: "go list ./... | grep -v {{ .OWNER }}/{{ .PROJECT }}/test | tr '\n' ' '"
@ -261,7 +263,7 @@ tasks:
- syft/pkg/cataloger/binary/test-fixtures/cache.fingerprint
- syft/pkg/cataloger/java/test-fixtures/java-builds/cache.fingerprint
- syft/pkg/cataloger/golang/test-fixtures/archs/binaries.fingerprint
- syft/pkg/cataloger/rpm/test-fixtures/rpms.fingerprint
- syft/pkg/cataloger/redhat/test-fixtures/rpms.fingerprint
- syft/pkg/cataloger/kernel/test-fixtures/cache.fingerprint
- test/install/cache.fingerprint
- test/cli/test-fixtures/cache.fingerprint
@ -275,7 +277,7 @@ tasks:
# for GO BINARY test fixtures
- "cd syft/pkg/cataloger/golang/test-fixtures/archs && make binaries.fingerprint"
# for RPM test fixtures
- "cd syft/pkg/cataloger/rpm/test-fixtures && make rpms.fingerprint"
- "cd syft/pkg/cataloger/redhat/test-fixtures && make rpms.fingerprint"
# for Kernel test fixtures
- "cd syft/pkg/cataloger/kernel/test-fixtures && make cache.fingerprint"
# for INSTALL integration test fixtures
@ -287,7 +289,7 @@ tasks:
desc: Generate test fixtures
cmds:
- "cd syft/pkg/cataloger/java/test-fixtures/java-builds && make"
- "cd syft/pkg/cataloger/rpm/test-fixtures && make"
- "cd syft/pkg/cataloger/redhat/test-fixtures && make"
- "cd syft/pkg/cataloger/binary/test-fixtures && make"
show-test-image-cache:

View file

@ -31,7 +31,7 @@
"properties": [
{
"name": "syft:package:foundBy",
"value": "go-mod-file-cataloger"
"value": "go-module-file-cataloger"
},
{
"name": "syft:package:language",

View file

@ -31,7 +31,7 @@
"properties": [
{
"name": "syft:package:foundBy",
"value": "go-mod-file-cataloger"
"value": "go-module-file-cataloger"
},
{
"name": "syft:package:language",

View file

@ -31,7 +31,7 @@
"properties": [
{
"name": "syft:package:foundBy",
"value": "go-mod-file-cataloger"
"value": "go-module-file-cataloger"
},
{
"name": "syft:package:language",

View file

@ -21,7 +21,7 @@
<cpe>cpe:2.3:a:wagoodman:go-partybus:v0.0.0-20230516145632-8ccac152c651:*:*:*:*:*:*:*</cpe>
<purl>pkg:golang/github.com/wagoodman/go-partybus@v0.0.0-20230516145632-8ccac152c651</purl>
<properties>
<property name="syft:package:foundBy">go-mod-file-cataloger</property>
<property name="syft:package:foundBy">go-module-file-cataloger</property>
<property name="syft:package:language">go</property>
<property name="syft:package:metadataType">GolangModMetadata</property>
<property name="syft:package:type">go-module</property>

View file

@ -21,7 +21,7 @@
<cpe>cpe:2.3:a:wagoodman:go-partybus:v0.0.0-20230516145632-8ccac152c651:*:*:*:*:*:*:*</cpe>
<purl>pkg:golang/github.com/wagoodman/go-partybus@v0.0.0-20230516145632-8ccac152c651</purl>
<properties>
<property name="syft:package:foundBy">go-mod-file-cataloger</property>
<property name="syft:package:foundBy">go-module-file-cataloger</property>
<property name="syft:package:language">go</property>
<property name="syft:package:metadataType">GolangModMetadata</property>
<property name="syft:package:type">go-module</property>

View file

@ -21,7 +21,7 @@
<cpe>cpe:2.3:a:wagoodman:go-partybus:v0.0.0-20230516145632-8ccac152c651:*:*:*:*:*:*:*</cpe>
<purl>pkg:golang/github.com/wagoodman/go-partybus@v0.0.0-20230516145632-8ccac152c651</purl>
<properties>
<property name="syft:package:foundBy">go-mod-file-cataloger</property>
<property name="syft:package:foundBy">go-module-file-cataloger</property>
<property name="syft:package:language">go</property>
<property name="syft:package:metadataType">GolangModMetadata</property>
<property name="syft:package:type">go-module</property>

View file

@ -5,7 +5,7 @@
"name": "github.com/wagoodman/go-partybus",
"version": "v0.0.0-20230516145632-8ccac152c651",
"type": "go-module",
"foundBy": "go-mod-file-cataloger",
"foundBy": "go-module-file-cataloger",
"locations": [
{
"path": "/go.mod",

View file

@ -0,0 +1,15 @@
/*
Package alpine provides a concrete Cataloger implementations for packages relating to the Alpine linux distribution.
*/
package alpine
import (
"github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/pkg/cataloger/generic"
)
// NewDBCataloger returns a new cataloger object initialized for Alpine package DB flat-file stores.
func NewDBCataloger() *generic.Cataloger {
return generic.NewCataloger("apk-db-cataloger").
WithParserByGlobs(parseApkDB, pkg.ApkDBGlob)
}

View file

@ -1,4 +1,4 @@
package apkdb
package alpine
import (
"testing"
@ -25,7 +25,7 @@ func TestCataloger_Globs(t *testing.T) {
FromDirectory(t, test.fixture).
ExpectsResolverContentQueries(test.expected).
IgnoreUnfulfilledPathResponses("etc/apk/repositories").
TestCataloger(t, NewApkdbCataloger())
TestCataloger(t, NewDBCataloger())
})
}
}

View file

@ -1,4 +1,4 @@
package apkdb
package alpine
import (
"strings"

View file

@ -1,4 +1,4 @@
package apkdb
package alpine
import (
"strings"

View file

@ -1,4 +1,4 @@
package apkdb
package alpine
import (
"bufio"

View file

@ -1,4 +1,4 @@
package apkdb
package alpine
import (
"io"

View file

@ -1,14 +0,0 @@
package alpm
import (
"github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/pkg/cataloger/generic"
)
const catalogerName = "alpmdb-cataloger"
// NewAlpmdbCataloger returns a new cataloger object initialized for arch linux pacman database flat-file stores.
func NewAlpmdbCataloger() *generic.Cataloger {
return generic.NewCataloger(catalogerName).
WithParserByGlobs(parseAlpmDB, pkg.AlpmDBGlob)
}

View file

@ -1,17 +0,0 @@
/*
Package apkdb provides a concrete Cataloger implementation for Alpine DB files.
*/
package apkdb
import (
"github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/pkg/cataloger/generic"
)
const catalogerName = "apkdb-cataloger"
// NewApkdbCataloger returns a new cataloger object initialized for Alpine package DB flat-file stores.
func NewApkdbCataloger() *generic.Cataloger {
return generic.NewCataloger(catalogerName).
WithParserByGlobs(parseApkDB, pkg.ApkDBGlob)
}

View file

@ -0,0 +1,15 @@
/*
Package arch provides a concrete Cataloger implementations for packages relating to the Arch linux distribution.
*/
package arch
import (
"github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/pkg/cataloger/generic"
)
// NewDBCataloger returns a new cataloger object initialized for arch linux pacman database flat-file stores.
func NewDBCataloger() *generic.Cataloger {
return generic.NewCataloger("alpm-db-cataloger").
WithParserByGlobs(parseAlpmDB, pkg.AlpmDBGlob)
}

View file

@ -1,4 +1,4 @@
package alpm
package arch
import (
"testing"
@ -18,7 +18,7 @@ func TestAlpmCataloger(t *testing.T) {
Name: "gmp",
Version: "6.2.1-2",
Type: pkg.AlpmPkg,
FoundBy: "alpmdb-cataloger",
FoundBy: "alpm-db-cataloger",
Licenses: pkg.NewLicenseSet(
pkg.NewLicenseFromLocations("LGPL3", dbLocation),
pkg.NewLicenseFromLocations("GPL", dbLocation),
@ -177,7 +177,7 @@ func TestAlpmCataloger(t *testing.T) {
FromDirectory(t, "test-fixtures/gmp-fixture").
WithCompareOptions(cmpopts.IgnoreFields(pkg.AlpmFileRecord{}, "Time")).
Expects(expectedPkgs, expectedRelationships).
TestCataloger(t, NewAlpmdbCataloger())
TestCataloger(t, NewDBCataloger())
}
@ -203,7 +203,7 @@ func TestCataloger_Globs(t *testing.T) {
FromDirectory(t, test.fixture).
ExpectsResolverContentQueries(test.expected).
IgnoreUnfulfilledPathResponses("var/lib/pacman/local/base-1.0/mtree", "var/lib/pacman/local/dive-0.10.0/mtree").
TestCataloger(t, NewAlpmdbCataloger())
TestCataloger(t, NewDBCataloger())
})
}
}

View file

@ -1,4 +1,4 @@
package alpm
package arch
import (
"strings"

View file

@ -1,4 +1,4 @@
package alpm
package arch
import (
"testing"

View file

@ -1,4 +1,4 @@
package alpm
package arch
import (
"bufio"

View file

@ -1,4 +1,4 @@
package alpm
package arch
import (
"bufio"

View file

@ -1,3 +1,6 @@
/*
Package binary provides a concrete Cataloger implementations for surfacing possible packages based on signatures found within binary files.
*/
package binary
import (

View file

@ -10,15 +10,16 @@ import (
"github.com/anchore/syft/internal/log"
"github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/pkg/cataloger/alpm"
"github.com/anchore/syft/syft/pkg/cataloger/apkdb"
"github.com/anchore/syft/syft/pkg/cataloger/alpine"
"github.com/anchore/syft/syft/pkg/cataloger/arch"
"github.com/anchore/syft/syft/pkg/cataloger/binary"
"github.com/anchore/syft/syft/pkg/cataloger/cpp"
"github.com/anchore/syft/syft/pkg/cataloger/dart"
"github.com/anchore/syft/syft/pkg/cataloger/deb"
"github.com/anchore/syft/syft/pkg/cataloger/debian"
"github.com/anchore/syft/syft/pkg/cataloger/dotnet"
"github.com/anchore/syft/syft/pkg/cataloger/elixir"
"github.com/anchore/syft/syft/pkg/cataloger/erlang"
"github.com/anchore/syft/syft/pkg/cataloger/gentoo"
"github.com/anchore/syft/syft/pkg/cataloger/githubactions"
"github.com/anchore/syft/syft/pkg/cataloger/golang"
"github.com/anchore/syft/syft/pkg/cataloger/haskell"
@ -27,10 +28,9 @@ import (
"github.com/anchore/syft/syft/pkg/cataloger/kernel"
"github.com/anchore/syft/syft/pkg/cataloger/nix"
"github.com/anchore/syft/syft/pkg/cataloger/php"
"github.com/anchore/syft/syft/pkg/cataloger/portage"
"github.com/anchore/syft/syft/pkg/cataloger/python"
"github.com/anchore/syft/syft/pkg/cataloger/r"
"github.com/anchore/syft/syft/pkg/cataloger/rpm"
"github.com/anchore/syft/syft/pkg/cataloger/redhat"
"github.com/anchore/syft/syft/pkg/cataloger/ruby"
"github.com/anchore/syft/syft/pkg/cataloger/rust"
"github.com/anchore/syft/syft/pkg/cataloger/sbom"
@ -42,61 +42,61 @@ const AllCatalogersPattern = "all"
// ImageCatalogers returns a slice of locally implemented catalogers that are fit for detecting installations of packages.
func ImageCatalogers(cfg Config) []pkg.Cataloger {
return filterCatalogers([]pkg.Cataloger{
alpm.NewAlpmdbCataloger(),
apkdb.NewApkdbCataloger(),
arch.NewDBCataloger(),
alpine.NewDBCataloger(),
binary.NewCataloger(),
cpp.NewConanInfoCataloger(),
deb.NewDpkgdbCataloger(),
debian.NewDBCataloger(),
dotnet.NewDotnetPortableExecutableCataloger(),
golang.NewGoModuleBinaryCataloger(cfg.Golang),
java.NewJavaCataloger(cfg.JavaConfig()),
java.NewArchiveCataloger(cfg.JavaConfig()),
java.NewNativeImageCataloger(),
javascript.NewPackageCataloger(),
nix.NewStoreCataloger(),
php.NewComposerInstalledCataloger(),
portage.NewPortageCataloger(),
python.NewPythonPackageCataloger(),
gentoo.NewPortageCataloger(),
python.NewInstalledPackageCataloger(),
r.NewPackageCataloger(),
rpm.NewRpmDBCataloger(),
redhat.NewDBCataloger(),
ruby.NewInstalledGemSpecCataloger(),
sbom.NewSBOMCataloger(),
sbom.NewCataloger(),
}, cfg.Catalogers)
}
// DirectoryCatalogers returns a slice of locally implemented catalogers that are fit for detecting packages from index files (and select installations)
func DirectoryCatalogers(cfg Config) []pkg.Cataloger {
return filterCatalogers([]pkg.Cataloger{
alpm.NewAlpmdbCataloger(),
apkdb.NewApkdbCataloger(),
arch.NewDBCataloger(),
alpine.NewDBCataloger(),
binary.NewCataloger(),
cpp.NewConanCataloger(),
dart.NewPubspecLockCataloger(),
deb.NewDpkgdbCataloger(),
debian.NewDBCataloger(),
dotnet.NewDotnetDepsCataloger(),
dotnet.NewDotnetPortableExecutableCataloger(),
elixir.NewMixLockCataloger(),
erlang.NewRebarLockCataloger(),
githubactions.NewActionUsageCataloger(),
githubactions.NewWorkflowUsageCataloger(),
golang.NewGoModFileCataloger(cfg.Golang),
golang.NewGoModuleFileCataloger(cfg.Golang),
golang.NewGoModuleBinaryCataloger(cfg.Golang),
haskell.NewHackageCataloger(),
java.NewJavaCataloger(cfg.JavaConfig()),
java.NewJavaGradleLockfileCataloger(),
java.NewJavaPomCataloger(),
java.NewArchiveCataloger(cfg.JavaConfig()),
java.NewGradleLockfileCataloger(),
java.NewPomCataloger(),
java.NewNativeImageCataloger(),
javascript.NewLockCataloger(),
nix.NewStoreCataloger(),
php.NewComposerLockCataloger(),
portage.NewPortageCataloger(),
python.NewPythonIndexCataloger(cfg.Python),
python.NewPythonPackageCataloger(),
rpm.NewFileCataloger(),
rpm.NewRpmDBCataloger(),
gentoo.NewPortageCataloger(),
python.NewPackageCataloger(cfg.Python),
python.NewInstalledPackageCataloger(),
redhat.NewArchiveCataloger(),
redhat.NewDBCataloger(),
ruby.NewGemFileLockCataloger(),
ruby.NewGemSpecCataloger(),
rust.NewCargoLockCataloger(),
sbom.NewSBOMCataloger(),
sbom.NewCataloger(),
swift.NewCocoapodsCataloger(),
swift.NewSwiftPackageManagerCataloger(),
}, cfg.Catalogers)
@ -105,24 +105,24 @@ func DirectoryCatalogers(cfg Config) []pkg.Cataloger {
// AllCatalogers returns all implemented catalogers
func AllCatalogers(cfg Config) []pkg.Cataloger {
return filterCatalogers([]pkg.Cataloger{
alpm.NewAlpmdbCataloger(),
apkdb.NewApkdbCataloger(),
arch.NewDBCataloger(),
alpine.NewDBCataloger(),
binary.NewCataloger(),
cpp.NewConanCataloger(),
dart.NewPubspecLockCataloger(),
deb.NewDpkgdbCataloger(),
debian.NewDBCataloger(),
dotnet.NewDotnetDepsCataloger(),
dotnet.NewDotnetPortableExecutableCataloger(),
elixir.NewMixLockCataloger(),
erlang.NewRebarLockCataloger(),
githubactions.NewActionUsageCataloger(),
githubactions.NewWorkflowUsageCataloger(),
golang.NewGoModFileCataloger(cfg.Golang),
golang.NewGoModuleFileCataloger(cfg.Golang),
golang.NewGoModuleBinaryCataloger(cfg.Golang),
haskell.NewHackageCataloger(),
java.NewJavaCataloger(cfg.JavaConfig()),
java.NewJavaGradleLockfileCataloger(),
java.NewJavaPomCataloger(),
java.NewArchiveCataloger(cfg.JavaConfig()),
java.NewGradleLockfileCataloger(),
java.NewPomCataloger(),
java.NewNativeImageCataloger(),
javascript.NewLockCataloger(),
javascript.NewPackageCataloger(),
@ -130,18 +130,18 @@ func AllCatalogers(cfg Config) []pkg.Cataloger {
nix.NewStoreCataloger(),
php.NewComposerInstalledCataloger(),
php.NewComposerLockCataloger(),
portage.NewPortageCataloger(),
python.NewPythonIndexCataloger(cfg.Python),
python.NewPythonPackageCataloger(),
gentoo.NewPortageCataloger(),
python.NewPackageCataloger(cfg.Python),
python.NewInstalledPackageCataloger(),
r.NewPackageCataloger(),
rpm.NewFileCataloger(),
rpm.NewRpmDBCataloger(),
redhat.NewArchiveCataloger(),
redhat.NewDBCataloger(),
ruby.NewGemFileLockCataloger(),
ruby.NewGemSpecCataloger(),
ruby.NewInstalledGemSpecCataloger(),
rust.NewAuditBinaryCataloger(),
rust.NewCargoLockCataloger(),
sbom.NewSBOMCataloger(),
sbom.NewCataloger(),
swift.NewCocoapodsCataloger(),
swift.NewSwiftPackageManagerCataloger(),
}, cfg.Catalogers)

View file

@ -26,16 +26,16 @@ func (d dummy) Catalog(_ file.Resolver) ([]pkg.Package, []artifact.Relationship,
func Test_filterCatalogers(t *testing.T) {
largeCatalogerList := []string{
"alpmdb-cataloger",
"alpm-db-cataloger",
"apkdb-cataloger",
"binary-cataloger",
"conan-cataloger",
"dartlang-lock-cataloger",
"dpkgdb-cataloger",
"dpkg-db-cataloger",
"dotnet-deps-cataloger",
"elixir-mix-lock-cataloger",
"erlang-rebar-lock-cataloger",
"go-mod-file-cataloger",
"go-module-file-cataloger",
"go-module-binary-cataloger",
"haskell-cataloger",
"graalvm-native-image-cataloger",
@ -46,12 +46,12 @@ func Test_filterCatalogers(t *testing.T) {
"php-composer-installed-cataloger",
"php-composer-lock-cataloger",
"portage-cataloger",
"python-index-cataloger",
"python-package-cataloger",
"python-installed-package-cataloger",
"rpm-db-cataloger",
"rpm-file-cataloger",
"rpm-archive-cataloger",
"ruby-gemfile-cataloger",
"ruby-gemspec-cataloger",
"ruby-installed-gemspec-cataloger",
"rust-cargo-lock-cataloger",
"cargo-auditable-binary-cataloger",
"sbom-cataloger",
@ -67,23 +67,23 @@ func Test_filterCatalogers(t *testing.T) {
name: "no filtering",
patterns: nil,
catalogers: []string{
"ruby-gemspec-cataloger",
"python-package-cataloger",
"ruby-installed-gemspec-cataloger",
"python-installed-package-cataloger",
"php-composer-installed-cataloger",
"javascript-package-cataloger",
"dpkgdb-cataloger",
"rpmdb-cataloger",
"dpkg-db-cataloger",
"rpm-db-cataloger",
"java-cataloger",
"apkdb-cataloger",
"go-module-binary-cataloger",
},
want: []string{
"ruby-gemspec-cataloger",
"python-package-cataloger",
"ruby-installed-gemspec-cataloger",
"python-installed-package-cataloger",
"php-composer-installed-cataloger",
"javascript-package-cataloger",
"dpkgdb-cataloger",
"rpmdb-cataloger",
"dpkg-db-cataloger",
"rpm-db-cataloger",
"java-cataloger",
"apkdb-cataloger",
"go-module-binary-cataloger",
@ -92,23 +92,23 @@ func Test_filterCatalogers(t *testing.T) {
{
name: "exact name match",
patterns: []string{
"rpmdb-cataloger",
"rpm-db-cataloger",
"javascript-package-cataloger",
},
catalogers: []string{
"ruby-gemspec-cataloger",
"python-package-cataloger",
"ruby-installed-gemspec-cataloger",
"python-installed-package-cataloger",
"php-composer-installed-cataloger",
"javascript-package-cataloger",
"dpkgdb-cataloger",
"rpmdb-cataloger",
"dpkg-db-cataloger",
"rpm-db-cataloger",
"java-cataloger",
"apkdb-cataloger",
"go-module-binary-cataloger",
},
want: []string{
"javascript-package-cataloger",
"rpmdb-cataloger",
"rpm-db-cataloger",
},
},
{
@ -118,20 +118,21 @@ func Test_filterCatalogers(t *testing.T) {
"installed",
},
catalogers: []string{
"ruby-gemspec-cataloger",
"ruby-installed-gemspec-cataloger",
"ruby-gemfile-cataloger",
"python-package-cataloger",
"python-installed-package-cataloger",
"php-composer-installed-cataloger",
"javascript-package-cataloger",
"dpkgdb-cataloger",
"rpmdb-cataloger",
"dpkg-db-cataloger",
"rpm-db-cataloger",
"java-cataloger",
"apkdb-cataloger",
"go-module-binary-cataloger",
},
want: []string{
"php-composer-installed-cataloger",
"ruby-gemspec-cataloger",
"python-installed-package-cataloger",
"ruby-installed-gemspec-cataloger",
"ruby-gemfile-cataloger",
},
},
@ -141,13 +142,13 @@ func Test_filterCatalogers(t *testing.T) {
"cataloger",
},
catalogers: []string{
"ruby-gemspec-cataloger",
"ruby-installed-gemspec-cataloger",
"ruby-gemfile-cataloger",
"python-package-cataloger",
"python-installed-package-cataloger",
"php-composer-installed-cataloger",
"javascript-package-cataloger",
"dpkgdb-cataloger",
"rpmdb-cataloger",
"dpkg-db-cataloger",
"rpm-db-cataloger",
"java-cataloger",
"apkdb-cataloger",
"go-module-binary-cataloger",
@ -161,13 +162,13 @@ func Test_filterCatalogers(t *testing.T) {
"go-module",
},
catalogers: []string{
"ruby-gemspec-cataloger",
"ruby-installed-gemspec-cataloger",
"ruby-gemfile-cataloger",
"python-package-cataloger",
"python-installed-package-cataloger",
"php-composer-installed-cataloger",
"javascript-package-cataloger",
"dpkgdb-cataloger",
"rpmdb-cataloger",
"dpkg-db-cataloger",
"rpm-db-cataloger",
"java-cataloger",
"apkdb-cataloger",
"go-module-binary-cataloger",
@ -196,7 +197,7 @@ func Test_filterCatalogers(t *testing.T) {
},
catalogers: largeCatalogerList,
want: []string{
"go-mod-file-cataloger",
"go-module-file-cataloger",
"go-module-binary-cataloger",
//"rust-cargo-lock-cataloger", // with naive "contains" matching
//"cargo-auditable-binary-cataloger", // with naive "contains" matching
@ -208,9 +209,10 @@ func Test_filterCatalogers(t *testing.T) {
"mod",
},
catalogers: largeCatalogerList,
want: []string{
"go-mod-file-cataloger",
//"go-module-binary-cataloger", // unfortunately not a full word (this should probably be renamed)
want: []string{
// important! these are NOT found
//"go-module-file-cataloger",
//"go-module-binary-cataloger",
},
},
}
@ -250,7 +252,7 @@ func Test_contains(t *testing.T) {
enabledCatalogers: []string{
"python",
},
catalogerName: "python-package-cataloger",
catalogerName: "python-installed-package-cataloger",
want: true,
},
{
@ -258,7 +260,7 @@ func Test_contains(t *testing.T) {
enabledCatalogers: []string{
"cataloger",
},
catalogerName: "python-package-cataloger",
catalogerName: "python-installed-package-cataloger",
want: false,
},
}

View file

@ -1,3 +1,6 @@
/*
Package cpp provides a concrete Cataloger implementations for the C/C++ language ecosystem.
*/
package cpp
import (

View file

@ -1,13 +1,14 @@
/*
Package dart provides a concrete Cataloger implementations for the Dart language ecosystem.
*/
package dart
import (
"github.com/anchore/syft/syft/pkg/cataloger/generic"
)
const catalogerName = "dartlang-lock-cataloger"
// NewPubspecLockCataloger returns a new Dartlang cataloger object base on pubspec lock files.
func NewPubspecLockCataloger() *generic.Cataloger {
return generic.NewCataloger(catalogerName).
return generic.NewCataloger("dart-pubspec-lock-cataloger").
WithParserByGlobs(parsePubspecLock, "**/pubspec.lock")
}

View file

@ -1,17 +1,15 @@
/*
Package deb provides a concrete Cataloger implementation for Debian package DB status files.
Package debian provides a concrete Cataloger implementation relating to packages within the Debian linux distribution.
*/
package deb
package debian
import (
"github.com/anchore/syft/syft/pkg/cataloger/generic"
)
const catalogerName = "dpkgdb-cataloger"
// NewDpkgdbCataloger returns a new Deb package cataloger capable of parsing DPKG status DB flat-file stores.
func NewDpkgdbCataloger() *generic.Cataloger {
return generic.NewCataloger(catalogerName).
// NewDBCataloger returns a new Deb package cataloger capable of parsing DPKG status DB flat-file stores.
func NewDBCataloger() *generic.Cataloger {
return generic.NewCataloger("dpkg-db-cataloger").
// note: these globs have been intentionally split up in order to improve search performance,
// please do NOT combine into: "**/var/lib/dpkg/{status,status.d/*}"
WithParserByGlobs(parseDpkgDB, "**/var/lib/dpkg/status", "**/var/lib/dpkg/status.d/*", "**/lib/opkg/info/*.control", "**/lib/opkg/status")

View file

@ -1,4 +1,4 @@
package deb
package debian
import (
"testing"
@ -19,7 +19,7 @@ func TestDpkgCataloger(t *testing.T) {
{
Name: "libpam-runtime",
Version: "1.1.8-3.6",
FoundBy: "dpkgdb-cataloger",
FoundBy: "dpkg-db-cataloger",
Licenses: pkg.NewLicenseSet(
pkg.NewLicenseFromLocations("GPL-1", file.NewVirtualLocation("/usr/share/doc/libpam-runtime/copyright", "/usr/share/doc/libpam-runtime/copyright")),
pkg.NewLicenseFromLocations("GPL-2", file.NewVirtualLocation("/usr/share/doc/libpam-runtime/copyright", "/usr/share/doc/libpam-runtime/copyright")),
@ -92,7 +92,7 @@ func TestDpkgCataloger(t *testing.T) {
{
Name: "libsqlite3-0",
Version: "3.34.1-3",
FoundBy: "dpkgdb-cataloger",
FoundBy: "dpkg-db-cataloger",
Licenses: pkg.NewLicenseSet(
pkg.NewLicenseFromLocations("public-domain", file.NewVirtualLocation("/usr/share/doc/libsqlite3-0/copyright", "/usr/share/doc/libsqlite3-0/copyright")),
pkg.NewLicenseFromLocations("GPL-2+", file.NewVirtualLocation("/usr/share/doc/libsqlite3-0/copyright", "/usr/share/doc/libsqlite3-0/copyright")),
@ -150,7 +150,7 @@ func TestDpkgCataloger(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := NewDpkgdbCataloger()
c := NewDBCataloger()
pkgtest.NewCatalogTester().
WithImageResolver(t, tt.name).
IgnoreLocationLayer(). // this fixture can be rebuilt, thus the layer ID will change
@ -183,7 +183,7 @@ func TestCataloger_Globs(t *testing.T) {
pkgtest.NewCatalogTester().
FromDirectory(t, test.fixture).
ExpectsResolverContentQueries(test.expected).
TestCataloger(t, NewDpkgdbCataloger())
TestCataloger(t, NewDBCataloger())
})
}
}

View file

@ -1,4 +1,4 @@
package deb
package debian
import (
"fmt"

View file

@ -1,4 +1,4 @@
package deb
package debian
import (
"testing"

View file

@ -1,4 +1,4 @@
package deb
package debian
import (
"bufio"

View file

@ -1,4 +1,4 @@
package deb
package debian
import (
"os"

View file

@ -1,4 +1,4 @@
package deb
package debian
import (
"bufio"

View file

@ -1,4 +1,4 @@
package deb
package debian
import (
"bufio"

View file

@ -1,4 +1,4 @@
package deb
package debian
import (
"bufio"

View file

@ -1,3 +1,6 @@
/*
Package dotnet provides a concrete Cataloger implementation relating to packages within the C#/.NET language/runtime ecosystem.
*/
package dotnet
import (

View file

@ -1,5 +1,5 @@
/*
Package elixir provides a concrete Cataloger implementation for elixir specific package manger files.
Package elixir provides a concrete Cataloger implementation relating to packages within the Elixir language ecosystem.
*/
package elixir
@ -7,10 +7,8 @@ import (
"github.com/anchore/syft/syft/pkg/cataloger/generic"
)
const catalogerName = "elixir-mix-lock-cataloger"
// NewMixLockCataloger returns a cataloger object for Elixir mix.lock files.
func NewMixLockCataloger() *generic.Cataloger {
return generic.NewCataloger(catalogerName).
return generic.NewCataloger("elixir-mix-lock-cataloger").
WithParserByGlobs(parseMixLock, "**/mix.lock")
}

View file

@ -1,5 +1,5 @@
/*
Package erlang provides a concrete Cataloger implementation for erlang specific package manger files.
Package erlang provides a concrete Cataloger implementation relating to packages within the Erlang language ecosystem.
*/
package erlang
@ -7,10 +7,8 @@ import (
"github.com/anchore/syft/syft/pkg/cataloger/generic"
)
const catalogerName = "erlang-rebar-lock-cataloger"
// NewRebarLockCataloger returns a new cataloger instance for Erlang rebar.lock files.
func NewRebarLockCataloger() *generic.Cataloger {
return generic.NewCataloger(catalogerName).
return generic.NewCataloger("erlang-rebar-lock-cataloger").
WithParserByGlobs(parseRebarLock, "**/rebar.lock")
}

View file

@ -1,7 +1,7 @@
/*
Package portage provides a concrete Cataloger implementation for Gentoo Portage.
Package gentoo provides a concrete Cataloger implementation related to packages within the Gentoo linux ecosystem.
*/
package portage
package gentoo
import (
"github.com/anchore/syft/syft/pkg/cataloger/generic"

View file

@ -1,4 +1,4 @@
package portage
package gentoo
import (
"testing"

View file

@ -1,4 +1,4 @@
package portage
package gentoo
import (
"bufio"

View file

@ -1,4 +1,4 @@
package portage
package gentoo
import (
"github.com/anchore/packageurl-go"

View file

@ -1,4 +1,4 @@
package portage
package gentoo
import (
"fmt"

View file

@ -1,3 +1,6 @@
/*
Package githubactions provides a concrete Cataloger implementation for GitHub Actions packages (both actions and workflows).
*/
package githubactions
import "github.com/anchore/syft/syft/pkg/cataloger/generic"

View file

@ -42,8 +42,8 @@ jobs:
- name: Restore RPM test-fixture cache
uses: actions/cache@v3
with:
path: syft/pkg/cataloger/rpm/test-fixtures/rpms
key: ${{ runner.os }}-unit-rpm-cache-${{ hashFiles( 'syft/pkg/cataloger/rpm/test-fixtures/rpms.fingerprint' ) }}
path: syft/pkg/cataloger/redhat/test-fixtures/rpms
key: ${{ runner.os }}-unit-rpm-cache-${{ hashFiles( 'syft/pkg/cataloger/redhat/test-fixtures/rpms.fingerprint' ) }}
- name: Restore go binary test-fixture cache
uses: actions/cache@v3

View file

@ -1,5 +1,5 @@
/*
Package golang provides a concrete Cataloger implementation for go.mod files.
Package golang provides a concrete Cataloger implementation relating to packages within the Go language ecosystem.
*/
package golang
@ -19,14 +19,14 @@ import (
var versionCandidateGroups = regexp.MustCompile(`(?P<version>\d+(\.\d+)?(\.\d+)?)(?P<candidate>\w*)`)
// NewGoModFileCataloger returns a new cataloger object that searches within go.mod files.
func NewGoModFileCataloger(opts GoCatalogerOpts) pkg.Cataloger {
// NewGoModuleFileCataloger returns a new cataloger object that searches within go.mod files.
func NewGoModuleFileCataloger(opts GoCatalogerOpts) pkg.Cataloger {
c := goModCataloger{
licenses: newGoLicenses(opts),
}
return &progressingCataloger{
progress: c.licenses.progress,
cataloger: generic.NewCataloger("go-mod-file-cataloger").
cataloger: generic.NewCataloger("go-module-file-cataloger").
WithParserByGlobs(c.parseGoModFile, "**/go.mod"),
}
}

View file

@ -30,7 +30,7 @@ func Test_Mod_Cataloger_Globs(t *testing.T) {
FromDirectory(t, test.fixture).
ExpectsResolverContentQueries(test.expected).
IgnoreUnfulfilledPathResponses("src/go.sum").
TestCataloger(t, NewGoModFileCataloger(GoCatalogerOpts{}))
TestCataloger(t, NewGoModuleFileCataloger(GoCatalogerOpts{}))
})
}
}

View file

@ -104,7 +104,7 @@ func Test_GoSumHashes(t *testing.T) {
Version: "v0.6.0",
PURL: "pkg:golang/github.com/CycloneDX/cyclonedx-go@v0.6.0",
Locations: file.NewLocationSet(file.NewLocation("go.mod")),
FoundBy: "go-mod-file-cataloger",
FoundBy: "go-module-file-cataloger",
Language: pkg.Go,
Type: pkg.GoModulePkg,
Metadata: pkg.GolangModuleEntry{},
@ -114,7 +114,7 @@ func Test_GoSumHashes(t *testing.T) {
Version: "v0.0.0-20180116102854-5a71ef0e047d",
PURL: "pkg:golang/github.com/acarl005/stripansi@v0.0.0-20180116102854-5a71ef0e047d",
Locations: file.NewLocationSet(file.NewLocation("go.mod")),
FoundBy: "go-mod-file-cataloger",
FoundBy: "go-module-file-cataloger",
Language: pkg.Go,
Type: pkg.GoModulePkg,
Metadata: pkg.GolangModuleEntry{
@ -126,7 +126,7 @@ func Test_GoSumHashes(t *testing.T) {
Version: "v0.0.0-20200706080929-d51e80ef957d",
PURL: "pkg:golang/github.com/mgutz/ansi@v0.0.0-20200706080929-d51e80ef957d",
Locations: file.NewLocationSet(file.NewLocation("go.mod")),
FoundBy: "go-mod-file-cataloger",
FoundBy: "go-module-file-cataloger",
Language: pkg.Go,
Type: pkg.GoModulePkg,
Metadata: pkg.GolangModuleEntry{
@ -142,7 +142,7 @@ func Test_GoSumHashes(t *testing.T) {
pkgtest.NewCatalogTester().
FromDirectory(t, test.fixture).
Expects(test.expected, nil).
TestCataloger(t, NewGoModFileCataloger(GoCatalogerOpts{}))
TestCataloger(t, NewGoModuleFileCataloger(GoCatalogerOpts{}))
})
}
}

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