Skip to content

Commit 1a039a7

Browse files
committed
Upload security SARIF files when repo is public
GitHub only allows SARIF files to be uploaded for paid tier GitHub users or if the repo is public. Add logic to prevent SARIF upload attempt when repo is private. Upload SARIF file as artifact.
1 parent 33c6836 commit 1a039a7

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

.github/workflows/security.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ jobs:
3434
with:
3535
go-version-file: go.mod
3636
check-latest: true
37-
upload-sarif: true
37+
upload-sarif: ${{ !github.event.repository.private }}
38+
- name: Upload govulncheck SARIF artifact
39+
if: always()
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: govulncheck-sarif
43+
path: '**/*.sarif'
44+
if-no-files-found: ignore
3845

3946
trivy:
4047
name: Trivy repo scan
@@ -57,8 +64,16 @@ jobs:
5764
# Include all severities for testing - Consider removing UNKNOWN,LOW,MEDIUM when enforcing.
5865
severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
5966
exit-code: 1 # Remove to enforce failure on high/critical
60-
- name: Upload SARIF
67+
- name: Upload Trivy SARIF artifact
68+
if: always()
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: trivy-sarif
72+
path: trivy-fs.sarif
73+
if-no-files-found: ignore
74+
- name: Upload SARIF to Code Scanning
75+
if: ${{ !github.event.repository.private }}
6176
uses: github/codeql-action/upload-sarif@v4
62-
if: steps.trivy_scan.outcome == 'failure'
6377
with:
6478
sarif_file: trivy-fs.sarif
79+
wait-for-processing: true

0 commit comments

Comments
 (0)