Skip to content

Commit 4842467

Browse files
pieternIsaac
andauthored
Bump dependencies flagged by GitHub repository advisories (#7320)
The vulnerable-dependency bumper only sees advisories in the Go vulnerability database. Maintainers often publish a GitHub repository security advisory (GHSA) days or weeks before it reaches GitHub's global advisory database and, from there, the Go vulnerability database. Until then neither govulncheck nor Dependabot reports it. `go.opentelemetry.io/otel/trace` v1.44.0 is an example: [GHSA-q7gw-24fr-5p69](GHSA-q7gw-24fr-5p69) was published on Oct 28 with a fix in v1.47.0, and none of these databases has it yet. This is a first step toward GHSA support. A new tool, `tools/repoadvisory`, maps each module linked into the CLI to its GitHub repository and checks it against that repository's published advisories. It emits only the advisories that name a patched version, as govulncheck-format JSON. Those without a patched version are logged and skipped, since there is nothing to bump to. The workflow feeds this output into `vulnbump` alongside govulncheck's, and the existing all-or-nothing behavior is unchanged: if any bump fails, no PR is opened and the run fails. `vulnbump` now links each advisory to the URL in its record, so GHSA IDs link to their GitHub page. A `dry_run` dispatch input computes and shows the bump without creating a pull request or failure issue. Against current main this produces one bump, otel 1.44.0 → 1.47.0. The two pgx advisories ([GHSA-j38q-h3ph-jjpq](GHSA-j38q-h3ph-jjpq), [GHSA-95fj-3fxw-g62g](GHSA-95fj-3fxw-g62g)) name no patched version and are skipped. This pull request and its description were written by Isaac. Co-authored-by: Isaac <no-reply@databricks.com>
1 parent f9a6aa4 commit 4842467

8 files changed

Lines changed: 1181 additions & 15 deletions

File tree

‎.github/workflows/bump-vuln-deps.yml‎

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
# Run daily at 05:30 UTC, just after the Go toolchain bumper.
66
- cron: "30 5 * * *"
77
workflow_dispatch:
8+
inputs:
9+
dry_run:
10+
description: "Compute and show the bump without creating a pull request or failure issue"
11+
type: boolean
12+
default: false
813

914
permissions:
1015
contents: write
@@ -35,11 +40,16 @@ jobs:
3540
# vulnbump lives in the tools module, which is what this job compiles.
3641
go-version-file: tools/go.mod
3742

38-
- name: Build vulnbump
39-
run: go -C tools/vulnbump build -o "$RUNNER_TEMP/vulnbump" .
43+
- name: Build vulnbump and repoadvisory
44+
run: |
45+
go -C tools/vulnbump build -o "$RUNNER_TEMP/vulnbump" .
46+
go -C tools/repoadvisory build -o "$RUNNER_TEMP/repoadvisory" .
4047
4148
- name: Bump vulnerable dependencies
4249
id: bump
50+
env:
51+
# repoadvisory reads public repository advisories through the GitHub API.
52+
GITHUB_TOKEN: ${{ github.token }}
4353
run: |
4454
set -euo pipefail
4555
@@ -57,8 +67,18 @@ jobs:
5767
scan="$(mktemp)"
5868
go tool -modfile=tools/go.mod govulncheck -scan module -format json > "$scan"
5969
70+
# Maintainers publish GitHub repository security advisories before
71+
# they reach the Go vulnerability database, so govulncheck misses
72+
# them. repoadvisory checks the modules linked into the CLI against
73+
# those advisories and emits the ones with a patched version in the
74+
# same JSON format. Each scan writes to its own file so a failure in
75+
# either aborts the job.
76+
advisories="$(mktemp)"
77+
go list -deps -f '{{with .Module}}{{if .Version}}{{.Path}} {{.Version}}{{end}}{{end}}' . \
78+
| "$RUNNER_TEMP/repoadvisory" > "$advisories"
79+
6080
summary_file="$(mktemp)"
61-
"$RUNNER_TEMP/vulnbump" . < "$scan" > "$summary_file"
81+
cat "$scan" "$advisories" | "$RUNNER_TEMP/vulnbump" . > "$summary_file"
6282
6383
if git diff --quiet; then
6484
echo "No vulnerable dependencies to bump."
@@ -78,7 +98,7 @@ jobs:
7898

7999
- name: Create pull request
80100
id: cpr
81-
if: steps.bump.outputs.needed == 'true'
101+
if: steps.bump.outputs.needed == 'true' && !inputs.dry_run
82102
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
83103
with:
84104
# A fixed branch means a daily run updates the existing open PR in
@@ -87,9 +107,9 @@ jobs:
87107
commit-message: "Bump dependencies with known vulnerabilities"
88108
title: "Bump dependencies with known vulnerabilities"
89109
body: |
90-
Bump dependencies flagged by `govulncheck -scan module` to their fixed versions.
110+
Bump dependencies flagged by `govulncheck -scan module` or by GitHub repository security advisories to their fixed versions.
91111
92-
Each CVE links to its Go advisory page.
112+
Each advisory links to its advisory page.
93113
94114
${{ steps.bump.outputs.summary }}
95115
@@ -126,7 +146,7 @@ jobs:
126146
127147
# A failed scheduled run is otherwise only visible in the Actions tab.
128148
- name: Report failure
129-
if: failure()
149+
if: failure() && !inputs.dry_run
130150
uses: ./.github/actions/report-failure
131151
with:
132152
label: bump-vuln-deps-failure

‎tools/repoadvisory/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/repoadvisory

0 commit comments

Comments
 (0)