-
Notifications
You must be signed in to change notification settings - Fork 650
Use package ID from decoded SBOMs when provided #1872
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
Conversation
Signed-off-by: James Neate <jamesmneate@gmail.com>
The alternate is that the entire BOM-Ref field becomes the ID instead of the package-id suffix? Happy to make said change if needed. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
…-provided Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
I've changed my mind on this -- if we can make this behavior change without introducing new fields then we should prefer that minimal approach. I'll get this across the finish line today. |
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing blocking, but I something doesn't sit well for me seeing hashes no longer redacted in the snapshots it seems like something slightly different could be done for testing here
Today if you use
syft convert
, the syft API (say via grype) with an SBOM, or use the SBOM cataloger, all packages raised up from the underlying SBOM get new IDs derived from the data discovered as opposed to using the ID found within the artifact. There are pros and cons with each approach, however, this PR is changing syft's opinion on this to prefer the ID of artifacts from the SBOM discovered.This is done by using the existing
pkg.Package.OverrideID()
at decode-time when constructing the package. If the ID is blank then we fallback to the standard derived Syft artifact ID.Note that this approach only affects package ID and not file IDs from decoded SBOMs --that will require further work since there could be drawbacks to adding an
id
field tofile.Coordinates
(which are heavily used as map keys).Here's an example of before and after of a grype run with these changes integrated; now the artifact IDs in the grype JSON are the native SBOM ID:
Addresses anchore/grype#1265
Design alternatives
There was another approach considered where we persist the upstream cyclonedx and spdx library types onto the package and the SBOM object. This would go a long way towards lossless conversion, however, this was a little too much to bite off for now and the current approach selected (using ID overrides) does not conflict with that future goal.
Type of change
Checklist