From 2735df6f121bd6fff2ab5f5a9454ce87bc92e023 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Tue, 31 Oct 2023 13:33:57 -0400 Subject: [PATCH 1/2] follow convention for naming catalogers Signed-off-by: Alex Goodman --- .github/workflows/validations.yaml | 4 +- DEVELOPING.md | 8 ++ README.md | 12 +-- Taskfile.yaml | 10 ++- .../test-fixtures/identify/1.3.json | 2 +- .../test-fixtures/identify/1.4.json | 2 +- .../test-fixtures/identify/1.5.json | 2 +- .../test-fixtures/identify/1.3.xml | 2 +- .../test-fixtures/identify/1.4.xml | 2 +- .../test-fixtures/identify/1.5.xml | 2 +- .../test-fixtures/identify/11.0.0.json | 2 +- syft/pkg/cataloger/alpine/cataloger.go | 15 ++++ .../{apkdb => alpine}/cataloger_test.go | 4 +- .../cataloger/{apkdb => alpine}/package.go | 2 +- .../{apkdb => alpine}/package_test.go | 2 +- .../{apkdb => alpine}/parse_apk_db.go | 2 +- .../{apkdb => alpine}/parse_apk_db_test.go | 2 +- .../{apkdb => alpine}/test-fixtures/base | 0 .../test-fixtures/empty-deps-and-provides | 0 .../test-fixtures/extra-file-attributes | 0 .../glob-paths/lib/apk/db/installed | 0 .../{apkdb => alpine}/test-fixtures/installed | 0 .../{apkdb => alpine}/test-fixtures/multiple | 0 .../{apkdb => alpine}/test-fixtures/single | 0 .../test-fixtures/very-large-entries | 0 syft/pkg/cataloger/alpm/cataloger.go | 14 --- syft/pkg/cataloger/apkdb/cataloger.go | 17 ---- syft/pkg/cataloger/arch/cataloger.go | 15 ++++ .../{alpm => arch}/cataloger_test.go | 8 +- syft/pkg/cataloger/{alpm => arch}/package.go | 2 +- .../cataloger/{alpm => arch}/package_test.go | 2 +- .../cataloger/{alpm => arch}/parse_alpm_db.go | 2 +- .../{alpm => arch}/parse_alpm_db_test.go | 2 +- .../{alpm => arch}/test-fixtures/files | 0 .../var/lib/pacman/local/base-1.0/desc | 0 .../var/lib/pacman/local/base-1.0/files | 0 .../var/lib/pacman/local/dive-0.10.0/desc | 0 .../var/lib/pacman/local/gmp-6.2.1-2/desc | 0 .../var/lib/pacman/local/gmp-6.2.1-2/files | 0 .../var/lib/pacman/local/gmp-6.2.1-2/mtree | Bin .../{alpm => arch}/test-fixtures/mtree | Bin syft/pkg/cataloger/binary/cataloger.go | 3 + syft/pkg/cataloger/cataloger.go | 78 ++++++++--------- syft/pkg/cataloger/cataloger_test.go | 80 +++++++++--------- syft/pkg/cataloger/cpp/cataloger.go | 3 + syft/pkg/cataloger/dart/cataloger.go | 7 +- .../cataloger/{deb => debian}/cataloger.go | 12 ++- .../{deb => debian}/cataloger_test.go | 10 +-- syft/pkg/cataloger/{deb => debian}/package.go | 2 +- .../cataloger/{deb => debian}/package_test.go | 2 +- .../{deb => debian}/parse_copyright.go | 2 +- .../{deb => debian}/parse_copyright_test.go | 2 +- .../{deb => debian}/parse_dpkg_db.go | 2 +- .../{deb => debian}/parse_dpkg_db_test.go | 2 +- .../{deb => debian}/parse_dpkg_info_files.go | 2 +- .../parse_dpkg_info_files_test.go | 2 +- .../test-fixtures/copyright/libaudit-common | 0 .../test-fixtures/copyright/libc6 | 0 .../test-fixtures/copyright/liblzma5 | 0 .../test-fixtures/copyright/python | 0 .../test-fixtures/copyright/trilicense | 0 .../usr/lib/opkg/info/pkg-1.0.control | 0 .../glob-paths/usr/lib/opkg/status | 0 .../glob-paths/var/lib/dpkg/status | 0 .../glob-paths/var/lib/dpkg/status.d/pkg-1.0 | 0 .../image-distroless-deb/Dockerfile | 0 .../usr/share/doc/libsqlite3-0/copyright | 0 .../var/lib/dpkg/status.d/libsqlite3-0 | 0 .../lib/dpkg/status.d/libsqlite3-0.md5sums | 0 .../test-fixtures/image-dpkg/Dockerfile | 0 .../usr/share/doc/libpam-runtime/copyright | 0 .../lib/dpkg/info/libpam-runtime.conffiles | 0 .../var/lib/dpkg/info/libpam-runtime.md5sums | 0 .../image-dpkg/var/lib/dpkg/status | 0 .../test-fixtures/info/util-linux.conffiles | 0 .../test-fixtures/info/zlib1g.md5sums | 0 .../status/coreutils-relationships | 0 .../test-fixtures/status/doc-examples | 0 .../test-fixtures/status/empty | 0 .../test-fixtures/status/installed-size-4KB | 0 .../test-fixtures/status/libpam-runtime | 0 .../test-fixtures/status/multiple | 0 .../test-fixtures/status/single | 0 syft/pkg/cataloger/dotnet/cataloger.go | 3 + syft/pkg/cataloger/elixir/cataloger.go | 6 +- syft/pkg/cataloger/erlang/cataloger.go | 6 +- .../{portage => gentoo}/cataloger.go | 4 +- .../{portage => gentoo}/cataloger_test.go | 2 +- .../parse_portage_contents.go | 2 +- .../pkg/cataloger/{portage => gentoo}/purl.go | 2 +- .../{portage => gentoo}/purl_test.go | 2 +- .../glob-paths/var/db/pkg/x/y/CONTENTS | 0 .../pkg/app-containers/skopeo-1.5.1/CONTENTS | 0 .../pkg/app-containers/skopeo-1.5.1/LICENSE | 0 .../db/pkg/app-containers/skopeo-1.5.1/SIZE | 0 syft/pkg/cataloger/githubactions/cataloger.go | 3 + .../test-fixtures/workflow-multi-job.yaml | 4 +- syft/pkg/cataloger/golang/cataloger.go | 8 +- syft/pkg/cataloger/golang/cataloger_test.go | 2 +- .../pkg/cataloger/golang/parse_go_mod_test.go | 8 +- syft/pkg/cataloger/haskell/cataloger.go | 3 + syft/pkg/cataloger/java/cataloger.go | 20 ++--- syft/pkg/cataloger/java/cataloger_test.go | 4 +- syft/pkg/cataloger/javascript/cataloger.go | 4 +- syft/pkg/cataloger/nix/cataloger.go | 10 +-- syft/pkg/cataloger/php/cataloger.go | 2 +- syft/pkg/cataloger/python/cataloger.go | 15 ++-- syft/pkg/cataloger/python/cataloger_test.go | 24 +++--- syft/pkg/cataloger/r/cataloger.go | 7 +- .../cataloger/{rpm => redhat}/cataloger.go | 21 ++--- .../{rpm => redhat}/cataloger_test.go | 6 +- syft/pkg/cataloger/{rpm => redhat}/package.go | 2 +- .../cataloger/{rpm => redhat}/package_test.go | 2 +- .../{rpm => redhat}/parse_rpm_archive.go | 2 +- .../{rpm => redhat}/parse_rpm_archive_test.go | 8 +- .../cataloger/{rpm => redhat}/parse_rpm_db.go | 2 +- .../{rpm => redhat}/parse_rpm_db_test.go | 2 +- .../{rpm => redhat}/parse_rpm_manifest.go | 2 +- .../parse_rpm_manifest_test.go | 2 +- .../{rpm => redhat}/test-fixtures/.gitignore | 0 .../{rpm => redhat}/test-fixtures/Makefile | 0 .../{rpm => redhat}/test-fixtures/Packages | Bin .../{rpm => redhat}/test-fixtures/bad/bad.rpm | 0 .../test-fixtures/container-manifest-2 | 0 .../test-fixtures/generate-fixture.sh | 0 .../test-fixtures/glob-paths/dive-0.10.0.rpm | 0 .../glob-paths/usr/lib/sysimage/rpm/Packages | 0 .../usr/lib/sysimage/rpm/Packages.db | 0 .../usr/lib/sysimage/rpm/rpmdb.sqlite | 0 .../glob-paths/usr/share/rpm/Packages | 0 .../glob-paths/usr/share/rpm/Packages.db | 0 .../glob-paths/usr/share/rpm/rpmdb.sqlite | 0 .../glob-paths/var/lib/rpm/Packages | 0 .../glob-paths/var/lib/rpm/Packages.db | 0 .../glob-paths/var/lib/rpm/rpmdb.sqlite | 0 .../var/lib/rpmmanifest/container-manifest-2 | 0 syft/pkg/cataloger/ruby/catalogers.go | 4 +- syft/pkg/cataloger/rust/cataloger.go | 2 +- syft/pkg/cataloger/sbom/cataloger.go | 7 +- syft/pkg/cataloger/sbom/cataloger_test.go | 4 +- syft/pkg/cataloger/swift/cataloger.go | 4 +- test/cli/packages_cmd_test.go | 2 +- .../acceptance-centos-8.2.2004.json | 6 +- test/integration/sbom_cataloger_test.go | 2 +- 144 files changed, 294 insertions(+), 273 deletions(-) create mode 100644 syft/pkg/cataloger/alpine/cataloger.go rename syft/pkg/cataloger/{apkdb => alpine}/cataloger_test.go (91%) rename syft/pkg/cataloger/{apkdb => alpine}/package.go (99%) rename syft/pkg/cataloger/{apkdb => alpine}/package_test.go (99%) rename syft/pkg/cataloger/{apkdb => alpine}/parse_apk_db.go (99%) rename syft/pkg/cataloger/{apkdb => alpine}/parse_apk_db_test.go (99%) rename syft/pkg/cataloger/{apkdb => alpine}/test-fixtures/base (100%) rename syft/pkg/cataloger/{apkdb => alpine}/test-fixtures/empty-deps-and-provides (100%) rename syft/pkg/cataloger/{apkdb => alpine}/test-fixtures/extra-file-attributes (100%) rename syft/pkg/cataloger/{apkdb => alpine}/test-fixtures/glob-paths/lib/apk/db/installed (100%) rename syft/pkg/cataloger/{apkdb => alpine}/test-fixtures/installed (100%) rename syft/pkg/cataloger/{apkdb => alpine}/test-fixtures/multiple (100%) rename syft/pkg/cataloger/{apkdb => alpine}/test-fixtures/single (100%) rename syft/pkg/cataloger/{apkdb => alpine}/test-fixtures/very-large-entries (100%) delete mode 100644 syft/pkg/cataloger/alpm/cataloger.go delete mode 100644 syft/pkg/cataloger/apkdb/cataloger.go create mode 100644 syft/pkg/cataloger/arch/cataloger.go rename syft/pkg/cataloger/{alpm => arch}/cataloger_test.go (97%) rename syft/pkg/cataloger/{alpm => arch}/package.go (99%) rename syft/pkg/cataloger/{alpm => arch}/package_test.go (99%) rename syft/pkg/cataloger/{alpm => arch}/parse_alpm_db.go (99%) rename syft/pkg/cataloger/{alpm => arch}/parse_alpm_db_test.go (99%) rename syft/pkg/cataloger/{alpm => arch}/test-fixtures/files (100%) rename syft/pkg/cataloger/{alpm => arch}/test-fixtures/glob-paths/var/lib/pacman/local/base-1.0/desc (100%) rename syft/pkg/cataloger/{alpm => arch}/test-fixtures/glob-paths/var/lib/pacman/local/base-1.0/files (100%) rename syft/pkg/cataloger/{alpm => arch}/test-fixtures/glob-paths/var/lib/pacman/local/dive-0.10.0/desc (100%) rename syft/pkg/cataloger/{alpm => arch}/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/desc (100%) rename syft/pkg/cataloger/{alpm => arch}/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/files (100%) rename syft/pkg/cataloger/{alpm => arch}/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/mtree (100%) rename syft/pkg/cataloger/{alpm => arch}/test-fixtures/mtree (100%) rename syft/pkg/cataloger/{deb => debian}/cataloger.go (52%) rename syft/pkg/cataloger/{deb => debian}/cataloger_test.go (97%) rename syft/pkg/cataloger/{deb => debian}/package.go (99%) rename syft/pkg/cataloger/{deb => debian}/package_test.go (99%) rename syft/pkg/cataloger/{deb => debian}/parse_copyright.go (99%) rename syft/pkg/cataloger/{deb => debian}/parse_copyright_test.go (99%) rename syft/pkg/cataloger/{deb => debian}/parse_dpkg_db.go (99%) rename syft/pkg/cataloger/{deb => debian}/parse_dpkg_db_test.go (99%) rename syft/pkg/cataloger/{deb => debian}/parse_dpkg_info_files.go (98%) rename syft/pkg/cataloger/{deb => debian}/parse_dpkg_info_files_test.go (99%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/copyright/libaudit-common (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/copyright/libc6 (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/copyright/liblzma5 (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/copyright/python (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/copyright/trilicense (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/glob-paths/usr/lib/opkg/info/pkg-1.0.control (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/glob-paths/usr/lib/opkg/status (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/glob-paths/var/lib/dpkg/status (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/glob-paths/var/lib/dpkg/status.d/pkg-1.0 (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/image-distroless-deb/Dockerfile (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/image-distroless-deb/usr/share/doc/libsqlite3-0/copyright (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/image-distroless-deb/var/lib/dpkg/status.d/libsqlite3-0 (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/image-distroless-deb/var/lib/dpkg/status.d/libsqlite3-0.md5sums (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/image-dpkg/Dockerfile (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/image-dpkg/usr/share/doc/libpam-runtime/copyright (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/image-dpkg/var/lib/dpkg/info/libpam-runtime.conffiles (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/image-dpkg/var/lib/dpkg/info/libpam-runtime.md5sums (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/image-dpkg/var/lib/dpkg/status (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/info/util-linux.conffiles (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/info/zlib1g.md5sums (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/status/coreutils-relationships (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/status/doc-examples (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/status/empty (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/status/installed-size-4KB (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/status/libpam-runtime (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/status/multiple (100%) rename syft/pkg/cataloger/{deb => debian}/test-fixtures/status/single (100%) rename syft/pkg/cataloger/{portage => gentoo}/cataloger.go (74%) rename syft/pkg/cataloger/{portage => gentoo}/cataloger_test.go (99%) rename syft/pkg/cataloger/{portage => gentoo}/parse_portage_contents.go (99%) rename syft/pkg/cataloger/{portage => gentoo}/purl.go (95%) rename syft/pkg/cataloger/{portage => gentoo}/purl_test.go (96%) rename syft/pkg/cataloger/{portage => gentoo}/test-fixtures/glob-paths/var/db/pkg/x/y/CONTENTS (100%) rename syft/pkg/cataloger/{portage => gentoo}/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/CONTENTS (100%) rename syft/pkg/cataloger/{portage => gentoo}/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/LICENSE (100%) rename syft/pkg/cataloger/{portage => gentoo}/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/SIZE (100%) rename syft/pkg/cataloger/{rpm => redhat}/cataloger.go (52%) rename syft/pkg/cataloger/{rpm => redhat}/cataloger_test.go (93%) rename syft/pkg/cataloger/{rpm => redhat}/package.go (99%) rename syft/pkg/cataloger/{rpm => redhat}/package_test.go (99%) rename syft/pkg/cataloger/{rpm => redhat}/parse_rpm_archive.go (99%) rename syft/pkg/cataloger/{rpm => redhat}/parse_rpm_archive_test.go (96%) rename syft/pkg/cataloger/{rpm => redhat}/parse_rpm_db.go (99%) rename syft/pkg/cataloger/{rpm => redhat}/parse_rpm_db_test.go (99%) rename syft/pkg/cataloger/{rpm => redhat}/parse_rpm_manifest.go (98%) rename syft/pkg/cataloger/{rpm => redhat}/parse_rpm_manifest_test.go (99%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/.gitignore (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/Makefile (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/Packages (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/bad/bad.rpm (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/container-manifest-2 (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/generate-fixture.sh (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/glob-paths/dive-0.10.0.rpm (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/glob-paths/usr/lib/sysimage/rpm/Packages (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/glob-paths/usr/lib/sysimage/rpm/Packages.db (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/glob-paths/usr/lib/sysimage/rpm/rpmdb.sqlite (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/glob-paths/usr/share/rpm/Packages (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/glob-paths/usr/share/rpm/Packages.db (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/glob-paths/usr/share/rpm/rpmdb.sqlite (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/glob-paths/var/lib/rpm/Packages (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/glob-paths/var/lib/rpm/Packages.db (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/glob-paths/var/lib/rpm/rpmdb.sqlite (100%) rename syft/pkg/cataloger/{rpm => redhat}/test-fixtures/glob-paths/var/lib/rpmmanifest/container-manifest-2 (100%) diff --git a/.github/workflows/validations.yaml b/.github/workflows/validations.yaml index 41363b2d876..862244d9bea 100644 --- a/.github/workflows/validations.yaml +++ b/.github/workflows/validations.yaml @@ -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 diff --git a/DEVELOPING.md b/DEVELOPING.md index ece0e5e9e46..f6cf8d97155 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -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: + +- 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-installed-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. diff --git a/README.md b/README.md index a64cbcf5516..19f6ca4b410 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Taskfile.yaml b/Taskfile.yaml index 1d7cc633d5e..388a1a0433a 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -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: diff --git a/syft/format/cyclonedxjson/test-fixtures/identify/1.3.json b/syft/format/cyclonedxjson/test-fixtures/identify/1.3.json index cf14029772b..efecdcbd1ae 100644 --- a/syft/format/cyclonedxjson/test-fixtures/identify/1.3.json +++ b/syft/format/cyclonedxjson/test-fixtures/identify/1.3.json @@ -31,7 +31,7 @@ "properties": [ { "name": "syft:package:foundBy", - "value": "go-mod-file-cataloger" + "value": "go-module-file-cataloger" }, { "name": "syft:package:language", diff --git a/syft/format/cyclonedxjson/test-fixtures/identify/1.4.json b/syft/format/cyclonedxjson/test-fixtures/identify/1.4.json index a95bfc6bc99..35093947a5b 100644 --- a/syft/format/cyclonedxjson/test-fixtures/identify/1.4.json +++ b/syft/format/cyclonedxjson/test-fixtures/identify/1.4.json @@ -31,7 +31,7 @@ "properties": [ { "name": "syft:package:foundBy", - "value": "go-mod-file-cataloger" + "value": "go-module-file-cataloger" }, { "name": "syft:package:language", diff --git a/syft/format/cyclonedxjson/test-fixtures/identify/1.5.json b/syft/format/cyclonedxjson/test-fixtures/identify/1.5.json index e63a6f069aa..ff649640ee1 100644 --- a/syft/format/cyclonedxjson/test-fixtures/identify/1.5.json +++ b/syft/format/cyclonedxjson/test-fixtures/identify/1.5.json @@ -31,7 +31,7 @@ "properties": [ { "name": "syft:package:foundBy", - "value": "go-mod-file-cataloger" + "value": "go-module-file-cataloger" }, { "name": "syft:package:language", diff --git a/syft/format/cyclonedxxml/test-fixtures/identify/1.3.xml b/syft/format/cyclonedxxml/test-fixtures/identify/1.3.xml index 089077bae7c..fbea82a2445 100644 --- a/syft/format/cyclonedxxml/test-fixtures/identify/1.3.xml +++ b/syft/format/cyclonedxxml/test-fixtures/identify/1.3.xml @@ -21,7 +21,7 @@ cpe:2.3:a:wagoodman:go-partybus:v0.0.0-20230516145632-8ccac152c651:*:*:*:*:*:*:* pkg:golang/github.com/wagoodman/go-partybus@v0.0.0-20230516145632-8ccac152c651 - go-mod-file-cataloger + go-module-file-cataloger go GolangModMetadata go-module diff --git a/syft/format/cyclonedxxml/test-fixtures/identify/1.4.xml b/syft/format/cyclonedxxml/test-fixtures/identify/1.4.xml index f8cbc7e3001..05ce4c9b3c3 100644 --- a/syft/format/cyclonedxxml/test-fixtures/identify/1.4.xml +++ b/syft/format/cyclonedxxml/test-fixtures/identify/1.4.xml @@ -21,7 +21,7 @@ cpe:2.3:a:wagoodman:go-partybus:v0.0.0-20230516145632-8ccac152c651:*:*:*:*:*:*:* pkg:golang/github.com/wagoodman/go-partybus@v0.0.0-20230516145632-8ccac152c651 - go-mod-file-cataloger + go-module-file-cataloger go GolangModMetadata go-module diff --git a/syft/format/cyclonedxxml/test-fixtures/identify/1.5.xml b/syft/format/cyclonedxxml/test-fixtures/identify/1.5.xml index 97ae0242840..c823d1a2cd8 100644 --- a/syft/format/cyclonedxxml/test-fixtures/identify/1.5.xml +++ b/syft/format/cyclonedxxml/test-fixtures/identify/1.5.xml @@ -21,7 +21,7 @@ cpe:2.3:a:wagoodman:go-partybus:v0.0.0-20230516145632-8ccac152c651:*:*:*:*:*:*:* pkg:golang/github.com/wagoodman/go-partybus@v0.0.0-20230516145632-8ccac152c651 - go-mod-file-cataloger + go-module-file-cataloger go GolangModMetadata go-module diff --git a/syft/format/syftjson/test-fixtures/identify/11.0.0.json b/syft/format/syftjson/test-fixtures/identify/11.0.0.json index d8bd1743c56..2dba6e23ee8 100644 --- a/syft/format/syftjson/test-fixtures/identify/11.0.0.json +++ b/syft/format/syftjson/test-fixtures/identify/11.0.0.json @@ -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", diff --git a/syft/pkg/cataloger/alpine/cataloger.go b/syft/pkg/cataloger/alpine/cataloger.go new file mode 100644 index 00000000000..5ff537f2611 --- /dev/null +++ b/syft/pkg/cataloger/alpine/cataloger.go @@ -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) +} diff --git a/syft/pkg/cataloger/apkdb/cataloger_test.go b/syft/pkg/cataloger/alpine/cataloger_test.go similarity index 91% rename from syft/pkg/cataloger/apkdb/cataloger_test.go rename to syft/pkg/cataloger/alpine/cataloger_test.go index 9be92209bd6..d9ed0e30c14 100644 --- a/syft/pkg/cataloger/apkdb/cataloger_test.go +++ b/syft/pkg/cataloger/alpine/cataloger_test.go @@ -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()) }) } } diff --git a/syft/pkg/cataloger/apkdb/package.go b/syft/pkg/cataloger/alpine/package.go similarity index 99% rename from syft/pkg/cataloger/apkdb/package.go rename to syft/pkg/cataloger/alpine/package.go index ddba886fc65..69c8a8d185e 100644 --- a/syft/pkg/cataloger/apkdb/package.go +++ b/syft/pkg/cataloger/alpine/package.go @@ -1,4 +1,4 @@ -package apkdb +package alpine import ( "strings" diff --git a/syft/pkg/cataloger/apkdb/package_test.go b/syft/pkg/cataloger/alpine/package_test.go similarity index 99% rename from syft/pkg/cataloger/apkdb/package_test.go rename to syft/pkg/cataloger/alpine/package_test.go index 8a3b08ad7f4..23a5fffd4d9 100644 --- a/syft/pkg/cataloger/apkdb/package_test.go +++ b/syft/pkg/cataloger/alpine/package_test.go @@ -1,4 +1,4 @@ -package apkdb +package alpine import ( "strings" diff --git a/syft/pkg/cataloger/apkdb/parse_apk_db.go b/syft/pkg/cataloger/alpine/parse_apk_db.go similarity index 99% rename from syft/pkg/cataloger/apkdb/parse_apk_db.go rename to syft/pkg/cataloger/alpine/parse_apk_db.go index e0b2839a50c..8f0ba9bc7c8 100644 --- a/syft/pkg/cataloger/apkdb/parse_apk_db.go +++ b/syft/pkg/cataloger/alpine/parse_apk_db.go @@ -1,4 +1,4 @@ -package apkdb +package alpine import ( "bufio" diff --git a/syft/pkg/cataloger/apkdb/parse_apk_db_test.go b/syft/pkg/cataloger/alpine/parse_apk_db_test.go similarity index 99% rename from syft/pkg/cataloger/apkdb/parse_apk_db_test.go rename to syft/pkg/cataloger/alpine/parse_apk_db_test.go index ecfdaff6aab..13a1a6cbe40 100644 --- a/syft/pkg/cataloger/apkdb/parse_apk_db_test.go +++ b/syft/pkg/cataloger/alpine/parse_apk_db_test.go @@ -1,4 +1,4 @@ -package apkdb +package alpine import ( "io" diff --git a/syft/pkg/cataloger/apkdb/test-fixtures/base b/syft/pkg/cataloger/alpine/test-fixtures/base similarity index 100% rename from syft/pkg/cataloger/apkdb/test-fixtures/base rename to syft/pkg/cataloger/alpine/test-fixtures/base diff --git a/syft/pkg/cataloger/apkdb/test-fixtures/empty-deps-and-provides b/syft/pkg/cataloger/alpine/test-fixtures/empty-deps-and-provides similarity index 100% rename from syft/pkg/cataloger/apkdb/test-fixtures/empty-deps-and-provides rename to syft/pkg/cataloger/alpine/test-fixtures/empty-deps-and-provides diff --git a/syft/pkg/cataloger/apkdb/test-fixtures/extra-file-attributes b/syft/pkg/cataloger/alpine/test-fixtures/extra-file-attributes similarity index 100% rename from syft/pkg/cataloger/apkdb/test-fixtures/extra-file-attributes rename to syft/pkg/cataloger/alpine/test-fixtures/extra-file-attributes diff --git a/syft/pkg/cataloger/apkdb/test-fixtures/glob-paths/lib/apk/db/installed b/syft/pkg/cataloger/alpine/test-fixtures/glob-paths/lib/apk/db/installed similarity index 100% rename from syft/pkg/cataloger/apkdb/test-fixtures/glob-paths/lib/apk/db/installed rename to syft/pkg/cataloger/alpine/test-fixtures/glob-paths/lib/apk/db/installed diff --git a/syft/pkg/cataloger/apkdb/test-fixtures/installed b/syft/pkg/cataloger/alpine/test-fixtures/installed similarity index 100% rename from syft/pkg/cataloger/apkdb/test-fixtures/installed rename to syft/pkg/cataloger/alpine/test-fixtures/installed diff --git a/syft/pkg/cataloger/apkdb/test-fixtures/multiple b/syft/pkg/cataloger/alpine/test-fixtures/multiple similarity index 100% rename from syft/pkg/cataloger/apkdb/test-fixtures/multiple rename to syft/pkg/cataloger/alpine/test-fixtures/multiple diff --git a/syft/pkg/cataloger/apkdb/test-fixtures/single b/syft/pkg/cataloger/alpine/test-fixtures/single similarity index 100% rename from syft/pkg/cataloger/apkdb/test-fixtures/single rename to syft/pkg/cataloger/alpine/test-fixtures/single diff --git a/syft/pkg/cataloger/apkdb/test-fixtures/very-large-entries b/syft/pkg/cataloger/alpine/test-fixtures/very-large-entries similarity index 100% rename from syft/pkg/cataloger/apkdb/test-fixtures/very-large-entries rename to syft/pkg/cataloger/alpine/test-fixtures/very-large-entries diff --git a/syft/pkg/cataloger/alpm/cataloger.go b/syft/pkg/cataloger/alpm/cataloger.go deleted file mode 100644 index cbbab9a2339..00000000000 --- a/syft/pkg/cataloger/alpm/cataloger.go +++ /dev/null @@ -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) -} diff --git a/syft/pkg/cataloger/apkdb/cataloger.go b/syft/pkg/cataloger/apkdb/cataloger.go deleted file mode 100644 index e1b6bbb1f7a..00000000000 --- a/syft/pkg/cataloger/apkdb/cataloger.go +++ /dev/null @@ -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) -} diff --git a/syft/pkg/cataloger/arch/cataloger.go b/syft/pkg/cataloger/arch/cataloger.go new file mode 100644 index 00000000000..0c00a4e2c56 --- /dev/null +++ b/syft/pkg/cataloger/arch/cataloger.go @@ -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) +} diff --git a/syft/pkg/cataloger/alpm/cataloger_test.go b/syft/pkg/cataloger/arch/cataloger_test.go similarity index 97% rename from syft/pkg/cataloger/alpm/cataloger_test.go rename to syft/pkg/cataloger/arch/cataloger_test.go index cd10e6596ba..91a735aebab 100644 --- a/syft/pkg/cataloger/alpm/cataloger_test.go +++ b/syft/pkg/cataloger/arch/cataloger_test.go @@ -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()) }) } } diff --git a/syft/pkg/cataloger/alpm/package.go b/syft/pkg/cataloger/arch/package.go similarity index 99% rename from syft/pkg/cataloger/alpm/package.go rename to syft/pkg/cataloger/arch/package.go index 5d55ec6b20c..f20a192f2b2 100644 --- a/syft/pkg/cataloger/alpm/package.go +++ b/syft/pkg/cataloger/arch/package.go @@ -1,4 +1,4 @@ -package alpm +package arch import ( "strings" diff --git a/syft/pkg/cataloger/alpm/package_test.go b/syft/pkg/cataloger/arch/package_test.go similarity index 99% rename from syft/pkg/cataloger/alpm/package_test.go rename to syft/pkg/cataloger/arch/package_test.go index 4e77f3293b9..47a09789811 100644 --- a/syft/pkg/cataloger/alpm/package_test.go +++ b/syft/pkg/cataloger/arch/package_test.go @@ -1,4 +1,4 @@ -package alpm +package arch import ( "testing" diff --git a/syft/pkg/cataloger/alpm/parse_alpm_db.go b/syft/pkg/cataloger/arch/parse_alpm_db.go similarity index 99% rename from syft/pkg/cataloger/alpm/parse_alpm_db.go rename to syft/pkg/cataloger/arch/parse_alpm_db.go index 25cf8937e03..53def2631ea 100644 --- a/syft/pkg/cataloger/alpm/parse_alpm_db.go +++ b/syft/pkg/cataloger/arch/parse_alpm_db.go @@ -1,4 +1,4 @@ -package alpm +package arch import ( "bufio" diff --git a/syft/pkg/cataloger/alpm/parse_alpm_db_test.go b/syft/pkg/cataloger/arch/parse_alpm_db_test.go similarity index 99% rename from syft/pkg/cataloger/alpm/parse_alpm_db_test.go rename to syft/pkg/cataloger/arch/parse_alpm_db_test.go index 70863fb82fa..213ca4cceb0 100644 --- a/syft/pkg/cataloger/alpm/parse_alpm_db_test.go +++ b/syft/pkg/cataloger/arch/parse_alpm_db_test.go @@ -1,4 +1,4 @@ -package alpm +package arch import ( "bufio" diff --git a/syft/pkg/cataloger/alpm/test-fixtures/files b/syft/pkg/cataloger/arch/test-fixtures/files similarity index 100% rename from syft/pkg/cataloger/alpm/test-fixtures/files rename to syft/pkg/cataloger/arch/test-fixtures/files diff --git a/syft/pkg/cataloger/alpm/test-fixtures/glob-paths/var/lib/pacman/local/base-1.0/desc b/syft/pkg/cataloger/arch/test-fixtures/glob-paths/var/lib/pacman/local/base-1.0/desc similarity index 100% rename from syft/pkg/cataloger/alpm/test-fixtures/glob-paths/var/lib/pacman/local/base-1.0/desc rename to syft/pkg/cataloger/arch/test-fixtures/glob-paths/var/lib/pacman/local/base-1.0/desc diff --git a/syft/pkg/cataloger/alpm/test-fixtures/glob-paths/var/lib/pacman/local/base-1.0/files b/syft/pkg/cataloger/arch/test-fixtures/glob-paths/var/lib/pacman/local/base-1.0/files similarity index 100% rename from syft/pkg/cataloger/alpm/test-fixtures/glob-paths/var/lib/pacman/local/base-1.0/files rename to syft/pkg/cataloger/arch/test-fixtures/glob-paths/var/lib/pacman/local/base-1.0/files diff --git a/syft/pkg/cataloger/alpm/test-fixtures/glob-paths/var/lib/pacman/local/dive-0.10.0/desc b/syft/pkg/cataloger/arch/test-fixtures/glob-paths/var/lib/pacman/local/dive-0.10.0/desc similarity index 100% rename from syft/pkg/cataloger/alpm/test-fixtures/glob-paths/var/lib/pacman/local/dive-0.10.0/desc rename to syft/pkg/cataloger/arch/test-fixtures/glob-paths/var/lib/pacman/local/dive-0.10.0/desc diff --git a/syft/pkg/cataloger/alpm/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/desc b/syft/pkg/cataloger/arch/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/desc similarity index 100% rename from syft/pkg/cataloger/alpm/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/desc rename to syft/pkg/cataloger/arch/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/desc diff --git a/syft/pkg/cataloger/alpm/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/files b/syft/pkg/cataloger/arch/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/files similarity index 100% rename from syft/pkg/cataloger/alpm/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/files rename to syft/pkg/cataloger/arch/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/files diff --git a/syft/pkg/cataloger/alpm/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/mtree b/syft/pkg/cataloger/arch/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/mtree similarity index 100% rename from syft/pkg/cataloger/alpm/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/mtree rename to syft/pkg/cataloger/arch/test-fixtures/gmp-fixture/var/lib/pacman/local/gmp-6.2.1-2/mtree diff --git a/syft/pkg/cataloger/alpm/test-fixtures/mtree b/syft/pkg/cataloger/arch/test-fixtures/mtree similarity index 100% rename from syft/pkg/cataloger/alpm/test-fixtures/mtree rename to syft/pkg/cataloger/arch/test-fixtures/mtree diff --git a/syft/pkg/cataloger/binary/cataloger.go b/syft/pkg/cataloger/binary/cataloger.go index 9f7325c3bc1..67bb9b448e3 100644 --- a/syft/pkg/cataloger/binary/cataloger.go +++ b/syft/pkg/cataloger/binary/cataloger.go @@ -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 ( diff --git a/syft/pkg/cataloger/cataloger.go b/syft/pkg/cataloger/cataloger.go index d74830b7102..a66a0569eb6 100644 --- a/syft/pkg/cataloger/cataloger.go +++ b/syft/pkg/cataloger/cataloger.go @@ -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) diff --git a/syft/pkg/cataloger/cataloger_test.go b/syft/pkg/cataloger/cataloger_test.go index 4f4b6ce83fd..5346df27cfb 100644 --- a/syft/pkg/cataloger/cataloger_test.go +++ b/syft/pkg/cataloger/cataloger_test.go @@ -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, }, } diff --git a/syft/pkg/cataloger/cpp/cataloger.go b/syft/pkg/cataloger/cpp/cataloger.go index 5d3b33a9b85..380206d35f9 100644 --- a/syft/pkg/cataloger/cpp/cataloger.go +++ b/syft/pkg/cataloger/cpp/cataloger.go @@ -1,3 +1,6 @@ +/* +Package cpp provides a concrete Cataloger implementations for the C/C++ language ecosystem. +*/ package cpp import ( diff --git a/syft/pkg/cataloger/dart/cataloger.go b/syft/pkg/cataloger/dart/cataloger.go index 5fbff6f088a..c8c1af42d03 100644 --- a/syft/pkg/cataloger/dart/cataloger.go +++ b/syft/pkg/cataloger/dart/cataloger.go @@ -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") } diff --git a/syft/pkg/cataloger/deb/cataloger.go b/syft/pkg/cataloger/debian/cataloger.go similarity index 52% rename from syft/pkg/cataloger/deb/cataloger.go rename to syft/pkg/cataloger/debian/cataloger.go index 19121349717..4efb3a02635 100644 --- a/syft/pkg/cataloger/deb/cataloger.go +++ b/syft/pkg/cataloger/debian/cataloger.go @@ -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") diff --git a/syft/pkg/cataloger/deb/cataloger_test.go b/syft/pkg/cataloger/debian/cataloger_test.go similarity index 97% rename from syft/pkg/cataloger/deb/cataloger_test.go rename to syft/pkg/cataloger/debian/cataloger_test.go index 9fc0eb2addc..5d3addcbf0d 100644 --- a/syft/pkg/cataloger/deb/cataloger_test.go +++ b/syft/pkg/cataloger/debian/cataloger_test.go @@ -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()) }) } } diff --git a/syft/pkg/cataloger/deb/package.go b/syft/pkg/cataloger/debian/package.go similarity index 99% rename from syft/pkg/cataloger/deb/package.go rename to syft/pkg/cataloger/debian/package.go index a67dee357d1..e762eeb8e3a 100644 --- a/syft/pkg/cataloger/deb/package.go +++ b/syft/pkg/cataloger/debian/package.go @@ -1,4 +1,4 @@ -package deb +package debian import ( "fmt" diff --git a/syft/pkg/cataloger/deb/package_test.go b/syft/pkg/cataloger/debian/package_test.go similarity index 99% rename from syft/pkg/cataloger/deb/package_test.go rename to syft/pkg/cataloger/debian/package_test.go index 56d695fc886..87c7728b91b 100644 --- a/syft/pkg/cataloger/deb/package_test.go +++ b/syft/pkg/cataloger/debian/package_test.go @@ -1,4 +1,4 @@ -package deb +package debian import ( "testing" diff --git a/syft/pkg/cataloger/deb/parse_copyright.go b/syft/pkg/cataloger/debian/parse_copyright.go similarity index 99% rename from syft/pkg/cataloger/deb/parse_copyright.go rename to syft/pkg/cataloger/debian/parse_copyright.go index 176e6aef89f..3f02131b781 100644 --- a/syft/pkg/cataloger/deb/parse_copyright.go +++ b/syft/pkg/cataloger/debian/parse_copyright.go @@ -1,4 +1,4 @@ -package deb +package debian import ( "bufio" diff --git a/syft/pkg/cataloger/deb/parse_copyright_test.go b/syft/pkg/cataloger/debian/parse_copyright_test.go similarity index 99% rename from syft/pkg/cataloger/deb/parse_copyright_test.go rename to syft/pkg/cataloger/debian/parse_copyright_test.go index e58162aa8f1..711990aa942 100644 --- a/syft/pkg/cataloger/deb/parse_copyright_test.go +++ b/syft/pkg/cataloger/debian/parse_copyright_test.go @@ -1,4 +1,4 @@ -package deb +package debian import ( "os" diff --git a/syft/pkg/cataloger/deb/parse_dpkg_db.go b/syft/pkg/cataloger/debian/parse_dpkg_db.go similarity index 99% rename from syft/pkg/cataloger/deb/parse_dpkg_db.go rename to syft/pkg/cataloger/debian/parse_dpkg_db.go index 14eb06fb89b..ab278184d35 100644 --- a/syft/pkg/cataloger/deb/parse_dpkg_db.go +++ b/syft/pkg/cataloger/debian/parse_dpkg_db.go @@ -1,4 +1,4 @@ -package deb +package debian import ( "bufio" diff --git a/syft/pkg/cataloger/deb/parse_dpkg_db_test.go b/syft/pkg/cataloger/debian/parse_dpkg_db_test.go similarity index 99% rename from syft/pkg/cataloger/deb/parse_dpkg_db_test.go rename to syft/pkg/cataloger/debian/parse_dpkg_db_test.go index bbebe623b3b..10cd440230f 100644 --- a/syft/pkg/cataloger/deb/parse_dpkg_db_test.go +++ b/syft/pkg/cataloger/debian/parse_dpkg_db_test.go @@ -1,4 +1,4 @@ -package deb +package debian import ( "bufio" diff --git a/syft/pkg/cataloger/deb/parse_dpkg_info_files.go b/syft/pkg/cataloger/debian/parse_dpkg_info_files.go similarity index 98% rename from syft/pkg/cataloger/deb/parse_dpkg_info_files.go rename to syft/pkg/cataloger/debian/parse_dpkg_info_files.go index 105c47da956..d9d6802baee 100644 --- a/syft/pkg/cataloger/deb/parse_dpkg_info_files.go +++ b/syft/pkg/cataloger/debian/parse_dpkg_info_files.go @@ -1,4 +1,4 @@ -package deb +package debian import ( "bufio" diff --git a/syft/pkg/cataloger/deb/parse_dpkg_info_files_test.go b/syft/pkg/cataloger/debian/parse_dpkg_info_files_test.go similarity index 99% rename from syft/pkg/cataloger/deb/parse_dpkg_info_files_test.go rename to syft/pkg/cataloger/debian/parse_dpkg_info_files_test.go index bd4f1bdabaf..88ace2330db 100644 --- a/syft/pkg/cataloger/deb/parse_dpkg_info_files_test.go +++ b/syft/pkg/cataloger/debian/parse_dpkg_info_files_test.go @@ -1,4 +1,4 @@ -package deb +package debian import ( "os" diff --git a/syft/pkg/cataloger/deb/test-fixtures/copyright/libaudit-common b/syft/pkg/cataloger/debian/test-fixtures/copyright/libaudit-common similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/copyright/libaudit-common rename to syft/pkg/cataloger/debian/test-fixtures/copyright/libaudit-common diff --git a/syft/pkg/cataloger/deb/test-fixtures/copyright/libc6 b/syft/pkg/cataloger/debian/test-fixtures/copyright/libc6 similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/copyright/libc6 rename to syft/pkg/cataloger/debian/test-fixtures/copyright/libc6 diff --git a/syft/pkg/cataloger/deb/test-fixtures/copyright/liblzma5 b/syft/pkg/cataloger/debian/test-fixtures/copyright/liblzma5 similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/copyright/liblzma5 rename to syft/pkg/cataloger/debian/test-fixtures/copyright/liblzma5 diff --git a/syft/pkg/cataloger/deb/test-fixtures/copyright/python b/syft/pkg/cataloger/debian/test-fixtures/copyright/python similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/copyright/python rename to syft/pkg/cataloger/debian/test-fixtures/copyright/python diff --git a/syft/pkg/cataloger/deb/test-fixtures/copyright/trilicense b/syft/pkg/cataloger/debian/test-fixtures/copyright/trilicense similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/copyright/trilicense rename to syft/pkg/cataloger/debian/test-fixtures/copyright/trilicense diff --git a/syft/pkg/cataloger/deb/test-fixtures/glob-paths/usr/lib/opkg/info/pkg-1.0.control b/syft/pkg/cataloger/debian/test-fixtures/glob-paths/usr/lib/opkg/info/pkg-1.0.control similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/glob-paths/usr/lib/opkg/info/pkg-1.0.control rename to syft/pkg/cataloger/debian/test-fixtures/glob-paths/usr/lib/opkg/info/pkg-1.0.control diff --git a/syft/pkg/cataloger/deb/test-fixtures/glob-paths/usr/lib/opkg/status b/syft/pkg/cataloger/debian/test-fixtures/glob-paths/usr/lib/opkg/status similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/glob-paths/usr/lib/opkg/status rename to syft/pkg/cataloger/debian/test-fixtures/glob-paths/usr/lib/opkg/status diff --git a/syft/pkg/cataloger/deb/test-fixtures/glob-paths/var/lib/dpkg/status b/syft/pkg/cataloger/debian/test-fixtures/glob-paths/var/lib/dpkg/status similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/glob-paths/var/lib/dpkg/status rename to syft/pkg/cataloger/debian/test-fixtures/glob-paths/var/lib/dpkg/status diff --git a/syft/pkg/cataloger/deb/test-fixtures/glob-paths/var/lib/dpkg/status.d/pkg-1.0 b/syft/pkg/cataloger/debian/test-fixtures/glob-paths/var/lib/dpkg/status.d/pkg-1.0 similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/glob-paths/var/lib/dpkg/status.d/pkg-1.0 rename to syft/pkg/cataloger/debian/test-fixtures/glob-paths/var/lib/dpkg/status.d/pkg-1.0 diff --git a/syft/pkg/cataloger/deb/test-fixtures/image-distroless-deb/Dockerfile b/syft/pkg/cataloger/debian/test-fixtures/image-distroless-deb/Dockerfile similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/image-distroless-deb/Dockerfile rename to syft/pkg/cataloger/debian/test-fixtures/image-distroless-deb/Dockerfile diff --git a/syft/pkg/cataloger/deb/test-fixtures/image-distroless-deb/usr/share/doc/libsqlite3-0/copyright b/syft/pkg/cataloger/debian/test-fixtures/image-distroless-deb/usr/share/doc/libsqlite3-0/copyright similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/image-distroless-deb/usr/share/doc/libsqlite3-0/copyright rename to syft/pkg/cataloger/debian/test-fixtures/image-distroless-deb/usr/share/doc/libsqlite3-0/copyright diff --git a/syft/pkg/cataloger/deb/test-fixtures/image-distroless-deb/var/lib/dpkg/status.d/libsqlite3-0 b/syft/pkg/cataloger/debian/test-fixtures/image-distroless-deb/var/lib/dpkg/status.d/libsqlite3-0 similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/image-distroless-deb/var/lib/dpkg/status.d/libsqlite3-0 rename to syft/pkg/cataloger/debian/test-fixtures/image-distroless-deb/var/lib/dpkg/status.d/libsqlite3-0 diff --git a/syft/pkg/cataloger/deb/test-fixtures/image-distroless-deb/var/lib/dpkg/status.d/libsqlite3-0.md5sums b/syft/pkg/cataloger/debian/test-fixtures/image-distroless-deb/var/lib/dpkg/status.d/libsqlite3-0.md5sums similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/image-distroless-deb/var/lib/dpkg/status.d/libsqlite3-0.md5sums rename to syft/pkg/cataloger/debian/test-fixtures/image-distroless-deb/var/lib/dpkg/status.d/libsqlite3-0.md5sums diff --git a/syft/pkg/cataloger/deb/test-fixtures/image-dpkg/Dockerfile b/syft/pkg/cataloger/debian/test-fixtures/image-dpkg/Dockerfile similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/image-dpkg/Dockerfile rename to syft/pkg/cataloger/debian/test-fixtures/image-dpkg/Dockerfile diff --git a/syft/pkg/cataloger/deb/test-fixtures/image-dpkg/usr/share/doc/libpam-runtime/copyright b/syft/pkg/cataloger/debian/test-fixtures/image-dpkg/usr/share/doc/libpam-runtime/copyright similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/image-dpkg/usr/share/doc/libpam-runtime/copyright rename to syft/pkg/cataloger/debian/test-fixtures/image-dpkg/usr/share/doc/libpam-runtime/copyright diff --git a/syft/pkg/cataloger/deb/test-fixtures/image-dpkg/var/lib/dpkg/info/libpam-runtime.conffiles b/syft/pkg/cataloger/debian/test-fixtures/image-dpkg/var/lib/dpkg/info/libpam-runtime.conffiles similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/image-dpkg/var/lib/dpkg/info/libpam-runtime.conffiles rename to syft/pkg/cataloger/debian/test-fixtures/image-dpkg/var/lib/dpkg/info/libpam-runtime.conffiles diff --git a/syft/pkg/cataloger/deb/test-fixtures/image-dpkg/var/lib/dpkg/info/libpam-runtime.md5sums b/syft/pkg/cataloger/debian/test-fixtures/image-dpkg/var/lib/dpkg/info/libpam-runtime.md5sums similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/image-dpkg/var/lib/dpkg/info/libpam-runtime.md5sums rename to syft/pkg/cataloger/debian/test-fixtures/image-dpkg/var/lib/dpkg/info/libpam-runtime.md5sums diff --git a/syft/pkg/cataloger/deb/test-fixtures/image-dpkg/var/lib/dpkg/status b/syft/pkg/cataloger/debian/test-fixtures/image-dpkg/var/lib/dpkg/status similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/image-dpkg/var/lib/dpkg/status rename to syft/pkg/cataloger/debian/test-fixtures/image-dpkg/var/lib/dpkg/status diff --git a/syft/pkg/cataloger/deb/test-fixtures/info/util-linux.conffiles b/syft/pkg/cataloger/debian/test-fixtures/info/util-linux.conffiles similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/info/util-linux.conffiles rename to syft/pkg/cataloger/debian/test-fixtures/info/util-linux.conffiles diff --git a/syft/pkg/cataloger/deb/test-fixtures/info/zlib1g.md5sums b/syft/pkg/cataloger/debian/test-fixtures/info/zlib1g.md5sums similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/info/zlib1g.md5sums rename to syft/pkg/cataloger/debian/test-fixtures/info/zlib1g.md5sums diff --git a/syft/pkg/cataloger/deb/test-fixtures/status/coreutils-relationships b/syft/pkg/cataloger/debian/test-fixtures/status/coreutils-relationships similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/status/coreutils-relationships rename to syft/pkg/cataloger/debian/test-fixtures/status/coreutils-relationships diff --git a/syft/pkg/cataloger/deb/test-fixtures/status/doc-examples b/syft/pkg/cataloger/debian/test-fixtures/status/doc-examples similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/status/doc-examples rename to syft/pkg/cataloger/debian/test-fixtures/status/doc-examples diff --git a/syft/pkg/cataloger/deb/test-fixtures/status/empty b/syft/pkg/cataloger/debian/test-fixtures/status/empty similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/status/empty rename to syft/pkg/cataloger/debian/test-fixtures/status/empty diff --git a/syft/pkg/cataloger/deb/test-fixtures/status/installed-size-4KB b/syft/pkg/cataloger/debian/test-fixtures/status/installed-size-4KB similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/status/installed-size-4KB rename to syft/pkg/cataloger/debian/test-fixtures/status/installed-size-4KB diff --git a/syft/pkg/cataloger/deb/test-fixtures/status/libpam-runtime b/syft/pkg/cataloger/debian/test-fixtures/status/libpam-runtime similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/status/libpam-runtime rename to syft/pkg/cataloger/debian/test-fixtures/status/libpam-runtime diff --git a/syft/pkg/cataloger/deb/test-fixtures/status/multiple b/syft/pkg/cataloger/debian/test-fixtures/status/multiple similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/status/multiple rename to syft/pkg/cataloger/debian/test-fixtures/status/multiple diff --git a/syft/pkg/cataloger/deb/test-fixtures/status/single b/syft/pkg/cataloger/debian/test-fixtures/status/single similarity index 100% rename from syft/pkg/cataloger/deb/test-fixtures/status/single rename to syft/pkg/cataloger/debian/test-fixtures/status/single diff --git a/syft/pkg/cataloger/dotnet/cataloger.go b/syft/pkg/cataloger/dotnet/cataloger.go index ec7832aba1e..85b20673a79 100644 --- a/syft/pkg/cataloger/dotnet/cataloger.go +++ b/syft/pkg/cataloger/dotnet/cataloger.go @@ -1,3 +1,6 @@ +/* +Package dotnet provides a concrete Cataloger implementation relating to packages within the C#/.NET language/runtime ecosystem. +*/ package dotnet import ( diff --git a/syft/pkg/cataloger/elixir/cataloger.go b/syft/pkg/cataloger/elixir/cataloger.go index bcd43cdca6f..9ddf5c2b419 100644 --- a/syft/pkg/cataloger/elixir/cataloger.go +++ b/syft/pkg/cataloger/elixir/cataloger.go @@ -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") } diff --git a/syft/pkg/cataloger/erlang/cataloger.go b/syft/pkg/cataloger/erlang/cataloger.go index 62f01330852..8eba5a7cee9 100644 --- a/syft/pkg/cataloger/erlang/cataloger.go +++ b/syft/pkg/cataloger/erlang/cataloger.go @@ -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") } diff --git a/syft/pkg/cataloger/portage/cataloger.go b/syft/pkg/cataloger/gentoo/cataloger.go similarity index 74% rename from syft/pkg/cataloger/portage/cataloger.go rename to syft/pkg/cataloger/gentoo/cataloger.go index e51d2e6d292..67c9a218afb 100644 --- a/syft/pkg/cataloger/portage/cataloger.go +++ b/syft/pkg/cataloger/gentoo/cataloger.go @@ -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" diff --git a/syft/pkg/cataloger/portage/cataloger_test.go b/syft/pkg/cataloger/gentoo/cataloger_test.go similarity index 99% rename from syft/pkg/cataloger/portage/cataloger_test.go rename to syft/pkg/cataloger/gentoo/cataloger_test.go index 6fd0c603b70..f2deeb199b4 100644 --- a/syft/pkg/cataloger/portage/cataloger_test.go +++ b/syft/pkg/cataloger/gentoo/cataloger_test.go @@ -1,4 +1,4 @@ -package portage +package gentoo import ( "testing" diff --git a/syft/pkg/cataloger/portage/parse_portage_contents.go b/syft/pkg/cataloger/gentoo/parse_portage_contents.go similarity index 99% rename from syft/pkg/cataloger/portage/parse_portage_contents.go rename to syft/pkg/cataloger/gentoo/parse_portage_contents.go index a0e774a382a..5da6e8c39f7 100644 --- a/syft/pkg/cataloger/portage/parse_portage_contents.go +++ b/syft/pkg/cataloger/gentoo/parse_portage_contents.go @@ -1,4 +1,4 @@ -package portage +package gentoo import ( "bufio" diff --git a/syft/pkg/cataloger/portage/purl.go b/syft/pkg/cataloger/gentoo/purl.go similarity index 95% rename from syft/pkg/cataloger/portage/purl.go rename to syft/pkg/cataloger/gentoo/purl.go index 9ff016b92b3..dc6fd626665 100644 --- a/syft/pkg/cataloger/portage/purl.go +++ b/syft/pkg/cataloger/gentoo/purl.go @@ -1,4 +1,4 @@ -package portage +package gentoo import ( "github.com/anchore/packageurl-go" diff --git a/syft/pkg/cataloger/portage/purl_test.go b/syft/pkg/cataloger/gentoo/purl_test.go similarity index 96% rename from syft/pkg/cataloger/portage/purl_test.go rename to syft/pkg/cataloger/gentoo/purl_test.go index 80541c26cd1..e4683930167 100644 --- a/syft/pkg/cataloger/portage/purl_test.go +++ b/syft/pkg/cataloger/gentoo/purl_test.go @@ -1,4 +1,4 @@ -package portage +package gentoo import ( "fmt" diff --git a/syft/pkg/cataloger/portage/test-fixtures/glob-paths/var/db/pkg/x/y/CONTENTS b/syft/pkg/cataloger/gentoo/test-fixtures/glob-paths/var/db/pkg/x/y/CONTENTS similarity index 100% rename from syft/pkg/cataloger/portage/test-fixtures/glob-paths/var/db/pkg/x/y/CONTENTS rename to syft/pkg/cataloger/gentoo/test-fixtures/glob-paths/var/db/pkg/x/y/CONTENTS diff --git a/syft/pkg/cataloger/portage/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/CONTENTS b/syft/pkg/cataloger/gentoo/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/CONTENTS similarity index 100% rename from syft/pkg/cataloger/portage/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/CONTENTS rename to syft/pkg/cataloger/gentoo/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/CONTENTS diff --git a/syft/pkg/cataloger/portage/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/LICENSE b/syft/pkg/cataloger/gentoo/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/LICENSE similarity index 100% rename from syft/pkg/cataloger/portage/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/LICENSE rename to syft/pkg/cataloger/gentoo/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/LICENSE diff --git a/syft/pkg/cataloger/portage/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/SIZE b/syft/pkg/cataloger/gentoo/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/SIZE similarity index 100% rename from syft/pkg/cataloger/portage/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/SIZE rename to syft/pkg/cataloger/gentoo/test-fixtures/image-portage/var/db/pkg/app-containers/skopeo-1.5.1/SIZE diff --git a/syft/pkg/cataloger/githubactions/cataloger.go b/syft/pkg/cataloger/githubactions/cataloger.go index 825d3942a7a..e484410879c 100644 --- a/syft/pkg/cataloger/githubactions/cataloger.go +++ b/syft/pkg/cataloger/githubactions/cataloger.go @@ -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" diff --git a/syft/pkg/cataloger/githubactions/test-fixtures/workflow-multi-job.yaml b/syft/pkg/cataloger/githubactions/test-fixtures/workflow-multi-job.yaml index 36502c1332d..bf0fc82c14d 100644 --- a/syft/pkg/cataloger/githubactions/test-fixtures/workflow-multi-job.yaml +++ b/syft/pkg/cataloger/githubactions/test-fixtures/workflow-multi-job.yaml @@ -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 diff --git a/syft/pkg/cataloger/golang/cataloger.go b/syft/pkg/cataloger/golang/cataloger.go index 4756df2425c..44c35a6c785 100644 --- a/syft/pkg/cataloger/golang/cataloger.go +++ b/syft/pkg/cataloger/golang/cataloger.go @@ -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\d+(\.\d+)?(\.\d+)?)(?P\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"), } } diff --git a/syft/pkg/cataloger/golang/cataloger_test.go b/syft/pkg/cataloger/golang/cataloger_test.go index b1e26ba3517..22964fb6dcf 100644 --- a/syft/pkg/cataloger/golang/cataloger_test.go +++ b/syft/pkg/cataloger/golang/cataloger_test.go @@ -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{})) }) } } diff --git a/syft/pkg/cataloger/golang/parse_go_mod_test.go b/syft/pkg/cataloger/golang/parse_go_mod_test.go index cc6809406d8..bd0217ee027 100644 --- a/syft/pkg/cataloger/golang/parse_go_mod_test.go +++ b/syft/pkg/cataloger/golang/parse_go_mod_test.go @@ -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{})) }) } } diff --git a/syft/pkg/cataloger/haskell/cataloger.go b/syft/pkg/cataloger/haskell/cataloger.go index f9231f22193..40b4bbc4d18 100644 --- a/syft/pkg/cataloger/haskell/cataloger.go +++ b/syft/pkg/cataloger/haskell/cataloger.go @@ -1,3 +1,6 @@ +/* +Package haskell provides a concrete Cataloger implementation relating to packages within the Haskell language ecosystem. +*/ package haskell import ( diff --git a/syft/pkg/cataloger/java/cataloger.go b/syft/pkg/cataloger/java/cataloger.go index 46127cc1ee0..2b543bf86d2 100644 --- a/syft/pkg/cataloger/java/cataloger.go +++ b/syft/pkg/cataloger/java/cataloger.go @@ -1,5 +1,5 @@ /* -Package java provides a concrete Cataloger implementation for Java archives (jar, war, ear, par, sar, jpi, hpi, and native-image formats). +Package java provides a concrete Cataloger implementation for packages relating to the Java language ecosystem. */ package java @@ -7,11 +7,11 @@ import ( "github.com/anchore/syft/syft/pkg/cataloger/generic" ) -// NewJavaCataloger returns a new Java archive cataloger object. -func NewJavaCataloger(cfg Config) *generic.Cataloger { +// NewArchiveCataloger returns a new Java archive cataloger object for detecting packages with archives (jar, war, ear, par, sar, jpi, hpi, and native-image formats) +func NewArchiveCataloger(cfg Config) *generic.Cataloger { gap := newGenericArchiveParserAdapter(cfg) - c := generic.NewCataloger("java-cataloger"). + c := generic.NewCataloger("java-archive-cataloger"). WithParserByGlobs(gap.parseJavaArchive, archiveFormatGlobs...) if cfg.SearchIndexedArchives { @@ -28,18 +28,16 @@ func NewJavaCataloger(cfg Config) *generic.Cataloger { return c } -// NewJavaPomCataloger returns a cataloger capable of parsing -// dependencies from a pom.xml file. +// NewPomCataloger returns a cataloger capable of parsing dependencies from a pom.xml file. // Pom files list dependencies that maybe not be locally installed yet. -func NewJavaPomCataloger() *generic.Cataloger { +func NewPomCataloger() *generic.Cataloger { return generic.NewCataloger("java-pom-cataloger"). WithParserByGlobs(parserPomXML, "**/pom.xml") } -// NewJavaGradleLockfileCataloger returns a cataloger capable of parsing -// dependencies from a gradle.lockfile file. -// older versions of lockfiles aren't supported yet -func NewJavaGradleLockfileCataloger() *generic.Cataloger { +// NewGradleLockfileCataloger returns a cataloger capable of parsing dependencies from a gradle.lockfile file. +// Note: Older versions of lockfiles aren't supported yet +func NewGradleLockfileCataloger() *generic.Cataloger { return generic.NewCataloger("java-gradle-lockfile-cataloger"). WithParserByGlobs(parseGradleLockfile, gradleLockfileGlob) } diff --git a/syft/pkg/cataloger/java/cataloger_test.go b/syft/pkg/cataloger/java/cataloger_test.go index ab09dc2fe0d..167082103fc 100644 --- a/syft/pkg/cataloger/java/cataloger_test.go +++ b/syft/pkg/cataloger/java/cataloger_test.go @@ -54,7 +54,7 @@ func Test_ArchiveCataloger_Globs(t *testing.T) { pkgtest.NewCatalogTester(). FromDirectory(t, test.fixture). ExpectsResolverContentQueries(test.expected). - TestCataloger(t, NewJavaCataloger(Config{ + TestCataloger(t, NewArchiveCataloger(Config{ SearchUnindexedArchives: true, SearchIndexedArchives: true, })) @@ -82,7 +82,7 @@ func Test_POMCataloger_Globs(t *testing.T) { pkgtest.NewCatalogTester(). FromDirectory(t, test.fixture). ExpectsResolverContentQueries(test.expected). - TestCataloger(t, NewJavaPomCataloger()) + TestCataloger(t, NewPomCataloger()) }) } } diff --git a/syft/pkg/cataloger/javascript/cataloger.go b/syft/pkg/cataloger/javascript/cataloger.go index 4ca766db53a..56127e373cd 100644 --- a/syft/pkg/cataloger/javascript/cataloger.go +++ b/syft/pkg/cataloger/javascript/cataloger.go @@ -1,5 +1,5 @@ /* -Package javascript provides a concrete Cataloger implementation for JavaScript ecosystem files (yarn and npm). +Package javascript provides a concrete Cataloger implementation for packages relating to the JavaScript language ecosystem. */ package javascript @@ -13,7 +13,7 @@ func NewPackageCataloger() *generic.Cataloger { WithParserByGlobs(parsePackageJSON, "**/package.json") } -// NewLockCataloger returns a new cataloger object for NPM (and NPM-adjacent) lock files. +// NewLockCataloger returns a new cataloger object for NPM (and NPM-adjacent, such as yarn) lock files. func NewLockCataloger() *generic.Cataloger { return generic.NewCataloger("javascript-lock-cataloger"). WithParserByGlobs(parsePackageLock, "**/package-lock.json"). diff --git a/syft/pkg/cataloger/nix/cataloger.go b/syft/pkg/cataloger/nix/cataloger.go index e4d69477e7d..562ca7323d0 100644 --- a/syft/pkg/cataloger/nix/cataloger.go +++ b/syft/pkg/cataloger/nix/cataloger.go @@ -1,3 +1,6 @@ +/* +Package nix provides a concrete Cataloger implementation for packages within the Nix packaging ecosystem. +*/ package nix import ( @@ -11,10 +14,7 @@ import ( "github.com/anchore/syft/syft/pkg" ) -const ( - catalogerName = "nix-store-cataloger" - nixStoreGlob = "**/nix/store/*" -) +const catalogerName = "nix-store-cataloger" // StoreCataloger finds package outputs installed in the Nix store location (/nix/store/*). type StoreCataloger struct{} @@ -32,7 +32,7 @@ func (c *StoreCataloger) Catalog(resolver file.Resolver) ([]pkg.Package, []artif var pkgs []pkg.Package var filesByPath = make(map[string]*file.LocationSet) for location := range resolver.AllLocations() { - matchesStorePath, err := doublestar.Match(nixStoreGlob, location.RealPath) + matchesStorePath, err := doublestar.Match("**/nix/store/*", location.RealPath) if err != nil { return nil, nil, fmt.Errorf("failed to match nix store path: %w", err) } diff --git a/syft/pkg/cataloger/php/cataloger.go b/syft/pkg/cataloger/php/cataloger.go index 07e06a9a512..bbdf61a52ca 100644 --- a/syft/pkg/cataloger/php/cataloger.go +++ b/syft/pkg/cataloger/php/cataloger.go @@ -1,5 +1,5 @@ /* -Package php provides a concrete Cataloger implementation for PHP ecosystem files. +Package php provides a concrete Cataloger implementation relating to packages within the PHP language ecosystem. */ package php diff --git a/syft/pkg/cataloger/python/cataloger.go b/syft/pkg/cataloger/python/cataloger.go index af5f0bd319e..82dfacc5803 100644 --- a/syft/pkg/cataloger/python/cataloger.go +++ b/syft/pkg/cataloger/python/cataloger.go @@ -1,3 +1,6 @@ +/* +Package python provides a concrete Cataloger implementation relating to packages within the Python language ecosystem. +*/ package python import ( @@ -16,19 +19,19 @@ func DefaultCatalogerConfig() CatalogerConfig { } } -// NewPythonIndexCataloger returns a new cataloger for python packages referenced from poetry lock files, requirements.txt files, and setup.py files. -func NewPythonIndexCataloger(cfg CatalogerConfig) *generic.Cataloger { +// NewPackageCataloger returns a new cataloger for python packages referenced from poetry lock files, requirements.txt files, and setup.py files. +func NewPackageCataloger(cfg CatalogerConfig) *generic.Cataloger { rqp := newRequirementsParser(cfg) - return generic.NewCataloger("python-index-cataloger"). + return generic.NewCataloger("python-package-cataloger"). WithParserByGlobs(rqp.parseRequirementsTxt, "**/*requirements*.txt"). WithParserByGlobs(parsePoetryLock, "**/poetry.lock"). WithParserByGlobs(parsePipfileLock, "**/Pipfile.lock"). WithParserByGlobs(parseSetup, "**/setup.py") } -// NewPythonPackageCataloger returns a new cataloger for python packages within egg or wheel installation directories. -func NewPythonPackageCataloger() *generic.Cataloger { - return generic.NewCataloger("python-package-cataloger"). +// NewInstalledPackageCataloger returns a new cataloger for python packages within egg or wheel installation directories. +func NewInstalledPackageCataloger() *generic.Cataloger { + return generic.NewCataloger("python-installed-package-cataloger"). WithParserByGlobs( parseWheelOrEgg, eggInfoGlob, diff --git a/syft/pkg/cataloger/python/cataloger_test.go b/syft/pkg/cataloger/python/cataloger_test.go index aa7f7503607..fd93a84888c 100644 --- a/syft/pkg/cataloger/python/cataloger_test.go +++ b/syft/pkg/cataloger/python/cataloger_test.go @@ -24,7 +24,7 @@ func Test_PackageCataloger(t *testing.T) { PURL: "pkg:pypi/no-version", Type: pkg.PythonPkg, Language: pkg.Python, - FoundBy: "python-package-cataloger", + FoundBy: "python-installed-package-cataloger", Metadata: pkg.PythonPackage{ Name: "no-version", SitePackagesRootPath: "test-fixtures", @@ -47,7 +47,7 @@ func Test_PackageCataloger(t *testing.T) { Licenses: pkg.NewLicenseSet( pkg.NewLicenseFromLocations("Apache 2.0", file.NewLocation("test-fixtures/egg-info/PKG-INFO")), ), - FoundBy: "python-package-cataloger", + FoundBy: "python-installed-package-cataloger", Metadata: pkg.PythonPackage{ Name: "requests", Version: "2.22.0", @@ -83,7 +83,7 @@ func Test_PackageCataloger(t *testing.T) { Licenses: pkg.NewLicenseSet( pkg.NewLicenseFromLocations("Apache 2.0", file.NewLocation("test-fixtures/casesensitive/EGG-INFO/PKG-INFO")), ), - FoundBy: "python-package-cataloger", + FoundBy: "python-installed-package-cataloger", Metadata: pkg.PythonPackage{ Name: "requests", Version: "2.22.0", @@ -120,7 +120,7 @@ func Test_PackageCataloger(t *testing.T) { Licenses: pkg.NewLicenseSet( pkg.NewLicenseFromLocations("BSD License", file.NewLocation("test-fixtures/dist-info/METADATA")), ), - FoundBy: "python-package-cataloger", + FoundBy: "python-installed-package-cataloger", Metadata: pkg.PythonPackage{ Name: "Pygments", Version: "2.6.1", @@ -159,7 +159,7 @@ func Test_PackageCataloger(t *testing.T) { Licenses: pkg.NewLicenseSet( pkg.NewLicenseFromLocations("BSD License", file.NewLocation("test-fixtures/casesensitive/DIST-INFO/METADATA")), ), - FoundBy: "python-package-cataloger", + FoundBy: "python-installed-package-cataloger", Metadata: pkg.PythonPackage{ Name: "Pygments", Version: "2.6.1", @@ -196,7 +196,7 @@ func Test_PackageCataloger(t *testing.T) { Licenses: pkg.NewLicenseSet( pkg.NewLicenseFromLocations("BSD License", file.NewLocation("test-fixtures/malformed-record/dist-info/METADATA")), ), - FoundBy: "python-package-cataloger", + FoundBy: "python-installed-package-cataloger", Metadata: pkg.PythonPackage{ Name: "Pygments", Version: "2.6.1", @@ -227,7 +227,7 @@ func Test_PackageCataloger(t *testing.T) { Licenses: pkg.NewLicenseSet( pkg.NewLicenseFromLocations("BSD License", file.NewLocation("test-fixtures/partial.dist-info/METADATA")), ), - FoundBy: "python-package-cataloger", + FoundBy: "python-installed-package-cataloger", Metadata: pkg.PythonPackage{ Name: "Pygments", Version: "2.6.1", @@ -250,7 +250,7 @@ func Test_PackageCataloger(t *testing.T) { Licenses: pkg.NewLicenseSet( pkg.NewLicenseFromLocations("Apache 2.0", file.NewLocation("test-fixtures/test.egg-info")), ), - FoundBy: "python-package-cataloger", + FoundBy: "python-installed-package-cataloger", Metadata: pkg.PythonPackage{ Name: "requests", Version: "2.22.0", @@ -275,7 +275,7 @@ func Test_PackageCataloger(t *testing.T) { pkgtest.NewCatalogTester(). WithResolver(resolver). Expects([]pkg.Package{test.expectedPackage}, nil). - TestCataloger(t, NewPythonPackageCataloger()) + TestCataloger(t, NewInstalledPackageCataloger()) }) } } @@ -296,7 +296,7 @@ func Test_PackageCataloger_IgnorePackage(t *testing.T) { t.Run(test.MetadataFixture, func(t *testing.T) { resolver := file.NewMockResolverForPaths(test.MetadataFixture) - actual, _, err := NewPythonPackageCataloger().Catalog(resolver) + actual, _, err := NewInstalledPackageCataloger().Catalog(resolver) require.NoError(t, err) if len(actual) != 0 { @@ -332,7 +332,7 @@ func Test_IndexCataloger_Globs(t *testing.T) { pkgtest.NewCatalogTester(). FromDirectory(t, test.fixture). ExpectsResolverContentQueries(test.expected). - TestCataloger(t, NewPythonIndexCataloger(DefaultCatalogerConfig())) + TestCataloger(t, NewPackageCataloger(DefaultCatalogerConfig())) }) } } @@ -361,7 +361,7 @@ func Test_PackageCataloger_Globs(t *testing.T) { pkgtest.NewCatalogTester(). FromDirectory(t, test.fixture). ExpectsResolverContentQueries(test.expected). - TestCataloger(t, NewPythonPackageCataloger()) + TestCataloger(t, NewInstalledPackageCataloger()) }) } } diff --git a/syft/pkg/cataloger/r/cataloger.go b/syft/pkg/cataloger/r/cataloger.go index 8cb4774a4af..9b3cb0949f3 100644 --- a/syft/pkg/cataloger/r/cataloger.go +++ b/syft/pkg/cataloger/r/cataloger.go @@ -1,13 +1,14 @@ +/* +Package r provides a concrete Cataloger implementation relating to packages within the R language ecosystem. +*/ package r import ( "github.com/anchore/syft/syft/pkg/cataloger/generic" ) -const catalogerName = "r-package-cataloger" - // NewPackageCataloger returns a new R cataloger object based on detection of R package DESCRIPTION files. func NewPackageCataloger() *generic.Cataloger { - return generic.NewCataloger(catalogerName). + return generic.NewCataloger("r-package-cataloger"). WithParserByGlobs(parseDescriptionFile, "**/DESCRIPTION") } diff --git a/syft/pkg/cataloger/rpm/cataloger.go b/syft/pkg/cataloger/redhat/cataloger.go similarity index 52% rename from syft/pkg/cataloger/rpm/cataloger.go rename to syft/pkg/cataloger/redhat/cataloger.go index 74782899e7e..6279ac54693 100644 --- a/syft/pkg/cataloger/rpm/cataloger.go +++ b/syft/pkg/cataloger/redhat/cataloger.go @@ -1,7 +1,7 @@ /* -Package rpm provides a concrete DBCataloger implementation for RPM "Package" DB files and a FileCataloger for RPM files. +Package redhat provides a concrete DBCataloger implementation relating to packages within the RedHat linux distribution. */ -package rpm +package redhat import ( "database/sql" @@ -11,26 +11,21 @@ import ( "github.com/anchore/syft/syft/pkg/cataloger/generic" ) -const ( - dbCatalogerName = "rpm-db-cataloger" - fileCatalogerName = "rpm-file-cataloger" -) - -// NewRpmDBCataloger returns a new RPM DB cataloger object. -func NewRpmDBCataloger() *generic.Cataloger { +// NewDBCataloger returns a new RPM DB cataloger object. +func NewDBCataloger() *generic.Cataloger { // check if a sqlite driver is available if !isSqliteDriverAvailable() { log.Warnf("sqlite driver is not available, newer RPM databases might not be cataloged") } - return generic.NewCataloger(dbCatalogerName). + return generic.NewCataloger("rpm-db-cataloger"). WithParserByGlobs(parseRpmDB, pkg.RpmDBGlob). WithParserByGlobs(parseRpmManifest, pkg.RpmManifestGlob) } -// NewFileCataloger returns a new RPM file cataloger object. -func NewFileCataloger() *generic.Cataloger { - return generic.NewCataloger(fileCatalogerName). +// NewArchiveCataloger returns a new RPM file cataloger object. +func NewArchiveCataloger() *generic.Cataloger { + return generic.NewCataloger("rpm-archive-cataloger"). WithParserByGlobs(parseRpmArchive, "**/*.rpm") } diff --git a/syft/pkg/cataloger/rpm/cataloger_test.go b/syft/pkg/cataloger/redhat/cataloger_test.go similarity index 93% rename from syft/pkg/cataloger/rpm/cataloger_test.go rename to syft/pkg/cataloger/redhat/cataloger_test.go index 31b7bf11b4b..12dfe394ce9 100644 --- a/syft/pkg/cataloger/rpm/cataloger_test.go +++ b/syft/pkg/cataloger/redhat/cataloger_test.go @@ -1,4 +1,4 @@ -package rpm +package redhat import ( "testing" @@ -35,7 +35,7 @@ func Test_DBCataloger_Globs(t *testing.T) { pkgtest.NewCatalogTester(). FromDirectory(t, test.fixture). ExpectsResolverContentQueries(test.expected). - TestCataloger(t, NewRpmDBCataloger()) + TestCataloger(t, NewDBCataloger()) }) } } @@ -60,7 +60,7 @@ func Test_RPMFileCataloger_Globs(t *testing.T) { pkgtest.NewCatalogTester(). FromDirectory(t, test.fixture). ExpectsResolverContentQueries(test.expected). - TestCataloger(t, NewFileCataloger()) + TestCataloger(t, NewArchiveCataloger()) }) } } diff --git a/syft/pkg/cataloger/rpm/package.go b/syft/pkg/cataloger/redhat/package.go similarity index 99% rename from syft/pkg/cataloger/rpm/package.go rename to syft/pkg/cataloger/redhat/package.go index 161753b4513..23954991ac6 100644 --- a/syft/pkg/cataloger/rpm/package.go +++ b/syft/pkg/cataloger/redhat/package.go @@ -1,4 +1,4 @@ -package rpm +package redhat import ( "fmt" diff --git a/syft/pkg/cataloger/rpm/package_test.go b/syft/pkg/cataloger/redhat/package_test.go similarity index 99% rename from syft/pkg/cataloger/rpm/package_test.go rename to syft/pkg/cataloger/redhat/package_test.go index 669c8f9e38b..b5459717a3c 100644 --- a/syft/pkg/cataloger/rpm/package_test.go +++ b/syft/pkg/cataloger/redhat/package_test.go @@ -1,4 +1,4 @@ -package rpm +package redhat import ( "testing" diff --git a/syft/pkg/cataloger/rpm/parse_rpm_archive.go b/syft/pkg/cataloger/redhat/parse_rpm_archive.go similarity index 99% rename from syft/pkg/cataloger/rpm/parse_rpm_archive.go rename to syft/pkg/cataloger/redhat/parse_rpm_archive.go index fb87de820b8..73e3ff4b0c3 100644 --- a/syft/pkg/cataloger/rpm/parse_rpm_archive.go +++ b/syft/pkg/cataloger/redhat/parse_rpm_archive.go @@ -1,4 +1,4 @@ -package rpm +package redhat import ( "fmt" diff --git a/syft/pkg/cataloger/rpm/parse_rpm_archive_test.go b/syft/pkg/cataloger/redhat/parse_rpm_archive_test.go similarity index 96% rename from syft/pkg/cataloger/rpm/parse_rpm_archive_test.go rename to syft/pkg/cataloger/redhat/parse_rpm_archive_test.go index 8ed81fe1fe6..dddf81a9c9d 100644 --- a/syft/pkg/cataloger/rpm/parse_rpm_archive_test.go +++ b/syft/pkg/cataloger/redhat/parse_rpm_archive_test.go @@ -1,4 +1,4 @@ -package rpm +package redhat import ( "testing" @@ -23,7 +23,7 @@ func TestParseRpmFiles(t *testing.T) { Version: "0:1.01-9.hg20160905.el7", PURL: "pkg:rpm/abc@1.01-9.hg20160905.el7?arch=x86_64&epoch=0&upstream=abc-1.01-9.hg20160905.el7.src.rpm", Locations: file.NewLocationSet(file.NewLocation("abc-1.01-9.hg20160905.el7.x86_64.rpm")), - FoundBy: "rpm-file-cataloger", + FoundBy: "rpm-archive-cataloger", Type: pkg.RpmPkg, Licenses: pkg.NewLicenseSet( pkg.NewLicenseFromLocations("MIT", abcRpmLocation), @@ -51,7 +51,7 @@ func TestParseRpmFiles(t *testing.T) { Version: "0:1.0.3-1.el7", PURL: "pkg:rpm/zork@1.0.3-1.el7?arch=x86_64&epoch=0&upstream=zork-1.0.3-1.el7.src.rpm", Locations: file.NewLocationSet(zorkRpmLocation), - FoundBy: "rpm-file-cataloger", + FoundBy: "rpm-archive-cataloger", Type: pkg.RpmPkg, Licenses: pkg.NewLicenseSet( pkg.NewLicenseFromLocations("Public Domain", zorkRpmLocation), @@ -90,7 +90,7 @@ func TestParseRpmFiles(t *testing.T) { pkgtest.NewCatalogTester(). FromDirectory(t, test.fixture). Expects(test.expected, nil). - TestCataloger(t, NewFileCataloger()) + TestCataloger(t, NewArchiveCataloger()) }) } } diff --git a/syft/pkg/cataloger/rpm/parse_rpm_db.go b/syft/pkg/cataloger/redhat/parse_rpm_db.go similarity index 99% rename from syft/pkg/cataloger/rpm/parse_rpm_db.go rename to syft/pkg/cataloger/redhat/parse_rpm_db.go index 03be3ae376b..672b1c753a6 100644 --- a/syft/pkg/cataloger/rpm/parse_rpm_db.go +++ b/syft/pkg/cataloger/redhat/parse_rpm_db.go @@ -1,4 +1,4 @@ -package rpm +package redhat import ( "fmt" diff --git a/syft/pkg/cataloger/rpm/parse_rpm_db_test.go b/syft/pkg/cataloger/redhat/parse_rpm_db_test.go similarity index 99% rename from syft/pkg/cataloger/rpm/parse_rpm_db_test.go rename to syft/pkg/cataloger/redhat/parse_rpm_db_test.go index ac75023fd5c..b4a9c460999 100644 --- a/syft/pkg/cataloger/rpm/parse_rpm_db_test.go +++ b/syft/pkg/cataloger/redhat/parse_rpm_db_test.go @@ -1,4 +1,4 @@ -package rpm +package redhat import ( "fmt" diff --git a/syft/pkg/cataloger/rpm/parse_rpm_manifest.go b/syft/pkg/cataloger/redhat/parse_rpm_manifest.go similarity index 98% rename from syft/pkg/cataloger/rpm/parse_rpm_manifest.go rename to syft/pkg/cataloger/redhat/parse_rpm_manifest.go index 5ee18ec5320..b3b06bdcbc2 100644 --- a/syft/pkg/cataloger/rpm/parse_rpm_manifest.go +++ b/syft/pkg/cataloger/redhat/parse_rpm_manifest.go @@ -1,4 +1,4 @@ -package rpm +package redhat import ( "bufio" diff --git a/syft/pkg/cataloger/rpm/parse_rpm_manifest_test.go b/syft/pkg/cataloger/redhat/parse_rpm_manifest_test.go similarity index 99% rename from syft/pkg/cataloger/rpm/parse_rpm_manifest_test.go rename to syft/pkg/cataloger/redhat/parse_rpm_manifest_test.go index 97965212391..5a2cd2666f4 100644 --- a/syft/pkg/cataloger/rpm/parse_rpm_manifest_test.go +++ b/syft/pkg/cataloger/redhat/parse_rpm_manifest_test.go @@ -1,4 +1,4 @@ -package rpm +package redhat import ( "testing" diff --git a/syft/pkg/cataloger/rpm/test-fixtures/.gitignore b/syft/pkg/cataloger/redhat/test-fixtures/.gitignore similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/.gitignore rename to syft/pkg/cataloger/redhat/test-fixtures/.gitignore diff --git a/syft/pkg/cataloger/rpm/test-fixtures/Makefile b/syft/pkg/cataloger/redhat/test-fixtures/Makefile similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/Makefile rename to syft/pkg/cataloger/redhat/test-fixtures/Makefile diff --git a/syft/pkg/cataloger/rpm/test-fixtures/Packages b/syft/pkg/cataloger/redhat/test-fixtures/Packages similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/Packages rename to syft/pkg/cataloger/redhat/test-fixtures/Packages diff --git a/syft/pkg/cataloger/rpm/test-fixtures/bad/bad.rpm b/syft/pkg/cataloger/redhat/test-fixtures/bad/bad.rpm similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/bad/bad.rpm rename to syft/pkg/cataloger/redhat/test-fixtures/bad/bad.rpm diff --git a/syft/pkg/cataloger/rpm/test-fixtures/container-manifest-2 b/syft/pkg/cataloger/redhat/test-fixtures/container-manifest-2 similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/container-manifest-2 rename to syft/pkg/cataloger/redhat/test-fixtures/container-manifest-2 diff --git a/syft/pkg/cataloger/rpm/test-fixtures/generate-fixture.sh b/syft/pkg/cataloger/redhat/test-fixtures/generate-fixture.sh similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/generate-fixture.sh rename to syft/pkg/cataloger/redhat/test-fixtures/generate-fixture.sh diff --git a/syft/pkg/cataloger/rpm/test-fixtures/glob-paths/dive-0.10.0.rpm b/syft/pkg/cataloger/redhat/test-fixtures/glob-paths/dive-0.10.0.rpm similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/glob-paths/dive-0.10.0.rpm rename to syft/pkg/cataloger/redhat/test-fixtures/glob-paths/dive-0.10.0.rpm diff --git a/syft/pkg/cataloger/rpm/test-fixtures/glob-paths/usr/lib/sysimage/rpm/Packages b/syft/pkg/cataloger/redhat/test-fixtures/glob-paths/usr/lib/sysimage/rpm/Packages similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/glob-paths/usr/lib/sysimage/rpm/Packages rename to syft/pkg/cataloger/redhat/test-fixtures/glob-paths/usr/lib/sysimage/rpm/Packages diff --git a/syft/pkg/cataloger/rpm/test-fixtures/glob-paths/usr/lib/sysimage/rpm/Packages.db b/syft/pkg/cataloger/redhat/test-fixtures/glob-paths/usr/lib/sysimage/rpm/Packages.db similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/glob-paths/usr/lib/sysimage/rpm/Packages.db rename to syft/pkg/cataloger/redhat/test-fixtures/glob-paths/usr/lib/sysimage/rpm/Packages.db diff --git a/syft/pkg/cataloger/rpm/test-fixtures/glob-paths/usr/lib/sysimage/rpm/rpmdb.sqlite b/syft/pkg/cataloger/redhat/test-fixtures/glob-paths/usr/lib/sysimage/rpm/rpmdb.sqlite similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/glob-paths/usr/lib/sysimage/rpm/rpmdb.sqlite rename to syft/pkg/cataloger/redhat/test-fixtures/glob-paths/usr/lib/sysimage/rpm/rpmdb.sqlite diff --git a/syft/pkg/cataloger/rpm/test-fixtures/glob-paths/usr/share/rpm/Packages b/syft/pkg/cataloger/redhat/test-fixtures/glob-paths/usr/share/rpm/Packages similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/glob-paths/usr/share/rpm/Packages rename to syft/pkg/cataloger/redhat/test-fixtures/glob-paths/usr/share/rpm/Packages diff --git a/syft/pkg/cataloger/rpm/test-fixtures/glob-paths/usr/share/rpm/Packages.db b/syft/pkg/cataloger/redhat/test-fixtures/glob-paths/usr/share/rpm/Packages.db similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/glob-paths/usr/share/rpm/Packages.db rename to syft/pkg/cataloger/redhat/test-fixtures/glob-paths/usr/share/rpm/Packages.db diff --git a/syft/pkg/cataloger/rpm/test-fixtures/glob-paths/usr/share/rpm/rpmdb.sqlite b/syft/pkg/cataloger/redhat/test-fixtures/glob-paths/usr/share/rpm/rpmdb.sqlite similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/glob-paths/usr/share/rpm/rpmdb.sqlite rename to syft/pkg/cataloger/redhat/test-fixtures/glob-paths/usr/share/rpm/rpmdb.sqlite diff --git a/syft/pkg/cataloger/rpm/test-fixtures/glob-paths/var/lib/rpm/Packages b/syft/pkg/cataloger/redhat/test-fixtures/glob-paths/var/lib/rpm/Packages similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/glob-paths/var/lib/rpm/Packages rename to syft/pkg/cataloger/redhat/test-fixtures/glob-paths/var/lib/rpm/Packages diff --git a/syft/pkg/cataloger/rpm/test-fixtures/glob-paths/var/lib/rpm/Packages.db b/syft/pkg/cataloger/redhat/test-fixtures/glob-paths/var/lib/rpm/Packages.db similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/glob-paths/var/lib/rpm/Packages.db rename to syft/pkg/cataloger/redhat/test-fixtures/glob-paths/var/lib/rpm/Packages.db diff --git a/syft/pkg/cataloger/rpm/test-fixtures/glob-paths/var/lib/rpm/rpmdb.sqlite b/syft/pkg/cataloger/redhat/test-fixtures/glob-paths/var/lib/rpm/rpmdb.sqlite similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/glob-paths/var/lib/rpm/rpmdb.sqlite rename to syft/pkg/cataloger/redhat/test-fixtures/glob-paths/var/lib/rpm/rpmdb.sqlite diff --git a/syft/pkg/cataloger/rpm/test-fixtures/glob-paths/var/lib/rpmmanifest/container-manifest-2 b/syft/pkg/cataloger/redhat/test-fixtures/glob-paths/var/lib/rpmmanifest/container-manifest-2 similarity index 100% rename from syft/pkg/cataloger/rpm/test-fixtures/glob-paths/var/lib/rpmmanifest/container-manifest-2 rename to syft/pkg/cataloger/redhat/test-fixtures/glob-paths/var/lib/rpmmanifest/container-manifest-2 diff --git a/syft/pkg/cataloger/ruby/catalogers.go b/syft/pkg/cataloger/ruby/catalogers.go index a7f86aa0170..0c8faf8ff77 100644 --- a/syft/pkg/cataloger/ruby/catalogers.go +++ b/syft/pkg/cataloger/ruby/catalogers.go @@ -1,5 +1,5 @@ /* -Package ruby bundler provides a concrete Cataloger implementation for Ruby Gemfile.lock bundler files. +Package ruby provides a concrete Cataloger implementation relating to packages within the Ruby language ecosystem. */ package ruby @@ -15,7 +15,7 @@ func NewGemFileLockCataloger() *generic.Cataloger { // NewInstalledGemSpecCataloger returns a new Bundler cataloger object tailored for detecting installations of gems (e.g. Gemspec). func NewInstalledGemSpecCataloger() *generic.Cataloger { - return generic.NewCataloger("ruby-gemspec-cataloger"). + return generic.NewCataloger("ruby-installed-gemspec-cataloger"). WithParserByGlobs(parseGemSpecEntries, "**/specifications/**/*.gemspec") } diff --git a/syft/pkg/cataloger/rust/cataloger.go b/syft/pkg/cataloger/rust/cataloger.go index a5128b24da4..51cdeab8f5a 100644 --- a/syft/pkg/cataloger/rust/cataloger.go +++ b/syft/pkg/cataloger/rust/cataloger.go @@ -1,5 +1,5 @@ /* -Package rust provides a concrete Cataloger implementation for Cargo.lock files. +Package rust provides a concrete Cataloger implementation relating to packages within the Rust language ecosystem. */ package rust diff --git a/syft/pkg/cataloger/sbom/cataloger.go b/syft/pkg/cataloger/sbom/cataloger.go index 548e5cad4e3..08c601455e4 100644 --- a/syft/pkg/cataloger/sbom/cataloger.go +++ b/syft/pkg/cataloger/sbom/cataloger.go @@ -1,3 +1,6 @@ +/* +Package sbom provides a concrete Cataloger implementation for capturing packages embedded within SBOM files. +*/ package sbom import ( @@ -15,8 +18,8 @@ import ( const catalogerName = "sbom-cataloger" -// NewSBOMCataloger returns a new SBOM cataloger object loaded from saved SBOM JSON. -func NewSBOMCataloger() *generic.Cataloger { +// NewCataloger returns a new SBOM cataloger object loaded from saved SBOM JSON. +func NewCataloger() *generic.Cataloger { return generic.NewCataloger(catalogerName). WithParserByGlobs(parseSBOM, "**/*.syft.json", diff --git a/syft/pkg/cataloger/sbom/cataloger_test.go b/syft/pkg/cataloger/sbom/cataloger_test.go index 7138e1c6e12..dbaf37b3088 100644 --- a/syft/pkg/cataloger/sbom/cataloger_test.go +++ b/syft/pkg/cataloger/sbom/cataloger_test.go @@ -421,7 +421,7 @@ func Test_parseSBOM(t *testing.T) { FromDirectory(t, tt.fixture). IgnorePackageFields("Metadata"). Expects(tt.wantPkgs, tt.wantRelationships). - TestCataloger(t, NewSBOMCataloger()) + TestCataloger(t, NewCataloger()) }) } } @@ -456,7 +456,7 @@ func Test_Cataloger_Globs(t *testing.T) { pkgtest.NewCatalogTester(). FromDirectory(t, test.fixture). ExpectsResolverContentQueries(test.expected). - TestCataloger(t, NewSBOMCataloger()) + TestCataloger(t, NewCataloger()) }) } } diff --git a/syft/pkg/cataloger/swift/cataloger.go b/syft/pkg/cataloger/swift/cataloger.go index a890b85818c..f928d3e04c5 100644 --- a/syft/pkg/cataloger/swift/cataloger.go +++ b/syft/pkg/cataloger/swift/cataloger.go @@ -1,5 +1,5 @@ /* -Package swift provides a concrete Cataloger implementation for Podfile.lock and Package.resolved files. +Package swift provides a concrete Cataloger implementation relating to packages within the swift language ecosystem. */ package swift @@ -8,7 +8,7 @@ import ( ) func NewSwiftPackageManagerCataloger() *generic.Cataloger { - return generic.NewCataloger("spm-cataloger"). + return generic.NewCataloger("swift-package-manager-cataloger"). WithParserByGlobs(parsePackageResolved, "**/Package.resolved", "**/.package.resolved") } diff --git a/test/cli/packages_cmd_test.go b/test/cli/packages_cmd_test.go index 89c9a7248f8..5baf0e289c8 100644 --- a/test/cli/packages_cmd_test.go +++ b/test/cli/packages_cmd_test.go @@ -235,7 +235,7 @@ func TestPackagesCmdFlags(t *testing.T) { }, { name: "catalogers-option", - // This will detect enable python-index-cataloger, python-package-cataloger and ruby-gemspec cataloger + // This will detect enable python-package-cataloger, python-installed-package-cataloger and ruby-gemspec cataloger args: []string{"packages", "-o", "json", "--catalogers", "python,ruby-gemspec", coverageImage}, assertions: []traitAssertion{ assertPackageCount(13), diff --git a/test/compare/test-fixtures/acceptance-centos-8.2.2004.json b/test/compare/test-fixtures/acceptance-centos-8.2.2004.json index 218f9a825fe..71bc5960bf6 100644 --- a/test/compare/test-fixtures/acceptance-centos-8.2.2004.json +++ b/test/compare/test-fixtures/acceptance-centos-8.2.2004.json @@ -31672,7 +31672,7 @@ "name": "gpg", "version": "1.10.0", "type": "python", - "foundBy": "python-package-cataloger", + "foundBy": "python-installed-package-cataloger", "locations": [ { "path": "/usr/lib64/python3.6/site-packages/gpg-1.10.0-py3.6.egg-info", @@ -95502,7 +95502,7 @@ "name": "rpm", "version": "4.14.2", "type": "python", - "foundBy": "python-package-cataloger", + "foundBy": "python-installed-package-cataloger", "locations": [ { "path": "/usr/lib64/python3.6/site-packages/rpm-4.14.2-py3.6.egg-info", @@ -98658,7 +98658,7 @@ "name": "setuptools", "version": "39.2.0", "type": "python", - "foundBy": "python-package-cataloger", + "foundBy": "python-installed-package-cataloger", "locations": [ { "path": "/usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info/METADATA", diff --git a/test/integration/sbom_cataloger_test.go b/test/integration/sbom_cataloger_test.go index 6faebbd13d9..65d94b3e059 100644 --- a/test/integration/sbom_cataloger_test.go +++ b/test/integration/sbom_cataloger_test.go @@ -18,7 +18,7 @@ func TestSbomCataloger(t *testing.T) { actualSbomPkgs := 0 actualGoModPkgs := 0 for pkg := range sbom.Artifacts.Packages.Enumerate(pkg.GoModulePkg) { - if pkg.FoundBy == "go-mod-file-cataloger" { + if pkg.FoundBy == "go-module-file-cataloger" { actualGoModPkgs += 1 } else if pkg.FoundBy == "sbom-cataloger" { actualSbomPkgs += 1 From ad0cfba1064513a3c4d25343f22c9b5358d8fe2f Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Thu, 2 Nov 2023 08:24:26 -0400 Subject: [PATCH 2/2] fix cataloger name example Signed-off-by: Alex Goodman --- DEVELOPING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DEVELOPING.md b/DEVELOPING.md index f6cf8d97155..f3b8edfbd75 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -204,11 +204,11 @@ From a high level catalogers have the following properties: Cataloger names should be unique and named with the following rules of thumb in mind: -- End with `-cataloger` +- 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-installed-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). +- 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