Skip to content

Commit 00f89fd

Browse files
Add a scheduled vulnerability scan (#464)
Scan both the current development codebase and latest release for vulnerabilities in dependencies. Signed-off-by: Mark S. Lewis <[email protected]>
1 parent 6a7c6ed commit 00f89fd

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

.github/actions/scan/action.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Security vulnerability scan"
2+
inputs:
3+
path:
4+
description: Path to scan
5+
required: false
6+
default: "."
7+
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Scan
12+
id: scan
13+
shell: bash
14+
run: |
15+
SOURCE_PATH="$(cd "${{ inputs.path }}" > /dev/null && pwd)"
16+
docker run --rm \
17+
--volume "${SOURCE_PATH}/:/src" \
18+
ghcr.io/google/osv-scanner:latest \
19+
scan \
20+
--lockfile=/src/go.mod \
21+
--format=markdown > osv-scanner.md
22+
- name: Report failure
23+
if: ${{ failure() && steps.scan.conclusion == 'failure' }}
24+
shell: bash
25+
run: |
26+
cat osv-scanner.md >> ${GITHUB_STEP_SUMMARY}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: "Security vulnerability scan"
2+
3+
on:
4+
schedule:
5+
- cron: "22 22 * * *"
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
dev:
13+
name: Scan development codebase
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17+
- uses: ./.github/actions/scan
18+
19+
release:
20+
name: Scan latest release
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
24+
with:
25+
sparse-checkout: |
26+
.github
27+
- name: Get latest releast tag
28+
id: latest-release
29+
run: echo "TAG=$(curl --location --silent --fail "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest" | jq --raw-output '.tag_name')" >> "${GITHUB_OUTPUT}"
30+
- name: Checkout release ${{ steps.latest-release.outputs.TAG }}
31+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
32+
with:
33+
ref: ${{ steps.latest-release.outputs.TAG }}
34+
path: src
35+
- uses: ./.github/actions/scan
36+
with:
37+
path: src

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,11 @@ dist-clean:
242242
-@rm -rf release/linux-arm64/hyperledger-fabric-ca-linux-arm64-$(RELEASE_VERSION).tar.gz ||:
243243

244244
.FORCE:
245+
246+
.PHONY: install-osv-scanner
247+
install-osv-scanner:
248+
go install github.com/google/osv-scanner/v2/cmd/osv-scanner@latest
249+
250+
.PHONY: scan
251+
scan: install-osv-scanner
252+
osv-scanner scan --lockfile=go.mod

0 commit comments

Comments
 (0)