Add support for serde traits to cyclonedx-bom types#868
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 4 |
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.
|
Could you explain the motivation behind this change? This looks like a different take on #802 but I'd like to hear what your use cases are like. |
Signed-off-by: Naxdy <naxdy@naxdy.org>
|
Our use case is an SBOM generation tool that supports merging the final BOM with manual annotations. Currently this includes VEX metadata and subcomponents. Our data sources output partial data that we would like to deserialize into the Currently, we're using our own newtypes and have The alternative would be to parse into the parent Basically, we'd like to be able to do something like this: #[derive(Serialize, Deserialize)]
struct CustomMeta {
vulnerabilities: Vec<Vulnerability>,
subcomponents: Vec<Component>,
// ...
}As a side note, @RossComputerGuy is a colleague of mine, and the SBOM tool referenced in #802 and in this comment are one and the same. |
Though the intended way to interact with the crate is to use the individual serialization functions for the different specs, sometimes it is desirable to parse into the main types directly when working with custom intermediate formats, or to only (de-)serialize part of a BOM (e.g. only
vulnerabilities).This PR adds optional
SerializeandDeserializederives to the mainBomstruct and all others that require it, but only when compiling with theserdefeature. Theserdefeature is opt-in, so as to preserve the current default behavior, and avoid potentially confusing new users with the intended usage.