Skip to content

feat: add patents and patent assertions (CycloneDX 1.7) - #1093

Draft
N4R3 wants to merge 1 commit into
CycloneDX:mainfrom
N4R3:feat/patents-1.7
Draft

N4R3 wants to merge 1 commit into
CycloneDX:mainfrom
N4R3:feat/patents-1.7

Conversation

@N4R3

@N4R3 N4R3 commented Dec 4, 2026

Copy link
Copy Markdown

Description

Adds support for CycloneDX 1.7 patent information, one of the open items of the v1.7 tracking ticket.

  • new module cyclonedx.model.patent:
    • Patent, PatentFamily, PatentAssertion, PriorityApplication
    • enums PatentLegalStatus, PatentAssertionType
  • Definitions.patents (mixed list of Patent and PatentFamily; patents sort before families)
  • Component.patent_assertions and Service.patent_assertions
  • all of the above are rendered for spec >= 1.7 only (@serializable.view(SchemaVersion1Dot7))
  • Bom.definitions now goes through a small helper so that no empty definitions is rendered
    when none of its parts are available in the target version (e.g. patents only, rendered as 1.6)
  • XML element order follows the 1.7 XSD. To place patentAssertions I had to shift the
    xml_sequence numbers after copyright (Component) and after licenses (Service) by one.
    Existing snapshots are unchanged.

Serialization notes / points for review:

  • patentAssignee is a plain array of entity/contact in JSON, but a repeated
    organizationOrIndividualType (<organization>/<individual> wrapper) in XML. py-serializable
    can't emit repeated sibling elements from one helper. So the assignees are rendered into a
    temporary container that the definitions.patents helper unwraps (and re-wraps when deserializing).
    Downside: calling Patent.as_xml() directly, outside the definitions.patents context, produces
    that container. I'm open to a different approach if you prefer one.
  • asserter (entity | contact | ref) and patentAssignee items in JSON carry no explicit
    discriminator. On deserialization, an object with email or phone becomes an
    OrganizationalContact, and anything else becomes an OrganizationalEntity.
  • Spec observation: in the 1.7 JSON schema both of these use oneOf over organizationalEntity and
    organizationalContact, so an object with only name (and/or bom-ref) matches both and fails
    validation. The XML is fine because of the wrapper elements. Should this be reported to the specification repo?
  • No model-level validation of patentNumber / jurisdiction patterns yet. Schema validation catches them.
    Happy to add it if you want it.
  • Patent bom-refs are not added to BomRefDiscriminator (same as Standard).

Tests: new fixtures get_bom_with_patents and get_bom_with_definitions_patents_only (snapshots for
all versions, JSON+XML schema validation, deserialization round-trip), enum tests for both new enums,
and unit tests in tests/test_model_patent.py.

Resolves or fixes issue: part of #903

AI Tool Disclosure

  • My contribution does not include any AI-generated content
  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: Grok Bot (autonomous coding assistant agent)
    • LLMs and versions: not exposed by the tool
    • Prompts: Implement CycloneDX 1.7 patent support (Patent, PatentFamily, definitions.patents, patentAssertions on Component/Service, 1.7-only) following the existing model/serialization/test conventions of this repo; add fixtures, snapshots and unit tests; run flake8/mypy/isort/bandit and the full test suite.
      I reviewed the code and ran all tests and linters locally.

Affirmation

Add the CycloneDX 1.7 patent data models:
- `cyclonedx.model.patent` with `Patent`, `PatentFamily`, `PatentAssertion`,
  `PriorityApplication` and enums `PatentLegalStatus`, `PatentAssertionType`
- `Definitions.patents`
- `Component.patent_assertions` and `Service.patent_assertions`

All of these are rendered for CycloneDX >= 1.7 only.
`Bom.definitions` is no longer rendered empty, when none of its parts is
available in the target schema version.

Part of CycloneDX#903

Assisted-by: AI coding assistant (reviewed and tested by the author)
Signed-off-by: Nare <[email protected]>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 164 complexity · 0 duplication

Metric Results
Complexity 164
Duplication 0

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

This branch has not been deployed

No deployments
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