Skip to content

cyclonedx: import firmware-typed components as packages#4855

Open
ChrisJr404 wants to merge 1 commit into
anchore:mainfrom
ChrisJr404:decode-cyclonedx-firmware-components
Open

cyclonedx: import firmware-typed components as packages#4855
ChrisJr404 wants to merge 1 commit into
anchore:mainfrom
ChrisJr404:decode-cyclonedx-firmware-components

Conversation

@ChrisJr404

Copy link
Copy Markdown
Contributor

Closes anchore/grype#2537.

The CycloneDX decoder filters on a hard-coded set of component types (application / framework / library / machine-learning-model). Anything else — including firmware — fell through silently, so a BOM describing u-boot or other firmware ended up with no packages, and grype reported no matches even though valid CVEs exist.

@kzantow confirmed in the issue:

we currently are not importing firmware component types … It looks like we should just need to add firmware, this is ready for anyone to work on; see the link above for the section of code that needs a change and please add a test if someone is able to get to this before us.

Changes

  • syft/format/internal/cyclonedxutil/helpers/decoder.go: add cyclonedx.ComponentTypeFirmware alongside Application / Framework / Library / MachineLearningModel in collectPackages.
  • decoder_test.go: new Test_decode_includesFirmwareComponents — constructs a single-firmware-component BOM and asserts the package is imported with the right name and version.

Verification

$ go test -count=1 -run 'Test_decode_includesFirmwareComponents|Test_decode$' \
    ./syft/format/internal/cyclonedxutil/helpers/
ok  	github.com/anchore/syft/syft/format/internal/cyclonedxutil/helpers	0.026s

The CycloneDX decoder was filtering on a hard-coded set of component
types (application/framework/library/machine-learning-model). Anything
else — including "firmware" — fell through silently, so a BOM
describing u-boot or other firmware ended up with no packages and
grype reported no matches (anchore/grype#2537).

@kzantow confirmed in the issue thread that firmware should be
included and gave this section as the spot to update.

Add ComponentTypeFirmware to the case list and a regression test that
constructs a single-firmware-component BOM and asserts the decoded
SBOM contains the package.

Closes anchore/grype#2537

Signed-off-by: Chris (ChrisJr404) <11917633+ChrisJr404@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grype doesn't match u-boot in SBOM if type is set to firmware

1 participant