I'm trying to generate an SBOM that includes all of Spring Boot's default dependencies. I've tried using the generated Maven pom and removing the <*Management> tags to declare everything as a dependency, then running mvn install and generating the SBOM, but it does not include all default dependencies.
I've also tried generating from Spring Boot's source but all dependencies are not included there either. Generating based on the root project is better, but also does not include all dependencies.
The following is copied from Spring Boot's internal CI steps
./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false \
--no-daemon --no-parallel --continue build
I'm attempting to generate an SBOM using cyclonedx. I tried with makeAggregateBom (default), makeBom, and makePackageBom
My end goal is to find projects overwriting Spring's default dependencies. For example, with Spring Boot 3.2.3 you should have logback-classic:1.4.14, (this page is not published as a json file anywhere I can find). If you have that in your project with a different version, then you are doing something suboptimal by overwriting the default version.
Reading "Supply Chain Security: SBOMs for Java Applications" de Thomas Vitale, you could automate SBOM generation as part of your build process, by including the CycloneDX Maven plugin in your project's
pom.xmlfile: it will generate an SBOM that you can then analyze to identify any dependency version overrides.Use
mvn clean verifyto generate the SBOM.With the SBOM generated, you can now analyze it to identify any dependencies where the version does not match the versions recommended by Spring Boot. That manual step involves comparing the versions listed in your SBOM against the default versions specified in the Spring Boot documentation or the
spring-boot-dependenciesPOM for your specific version of Spring Boot.To automate the process of identifying overrides, you might consider scripting a solution that parses the generated SBOM and compares each dependency version against the recommended versions. That could be done using XML or JSON parsing tools in your language of choice, depending on the format of your SBOM.
So to generate an SBOM that reflects all the managed dependencies of a Spring Boot project, including those defined in
spring-boot-dependencies, you will need a different approach.One workaround is to create a synthetic (or dummy) POM project that explicitly declares dependencies on all the libraries you are interested in tracking. That POM does not have to build anything; it just needs to list dependencies.
For this approach, you would:
<dependencies>section of this project'spom.xml, explicitly list all the dependencies and their versions as managed by thespring-boot-dependenciesPOM you are interested in. The example below includes a few common Spring Boot starters for illustration.Here is an example of what the synthetic project's
pom.xmlmight look like:That would make sure the CycloneDX plugin can see and include all these dependencies in the generated SBOM, as they are now direct dependencies of this synthetic project.
Manually listing all dependencies can be tedious and error-prone, especially considering the number of dependencies managed by Spring Boot and their updates over time. To automate this process, consider writing a script that:
spring-boot-dependenciesPOM file to extract managed dependencies and their versions.pom.xmlfile with these dependencies listed explicitly.With the synthetic project set up and populated with dependencies, you can generate the SBOM using the CycloneDX Maven plugin, as you already know:
That command will generate an SBOM including all the dependencies you have explicitly listed in your synthetic project.
Now that you have an SBOM reflecting all dependencies managed by
spring-boot-dependencies, you can proceed with analyzing it for any overrides. That involves comparing the dependency versions in your SBOM against the project's actual dependencies to identify mismatches.You could also try and create a synthetic or dummy
pom.xmlfor the purpose of generating an SBOM that lists all managed dependencies of a Spring Boot project.Assuming you are interested in Spring Boot version 2.5.0 dependencies, that
pom.xmlwould be:Use the Maven Dependency Plugin to list all dependencies. That step might be more about understanding or inspecting rather than modifying the
pom.xml:Or, for a hierarchical view:
You could then:
mvn dependency:listormvn dependency:tree.pom.xmlwith these dependencies listed explicitly.pom.xmlto produce the SBOM.