Skip to content

feat(sca): CycloneDX SBOM export via --format cyclonedx (closes #31) - #36

Merged
filipi86 merged 1 commit into
mainfrom
feat/cyclonedx-sbom
Jun 23, 2026
Merged

feat(sca): CycloneDX SBOM export via --format cyclonedx (closes #31)#36
filipi86 merged 1 commit into
mainfrom
feat/cyclonedx-sbom

Conversation

@filipi86

Copy link
Copy Markdown
Owner

Summary

Implements the SBOM export requested in #31. The SCA engine already discovers a dependency inventory; this surfaces it as a standard CycloneDX 1.5 JSON BOM so results can be consumed by Grype, Trivy, and Dependency-Track.

drogonsec scan . --format cyclonedx --output sbom.json

CycloneDX is itself an OWASP project, so this also strengthens the OWASP-alignment story.

What's included

  • sca: Engine.Dependencies() retains the full inventory from Analyze so the SBOM is built without re-walking the tree.
  • analyzer: the inventory is carried on ScanResult.Dependencies.
  • reporter: new CycloneDXReporter emitting CycloneDX 1.5 with:
    • per-ecosystem Package URLs (npm, pypi, golang, maven, gem, composer, pub), including npm scopes (pkg:npm/%40angular/core@...) and full golang module paths
    • component dedup by purl (same dep across manifests / prod+dev)
    • stable sorting and a urn:uuid serial number
  • cli: registers the cyclonedx format and a shell-completion entry.
  • tests: purl derivation, dedup, sorting, and valid-JSON output.
  • docs: README output-formats section + CHANGELOG.

Verified locally

drogonsec scan . --format cyclonedx -o sbom.json against this repo produced a valid CycloneDX 1.5 BOM with 43 components and correct pkg:golang/... purls. go build, go vet, gofmt, and the full test suite pass.

Scope note (v1)

This is a flat component list. The SCA engine resolves manifests, not full lockfiles, so the transitive dependency graph is not yet expressed. Transitive resolution and SPDX output are planned for a later release, as discussed in #31.

Closes #31

🤖 Generated with Claude Code

Implements SBOM export requested in #31. The SCA engine already discovers a
dependency inventory; this surfaces it as a standard CycloneDX 1.5 JSON BOM so
results can be consumed by Grype, Trivy, and Dependency-Track.

- sca: retain the full dependency inventory from Analyze (Engine.Dependencies)
  so an SBOM can be built without re-walking the tree
- analyzer: carry the inventory on ScanResult.Dependencies
- reporter: new CycloneDXReporter emitting CycloneDX 1.5 with per-ecosystem
  Package URLs (npm, pypi, golang, maven, gem, composer, pub), component dedup
  by purl, stable sorting, and a urn:uuid serial number
- cli: register the `cyclonedx` format and shell-completion entry
- tests: purl derivation (incl. npm scopes and golang module paths), dedup,
  sorting, and valid-JSON output

Scope note: this is a flat component list. The SCA engine resolves manifests,
not full lockfiles, so the transitive dependency graph is not yet expressed.
Transitive resolution and SPDX output are planned for a later release.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 77.27273% with 20 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/reporter/cyclonedx.go 89.18% 4 Missing and 4 partials ⚠️
internal/analyzer/analyzer.go 0.00% 7 Missing ⚠️
internal/sca/engine.go 0.00% 3 Missing ⚠️
internal/cli/scan.go 0.00% 1 Missing ⚠️
internal/reporter/reporter.go 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@filipi86
filipi86 merged commit 1758828 into main Jun 23, 2026
8 checks passed
filipi86 added a commit that referenced this pull request Jun 23, 2026
Follows up #36 by documenting the new --format cyclonedx everywhere users look
for output formats.

- docs/usage.md: bump "four formats" to five, add the format to the table, add a
  dedicated CycloneDX SBOM section with example output and scope/usage notes
- docs/modules.md: add an SBOM Export subsection under the SCA engine
- docs/index.md: list CycloneDX in standards and the reporter package comment
- docs/branch-monitoring.md: add cyclonedx to the monitor --format values
- docs/security.md: include cyclonedx in the 0600 report-permission note
- README.md: reporter package comment
- cli/monitor: add cyclonedx to the --format help text (monitor routes through
  reporter.New, so the format already works there)

Co-authored-by: filipi86 <filipi86@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@filipi86
filipi86 deleted the feat/cyclonedx-sbom branch June 30, 2026 19:47
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.

2 participants