Skip to content

Commit 63816aa

Browse files
Use OSV-Scanner instead of dependency-check (#321)
The existing dependency-check version is no longer supported and might fail after the NVD data feeds it uses are deprecated on 2023-12-15. The updated version requires an API key to interact with the newer NVD APIs. For details see: - https://github.com/jeremylong/DependencyCheck#900-upgrade-notice It also requires periodic triage and suppression of false positive detections. OSV-Scanner appears less prone to false positives and does not require an API key to be maintained. Implement a scheduled vulnerability scan (using OSV-Scanner) so that vulnerabilities are more visible than the current (dependency-check) implementation, which runs in PR builds but does not fail builds or make the results very visible. Signed-off-by: Mark S. Lewis <[email protected]>
1 parent 233e382 commit 63816aa

File tree

8 files changed

+55
-72
lines changed

8 files changed

+55
-72
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
uses: gradle/gradle-build-action@v2
7272
with:
7373
arguments: |
74-
:fabric-chaincode-docker:copyAllDeps -x dependencyCheckAnalyze
74+
:fabric-chaincode-docker:copyAllDeps
7575
- name: Set up QEMU
7676
uses: docker/setup-qemu-action@v2
7777
- name: Set up Docker Buildx

.github/workflows/scheduled-scan.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Scheduled vulnerability scan"
2+
3+
on:
4+
schedule:
5+
- cron: "20 3 * * *"
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
osv-scanner:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Go
17+
uses: actions/setup-go@v4
18+
with:
19+
go-version: stable
20+
- name: Scan
21+
run: make scan

.github/workflows/test.yml

+2-9
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,12 @@ jobs:
2626
cache: 'gradle'
2727
- name: Validate Gradle wrapper
2828
uses: gradle/wrapper-validation-action@v1
29-
- name: Dependency Check
30-
uses: gradle/gradle-build-action@v2
31-
with:
32-
arguments: |
33-
:fabric-chaincode-shim:dependencyCheckAnalyze
3429
- name: Build and Unit test
3530
uses: gradle/gradle-build-action@v2
3631
with:
3732
arguments: |
3833
:fabric-chaincode-shim:build
39-
-xdependencyCheckAnalyze
40-
34+
4135
intergationtest:
4236
runs-on: ubuntu-latest
4337
steps:
@@ -72,5 +66,4 @@ jobs:
7266
uses: gradle/gradle-build-action@v2
7367
with:
7468
arguments: |
75-
:fabric-chaincode-integration-test:build
76-
-xdependencyCheckAnalyze
69+
:fabric-chaincode-integration-test:build

CONTRIBUTING.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,25 @@ Should you have any questions or concerns, please reach out to one of the projec
4141

4242
## How to work with the Codebase
4343

44-
Some useful gradle commands to help with building. You can add or remove the `--no-daemon` and `-x dependencyCheckAnalyze` as you wish; depending on the performance of you local machine.
44+
Some useful gradle commands to help with building. You can add or remove the `--no-daemon` as you wish; depending on the performance of you local machine.
4545

46-
```
47-
# build everything , but skip the (slow) dependency checks
48-
./gradlew --no-daemon build -x dependencyCheckAnalyze
46+
```shell
47+
# build everything
48+
./gradlew --no-daemon build
4949

5050
# clean up to force tests and compile to rerun
5151
./gradlew clean cleanTest
52-
./gradlew --no-daemon :fabric-chaincode-shim:build -x dependencyCheckAnalyze
52+
./gradlew --no-daemon :fabric-chaincode-shim:build
5353

5454
# build docker image
5555
./gradlew :fabric-chaincode-docker:buildImage
5656
```
5757

58+
You can also scan for vulnerabilities in dependencies (requires [Make](https://www.gnu.org/software/make/) and [Go](https://go.dev/) to be installed):
59+
```shell
60+
make scan
61+
```
62+
5863
## Hyperledger Fabric
5964

6065
See the

Makefile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
5+
.PHONEY: scan
6+
scan:
7+
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'

dependency-suppression.xml

-38
This file was deleted.

fabric-chaincode-docker/Dockerfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ RUN gradle \
4141
-x javadoc \
4242
-x test \
4343
-x checkstyleMain \
44-
-x checkstyleTest \
45-
-x dependencyCheckAnalyze
44+
-x checkstyleTest
4645

4746
WORKDIR /root/chaincode-java
4847
# Run the Gradle and Maven commands to generate the wrapper variants

fabric-chaincode-shim/build.gradle

+11-17
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ plugins {
1717
id 'jacoco'
1818
id 'signing'
1919
id 'checkstyle'
20+
id 'org.cyclonedx.bom' version '1.8.1'
2021
}
2122

22-
apply plugin: 'org.owasp.dependencycheck'
23-
2423
checkstyle {
2524
toolVersion '10.12.2'
2625
configFile file("../ci/checkstyle/checkstyle.xml")
@@ -34,13 +33,18 @@ checkstyleTest {
3433
source ='src/test/java'
3534
}
3635

37-
dependencyCheck {
38-
suppressionFile='dependency-suppression.xml'
39-
scanConfigurations = ['runtimeClasspath']
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
4046
}
4147

42-
check.dependsOn dependencyCheckAnalyze
43-
4448
tasks.withType(org.gradle.api.tasks.testing.Test) {
4549
systemProperty 'CORE_CHAINCODE_LOGGING_LEVEL', 'DEBUG'
4650
}
@@ -76,16 +80,6 @@ dependencies {
7680
implementation 'io.opentelemetry.instrumentation:opentelemetry-grpc-1.6:1.32.0-alpha'
7781
}
7882

79-
dependencyCheck {
80-
format='ALL'
81-
analyzers {
82-
assemblyEnabled=false
83-
ossIndex {
84-
enabled=false
85-
}
86-
}
87-
}
88-
8983
sourceSets {
9084
main {
9185
java {

0 commit comments

Comments
 (0)