Skip to content

Commit 13918c9

Browse files
Use OSV-Scanner v2 (#376)
Update the vulnerability scan of dependencies to use OSV-Scanner v2. Also rework the Makefile targets so that a precompiled OSV-Scanner binary is downloaded and avoid the need for Go to be installed. Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
1 parent 48f9606 commit 13918c9

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

.github/workflows/scan.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,5 @@ jobs:
2424
distribution: temurin
2525
java-version: 21
2626
- uses: gradle/actions/setup-gradle@v4
27-
- name: Set up Go
28-
uses: actions/setup-go@v5
29-
with:
30-
go-version: stable
31-
cache: false
3227
- name: Scan
3328
run: make scan

Makefile

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,29 @@
22
# SPDX-License-Identifier: Apache-2.0
33
#
44

5-
.PHONEY: scan
6-
scan:
7-
go install github.com/google/osv-scanner/cmd/osv-scanner@latest
8-
./gradlew --quiet resolveAndLockAll --write-locks
9-
osv-scanner scan --lockfile=fabric-chaincode-shim/gradle.lockfile
5+
bin_dir := bin
6+
osv-scanner := $(bin_dir)/osv-scanner
7+
8+
kernel_name := $(shell uname -s | tr '[:upper:]' '[:lower:]')
9+
machine_hardware := $(shell uname -m)
10+
ifeq ($(machine_hardware), x86_64)
11+
machine_hardware := amd64
12+
endif
13+
ifeq ($(machine_hardware), aarch64)
14+
machine_hardware := arm64
15+
endif
16+
17+
.PHONY: scan
18+
scan: $(osv-scanner)
19+
./gradlew --quiet :fabric-chaincode-shim:dependencies --write-locks --configuration runtimeClasspath
20+
bin/osv-scanner scan --lockfile=fabric-chaincode-shim/gradle.lockfile
21+
22+
.PHONY: install-osv-scanner
23+
install-osv-scanner:
24+
mkdir -p '$(bin_dir)'
25+
curl --fail --location --show-error --silent --output '$(osv-scanner)' \
26+
'https://github.com/google/osv-scanner/releases/latest/download/osv-scanner_$(kernel_name)_$(machine_hardware)'
27+
chmod u+x '$(osv-scanner)'
28+
29+
$(osv-scanner):
30+
$(MAKE) install-osv-scanner

fabric-chaincode-shim/build.gradle

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@ configurations {
2626
}
2727
}
2828

29-
tasks.register('resolveAndLockAll') {
30-
notCompatibleWithConfigurationCache("Filters configurations at execution time")
31-
doFirst {
32-
assert gradle.startParameter.writeDependencyLocks : "$path must be run from the command line with the `--write-locks` flag"
33-
}
34-
doLast {
35-
configurations.findAll { it.canBeResolved }.each { it.resolve() }
36-
}
37-
}
38-
3929
tasks.withType(org.gradle.api.tasks.testing.Test) {
4030
systemProperty 'CORE_CHAINCODE_LOGGING_LEVEL', 'DEBUG'
4131
}

0 commit comments

Comments
 (0)