10000 Use package ID from decoded SBOMs when provided by jneate · Pull Request #1872 · anchore/syft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 5 commits into from
May 8, 2025

Conversation

jneate
Copy link
Contributor
@jneate jneate commented Jun 10, 2023

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 to file.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:

Screenshot 2025-05-07 at 10 13 04 PM

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

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added unit tests that cover changed behavior
  • I have tested my code in common scenarios and confirmed there are no regressions
  • I have added comments to my code, particularly in hard-to-understand sections

Signed-off-by: James Neate <jamesmneate@gmail.com>
@jneate
Copy link
Contributor Author
jneate commented Jun 10, 2023

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.

@kzantow

This comment was marked as outdated.

@wagoodman

This comment was marked as outdated.

@wagoodman wagoodman closed this May 8, 2025
…-provided

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@wagoodman wagoodman reopened this May 8, 2025
@wagoodman
Copy link
Contributor
wagoodman commented May 8, 2025

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.

wagoodman added 3 commits May 8, 2025 09:19
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 wagoodman changed the title fix: use package id from cyclonedx when provided Use package ID from decoded SBOMs when provided May 8, 2025
@wagoodman wagoodman added enhancement New feature or request and removed hold labels May 8, 2025
@wagoodman wagoodman self-assigned this May 8, 2025
@wagoodman wagoodman added this to OSS May 8, 2025
@wagoodman wagoodman moved this to In Review in OSS May 8, 2025
@wagoodman wagoodman requested a review from a team May 8, 2025 13:41
@wagoodman wagoodman merged commit 00c4a4e into anchore:main May 8, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in OSS May 8, 2025
Copy link
Contributor
@kzantow kzantow left a 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

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
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants
0