Skip to content

Commit 7666c0c

Browse files
committed
up
1 parent f88239e commit 7666c0c

1 file changed

Lines changed: 45 additions & 3 deletions

File tree

.github/workflows/security.yml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,24 @@ jobs:
3030
p/security-audit
3131
p/secrets
3232
p/owasp-top-ten
33+
continue-on-error: true
34+
35+
- name: Check if Semgrep SARIF file exists
36+
id: check-semgrep-sarif
37+
run: |
38+
echo "Files in current directory:"
39+
ls -la *.sarif 2>/dev/null || echo "No SARIF files found"
40+
if [ -f "semgrep.sarif" ] && [ -s "semgrep.sarif" ]; then
41+
echo "sarif-exists=true" >> $GITHUB_OUTPUT
42+
echo "Semgrep SARIF file found and not empty"
43+
else
44+
echo "sarif-exists=false" >> $GITHUB_OUTPUT
45+
echo "No Semgrep SARIF file generated or file is empty"
46+
fi
3347
3448
- name: Upload SARIF to GitHub Security tab
3549
uses: github/codeql-action/upload-sarif@v3
36-
if: always()
50+
if: steps.check-semgrep-sarif.outputs.sarif-exists == 'true'
3751
with:
3852
sarif_file: semgrep.sarif
3953

@@ -74,10 +88,24 @@ jobs:
7488
image-ref: 'devsecops-app:latest'
7589
format: 'sarif'
7690
output: 'trivy-container.sarif'
91+
continue-on-error: true
92+
93+
- name: Check if SARIF file exists
94+
id: check-sarif
95+
run: |
96+
echo "Files in current directory:"
97+
ls -la *.sarif 2>/dev/null || echo "No SARIF files found"
98+
if [ -f "trivy-container.sarif" ] && [ -s "trivy-container.sarif" ]; then
99+
echo "sarif-exists=true" >> $GITHUB_OUTPUT
100+
echo "SARIF file found and not empty"
101+
else
102+
echo "sarif-exists=false" >> $GITHUB_OUTPUT
103+
echo "No SARIF file generated or file is empty"
104+
fi
77105
78106
- name: Upload Trivy results to GitHub Security tab
79107
uses: github/codeql-action/upload-sarif@v3
80-
if: always()
108+
if: steps.check-sarif.outputs.sarif-exists == 'true'
81109
with:
82110
sarif_file: trivy-container.sarif
83111
category: container-security
@@ -99,10 +127,24 @@ jobs:
99127
scan-ref: '.'
100128
format: 'sarif'
101129
output: 'trivy-iac.sarif'
130+
continue-on-error: true
131+
132+
- name: Check if IaC SARIF file exists
133+
id: check-iac-sarif
134+
run: |
135+
echo "Files in current directory:"
136+
ls -la *.sarif 2>/dev/null || echo "No SARIF files found"
137+
if [ -f "trivy-iac.sarif" ] && [ -s "trivy-iac.sarif" ]; then
138+
echo "sarif-exists=true" >> $GITHUB_OUTPUT
139+
echo "IaC SARIF file found and not empty"
140+
else
141+
echo "sarif-exists=false" >> $GITHUB_OUTPUT
142+
echo "No IaC SARIF file generated or file is empty"
143+
fi
102144
103145
- name: Upload IaC results to GitHub Security tab
104146
uses: github/codeql-action/upload-sarif@v3
105-
if: always()
147+
if: steps.check-iac-sarif.outputs.sarif-exists == 'true'
106148
with:
107149
sarif_file: trivy-iac.sarif
108150
category: iac

0 commit comments

Comments
 (0)