Skip to content

Write a mapped license in the CycloneDX license wrapper - #17207

Merged
jdaugherty merged 1 commit into
7.0.xfrom
fix/sbom-mapped-license-wrapper
Nov 28, 2026
Merged

jdaugherty merged 1 commit into
7.0.xfrom
fix/sbom-mapped-license-wrapper

Conversation

@matrei

@matrei matrei commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

The problem

In a CycloneDX BOM, each entry of a component's licenses holds its license under the key license. When SbomPlugin overrides a dependency's license from LICENSE_MAPPING, pickLicense returned the license block itself, {id, url} or {name, url}, without that key. So the SBOM of every module with such a dependency fails validation against the CycloneDX 1.6 schema:

/components/13/licenses/0: required property 'license' not found

cyclonedx-core-java's parser reads the entry anyway, which is why the build never noticed. The SBOMs in released jars have it, for example grails-layout 7.0.17 (sitemesh), and grails-layout and grails-shell-cli 8.0.0 (sitemesh, jline).

It was found in the review of #17203, which fixes it on 8.0.x along with the CycloneDX update. This PR fixes the 7.x branches.

The fix

pickLicense returns [license: licenseBlock] for a mapped license. A license that isn't mapped already came back as the entry CycloneDX wrote, with the key.

Tests

SbomPluginSpec is new on 7.0.x. Its TestKit feature builds the SBOM of a library with three dependencies from a local repository:

  • jzlib, mapped to the id BSD-3-Clause;
  • sitemesh, mapped to the OpenSymphony license, which has only a name;
  • a module with the Apache license, which is preferred and not mapped.

It validates the SBOM against the CycloneDX 1.6 schema with cyclonedx-core-java's JsonParser, and checks each license entry. Without the fix, the schema check fails.

On JDK 17.0.18, :build-logic:check in build-logic runs 17 tests with 0 failures.

I also regenerated all 130 SBOMs of the root, grails-gradle and grails-forge builds, with cyclonedxBom --rerun --no-build-cache, and validated each against the CycloneDX 1.6 schema:

  • Without the fix, 24 of them fail.
  • With the fix, all of them pass.

The only difference between the two sets is the added license key, on 31 entries for 11 dependencies: sitemesh, jline 2 and 3, antlr4-runtime, org.json, liquibase-hibernate5, the three Bouncy Castle modules and the two coherence BOMs.

Merging up

Tests on 7.0.x run only with the run ci label, which this PR has.

Each entry of a component's licenses in a CycloneDX BOM holds its
license under the key license. pickLicense returned a license it took
from LICENSE_MAPPING without that key, as {id, url} or {name, url}, so
the SBOM of every module with such a dependency, such as sitemesh,
jline or jzlib, failed validation against the CycloneDX 1.6 schema.
cyclonedx-core-java's parser read the entry anyway.

The new SbomPluginSpec builds the SBOM of a library with a dependency
mapped to a license id, one mapped to a license name and one with a
preferred license, and validates it against the schema.
@matrei matrei added the run ci label Nov 28, 2026
@matrei
matrei marked this pull request as ready for review November 28, 2026 13:00
@matrei
matrei requested a review from jdaugherty November 28, 2026 14:18
@testlens-app

testlens-app Bot commented Nov 28, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 6586c94
▶️ Tests: 60920 executed
⚪️ Checks: 117/117 completed


Learn more about TestLens at testlens.app/docs.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes look good.

@jdaugherty
jdaugherty merged commit 6e69247 into 7.0.x Nov 28, 2026
64 of 118 checks passed
@jdaugherty
jdaugherty deleted the fix/sbom-mapped-license-wrapper branch November 28, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants