-
Notifications
You must be signed in to change notification settings - Fork 10
fix: prefer Syft over cdxgen for Docker image SBOMs #273
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
Open
vpetersson
wants to merge
4
commits into
master
Choose a base branch
from
fix/prefer-syft-for-docker-images
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
aef092f
fix: prefer Syft over cdxgen for Docker image SBOMs
vpetersson ff6a3b4
Address Copilot's round-1 review on the image generator priorities
vpetersson 2b97439
Address Copilot's round-2 review on the image generator priorities
vpetersson e6b6f87
Address Copilot's round-3 review on the image generator priorities
vpetersson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| """cdxgen generator plugins for filesystem and Docker image scanning. | ||
|
|
||
| Priority: 20 (comprehensive multi-ecosystem) | ||
| Priority: 20 for lock files (comprehensive multi-ecosystem), | ||
| 40 for Docker images (fallback behind Syft — see CdxgenImageGenerator). | ||
|
|
||
| cdxgen is a comprehensive SBOM generator that supports many ecosystems | ||
| and programming languages with excellent coverage. | ||
|
|
@@ -228,6 +229,11 @@ class CdxgenImageGenerator: | |
|
|
||
| Uses cdxgen to scan Docker images and generate SBOMs. | ||
|
|
||
| Fallback behind Syft for Docker images: cdxgen image SBOMs lack the | ||
| `operating-system` component, so vulnerability scanners like Trivy | ||
| (including Dependency-Track's Trivy analyzer) can't detect OS | ||
| packages and scan nothing (see issue #264). | ||
|
|
||
| Verified capabilities (cdxgen 12.0.0): | ||
| - CycloneDX versions: 1.4, 1.5, 1.6, 1.7 (default: 1.6) | ||
| - SPDX: Not supported | ||
|
|
@@ -245,8 +251,9 @@ def command(self) -> str: | |
|
|
||
| @property | ||
| def priority(self) -> int: | ||
| # Comprehensive multi-ecosystem, higher priority than Trivy/Syft | ||
| return 20 | ||
| # Fallback behind Syft (25): cdxgen image SBOMs omit the | ||
| # operating-system component that Trivy/Dependency-Track need | ||
| return 40 | ||
|
|
||
| @property | ||
| def supported_formats(self) -> list[FormatVersion]: | ||
|
|
@@ -306,10 +313,11 @@ def generate(self, input: GenerationInput) -> GenerationResult: | |
|
|
||
| try: | ||
| # run_command raises SBOMGenerationError on failure (uses check=True). | ||
| # log_errors=False: cdxgen image scanning is a priority-20 fallback | ||
| # ahead of syft; a benign failure here shouldn't spam ERROR when syft | ||
| # can still succeed. (Docker-image-not-found is handled separately and | ||
| # still logs at WARNING.) | ||
| # log_errors=False: cdxgen image scanning is a fallback behind syft; | ||
| # a benign failure here shouldn't spam ERROR — if every generator | ||
| # fails, the pipeline raises SBOMGenerationError and the run fails. | ||
| # (Docker-image-not-found is handled separately and still logs at | ||
| # WARNING.) | ||
|
Comment on lines
315
to
+320
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 2b97439 — reworded to say the pipeline raises SBOMGenerationError when every generator fails, rather than claiming the orchestrator logs an ERROR (the registry logs failures at INFO, as you noted). |
||
| run_command(cmd, "cdxgen", timeout=DEFAULT_TIMEOUT, docker_image=input.docker_image, log_errors=False) | ||
|
|
||
| # Verify output file was created | ||
|
|
||
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
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
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.
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.
Fixed in e6b6f87 — updated the generators/init.py docstring to the new priorities (syft-image 25, cdxgen-image 40) and reordered the list by priority. Also swept the generation module for any other stale priority references; none remain.