MavenとGradleでJavaのSBOMを作成する方法
2022年10月31日
13 分で読めますJavaアプリケーションを
先日、
SBOMとは?
ソフトウェア部品表は、
ただし、
SBOMは
SBOMを作成する理由
SBOMを
近年、サプライチェーンに
ソフトウェアを
SBOMの標準規格:SPDXとCycloneDX
現在、
Software Package Data Exchange
CycloneDXは、
JavaでSBOMを作成するタイミング
Javaは
MavenでJavaのSBOMを作成する
Maven用CycloneDXプラグイン
Maven CentralとGitHubで
<plugins>
<plugin>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
<version>2.7.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>makeAggregateBom</goal>
</goals>
</execution>
</executions>
<configuration>
<projectType>library</projectType>
<schemaVersion>1.4</schemaVersion>
<includeBomSerialNumber>true</includeBomSerialNumber>
<includeCompileScope>true</includeCompileScope>
<includeProvidedScope>true</includeProvidedScope>
<includeRuntimeScope>true</includeRuntimeScope>
<includeSystemScope>true</includeSystemScope>
<includeTestScope>false</includeTestScope>
<includeLicenseText>false</includeLicenseText>
<outputReactorProjects>true</outputReactorProjects>
<outputFormat>all</outputFormat>
<outputName>CycloneDX-Sbom</outputName>
</configuration>
</plugin>
</plugins>CycloneDXmakeAggregateBomゴールを
直接jackson-databindパッケージがsprint-boot-starter-web経由で
<component type="library" bom-ref="pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.13.4?type=jar">
<publisher>FasterXML</publisher>
<group>com.fasterxml.jackson.core</group>
<name>jackson-databind</name>
<version>2.13.4</version>
<description>General data-binding functionality for Jackson: works on core streaming API</description>
<hashes>
<hash alg="MD5">03cb7aea126610e4c96ca6d14d75cc55</hash>
<hash alg="SHA-1">98b0edfa8e4084078f10b7b356c300ded4a71491</hash>
<hash alg="SHA-256">c9faff420d9e2c7e1e4711dbeebec2506a32c9942027211c5c293d8d87807eb6</hash>
<hash alg="SHA-512">23f32026b181c6c71efc7789a8420c7d5cbcfb15f7696657e75f9cbe3635d13a88634b5db3c344deb914b719d60e3a9bfc1b63fa23152394e1e70b8e7bcd2116</hash>
<hash alg="SHA-384">e25e844575891b2f3bcb2fdc67ae9fadf54d2836052c9ea2c045f1375eaa97e4780cd6752bef0ebc658fa17400c55268</hash>
<hash alg="SHA3-384">e6955877c2c27327f6814f06d681118be2ae1a36bc5ff2e84ad27f213203bf77c347ba18d9abc61d5f1c99b6e81f6c2d</hash>
<hash alg="SHA3-256">88b12b0643a4791fa5cd0c5e30bc2631903870cf916c8a1b4198c856fd91e5f4</hash>
<hash alg="SHA3-512">7e86a69bcf7b4c8a6949acce0ec15f33b74d5ac604f23cd631ec16bfdfd70d42499028b9d062648b31d7a187ea4dc98ec296a329f4cfd4952744ed1281fa9d9a</hash>
</hashes>
<licenses>
<license>
<id>Apache-2.0</id>
</license>
</licenses>
<purl>pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.13.4?type=jar</purl>
<externalReferences><reference type="vcs"><url>http://github.com/FasterXML/jackson-databind</url></reference><reference type="website"><url>http://fasterxml.com/</url></reference><reference type="distribution"><url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url></reference></externalReferences>
</component>Maven用SPDXプラグイン(プロトタイプ)
SPDXにもMaven
<plugin>
<groupId>org.spdx</groupId>
<artifactId>spdx-maven-plugin</artifactId>
<version>0.6.1</version>
<executions>
<execution>
<id>build-spdx</id>
<phase>package</phase>
<goals>
<goal>createSPDX</goal>
</goals>
</execution>
</executions>
</plugin>この/target/site/{groupId}_{artifactId}-{version}.spdx.jsonに
出力を
Maven用SPDX CLIツール
別の
アプリケーションの
./spdx-sbom-generator生成された
##### Package representing the jackson-databind
PackageName: jackson-databind
SPDXID: SPDXRef-Package-jackson-databind-2.13.4
PackageVersion: 2.13.4
PackageSupplier: Organization: jackson-databind
PackageDownloadLocation: https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind/2.13.4
FilesAnalyzed: false
PackageChecksum: SHA1: 7d03e73aa50d143b3ecbdea2c0c9e158e5ed8021
PackageHomePage: NOASSERTION
PackageLicenseConcluded: NOASSERTION
PackageLicenseDeclared: NOASSERTION
PackageCopyrightText: NOASSERTION
PackageLicenseComments: NOASSERTION
PackageComment: NOASSERTION
Relationship: SPDXRef-Package-jackson-databind-2.13.4 DEPENDS_ON SPDXRef-Package-jackson-annotations-2.13.4
Relationship: SPDXRef-Package-jackson-databind-2.13.4 DEPENDS_ON SPDXRef-Package-jackson-core-2.13.4SPDX形式の
GradleでJavaのSBOMを作成する
次に、
Gradle用CycloneDX
Gradle用の
プラグインを
plugins {
id 'org.cyclonedx.bom' version '1.7.2'
}以下のように、cyclonedxBomブロックを
cyclonedxBom {
includeConfigs = ["runtimeClasspath"]
skipConfigs = ["compileClasspath", "testCompileClasspath"]
projectType = "application"
schemaVersion = "1.4"
destination = file("build/reports")
outputName = "CycloneDX-Sbom"
outputFormat = "all"
includeBomSerialNumber = true
componentVersion = "2.0.0"
}このbuild.finalizedBy('cyclonedxBom')とcyclonedxBomターゲットが
出力はbuildフォルダーに
Gradle用SPDX
残念ながら、
JavaプロジェクトのSBOMを作成する
Javaプロジェクトの
Mavenと
CTFを 始めよう
オンデマンドの



