Skip to content

Conversation

@rpkelly
Copy link
Contributor

@rpkelly rpkelly commented Dec 30, 2025

Fix three bugs in the SBOM merge process:

  1. Remove DocumentRoot filter that incorrectly dropped primary packages

    • The filter was removing packages whose ID contained 'DocumentRoot'
    • CycloneDX puts the scan target in metadata.component, not components[]
    • When syft decodes this, it creates a package with DocumentRoot in ID
    • Now we only filter packages with empty names
  2. Preserve Locations and Metadata during package merging

    • Locations (file paths) were not being merged, causing all syft:location:* properties to be lost
    • Metadata was not being preserved, causing all syft:metadata:* and syft:package:* properties to be lost
    • Now we merge all Locations from duplicate packages (union)
    • Now we preserve Metadata from first package with non-nil metadata
  3. Use CycloneDX 1.6 for output encoding

    • The default encoder used CycloneDX 1.2 which doesn't support the properties field on components (added in 1.3)
    • Now explicitly use CycloneDX 1.6 encoder to preserve all properties

Issue number: #316

Description of changes:
Changed SBOM tool to preserve more information during a merge. Changes now keep the document root package, as well as ensure that CycloneDX encoding is 1.6 for more metadata.

Testing done:
Generated SBOMs for Bottlerocket core and kernel kits. See here for full before and partial after (full after seems to give gist problems)

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Copy link
Contributor

@ginglis13 ginglis13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in "Testing Done", could you also share some before/after SBOM examples for a variant?

Fix three bugs in the SBOM merge process:

1. Remove DocumentRoot filter that incorrectly dropped primary packages
   - The filter was removing packages whose ID contained 'DocumentRoot'
   - CycloneDX puts the scan target in metadata.component, not components[]
   - When syft decodes this, it creates a package with DocumentRoot in ID
   - Now we only filter packages with empty names

2. Preserve Locations and Metadata during package merging
   - Locations (file paths) were not being merged, causing all
     syft:location:* properties to be lost
   - Metadata was not being preserved, causing all syft:metadata:*
     and syft:package:* properties to be lost
   - Now we merge all Locations from duplicate packages (union)
   - Now we preserve Metadata from first package with non-nil metadata

3. Use CycloneDX 1.6 for output encoding
   - The default encoder used CycloneDX 1.2 which doesn't support
     the properties field on components (added in 1.3)
   - Now explicitly use CycloneDX 1.6 encoder to preserve all properties

Signed-off-by: Richard Kelly <[email protected]>
SBOM data was previously missing data from the root node of the
dependency graph when merged. Fixed merge to include this node as well

Signed-off-by: Richard Kelly <[email protected]>
@rpkelly rpkelly merged commit 2c919ab into bottlerocket-os:develop Jan 16, 2026
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.

3 participants