Skip to content

feat(crypto): CBOM model metadata#1016

Open
qkaiser wants to merge 7 commits into
CycloneDX:mainfrom
qkaiser:cbom-model-metadata
Open

feat(crypto): CBOM model metadata#1016
qkaiser wants to merge 7 commits into
CycloneDX:mainfrom
qkaiser:cbom-model-metadata

Conversation

@qkaiser

@qkaiser qkaiser commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Description

This branch expands the cryptographic asset model with CycloneDX 1.7 certificate metadata. Certificates can now include serial numbers, preferred file extensions, fingerprints, lifecycle dates, predefined or custom lifecycle states, and standardized or custom X.509 extensions. Related cryptographic material also gains fingerprints, while both certificates and related material can express typed relationships to other cryptographic assets such as algorithms and public keys.

All new fields are version-gated to CycloneDX 1.7 and support deterministic comparison, hashing, and JSON/XML round-tripping. Existing CycloneDX 1.6 fields (including deprecated certificate extensions and direct asset references) remain intact for backward compatibility, with expanded schema-validation, enum, snapshot, and serialization tests covering the new behavior.

AI Tool Disclosure

  • My contribution does not include any AI-generated content
  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: codex
    • LLMs and versions: codex-5.6-sol xhigh
    • Prompts: see below
LLM prompt
## Complete CycloneDX 1.7 cryptography models

Summary

Extend cyclonedx.model.crypto to model and round-trip every requested CycloneDX 1.7 CBOM field in JSON and XML. Preserve all existing 1.6 APIs and deprecated reference fields; the already-implemented key-wrap primitive and 1.7 protocol types require verification rather than duplication.

Public API and model changes

  • Add reusable RelatedCryptographicAsset(type, ref) and related_cryptographic_assets collections to certificate, related-material, and protocol properties.
  • Extend CertificateProperties with:
  • serial_number, certificate_file_extension, and fingerprint: HashType.
  • certificate_states, using CertificateLifecycleState, CertificatePredefinedState, and CertificateCustomState.
  • Creation, activation, deactivation, revocation, and destruction timestamps.
  • certificate_extensions, using common/custom extension models and a schema-backed common-extension-name enum.
  • Extend RelatedCryptoMaterialProperties with fingerprint and related_cryptographic_assets.
  • Keep signature_algorithm_ref, subject_public_key_ref, certificate_extension, algorithm_ref, and crypto_refs operational for both 1.6 and 1.7.

Serialization behavior

  • Gate new fields and structured models to SchemaVersion1Dot7, with exact CycloneDX JSON names, XML element names, ordering, nested arrays, and date/hash mappings.
  • Add union serialization helpers for certificate states and extensions so JSON and XML deserialize into the correct predefined/custom model.
  • Include every new property in comparison, hashing, sorting, and representation behavior where applicable.

Test plan

  • Add enum completeness tests against the bundled 1.7 schemas, including algorithm families, elliptic curves, certificate states/extensions, key-wrap, and protocol types.
  • Add model tests for construction, equality, hashing, sorting, union discrimination, and mixed-IKEv2 rejection.
  • Expand representative crypto BOM fixtures and JSON/XML snapshots with every new field.
  • Validate 1.7 output against strict bundled schemas and test JSON/XML round-trip deserialization.
  • Verify 1.6 output remains schema-valid, retains legacy fields, omits 1.7-only fields, and preserves protocol-type downgrade behavior.
  • Run the full unittest suite plus mypy and flake8.

Assumptions

  • This change targets the upstream library only; Inspector’s temporary extension properties and dependency-graph compatibility relationships remain until it upgrades to a release containing these models.
  • Existing deprecated CycloneDX fields are not removed or automatically translated into preferred 1.7 relationships.
  • Schema arrays follow the library convention of deterministic SortedSet storage.

Affirmation

qkaiser added 7 commits July 14, 2026 12:40
Certificate serial numbers are needed to identify issued certificates
unambiguously in CycloneDX 1.7 CBOMs.

Gate the value to the 1.7 serialization view, place it in schema order
for XML, and include it in deterministic comparison and round-trip
coverage.

Refs: CycloneDX 1.7
`cryptoProperties.certificateProperties.serialNumber`.
Signed-off-by: Quentin Kaiser <quentin.kaiser@onekey.com>
Consumers need the preferred CycloneDX 1.7 representation while older
documents still rely on the deprecated certificate extension field.

Store and serialize both values independently, gate the preferred value
to 1.7, and retain the legacy value during downgrade and round-trip
operations.

Refs: CycloneDX 1.7
`cryptoProperties.certificateProperties.certificateFileExtension`.
Signed-off-by: Quentin Kaiser <quentin.kaiser@onekey.com>
CBOM consumers need stable digests for certificates and related
cryptographic material without conflating those digests with signatures.

Reuse the existing hash model for JSON and XML mappings, gate both
properties to 1.7, and include them in deterministic comparison and
schema-valid round trips.

Refs: CycloneDX 1.7 certificate and related-material `fingerprint`
properties.
Signed-off-by: Quentin Kaiser <quentin.kaiser@onekey.com>
Certificate inventories need machine-readable lifecycle status while
still permitting organization-specific states.

Model predefined and custom variants as a discriminated union, store
them deterministically, and select the concrete variant from its JSON or
XML shape during deserialization.

Refs: CycloneDX 1.7
`cryptoProperties.certificateProperties.certificateState`.
Signed-off-by: Quentin Kaiser <quentin.kaiser@onekey.com>
Certificate lifecycle analysis depends on distinct issuance, operation,
retirement, and destruction events rather than validity bounds alone.

Map each timestamp through the existing date-time serializer, gate them
to 1.7, preserve schema ordering, and include them in equality, hashing,
and round-trip coverage.

Refs: CycloneDX 1.7 certificate lifecycle date properties.
Signed-off-by: Quentin Kaiser <quentin.kaiser@onekey.com>
X.509 inventories need standardized extension names and vendor-defined
extensions without collapsing their distinct shapes into unstructured
strings.

Model common and custom variants as a discriminated union, derive common
names from the 1.7 schema, and preserve concrete variants across
deterministic JSON and XML round trips.

Refs: CycloneDX 1.7
`cryptoProperties.certificateProperties.certificateExtensions`.
Signed-off-by: Quentin Kaiser <quentin.kaiser@onekey.com>
Deprecated direct references cannot describe all relationships between
certificates, related material, algorithms, and keys.

Use reusable typed references in deterministic collections, gate them to
1.7, and retain every deprecated reference unchanged for compatibility
with existing 1.6 and 1.7 consumers.

Refs: CycloneDX 1.7 `relatedCryptographicAssets`.
Signed-off-by: Quentin Kaiser <quentin.kaiser@onekey.com>
@qkaiser qkaiser requested a review from a team as a code owner July 14, 2026 11:01
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 123 complexity · 6 duplication

Metric Results
Complexity 123
Duplication 6

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.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 CycloneDX Python Library | 🛠️ Build #33581026 | 📁 Comparing 546d0b4 against latest (cf392e0)

  🔍 Preview build  

2 files changed
± genindex.html
± autoapi/cyclonedx/model/crypto/index.html

@qkaiser qkaiser changed the title Cbom model metadata CBOM model metadata Jul 15, 2026
@qkaiser qkaiser changed the title CBOM model metadata feat(crypto): CBOM model metadata Jul 15, 2026
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.

1 participant