SBOMs for Ruby and Bundler
Bundler has no built-in SBOM command. sbombox generate detects Gemfile.lock and uses cdxgen or syft. The bundler-sbom plugin is the do-it-yourself option.
At a glance
| Package manager | Built-in SBOM command | What sbombox generate runs | Lockfile to commit |
|---|---|---|---|
| Bundler | No | cdxgen, then syft | Gemfile.lock |
SBOMBox detects Ruby by Gemfile.lock. A project with only a Gemfile is not detected: run bundle lock and commit the lockfile.
Generate with SBOMBox
curl -fsSL https://sbombox.com/install.sh | sh
sbombox generate -o sbom.json
sbombox score sbom.jsonTo use cdxgen, which is more thorough but slower, install it with the CLI:
curl -fsSL https://sbombox.com/install.sh | SBOMBOX_GENERATORS=syft,cdxgen shTo pin the choice, set SBOMBOX_GENERATOR to one or more generator names, comma-separated. SBOMBox tries them in that order and skips any that are not installed. An unknown name fails with the list of valid names.
SBOMBOX_GENERATOR=syft sbombox generate -o sbom.jsonUse the bundler-sbom plugin
The plugin writes SPDX by default. -s cyclonedx writes CycloneDX JSON to bom-cyclonedx.json. --without leaves Bundler groups out.
bundler plugin install bundler-sbom
bundle sbom dump -s cyclonedx --without development:test# See what lowers the score
sbombox score bom-cyclonedx.json --format detailed
# Check a ruleset, e.g. EU Cyber Resilience Act readiness
sbombox compliance bom-cyclonedx.json -p cra-readiness
# Upload it to the active project, labelled with the release
sbombox push bom-cyclonedx.json --version v1.4.0Defaults have changed between plugin releases. Check the version you install and the file it writes.
Monorepos
- Each app with its own
Gemfile.lockis a separate SBOM. Runsbombox generate --dir path/to/appfor each. - Upload each to its own SBOMBox project with
sbombox push FILE --project ID.
Known gaps
- Bundler has no SBOM command, and SBOMBox has no native Ruby generator. A universal tool is used.
- A universal tool reading
Gemfile.lockcannot tell which groups you deploy. Use bundler-sbom with--withoutfor a strict release SBOM. - RubyGems.org has SBOM support on its roadmap. This page will change when it ships.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Could not detect project ecosystem in <dir>: no supported manifest or lockfile. | Only a Gemfile, no Gemfile.lock | Run bundle lock and commit Gemfile.lock |
No SBOM generator found for ecosystems [...]. Install one with: curl -fsSL https://sbombox.com/install.sh | sh | Neither cdxgen nor syft is installed | Run curl -fsSL https://sbombox.com/install.sh | sh |
| RSpec or RuboCop in the SBOM | Development and test groups included | Use bundler-sbom with --without development:test |
In CI, run the same commands. See GitHub Actions, GitLab CI, Jenkins, Azure Pipelines, Bitbucket Pipelines or CircleCI, or use the GitHub Action.