add support for extra sbom information in Cargo.toml - #875
Open
richard-uk1 wants to merge 1 commit into
Open
richard-uk1 wants to merge 1 commit into
richard-uk1 wants to merge 1 commit into
Conversation
The schema for Cargo.toml allows arbitrary extra data to be stored under the `[package.metadata]` table. It is convention to create a subtable under this (e.g. `[package.metadata.cyclonedx]`), and then to read/write data in this table for your custom use-case. This PR uses the `[package.metadata]` table to store more SBOM information for a crate. In particular, it adds support for the `modified` field on components (which is what my project needs). I could add support for other fields as required. The name of the subtable is customizable from a CLI argument, and by default is empty, meaning no attempt is made to access the data. I also made a small change to a test to write a main function in a `main.rs` file. It's not essential to the patch and I can remove it if requested. Signed-off-by: Richard Dodd <richard.o.dodd@gmail.com>
richard-uk1
force-pushed
the
add-extra-bom-info
branch
from
August 9, 2026 12:23
eb2a3c2 to
0528371
Compare
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 25 |
| Duplication | 7 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Contributor
|
If you just need to set or alter some fields in the generated CycloneDX in ways you know and that doesn't derive from data computed by Cargo, you're much better off just writing a script that does it in the final CycloneDX file once and for all, instead of adding a different way to do it in every language-specific tool. I am inclined to close this, since you are better off with a language-agnostic tool that edits standardized CycloneDX, and cargo-cyclonedx is better off without the additional maintenance burden. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The schema for Cargo.toml allows arbitrary extra data to be stored under the
[package.metadata]table. It is convention to create a subtable under this (e.g.[package.metadata.cyclonedx]), and then to read/write data in this table for your custom use-case.This PR uses the
[package.metadata]table to store more SBOM information for a crate. In particular, it adds support for themodifiedfield on components (which is what my project needs). I could add support for other fields as required. The name of the subtable is customizable from a CLI argument, and by default is empty, meaning no attempt is made to access the data.I also made a small change to a test to write a main function in a
main.rsfile. It's not essential to the patch and I can remove it if requested.