Skip to content

Commit a645338

Browse files
Use Gradle lockfile instead of CycloneDX SBOM for scan (#351)
A CycloneDX SBOM was generated to allow OSV-Scanner to scan all transitive dependencies. A similar result can be achieved using Gradle lockfiles, removing the need to use CycloneDX. Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
1 parent 7ad1342 commit a645338

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ repository
1616
.gradle
1717
/build/
1818
out/
19+
gradle.lockfile
1920
!gradle/wrapper/gradle-wrapper.jar
2021

2122
### STS ###

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
.PHONEY: scan
66
scan:
77
go install github.com/google/osv-scanner/cmd/osv-scanner@latest
8-
./gradlew cyclonedxBom
9-
osv-scanner --sbom='fabric-chaincode-shim/build/reports/bom.json'
8+
./gradlew --quiet resolveAndLockAll --write-locks
9+
osv-scanner scan --lockfile=fabric-chaincode-shim/gradle.lockfile

fabric-chaincode-shim/build.gradle

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,20 @@ checkstyleTest {
3333
source ='src/test/java'
3434
}
3535

36-
cyclonedxBom {
37-
includeConfigs = ["runtimeClasspath"]
38-
skipConfigs = ["compileClasspath", "testCompileClasspath"]
39-
projectType = "library"
40-
schemaVersion = "1.5"
41-
destination = file("build/reports")
42-
outputName = "bom"
43-
outputFormat = "json"
44-
includeBomSerialNumber = false
45-
includeLicenseText = false
36+
configurations {
37+
runtimeClasspath {
38+
resolutionStrategy.activateDependencyLocking()
39+
}
40+
}
41+
42+
tasks.register('resolveAndLockAll') {
43+
notCompatibleWithConfigurationCache("Filters configurations at execution time")
44+
doFirst {
45+
assert gradle.startParameter.writeDependencyLocks : "$path must be run from the command line with the `--write-locks` flag"
46+
}
47+
doLast {
48+
configurations.findAll { it.canBeResolved }.each { it.resolve() }
49+
}
4650
}
4751

4852
tasks.withType(org.gradle.api.tasks.testing.Test) {

0 commit comments

Comments
 (0)