Skip to content

Commit a365238

Browse files
committed
.github: scan Go modules for known vulnerabilities
Add govulncheck CI and Dependabot for the two Go modules, src/webui and src/netbrowse, so vendored dependencies don't quietly accumulate CVEs between manual updates. The workflow reports every finding in the run summary but only fails on vulnerabilities our code actually calls in a dependency. Called stdlib vulnerabilities are surfaced too, but they're fixed by bumping the Buildroot host Go rather than a module's go.mod, so they don't gate the build. Dependabot ignores openconfig/goyang: it's pinned to our kernelkit fork via a replace directive and stepped by hand. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent d02f45d commit a365238

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: /src/webui
5+
schedule:
6+
interval: weekly
7+
# goyang is pinned to our kernelkit fork via a replace directive and
8+
# stepped by hand when we add patches; leave it for Dependabot to ignore.
9+
ignore:
10+
- dependency-name: github.com/openconfig/goyang
11+
12+
- package-ecosystem: gomod
13+
directory: /src/netbrowse
14+
schedule:
15+
interval: weekly

.github/workflows/govulncheck.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Go Vulnerability Scan
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'src/webui/**'
9+
- 'src/netbrowse/**'
10+
- '.github/workflows/govulncheck.yml'
11+
pull_request:
12+
paths:
13+
- 'src/webui/**'
14+
- 'src/netbrowse/**'
15+
- '.github/workflows/govulncheck.yml'
16+
schedule:
17+
- cron: '5 0 * * 6' # Saturday at 00:05 UTC, same as Coverity
18+
workflow_dispatch:
19+
20+
jobs:
21+
govulncheck:
22+
if: ${{ github.repository_owner == 'kernelkit' }}
23+
runs-on: ubuntu-latest
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
module:
28+
- src/webui
29+
- src/netbrowse
30+
steps:
31+
- uses: actions/checkout@v6
32+
33+
- uses: actions/setup-go@v6
34+
with:
35+
go-version: stable
36+
37+
- name: Install govulncheck
38+
run: go install golang.org/x/vuln/cmd/govulncheck@latest
39+
40+
- name: Scan ${{ matrix.module }}
41+
working-directory: ${{ matrix.module }}
42+
run: |
43+
# Full report, for the run summary. govulncheck exits non-zero
44+
# whenever it finds anything, so don't let it fail the step here.
45+
{
46+
echo "## govulncheck: ${{ matrix.module }}"
47+
echo '```'
48+
govulncheck ./... || true
49+
echo '```'
50+
} | tee -a "$GITHUB_STEP_SUMMARY"
51+
52+
# Gate on vulnerabilities reachable from our code through a
53+
# dependency. govulncheck's call-graph analysis is transitive,
54+
# so indirect use counts too (we call a dep that calls the bad
55+
# symbol). trace[0] is the vulnerable symbol; we key on the
56+
# module it lives in. A chain that bottoms out in stdlib is
57+
# fixed by bumping the Buildroot host Go, not this module's
58+
# go.mod, so it's reported above but doesn't fail the build.
59+
# Keep the json scan and jq unguarded so a tool failure fails the
60+
# gate closed; only grep's no-match exit (all-clear) is tolerated.
61+
govulncheck -format json ./... > scan.json || true
62+
called=$(jq -r 'select(.finding.trace[0].function != null) |
63+
.finding.trace[0].module' scan.json | sort -u)
64+
vulns=$(printf '%s' "$called" | grep -vx stdlib || true)
65+
if [ -n "$vulns" ]; then
66+
echo "::error::Called vulnerabilities in dependencies: $(echo "$vulns" | paste -sd, -)"
67+
exit 1
68+
fi

0 commit comments

Comments
 (0)