Skip to content

Write metadata distribution constraints - #986

Open
wleeaf wants to merge 1 commit into
CycloneDX:masterfrom
wleeaf:metadata-distribution-constraints
Open

wleeaf wants to merge 1 commit into
CycloneDX:masterfrom
wleeaf:metadata-distribution-constraints

Conversation

@wleeaf

@wleeaf wleeaf commented Oct 25, 2026

Copy link
Copy Markdown

Metadata.distributionConstraints (CycloneDX 1.7) is parsed from both JSON and XML; JsonParserTest and XmlParserTest check tlp is RED. But MetadataSerializer writes each metadata field by hand and has no case for it, so generators never write the field. Parsing valid-metadata-distribution-1.7.json and generating 1.7 JSON gives:

"metadata" : { }

The XML output gives <metadata/>. So the TLP classification is lost from every BOM the library writes.

This writes distributionConstraints after properties, which is where the 1.7 XSD puts it in the metadata sequence. It is guarded by shouldSerializeField, so the field's @VersionFilter(Version.VERSION_17) still keeps it out of older versions.

New tests:

  • schema17MetadataDistributionConstraintsJsonTest checks that 1.7 JSON has distributionConstraints.tlp set to RED and that 1.6 JSON leaves it out.
  • schema17MetadataDistributionConstraintsGenerationTest checks that 1.7 XML has <tlp>RED</tlp> and passes the XSD.

Both fail without the change and pass with it. mvn -B test passes: 1763 tests, 0 failures.

Metadata.distributionConstraints (CycloneDX 1.7) is parsed from JSON
and XML, but MetadataSerializer writes every metadata field by hand and
had no case for it, so the TLP classification was dropped from every
generated BOM. Re-generating the spec test file
valid-metadata-distribution-1.7.json gave an empty metadata object.

Write it after the properties, where the 1.7 XSD expects it, for the
versions its @VersionFilter allows.

Signed-off-by: Wleeaf <179125857+wleeaf@users.noreply.github.com>
@wleeaf
wleeaf requested a review from a team as a code owner October 25, 2026 10:46
Copilot AI balanced review requested due to automatic review settings October 25, 2026 10:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 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.

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.

2 participants