Skip to content

Commit 92a6789

Browse files
committed
build: capture govulncheck results as Code Scanning alerts
Related to [0] and regular questions we've had in the past, we don't have a clear answer for "are we vulnerable to a CVE" in a way that our users are clearly able to determine, as well as "will oapi-codegen fix it". As a step towards answering the former, and leading towards the latter, we can start running `govulncheck` in CI as a way to ensure that we always have that information to hand. This will re-run on commits to HEAD, as well as on a schedule, to make sure we're aware of new CVEs. By producing this in SARIF format, we can then have this uploaded to GitHub's Code Scanning alerts, which are more straightforward to validate. The Code Scanning alerts page is gated to maintainers, but doesn't (currently) hide anything that can't be seen by someone running `govulncheck` themselves on the project. We also make sure to explicitly note what permissions are required to handle the workflow. [0]: oapi-codegen/governance#11
1 parent aea1d0c commit 92a6789

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/workflows/govulncheck.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Determine known CVEs through `govulncheck`
2+
on:
3+
push:
4+
branches:
5+
- main
6+
schedule:
7+
# Mondays at 0000
8+
- cron: "0 0 * * 1"
9+
jobs:
10+
check-for-vulnerabilities:
11+
name: Check for vulnerabilities using `govulncheck`
12+
runs-on: ubuntu-latest
13+
permissions:
14+
security-events: write
15+
contents: read
16+
steps:
17+
- uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4
18+
with:
19+
go-package: ./...
20+
# NOTE that we want to produce the SARIF-formatted report, which can then be consumed by other tools ...
21+
output-format: sarif
22+
output-file: govulncheck.sarif
23+
24+
# ... such as the Code Scanning tab (https://github.com/oapi-codegen/runtime/security/code-scanning?query=is%3Aopen+branch%3Amain+tool%3Agovulncheck)
25+
- name: Upload SARIF file
26+
uses: github/codeql-action/upload-sarif@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.2
27+
with:
28+
sarif_file: govulncheck.sarif
29+
category: govulncheck
30+
31+
- name: Print code scanning results URL
32+
run: |
33+
echo "Results: https://github.com/${{ github.repository }}/security/code-scanning?query=is%3Aopen+branch%3Amain+tool%3Agovulncheck"

0 commit comments

Comments
 (0)