Skip to content

Commit 797addf

Browse files
committed
fix: [#251] upload SARIF files with unique categories per image
1 parent cebf2a7 commit 797addf

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

.github/workflows/docker-security-scan.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,24 @@ jobs:
137137
merge-multiple: false
138138

139139
- name: Upload SARIF files to GitHub Security
140-
uses: github/codeql-action/upload-sarif@v4
141-
with:
142-
sarif_file: "."
143-
category: "docker-security-scan"
140+
run: |
141+
# Upload each SARIF file with a unique category
142+
find . -name "*.sarif" -type f | while read -r sarif_file; do
143+
# Extract image name from directory path for category
144+
category=$(basename $(dirname "$sarif_file") | sed 's/^sarif-//' | sed 's/-[0-9]*$//')
145+
echo "Uploading $sarif_file with category: docker-$category"
146+
147+
# Use gh CLI to upload SARIF (simpler than action in loop)
148+
cat "$sarif_file" | gh api \
149+
--method POST \
150+
-H "Accept: application/vnd.github+json" \
151+
-H "X-GitHub-Api-Version: 2022-11-28" \
152+
/repos/${{ github.repository }}/code-scanning/sarifs \
153+
-f sarif=@- \
154+
-f ref="${{ github.ref }}" \
155+
-f commit_sha="${{ github.sha }}" \
156+
-f checkout_uri="${{ github.server_url }}/${{ github.repository }}" \
157+
-f category="docker-$category" || echo "Failed to upload $sarif_file"
158+
done
159+
env:
160+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)