Replace core SBOM-creation API with builder pattern#1383
Merged
Conversation
5 tasks
57a9877 to
64f7af5
Compare
Benchmark Test ResultsBenchmark results from the latest changes vs base branch |
64f7af5 to
99f9d1e
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This was referenced Feb 16, 2023
This was referenced May 19, 2023
d36be02 to
efb97f4
Compare
This was referenced Nov 20, 2023
624ff9f to
f8aaae5
Compare
This was referenced Nov 28, 2023
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
wagoodman
commented
Jan 10, 2024
wagoodman
commented
Jan 10, 2024
wagoodman
commented
Jan 10, 2024
| } | ||
| }) | ||
|
|
||
| result, err := digestsCataloger.Catalog(resolver, coordinates...) |
Contributor
Author
There was a problem hiding this comment.
from @willmurphyscode , blocking: we need to explicitly pass all coordinates, since there is no guarantee to have any results from a owned-files indication
Contributor
Author
There was a problem hiding this comment.
I'm going to fix the functional problem in this PR, but to address the signature and generator issue I really should break that into a separate PR that I follow up with after this PR
Contributor
Author
There was a problem hiding this comment.
I think this will have some play into the solution here #2487
wagoodman
commented
Jan 10, 2024
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
wagoodman
commented
Jan 11, 2024
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
willmurphyscode
approved these changes
Jan 12, 2024
Contributor
willmurphyscode
left a comment
There was a problem hiding this comment.
Thanks for all the careful thought in making the API and configs easier to use for the future.
This was referenced Jan 16, 2024
GijsCalis
pushed a commit
to GijsCalis/syft
that referenced
this pull request
Feb 19, 2024
* remove existing cataloging API Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add file cataloging config Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add package cataloging config Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add configs for cross-cutting concerns Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * rename CLI option configs to not require import aliases later Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update all nested structs for the Catalog struct Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update Catalog cli options - add new cataloger selection options (selection and default) - remove the excludeBinaryOverlapByOwnership - deprecate "catalogers" flag - add new javascript configuration Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * migrate relationship capabilities to separate internal package Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * refactor golang cataloger to use configuration options when creating packages Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * create internal object to facilitate reading from and writing to an SBOM Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * create a command-like object (task) to facilitate partial SBOM creation Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add cataloger selection capability - be able to parse string expressions into a set of resolved actions against sets - be able to use expressions to select/add/remove tasks to/from the final set of tasks to run Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add package, file, and environment related tasks Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update existing file catalogers to use nested UI elements Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add CreateSBOMConfig that drives the SBOM creation process Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * capture SBOM creation info as a struct Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add CreateSBOM() function Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update docs with SBOM selection help + breaking changes Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix multiple override default inputs Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix deprecation flag printing to stdout Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * refactor cataloger selection description to separate object Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * address review comments Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * keep expression errors and show specific suggestions only Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * address additional review feedback Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * address more review comments Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * addressed additional PR review feedback Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix file selection references Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * remove guess language data generation option Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add tests for coordinatesForSelection Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * rename relationship attributes Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add descriptions to relationships config fields Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * improve documentation around configuration options Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add explicit errors around legacy config entries Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Closed
This was referenced Mar 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a top-level replacement for the syft API. The idea is to allow for encapsulation of more kinds of cataloging without the need to share a data interface. This allows for file-base cataloging and package-based cataloging to share the same approach to selection and configuration.
The existing cataloging functions have been removed, which is why this is a breaking change. I initially attempted to keep both schemes in place, however, the configuration management became ultimately confusing.
This PR adds high-level configuration:
syft/cataloging/*.go: cross-cutting configuration that could affect all catalogers, the artifacts they produce, or add downstream artifacts based on these descriptions. This is a set of configurations NOT capabilities (e.g. behavior, such as catalogers themselves).syft/cataloging/pkgcataloging/*.go: wires up configurations for all package catalogerssyft/cataloging/filecataloging/*.go: wires up all configurations for file catalogersThis PR removes the existing configurations:
syft/pkg/cataloger/config.goFrom a high-level, the
CreateSBOMConfigis the entrypoint to all cataloging. The configuration itself describes what should be done. Ultimately all capabilities (file cataloging, pkg cataloging, linux distro identification, and cross-cutting relationship additions) are expressed as "tasks". Tasks act like a facade, similar to the command pattern, and encapsulates pre-configured behavior that ultimately writes to an SBOM. The notion of "tasks" has not been exported to the public API.Secondarily, this PR makes the following adjustments:
relationshippackageexclude-binary-overlap-by-ownershiphas been moved topackage.exclude-binary-overlap-by-ownershipdefault-image-pull-sourcehas been moved tosource.image.default-pull-sourceMinimal example of using the new API:
or
Leveraging a little more of the API:
Today when the cataloging process is run, the application configuration is captured to show the exact input. I've changed this some to instead capture an API-level construct instead of a construct that is in the
cmdpackage. Here is an example of thesyft-jsondescriptorsection:{ "name": "syft", "version": "v0.99.0", "configuration": { "catalogers": { "requested": { "default": [ "binary" ], "selection": [] }, "used": [ "binary-cataloger", "cargo-auditable-binary-cataloger", "dotnet-portable-executable-cataloger", "go-module-binary-cataloger" ] }, "data-generation": { "generate-cpes": true }, "extra": null, "files": { "hashers": [ "sha-1", "sha-256" ], "selection": "owned-files" }, "packages": { "golang": {...}, "java": {...}, "javascript": {... }, "linux-kernel": {... }, "python": {...} }, "relationships": { "exclude-binary-packages-with-file-ownership-overlap": true, "file-ownership": true, "file-ownership-overlap": true }, "search": { "scope": "squashed" } } }click to see all options in an example
{ "name": "syft", "version": "[not provided]", "configuration": { "catalogers": { "requested": { "default": [ "binary" ], "selection": [] }, "used": [ "binary-cataloger", "cargo-auditable-binary-cataloger", "dotnet-portable-executable-cataloger", "go-module-binary-cataloger" ] }, "data-generation": { "generate-cpes": true }, "extra": null, "files": { "hashers": [ "sha-1", "sha-256" ], "selection": "owned-files" }, "packages": { "golang": { "local-mod-cache-dir": "/Users/wagoodman/.local/share/rtx/installs/go/1.21.1/packages/pkg/mod", "proxies": [ "https://proxy.golang.org", "direct" ], "search-local-mod-cache-licenses": false, "search-remote-licenses": false }, "java-archive": { "include-indexed-archives": true, "include-unindexed-archives": false, "maven-base-url": "https://repo1.maven.org/maven2", "max-parent-recursive-depth": 5, "use-network": false }, "javascript": { "npm-base-url": "https://registry.npmjs.org", "search-remote-licenses": false }, "linux-kernel": { "catalog-modules": true }, "python": { "guess-unpinned-requirements": false } }, "relationships": { "exclude-binary-packages-with-file-ownership-overlap": true, "file-ownership": true, "file-ownership-overlap": true }, "search": { "scope": "squashed" } } }This beats the current approach of using the catalogers: https://gist.github.com/wagoodman/57ed59a6d57600c23913071b8470175b
PRs broken off of this one
Follow up PRs
Partially implements #558
Fixes #2136
Closes #1731
Closes #1039
Closes #477