Skip to content

Commit e6dafa5

Browse files
committed
Add required options and log versions
1 parent 53e2be0 commit e6dafa5

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed

.github/workflows/scripts/govulncheck-sarif.sh renamed to .github/workflows/scripts/govulncheck-run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ REPO_PREFIX=$(go list -m)
1717
for pkg in $ALL_PKG_DIRS; do
1818
OUTPUT_FILE="./govulncheck/$(echo "$pkg" | sed "s|^$REPO_PREFIX/||" | tr '/' '_').sarif"
1919
echo -e "\nRunning govulncheck for package $pkg"
20-
if ! govulncheck ${GOVULN_OPT:-} "$pkg" > "$OUTPUT_FILE"; then
20+
if ! govulncheck ${GOVULN_OPTS:-} "$pkg" > "$OUTPUT_FILE"; then
2121
echo "govulncheck failed for package $pkg, output saved to $OUTPUT_FILE"
2222
FAILED=1
2323
else

.github/workflows/vuln-scans.yml

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ jobs:
267267
with:
268268
sarif_file: snyk.sarif
269269

270-
govulncheck:
270+
govulncheck-run:
271271
runs-on: ubuntu-24.04
272272
timeout-minutes: 30
273273
steps:
@@ -278,12 +278,65 @@ jobs:
278278
with:
279279
go-version: ${{ env.GO_VERSION }}
280280
cache-dependency-path: '**/go.sum'
281+
281282
- name: Install Tools
282283
run: make install-tools
284+
285+
- run: govulncheck --version
286+
283287
- name: Run `govulncheck` script
284-
run: ./.github/workflows/scripts/govulncheck-sarif.sh
288+
env:
289+
GOVULN_OPTS: --format sarif --scan package
290+
run: ./.github/workflows/scripts/govulncheck-run.sh
291+
292+
- name: Save govulncheck results as artifact
293+
uses: actions/upload-artifact@v4
294+
with:
295+
name: govulncheck-results
296+
path: ./govulncheck/
297+
298+
govulncheck-categories:
299+
runs-on: ubuntu-24.04
300+
outputs:
301+
matrix: ${{ steps.capture-packages.outputs.matrix }}
302+
steps:
303+
- name: Checkout Repo
304+
uses: actions/checkout@v4
305+
- name: Setup Go
306+
uses: actions/setup-go@v5
307+
with:
308+
go-version: ${{ env.GO_VERSION }}
309+
cache-dependency-path: '**/go.sum'
310+
- name: Capture Go Packages
311+
id: capture-packages
312+
run: |
313+
REPO_PREFIX=$(go list -m)
314+
PACKAGES=$(go list ./... | sed "s|^$REPO_PREFIX/||" | tr '/' '_')
315+
JSON_ARRAY=$(echo $PACKAGES | jq -R -s 'split("\n") | map(select(. != ""))' | sed "s/\"/'/g")
316+
category=$(for p in $(echo -e "$PACKAGES"); do echo "\"$p\","; done)
317+
matrix=$(echo "{\"category\": [${category%,}]}" | tr -d '\n')
318+
echo "$matrix" | jq
319+
echo $matrix
320+
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
321+
322+
govulncheck-upload:
323+
runs-on: ubuntu-24.04
324+
needs: [govulncheck-run, govulncheck-categories]
325+
strategy:
326+
matrix: ${{ fromJSON(needs.govulncheck-categories.outputs.matrix) }}
327+
steps:
328+
- name: Checkout Repo
329+
uses: actions/checkout@v4
330+
331+
- name: Download govulncheck results artifact
332+
uses: actions/download-artifact@v4
333+
with:
334+
name: govulncheck-results
335+
path: ./govulncheck/
336+
285337
- name: Upload result to GitHub Code Scanning
286338
if: always()
287339
uses: github/codeql-action/upload-sarif@v3
288340
with:
289-
sarif_file: ./govulncheck/
341+
sarif_file: ./govulncheck/${{ matrix.category }}.sarif
342+
category: ${{ matrix.category }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ deployments/heroku/test/node_modules
5555

5656
# temp file created during testing
5757
tests/installation/testdata/systemd/splunk-otel-collector.conf
58+
59+
# For convenience excluding sarif files generated by ./.github/workflows/scripts/govulncheck-run.sh
60+
/govulncheck/

0 commit comments

Comments
 (0)