Skip to content

Add jarmode tools SBOM command - #51505

Open
xxxxxxjun wants to merge 2 commits into
spring-projects:mainfrom
xxxxxxjun:add-jarmode-tools-sbom-command
Open

Add jarmode tools SBOM command#51505
xxxxxxjun wants to merge 2 commits into
spring-projects:mainfrom
xxxxxxjun:add-jarmode-tools-sbom-command

Conversation

@xxxxxxjun

@xxxxxxjun xxxxxxjun commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Adds an sbom command to the tools jar mode. Given an uber jar or war, it prints the packaged SBOM. Reading that SBOM currently means starting the application and calling the actuator's sbom endpoint.

To find the SBOM, the command reads the Sbom-Location manifest attribute and uses the value as-is: the Gradle plugin already writes the WEB-INF/classes/ prefix for wars. The entry at that location is written byte for byte to the console, or to the file given by --destination. Because the output is meant to be piped elsewhere, the command exits with a non-zero code if it can't write to the console.

The second commit fixes a problem this command exposed. ToolsJarMode wrapped every exception in IllegalStateException, so a JarModeErrorException never reached JarModeRunner's Error: <message> branch and was printed as a stack trace. That matters here because CycloneDX generation is opt-in, and "no SBOM found" is likely to be the most common outcome for sbom. Rethrowing the exception ahead of the generic catch restores that branch. It also changes what extract and list-layers print when they fail, so I'm happy to move it to its own PR if you'd prefer.

Closes #45954

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 29, 2026
Add an 'sbom' command to the tools jar mode which prints the SBOM
packaged in an uber jar or war. The SBOM is located using the
Sbom-Location manifest attribute and its bytes are copied verbatim to
the console, or to the file given by --destination.

Signed-off-by: Hyeongjun Cho <ryuu.public@gmail.com>
ToolsJarMode wrapped every exception in IllegalStateException, so a
JarModeErrorException thrown by a command never reached the simple
message branch of JarModeRunner and was printed as a stack trace.
Rethrow it so failures such as a missing SBOM are reported as
'Error: <message>' with a non-zero exit code.

Signed-off-by: Hyeongjun Cho <ryuu.public@gmail.com>
@xxxxxxjun
xxxxxxjun force-pushed the add-jarmode-tools-sbom-command branch from 94897a0 to 74ccdfb Compare August 29, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add jarmode tools command to print / export the SBOM

2 participants