Skip to content

Conversation

jdaugherty
Copy link
Contributor

@jdaugherty jdaugherty commented Sep 19, 2025

With the recent compromises of NPM, it's important we publish an SBOM.

This change generates sboms per the recommended standard. The files will not be published individually at this time (publish plugin needs enhancements). Instead, the files will be published inside of the binary jar files at META-INF/sbom.json.

Other notes on this PR:

  • As part of testing the cyclonedx gradle plugin, there are some quality issues with the plugin. It does not support the latest best practices for gradle. There is a 3.x version upcoming, but it's still alpha and has other issues (you can't set the component type).
  • I discovered we were generating jar files with just license / ASF policy files, so I've stopped generating those files as of this change (grails-dependencies-*,etc)
  • I'm not creating an aggregate sbom for the Grails framework. Right now, an individual sbom for every project will be generated.
  • I'm not widely documenting this feature at the start since we'll want to review all of these sboms. Security software is the main target of these files, so it will find them on it's own.

@jdaugherty
Copy link
Contributor Author

I've gone ahead and updated this PR to also strictly validate licenses based on current versions. This means that as we update dependencies in the future, we can adjust our exceptions/ mappings and be confident there hasn't been a license change.

@jamesfredley jamesfredley linked an issue Sep 19, 2025 that may be closed by this pull request
Copy link
Contributor

@jamesfredley jamesfredley left a comment

Choose a reason for hiding this comment

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

Great work!

@matrei
Copy link
Contributor

matrei commented Sep 22, 2025

I'm getting:

Unpermitted License found for bom dependency: pkg:maven/org.hdrhistogram/[email protected]?type=jar in project grails-dependencies-starter-web : CC0-1.0

when running ./gradlew clean cyclonedxBom: https://ge.grails.org/s/y74nwrngrwqtq

@jdaugherty
Copy link
Contributor Author

jdaugherty commented Sep 22, 2025

The starter projects don't generate a jar so they don't run the license check by default. I guess I could depend on assemble instead ... let me make that change and fix the fallout

@jdaugherty
Copy link
Contributor Author

jdaugherty commented Sep 22, 2025

@matrei I populated most of the other licenses that the ASF considers acceptable from https://www.apache.org/legal/resolved.html & run the validation on assemble as well. This fixes the error you're seeing from the spring actuator project.

@matrei
Copy link
Contributor

matrei commented Sep 22, 2025

Do we need to include the license texts in the SBOMs?

@jdaugherty
Copy link
Contributor Author

Do we need to include the license texts in the SBOMs?

I'm not sure if I understand this - are you proposing we don't include the text or are you asking us to?

The SPDX code is what identifies the license text. The cyclonedx is a json standard, so we're simply including what the upstream authors have published. Most of the licenses are included via a base64 encoding. We could technically strip the text and ensure the id is present. I'm inclined to use what the standard does by default since this is meant for security review.

@matrei
Copy link
Contributor

matrei commented Sep 22, 2025

I'm not sure if I understand this - are you proposing we don't include the text or are you asking us to?

The SPDX code is what identifies the license text. The cyclonedx is a json standard, so we're simply including what the upstream authors have published. Most of the licenses are included via a base64 encoding. We could technically strip the text and ensure the id is present. I'm inclined to use what the standard does by default since this is meant for security review.

I'm wondering if there is any downside to set the includeLicenseText property to false (https://github.com/CycloneDX/cyclonedx-gradle-plugin?tab=readme-ov-file#configuration-properties).

@jdaugherty
Copy link
Contributor Author

I'm not sure if I understand this - are you proposing we don't include the text or are you asking us to?

The SPDX code is what identifies the license text. The cyclonedx is a json standard, so we're simply including what the upstream authors have published. Most of the licenses are included via a base64 encoding. We could technically strip the text and ensure the id is present. I'm inclined to use what the standard does by default since this is meant for security review.

I'm wondering if there is any downside to set the includeLicenseText property to false (https://github.com/CycloneDX/cyclonedx-gradle-plugin?tab=readme-ov-file#configuration-properties).

One downside is there isn't an SPDX code for the sitemesh license. The actual standard only requires id or name though. https://cyclonedx.org/docs/1.6/json/#tab-pane_components_items_licenses_oneOf_i0_items_license_oneOf_i0

Why would you want to not include the license text?

@matrei
Copy link
Contributor

matrei commented Sep 22, 2025

Why would you want to not include the license text?

I was thinking about jar size.

@jdaugherty
Copy link
Contributor Author

jdaugherty commented Sep 22, 2025 via email

@jdaugherty
Copy link
Contributor Author

File sizes for the hibernate-core.jar:

  1. has license text: 655K
  2. no license text: 588K

I guess with the base64 encoding, zip can't optimize the sizes so it seems reasonable to turn off the text include.

Copy link
Contributor

@matrei matrei left a comment

Choose a reason for hiding this comment

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

Great work James! 🎉

]

def pickLicense = { String bomRef, List licenseChoices ->
if(!bomRef) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Space after if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would have assumed codenarc was applied to our gradle files, but apparently not. Do you know if it's possible to apply our code style rules to gradle files?

@jdaugherty jdaugherty merged commit 5d3964d into 7.0.x Sep 23, 2025
10 checks passed
@jdaugherty jdaugherty deleted the feature/sbom branch September 23, 2025 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate Dependency Licenses at build time & generate SBOMs
3 participants