Skip to content

Commit 3c59a19

Browse files
committed
fix: sanitize Dockle SARIF to remove invalid URIs before upload
Add sanitization step to filter out Dockle SARIF results containing invalid URIs like "ENVIRONMENT variable on HOST OS" that cause GitHub code scanning upload failures. The jq filter removes results where location URIs contain whitespace or other non-file-path characters, while preserving results with no locations. Signed-off-by: Manav Gupta <[email protected]>
1 parent c057be3 commit 3c59a19

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

.github/workflows/docker-image.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ jobs:
148148
--output dockle-results.sarif \
149149
$IMAGE_NAME:latest || true
150150
echo "DOCKLE_EXIT=$?" >> "$GITHUB_ENV"
151+
- name: 🧹 Sanitize Dockle SARIF (remove invalid URIs)
152+
if: always() && hashFiles('dockle-results.sarif') != ''
153+
run: |
154+
# Filter out results with invalid URIs (containing spaces or non-file-path characters)
155+
jq '.runs[].results |= map(select(
156+
(.locations // []) | length == 0 or
157+
all(.physicalLocation.artifactLocation.uri | test("^[^\\s]+$"))
158+
))' dockle-results.sarif > dockle-results-clean.sarif || cp dockle-results.sarif dockle-results-clean.sarif
159+
mv dockle-results-clean.sarif dockle-results.sarif
151160
- name: ☁️ Upload Dockle SARIF
152161
if: always() && hashFiles('dockle-results.sarif') != ''
153162
uses: github/codeql-action/upload-sarif@v3

0 commit comments

Comments
 (0)