Skip to content

Commit f07477b

Browse files
bestbeforetodaydenyeart
authored andcommitted
Run vulnerability scan on latest release tags
Vulnerability scans were previously run only on the latest state of currently developed branches. This provided assurance that the current branch state did not contain known vulnerabilities in dependencies, but did not provide assurance that the currently released code was free of vulnerabilities. This change runs additional vulnerability scans on the most recent release version tag for currently developed branches. Scan failures now indicate that a new release is required to address vulnerabilities in dependencies. Signed-off-by: Mark S. Lewis <[email protected]>
1 parent 84d7d77 commit f07477b

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

.github/workflows/vulnerability-scan.yml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ permissions:
1313
contents: read
1414

1515
jobs:
16-
scan:
16+
latest:
1717
# Only run the scheduled job in hyperledger/fabric repository, not on personal forks
1818
if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository == 'hyperledger/fabric')
1919
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
@@ -24,12 +24,43 @@ jobs:
2424
- main
2525
- release-2.5
2626
steps:
27-
- uses: actions/checkout@v4
27+
- name: Checkout ${{ matrix.ref }} branch
28+
uses: actions/checkout@v4
2829
with:
2930
ref: ${{ matrix.ref }}
3031
- name: Set up Go
3132
uses: actions/setup-go@v5
3233
with:
3334
go-version: 1.24.0
3435
- name: Scan
35-
run: make scan
36+
run: go run github.com/google/osv-scanner/cmd/osv-scanner@b37c83e19af3b2555864457cbd0b08ef0e1f9d7d scan --lockfile=go.mod || (( $? > 1 && $? < 127 ))
37+
38+
release:
39+
# Only run the scheduled job in hyperledger/fabric repository, not on personal forks
40+
if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository == 'hyperledger/fabric')
41+
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
ref:
46+
- main
47+
- release-2.5
48+
steps:
49+
- name: Checkout ${{ matrix.ref }} branch
50+
uses: actions/checkout@v4
51+
with:
52+
ref: ${{ matrix.ref }}
53+
fetch-depth: 0
54+
- name: Get latest release tag
55+
id: latest-release
56+
run: echo "tag=$(git -c versionsort.suffix=- tag --merged HEAD --sort=-version:refname | head -1)" >> "${GITHUB_OUTPUT}"
57+
- name: Checkout ${{ steps.latest-release.outputs.tag }}
58+
uses: actions/checkout@v4
59+
with:
60+
ref: ${{ steps.latest-release.outputs.tag }}
61+
- name: Set up Go
62+
uses: actions/setup-go@v5
63+
with:
64+
go-version: 1.24.0
65+
- name: Scan
66+
run: go run github.com/google/osv-scanner/cmd/osv-scanner@b37c83e19af3b2555864457cbd0b08ef0e1f9d7d scan --lockfile=go.mod || (( $? > 1 && $? < 127 ))

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,19 @@ help: ## List all commands with documentation
106106
@awk 'BEGIN {FS = ":.*?## "}; /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
107107

108108
.PHONY: all
109-
all: ## Builds all targets and runs all non-integration tests/checks
109+
all: ## Builds all targets and runs all non-integration tests/checks
110110
check-go-version native docker checks
111111

112112
.PHONY: checks
113-
checks: ## Runs basic checks along with unit and integration tests
113+
checks: ## Runs basic checks along with unit and integration tests
114114
basic-checks unit-test integration-test
115115

116116
.PHONY: basic-checks
117-
basic-checks: check-go-version license spelling references trailing-spaces linter check-help-docs check-metrics-doc filename-spaces check-swagger ## Performs basic checks like license, spelling, trailing spaces and linter
117+
basic-checks: check-go-version license spelling references trailing-spaces linter check-help-docs check-metrics-doc filename-spaces check-swagger ## Performs basic checks like license, spelling, trailing spaces and linter
118118

119119

120120
.PHONY: desk-checks
121-
desk-check: ## Runs linters and verify to test changed packages
121+
desk-check: ## Runs linters and verify to test changed packages
122122
checks verify
123123

124124
.PHONY: help-docs
@@ -344,7 +344,7 @@ release-clean: $(RELEASE_PLATFORMS:%=%-release-clean) ## Clean release packages
344344
-@rm -rf release/$*
345345

346346
.PHONY: unit-test-clean
347-
unit-test-clean:
347+
unit-test-clean:
348348

349349
.PHONY: filename-spaces
350350
spaces: # Check for spaces in file names
@@ -372,8 +372,8 @@ ccaasbuilder/%: ccaasbuilder-clean
372372
ccaasbuilder: ccaasbuilder/$(MARCH)
373373

374374
.PHONY: scan
375-
scan: scan-govulncheck ## Run all security scans
375+
scan: scan-osv-scanner ## Run all vulnerability scans
376376

377-
.PHONY: scan-govulncheck
378-
scan-govulncheck: gotool.govulncheck ## Run gosec security scan
379-
govulncheck ./...
377+
.PHONY: scan-osv-scanner ## Run OSV-Scanner vulnerability scan
378+
scan-osv-scanner:
379+
go run github.com/google/osv-scanner/cmd/osv-scanner@b37c83e19af3b2555864457cbd0b08ef0e1f9d7d scan --lockfile=go.mod || [ \( $$? -gt 1 \) -a \( $$? -lt 127 \) ]

gotools.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ go.fqp.gocov-xml := github.com/AlekSi/gocov-xml
1616
go.fqp.gofumpt := mvdan.cc/gofumpt
1717
go.fqp.goimports := golang.org/x/tools/cmd/goimports
1818
go.fqp.golint := golang.org/x/lint/golint
19-
go.fqp.govulncheck := golang.org/x/vuln/cmd/govulncheck@latest
2019
go.fqp.misspell := github.com/client9/misspell/cmd/misspell
2120
go.fqp.mockery := github.com/vektra/mockery/v2
2221
go.fqp.protoc-gen-go := google.golang.org/protobuf/cmd/protoc-gen-go

0 commit comments

Comments
 (0)