Skip to content

feat: optional CBOM generation via cdxgen, plus CBOM pipeline recipes - #300

Draft
aurangzaib048 wants to merge 8 commits into
sbomify:masterfrom
aurangzaib048:feat/cbom-generation
Draft

feat: optional CBOM generation via cdxgen, plus CBOM pipeline recipes#300
aurangzaib048 wants to merge 8 commits into
sbomify:masterfrom
aurangzaib048:feat/cbom-generation

Conversation

@aurangzaib048

Copy link
Copy Markdown
Contributor

Closes #291. Closes #290.

What

  • CBOM_GENERATE=true (action input cbom-generate) generates a CBOM from the LOCK_FILE project via cdxgen --include-crypto and uploads it with bom_type=cbom. Covers Java and Python projects plus JS/TS source analysis, keystores, and certificates.
  • README gains a CBOM section with three recipes: generate with this action, pass through from cbomkit-action (tag v2 and output pattern verified against their action.yml), and pass through any other CycloneDX CBOM verbatim.
  • Pins @cyclonedx/cdxgen to ^12.0.0 (was tracking git master).

Guard rails

  • CBOM_GENERATE implies BOM_TYPE=cbom; a conflicting explicit BOM_TYPE is rejected.
  • Requires LOCK_FILE; DOCKER_IMAGE and pre-authored SBOM_FILE are rejected (container CBOMs stay parked per container-image CBOMs via cbomkit-theia (stretch) #292).
  • Augmentation and enrichment stay off, matching the passthrough contract.
  • Only CdxgenFsGenerator claims include_crypto inputs; every other generator declines them, so the orchestrator can never satisfy a CBOM request with a plain SBOM.

Tests

  • Config: implies cbom, requires LOCK_FILE, rejects docker image, pre-authored file, and conflicting type; forces augment and enrich off.
  • Generators: --include-crypto present and absent on the cdxgen argv; cyclonedx-py, syft, and trivy decline crypto inputs.
  • Full suite: 2250 passed, 4 skipped.

CBOM_GENERATE=true (action input cbom-generate) generates a Cryptography
Bill of Materials from the LOCK_FILE project via cdxgen --include-crypto
(Java and Python projects, JS/TS source analysis, keystores,
certificates) and uploads it with bom_type=cbom.

The flag implies BOM_TYPE=cbom and requires LOCK_FILE; Docker images,
pre-authored SBOM_FILE input, and conflicting BOM_TYPE values are
rejected. Augmentation and enrichment stay off, matching the passthrough
contract. Only the cdxgen filesystem generator claims include_crypto
inputs, so the orchestrator can never hand CBOM generation to a
generator that would produce a plain SBOM.

Pins @cyclonedx/cdxgen to ^12.0.0 (was git master).
Copilot AI review requested due to automatic review settings July 22, 2026 14:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class, opt-in CBOM generation to the sbomify-action pipeline by routing a “crypto inventory” request to cdxgen, while preserving the existing verbatim-upload contract for non-SBOM artifact types.

Changes:

  • Introduces CBOM_GENERATE / cbom-generate to generate a CBOM from LOCK_FILE via cdxgen --include-crypto, and forces BOM_TYPE=cbom with guard rails in config validation.
  • Threads a new include_crypto flag through the generation protocol and ensures non-cdxgen generators decline such inputs.
  • Pins @cyclonedx/cdxgen to a released semver range and documents CBOM recipes in the README, plus adds tests for the new behavior.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
sbomify_action/cli/main.py Adds cbom_generate config, validation guard rails, and passes crypto flag into lockfile generation path.
sbomify_action/generation.py Threads include_crypto through public generation helpers into GenerationInput.
sbomify_action/_generation/protocol.py Extends GenerationInput with include_crypto flag.
sbomify_action/_generation/generators/cdxgen.py Appends --include-crypto for filesystem generation when requested; declines crypto inputs for image generator.
sbomify_action/_generation/generators/{trivy,syft,cyclonedx_py,cyclonedx_cargo}.py Ensures non-cdxgen generators decline include_crypto inputs.
tests/test_config.py Adds config validation tests for CBOM_GENERATE behavior.
tests/test_generation_plugin.py Adds generator-level tests for --include-crypto argument behavior and non-cdxgen declination.
README.md Adds CBOM documentation section and example workflows/recipes.
action.yml Adds cbom-generate action input and maps it to CBOM_GENERATE env var.
package.json Pins @cyclonedx/cdxgen to ^12.0.0.
bun.lock Updates lockfile to reflect the pinned cdxgen version and transitive changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_config.py Outdated
Comment thread tests/test_config.py Outdated
Comment thread tests/test_config.py Outdated
Comment thread tests/test_config.py Outdated
Comment thread tests/test_generation_plugin.py Outdated
Comment thread tests/test_generation_plugin.py Outdated
Comment thread sbomify_action/generation.py
Comment thread sbomify_action/generation.py
…stry capability

Review findings on the CBOM generation PR:

CBOM_GENERATE was read only by load_config(), which production never
calls; the Click cli() entrypoint had no such option, so the shipped
input was a silent no-op (a plain SBOM uploaded with no error). cli()
now carries --cbom-generate/--no-cbom-generate with the standard
bool-envvar callback and threads it into build_config; regression tests
drive the real entrypoint via CliRunner for the env var, the flag, and
the default.

Crypto generation is now an opt-in registry capability instead of an
opt-out guard pasted into seven supports() methods: the registry skips
any generator without supports_crypto=True for include_crypto inputs,
so a future generator can never silently satisfy a CBOM request with a
plain SBOM. Only CdxgenFsGenerator opts in.
Copilot AI review requested due to automatic review settings July 22, 2026 15:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

sbomify_action/generation.py:98

  • The new include_crypto parameter is not documented in generate_sbom()’s docstring, so API consumers won’t know how to request CBOM/crypto-asset inclusion.
    include_crypto: bool = False,

sbomify_action/generation.py:153

  • process_lock_file() now accepts include_crypto, but the docstring doesn’t describe it. This makes the new CBOM/crypto flag easy to miss for callers using the public API.
    include_crypto: bool = False,

Comment thread sbomify_action/_generation/generators/cdxgen.py
…ument include_crypto, decline crypto in image generator
Copilot AI review requested due to automatic review settings July 24, 2026 11:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Comment thread tests/test_cli.py Outdated
Comment thread tests/test_config.py Outdated
Comment thread tests/test_generation_plugin.py
Copilot AI review requested due to automatic review settings July 24, 2026 12:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Comment thread sbomify_action/cli/main.py Outdated
Comment thread tests/test_config.py
Copilot AI review requested due to automatic review settings July 24, 2026 12:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Comment thread sbomify_action/cli/main.py
Comment thread sbomify_action/_generation/registry.py Outdated
Additional-packages-only mode would otherwise proceed and upload an
empty document labeled cbom when additional packages are configured.
Copilot AI review requested due to automatic review settings July 24, 2026 12:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

sbomify_action/cli/main.py:352

  • In the CBOM_GENERATE validation, the allowlist includes an empty-string BOM_TYPE (""), but BOM_TYPE is already validated against VALID_BOM_TYPES earlier in validate(), and "" is not a valid value there. This makes the "" branch effectively unreachable and can be removed to avoid confusion.
        if self.cbom_generate:
            if self.bom_type not in (None, "sbom", "cbom"):

Copilot AI review requested due to automatic review settings July 24, 2026 12:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Comment thread sbomify_action/cli/main.py
…CBOM_GENERATE

Both steps rewrite the generated document; a CBOM must be preserved as
generated, and package dependencies/hashes belong to SBOM output.
Copilot AI review requested due to automatic review settings July 24, 2026 12:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.

@aurangzaib048
aurangzaib048 marked this pull request as draft July 24, 2026 15:39
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.

optional CBOM generation via the existing cdxgen generator docs: end-to-end CBOM pipeline recipes

2 participants