Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cataloger list command #2366

Merged
merged 4 commits into from
Jan 16, 2024
Merged

Add cataloger list command #2366

merged 4 commits into from
Jan 16, 2024

Conversation

wagoodman
Copy link
Contributor

@wagoodman wagoodman commented Nov 28, 2023

Adds a command to list out what catalogers are available and what organizational tags you can select them by:

$ syft cataloger list                                                  
┌────────────────────────────────────────┬───────────────────────────────────────────────────────────────────────────┐
│ CATALOGER                              │ TAGS                                                                      │
├────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────┤
│ alpm-db-cataloger                      │ alpm, archlinux, directory, image, installed, linux, os, package          │
│ apk-db-cataloger                       │ alpine, apk, directory, image, installed, linux, os, package              │
│ binary-cataloger                       │ binary, declared, directory, image, package                               │
│ cargo-auditable-binary-cataloger       │ binary, image, installed, language, package, rust                         │
│ cocoapods-cataloger                    │ cocoapods, declared, directory, language, package, swift                  │
│ conan-cataloger                        │ conan, cpp, declared, directory, language, package                        │
│ conan-info-cataloger                   │ conan, cpp, image, installed, language, package                           │
│ dart-pubspec-lock-cataloger            │ dart, declared, directory, language, package                              │
│ dotnet-deps-cataloger                  │ c#, declared, directory, dotnet, language, package                        │
│ dotnet-portable-executable-cataloger   │ c#, directory, dotnet, image, installed, language, package                │
│ dpkg-db-cataloger                      │ debian, directory, dpkg, image, installed, linux, os, package             │
│ elixir-mix-lock-cataloger              │ declared, directory, elixir, language, package                            │
│ erlang-rebar-lock-cataloger            │ declared, directory, erlang, language, package                            │
│ github-action-workflow-usage-cataloger │ declared, directory, github, github-actions, package                      │
│ github-actions-usage-cataloger         │ declared, directory, github, github-actions, package                      │
│ go-module-binary-cataloger             │ binary, directory, go, golang, gomod, image, installed, language, package │
│ go-module-file-cataloger               │ declared, directory, go, golang, gomod, language, package                 │
│ graalvm-native-image-cataloger         │ directory, image, installed, java, language, package                      │
│ haskell-cataloger                      │ cabal, declared, directory, hackage, haskell, language, package           │
│ java-archive-cataloger                 │ directory, image, installed, java, language, maven, package               │
│ java-gradle-lockfile-cataloger         │ declared, directory, gradle, java, language, package                      │
│ java-pom-cataloger                     │ declared, directory, java, language, maven, package                       │
│ javascript-lock-cataloger              │ declared, directory, javascript, language, node, npm, package             │
│ javascript-package-cataloger           │ image, installed, javascript, language, node, package                     │
│ nix-store-cataloger                    │ directory, image, installed, language, nix, package                       │
│ php-composer-installed-cataloger       │ composer, image, installed, language, package, php                        │
│ php-composer-lock-cataloger            │ composer, declared, directory, language, package, php                     │
│ portage-cataloger                      │ directory, gentoo, image, installed, linux, os, package, portage          │
│ python-installed-package-cataloger     │ directory, image, installed, language, package, python                    │
│ python-package-cataloger               │ declared, directory, language, package, python                            │
│ r-package-cataloger                    │ image, installed, language, package, r                                    │
│ rpm-archive-cataloger                  │ declared, directory, linux, os, package, redhat, rpm                      │
│ rpm-db-cataloger                       │ directory, image, installed, linux, os, package, redhat, rpm              │
│ ruby-gemfile-cataloger                 │ declared, directory, gem, language, package, ruby                         │
│ ruby-gemspec-cataloger                 │ declared, directory, gem, gemspec, language, package, ruby                │
│ ruby-installed-gemspec-cataloger       │ gem, gemspec, image, installed, language, package, ruby                   │
│ rust-cargo-lock-cataloger              │ cargo, declared, directory, language, package, rust                       │
│ sbom-cataloger                         │ declared, directory, image, package, sbom                                 │
│ swift-package-manager-cataloger        │ declared, directory, language, package, spm, swift                        │
└────────────────────────────────────────┴───────────────────────────────────────────────────────────────────────────┘

Also allows you to test cataloger selection expressions with -s/--select:

$ syft cataloger list -s image  -s binary -s '-java,r,ruby,rust,python'
Selected by expressions:
  - "image"
  - "binary"
  - "-java,r,ruby,rust,python"
┌──────────────────────────────────────┬───────────────────────────────────────────────────────────────────────────┐
│ CATALOGER                            │ TAGS                                                                      │
├──────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────┤
│ alpm-db-cataloger                    │ alpm, archlinux, directory, image, installed, linux, os, package          │
│ apk-db-cataloger                     │ alpine, apk, directory, image, installed, linux, os, package              │
│ binary-cataloger                     │ binary, declared, directory, image, package                               │
│ conan-info-cataloger                 │ conan, cpp, image, installed, language, package                           │
│ dotnet-portable-executable-cataloger │ c#, directory, dotnet, image, installed, language, package                │
│ dpkg-db-cataloger                    │ debian, directory, dpkg, image, installed, linux, os, package             │
│ go-module-binary-cataloger           │ binary, directory, go, golang, gomod, image, installed, language, package │
│ javascript-package-cataloger         │ image, installed, javascript, language, node, package                     │
│ nix-store-cataloger                  │ directory, image, installed, language, nix, package                       │
│ php-composer-installed-cataloger     │ composer, image, installed, language, package, php                        │
│ portage-cataloger                    │ directory, gentoo, image, installed, linux, os, package, portage          │
│ rpm-db-cataloger                     │ directory, image, installed, linux, os, package, redhat, rpm              │
│ sbom-cataloger                       │ declared, directory, image, package, sbom                                 │
└──────────────────────────────────────┴───────────────────────────────────────────────────────────────────────────┘

Additionally supports being able to get the same information out in json form:

$ syft cataloger list -o json | jq
{
  "default": [
    "all"
  ],
  "selection": [],
  "catalogers": [
    {
      "name": "alpm-db-cataloger",
      "tags": [
        "alpm",
        "archlinux",
        "directory",
        "image",
        "installed",
        "linux",
        "os",
        "package"
      ]
    },
    {
      "name": "apk-db-cataloger",
      "tags": [
        "alpine",
        "apk",
        "directory",
        "image",
        "installed",
        "linux",
        "os",
        "package"
      ]
    },
    {
      "name": "binary-cataloger",
      "tags": [
        "binary",
        "declared",
        "directory",
        "image",
        "package"
      ]
    },
  ...
}

Where expressions show the selection expressions used to get the result:

$ syft cataloger list --override-default-catalogers image --select-catalogers -java,-r --select-catalogers -ruby,-rust,-python -o json | jq
{
  "default": [
    "image"
  ],
  "selection": [
    "-java,-r",
    "-ruby,-rust,-python"
  ],
  "catalogers": [ ... ]
}

Must be merged after #1383

@wagoodman wagoodman added enhancement New feature or request WIP work in progress / do not merge labels Nov 28, 2023
@wagoodman wagoodman force-pushed the add-cataloger-command branch 2 times, most recently from b61ad23 to 6af5062 Compare December 1, 2023 17:21
Base automatically changed from refactor-cataloging-api to main January 12, 2024 22:39
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@wagoodman wagoodman marked this pull request as ready for review January 15, 2024 19:38
spiffcs and others added 2 commits January 16, 2024 08:59
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
cmd/syft/cli/commands/packages.go Show resolved Hide resolved
@wagoodman wagoodman removed the WIP work in progress / do not merge label Jan 16, 2024
@wagoodman wagoodman merged commit 313d921 into main Jan 16, 2024
10 checks passed
@wagoodman wagoodman deleted the add-cataloger-command branch January 16, 2024 14:41
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
* add cataloger list command

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

* add tests

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

* chore: tidy go mod

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

---------

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Co-authored-by: Christopher Angelo Phillips <32073428+spiffcs@users.noreply.github.com>
Co-authored-by: Christopher Phillips <christopher.phillips@anchore.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants