Skip to content

add support for extra sbom information in Cargo.toml - #875

Open
richard-uk1 wants to merge 1 commit into
CycloneDX:mainfrom
richard-uk1:add-extra-bom-info
Open

richard-uk1 wants to merge 1 commit into
CycloneDX:mainfrom
richard-uk1:add-extra-bom-info

Conversation

@richard-uk1

Copy link
Copy Markdown

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.

@richard-uk1
richard-uk1 requested a review from a team as a code owner August 9, 2026 12:22
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>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 25 complexity · 7 duplication

Metric Results
Complexity 25
Duplication 7

View in Codacy

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.

@Shnatsel

Shnatsel commented Aug 9, 2026

Copy link
Copy Markdown
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.

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