Skip to content

Commit 7dffc39

Browse files
authored
Merge pull request cli#11332 from cli/andyfeller/11209-automate-govulncheck
Incorporate govulncheck into workflows
2 parents 43e7609 + 4da24b8 commit 7dffc39

2 files changed

Lines changed: 49 additions & 3 deletions

File tree

.github/workflows/govulncheck.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Go Vulnerability Check
2+
on:
3+
schedule:
4+
- cron: "0 0 * * 1" # Every Monday at midnight UTC
5+
jobs:
6+
govulncheck:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
security-events: write
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: 'go.mod'
19+
20+
# `govulncheck -format sarif` exits successfully regardless of results, which are not in stdout.
21+
# See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck#hdr-Exit_codes for more information on exit codes.
22+
- name: Check Go vulnerabilities
23+
run: |
24+
make
25+
go run golang.org/x/vuln/cmd/govulncheck@d1f380186385b4f64e00313f31743df8e4b89a77 -mode=binary -format sarif bin/gh > gh.sarif
26+
27+
- name: Upload SARIF report
28+
uses: github/codeql-action/upload-sarif@9b02dc2f60288b463e7a66e39c78829b62780db7 # 2.22.1
29+
with:
30+
sarif_file: gh.sarif

.github/workflows/lint.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ on:
1616
- go.sum
1717
- ".github/licenses.tmpl"
1818
- "script/licenses*"
19-
2019
permissions:
2120
contents: read
22-
2321
jobs:
2422
lint:
2523
runs-on: ubuntu-latest
26-
2724
steps:
2825
- name: Check out code
2926
uses: actions/checkout@v4
@@ -64,3 +61,22 @@ jobs:
6461
export PATH=${GOROOT}/bin:$PATH
6562
go install github.com/google/go-licenses@5348b744d0983d85713295ea08a20cca1654a45e
6663
make licenses-check
64+
65+
# Discover vulnerabilities within Go standard libraries used to build GitHub CLI using govulncheck.
66+
govulncheck:
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Check out code
70+
uses: actions/checkout@v4
71+
72+
- name: Set up Go
73+
uses: actions/setup-go@v5
74+
with:
75+
go-version-file: 'go.mod'
76+
77+
# `govulncheck` exits unsuccessfully if vulnerabilities are found, providing results in stdout.
78+
# See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck#hdr-Exit_codes for more information on exit codes.
79+
- name: Check Go vulnerabilities
80+
run: |
81+
make
82+
go run golang.org/x/vuln/cmd/govulncheck@d1f380186385b4f64e00313f31743df8e4b89a77 -mode=binary bin/gh

0 commit comments

Comments
 (0)