Skip to content

Commit f7f51f2

Browse files
committed
ci: use snyk/actions/node for code test and add fallback for missing SARIF
1 parent b473d4c commit f7f51f2

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

.github/workflows/snyk-security.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,25 @@ jobs:
3939
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
4040
steps:
4141
- uses: actions/checkout@v4
42-
- name: Set up Snyk CLI to check for security issues
43-
uses: snyk/actions/setup@master
44-
4542
- name: Snyk Code test
46-
run: snyk code test --sarif-file-output=snyk-code.sarif
43+
uses: snyk/actions/node@master
4744
continue-on-error: true
45+
with:
46+
command: code test
47+
args: --sarif-file-output=snyk-code.sarif
4848
env:
4949
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
5050

51+
- name: Verify SARIF file
52+
run: |
53+
if [ -f snyk-code.sarif ]; then
54+
echo "SARIF file found."
55+
ls -l snyk-code.sarif
56+
else
57+
echo "SARIF file NOT found. Creating empty valid SARIF to prevent crash."
58+
echo '{"$schema":"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json","version":"2.1.0","runs":[]}' > snyk-code.sarif
59+
fi
60+
5161
# Runs Snyk Open Source (SCA) analysis and uploads result to Snyk.
5262
- name: Snyk Open Source monitor
5363
run: snyk monitor --all-projects || true

0 commit comments

Comments
 (0)