diff --git a/syft/format/internal/cyclonedxutil/helpers/decoder.go b/syft/format/internal/cyclonedxutil/helpers/decoder.go index 0f1783362..aff76f66a 100644 --- a/syft/format/internal/cyclonedxutil/helpers/decoder.go +++ b/syft/format/internal/cyclonedxutil/helpers/decoder.go @@ -62,7 +62,7 @@ func collectPackages(component *cyclonedx.Component, s *sbom.SBOM, idMap map[str switch component.Type { case cyclonedx.ComponentTypeOS: case cyclonedx.ComponentTypeContainer: - case cyclonedx.ComponentTypeApplication, cyclonedx.ComponentTypeFramework, cyclonedx.ComponentTypeLibrary, cyclonedx.ComponentTypeMachineLearningModel: + case cyclonedx.ComponentTypeApplication, cyclonedx.ComponentTypeFramework, cyclonedx.ComponentTypeLibrary, cyclonedx.ComponentTypeMachineLearningModel, cyclonedx.ComponentTypeFirmware: p := decodeComponent(component) idMap[component.BOMRef] = p if component.BOMRef != "" { diff --git a/syft/format/internal/cyclonedxutil/helpers/decoder_test.go b/syft/format/internal/cyclonedxutil/helpers/decoder_test.go index b5c1f3c27..5092c3ff0 100644 --- a/syft/format/internal/cyclonedxutil/helpers/decoder_test.go +++ b/syft/format/internal/cyclonedxutil/helpers/decoder_test.go @@ -259,6 +259,30 @@ func Test_decode(t *testing.T) { } } +func Test_decode_includesFirmwareComponents(t *testing.T) { + // CycloneDX BOMs that describe firmware (e.g. u-boot) use + // component type "firmware". Prior to issue #2537 the decoder skipped + // these and downstream tools (e.g. grype) reported zero matches. + bom := cyclonedx.BOM{ + Components: &[]cyclonedx.Component{ + { + BOMRef: "u-boot", + Type: cyclonedx.ComponentTypeFirmware, + Name: "u-boot", + Version: "2024.04", + PackageURL: "pkg:generic/u-boot@2024.04", + }, + }, + } + model, err := ToSyftModel(&bom) + require.NoError(t, err) + + pkgs := model.Artifacts.Packages.Sorted() + require.Len(t, pkgs, 1, "firmware component should be imported as a package") + assert.Equal(t, "u-boot", pkgs[0].Name) + assert.Equal(t, "2024.04", pkgs[0].Version) +} + func Test_relationshipDirection(t *testing.T) { cyclonedx_bom := cyclonedx.BOM{Metadata: nil, Components: &[]cyclonedx.Component{