Skip to content

Add CycloneDX spec version 1.6 and 1.7 support - #872

Open
Saturate wants to merge 6 commits into
CycloneDX:mainfrom
Saturate:feat/spec-1.6-1.7-support
Open

Add CycloneDX spec version 1.6 and 1.7 support#872
Saturate wants to merge 6 commits into
CycloneDX:mainfrom
Saturate:feat/spec-1.6-1.7-support

Conversation

@Saturate

@Saturate Saturate commented Jun 26, 2026

Copy link
Copy Markdown

Adds support for CycloneDX specification versions 1.6 (ECMA-424 1st Edition) and 1.7 (ECMA-424 2nd Edition) to both the cyclonedx-bom library and the cargo-cyclonedx CLI.

The diff is large but mostly mechanical: v1_6 and v1_7 spec modules mirror the v1_5 structure, and the #[versioned] annotations in common spec files are extended to generate the new module variants.

Changes

  • SpecVersion::V1_6 and V1_7 enum variants with full JSON/XML parse and output methods
  • v1_6 and v1_7 spec modules with correct XML namespaces and specVersion strings
  • All #[versioned] annotations extended across 10 common spec files
  • Official JSON schemas for validation (from CycloneDX/specification)

New spec fields (1.6)

  • Component: manufacturer, authors (replaces deprecated author), omniborId, swhid, cryptoProperties
  • Metadata: manufacturer
  • BOM: declarations, definitions

New spec fields (1.7)

  • Component: isExternal, versionRange, patentAssertions
  • Metadata: distributionConstraints (with typed TLP classification)
  • BOM: citations

XML/JSON parity

All new fields round-trip through both JSON and XML. Simple fields (manufacturer, authors, omniborId, swhid, isExternal, versionRange) use typed structs with explicit ToXml/FromXml implementations. Complex deeply-nested types (declarations, definitions, cryptoProperties, patentAssertions, citations, distributionConstraints) use serde_json::Value with a generic Value-to-XML bridge (write_value_as_xml/read_xml_as_value in xml.rs) to avoid thousands of lines of struct definitions while maintaining correct serialization in both formats.

Design note on serde_json::Value

Previous versions (1.3-1.5) used fully typed structs for every field. For 1.6/1.7, several new types have deeply nested schemas (e.g. declarations.targets recurses into the full component/service type hierarchy, ~570 fields). I opted for serde_json::Value pass-through for these, which gives correct round-trip behavior in ~90 lines of bridge code. The tradeoff is that consumers accessing these fields work with serde_json::Value rather than typed Rust structs.

A follow-up PR could add typed structs for individual complex types as needed, or I could do it here, but it's really uo to you. Let me know if you think I should add it, or this is fine.

Resolves #769

Saturate added 3 commits June 25, 2026 15:28
Wire up SpecVersion V1_6 and V1_7 with parse/output methods for
JSON and XML. Create v1_6 and v1_7 spec modules mirroring v1_5
structure. Extend versioned annotations in common spec files to
generate the new module variants.

Includes JSON schemas, test fixtures, and updated CLI help text.

Resolves: CycloneDX#769
Signed-off-by: Allan Kimmer Jensen <hi@akj.io>
Component gains manufacturer, authors (replaces deprecated author),
omniborId, and swhid in 1.6. In 1.7 it adds isExternal and
versionRange. Metadata gains manufacturer in 1.6.

All fields are optional and wire through the versioned spec
serialization for both JSON and XML.

Signed-off-by: Allan Kimmer Jensen <hi@akj.io>
BOM gains declarations, definitions (1.6) and citations (1.7) as
pass-through JSON values for complex nested types.

Component gains cryptoProperties (1.6) and patentAssertions (1.7)
as pass-through JSON values.

Metadata gains distributionConstraints (1.7) with a typed TLP
classification enum (CLEAR, GREEN, AMBER, AMBER+STRICT, RED).

Signed-off-by: Allan Kimmer Jensen <hi@akj.io>
@codacy-production

codacy-production Bot commented Jun 26, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 2835 complexity · 408 duplication

Metric Results
Complexity 2835
Duplication 408

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.

@Saturate
Saturate marked this pull request as ready for review June 26, 2026 06:19
@Saturate
Saturate requested a review from a team as a code owner June 26, 2026 06:19
Saturate added 3 commits June 26, 2026 08:35
Add XML read/write for new 1.6/1.7 component fields (manufacturer,
authors, omniborId, swhid) and metadata manufacturer. JSON-only
pass-through fields (cryptoProperties, declarations, etc.) remain
XML-unsupported since they lack a defined XML representation in the
current codebase.

Fix field ordering in the From<Component> impl where version_range
was split by crypto_properties.

Add Unknown(String) variant to TlpClassification so future TLP
values round-trip instead of being silently dropped.

Signed-off-by: Allan Kimmer Jensen <hi@akj.io>
Avoids unused-import warning in v1_3/v1_4/v1_5 generated modules
since the type is only used in 1.6+ fields.

Signed-off-by: Allan Kimmer Jensen <hi@akj.io>
Add generic Value-to-XML bridge (write_value_as_xml, read_xml_as_value)
for bidirectional XML serialization of complex pass-through types.

All new fields now round-trip through both JSON and XML:
- BOM: declarations, definitions (1.6), citations (1.7)
- Component: manufacturer, authors, omniborId, swhid,
  cryptoProperties (1.6), isExternal, versionRange,
  patentAssertions (1.7)
- Metadata: manufacturer (1.6), distributionConstraints (1.7)

Signed-off-by: Allan Kimmer Jensen <hi@akj.io>
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.

[Feature] Support CycloneDX 1.6

1 participant