Skip to content

Commit a43e760

Browse files
authored
fix(snyk): Update action and split report upload (#318)
* fix(snyk): Update action and split report upload * fix(snyk): Guard SARIF uploads when output files are missing. * fix(snyk): Update setup icon
1 parent 29b2c20 commit a43e760

2 files changed

Lines changed: 65 additions & 13 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
id: TASK-11
3+
title: Fix snyk workflow
4+
status: Done
5+
assignee:
6+
- claude
7+
- piotrzajac
8+
created_date: '2026-04-12'
9+
updated_date: '2026-04-12'
10+
labels: [ci-cd, sec]
11+
dependencies: []
12+
priority: medium
13+
---
14+
15+
## Description
16+
17+
<!-- SECTION:DESCRIPTION:BEGIN -->
18+
Two issues need fixing in `.github/workflows/snyk.yml`:
19+
20+
### Issue 1 — Deprecated action
21+
22+
All three scan/monitor steps use `snyk/actions/dotnet@master`, which is officially
23+
deprecated and no longer supported by Snyk (no .NET-specific replacement exists).
24+
25+
The recommended migration is `snyk/actions/setup@master` (installs the Snyk CLI only)
26+
combined with explicit `run: snyk ...` commands. Since the workflow already runs on
27+
`ubuntu-latest`, the Docker-based `setup` action works without any runner change.
28+
29+
### Issue 2 — Multiple SARIF runs under the same category
30+
31+
The single `upload-sarif` step points to the `snyk/` directory, which contains two
32+
SARIF files (`opensource.sarif` and `code.sarif`). GitHub Code Scanning no longer
33+
allows multiple SARIF runs uploaded under the same category (announced 2025-07-21),
34+
causing the workflow to fail with:
35+
36+
> The CodeQL Action does not support uploading multiple SARIF runs with the same
37+
> category. Please update your workflow to upload a single run per category.
38+
39+
**Fix:** replace the single directory upload with two steps, each pointing to a
40+
specific file with a distinct `category`. The `category` parameter creates an
41+
independent slot in the GitHub Advanced Security dashboard — uploads coexist and
42+
neither overwrites the other.
43+
<!-- SECTION:DESCRIPTION:END -->
44+
45+
## Acceptance Criteria
46+
47+
- [x] #1 All three `snyk/actions/dotnet@master` steps are replaced with `snyk/actions/setup@master` + `run:` commands
48+
- [x] #2 The single `upload-sarif` directory step is replaced by two file-specific steps
49+
- [x] #3 Each upload step specifies a distinct `category` (`snyk-opensource` and `snyk-code`)
50+
- [x] #4 Both upload steps retain `if: ${{ always() }}` so results upload even when scans report findings
51+
- [x] #5 The workflow runs without error

.github/workflows/snyk.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,31 @@ jobs:
4545
if ($LastExitCode -ne 0) {
4646
throw "dotnet restore failed with exit code $LastExitCode"
4747
}
48+
- name: 🛠️ setup snyk
49+
uses: snyk/actions/setup@v1.0.0
4850
- name: 🔬 snyk opensource scan
49-
uses: snyk/actions/dotnet@master
51+
run: snyk test --sarif-file-output=snyk/opensource.sarif --all-projects --exclude=Objectivity.AutoFixture.XUnit2.AutoFakeItEasy.Tests,Objectivity.AutoFixture.XUnit2.AutoMoq.Tests,Objectivity.AutoFixture.XUnit2.AutoNSubstitute.Tests,Objectivity.AutoFixture.XUnit2.Core.Tests
5052
continue-on-error: true
5153
env:
5254
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
53-
with:
54-
args: --sarif-file-output=snyk/opensource.sarif --all-projects --exclude=Objectivity.AutoFixture.XUnit2.AutoFakeItEasy.Tests,Objectivity.AutoFixture.XUnit2.AutoMoq.Tests,Objectivity.AutoFixture.XUnit2.AutoNSubstitute.Tests,Objectivity.AutoFixture.XUnit2.Core.Tests
5555
- name: 🔬 snyk code scan
56-
uses: snyk/actions/dotnet@master
56+
run: snyk code test --sarif-file-output=snyk/code.sarif
5757
continue-on-error: true
5858
env:
5959
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
60-
with:
61-
args: --sarif-file-output=snyk/code.sarif
62-
command: code test
6360
- name: 📈 snyk monitor
64-
uses: snyk/actions/dotnet@master
61+
run: snyk monitor --all-projects --exclude=Objectivity.AutoFixture.XUnit2.AutoFakeItEasy.Tests,Objectivity.AutoFixture.XUnit2.AutoMoq.Tests,Objectivity.AutoFixture.XUnit2.AutoNSubstitute.Tests,Objectivity.AutoFixture.XUnit2.Core.Tests
6562
env:
6663
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
64+
- name: 📊 upload opensource sarif for GitHub Advanced Security Dashboard
65+
uses: github/codeql-action/upload-sarif@v4
6766
with:
68-
args: --all-projects --exclude=Objectivity.AutoFixture.XUnit2.AutoFakeItEasy.Tests,Objectivity.AutoFixture.XUnit2.AutoMoq.Tests,Objectivity.AutoFixture.XUnit2.AutoNSubstitute.Tests,Objectivity.AutoFixture.XUnit2.Core.Tests
69-
command: monitor
70-
- name: 📊 upload sarif file for GitHub Advanced Security Dashboard
67+
sarif_file: snyk/opensource.sarif
68+
category: snyk-opensource
69+
if: ${{ always() && hashFiles('snyk/opensource.sarif') != '' }}
70+
- name: 📊 upload code sarif for GitHub Advanced Security Dashboard
7171
uses: github/codeql-action/upload-sarif@v4
7272
with:
73-
sarif_file: snyk
74-
if: ${{ always() }}
73+
sarif_file: snyk/code.sarif
74+
category: snyk-code
75+
if: ${{ always() && hashFiles('snyk/code.sarif') != '' }}

0 commit comments

Comments
 (0)