Skip to content

Fix SARIF upload in security workflow#159

Open
fabian-hiller wants to merge 1 commit into
mainfrom
fix/security-sarif-upload
Open

Fix SARIF upload in security workflow#159
fabian-hiller wants to merge 1 commit into
mainfrom
fix/security-sarif-upload

Conversation

@fabian-hiller

@fabian-hiller fabian-hiller commented Jul 20, 2026

Copy link
Copy Markdown
Member

Problem

The "Code scanning results / CVE Lite CLI" check fails on pull requests, reporting all pre-existing dependency alerts as newly introduced (currently "65 new alerts including 29 errors"), and every Security run emits "inconsistent fingerprint" warning annotations.

CVE Lite CLI writes its own partialFingerprints into the SARIF report, and the values differ between runs. GitHub code scanning matches alerts across runs and branches by these fingerprints, so no alert from a pull request upload ever matches its counterpart on main — everything counts as new. The upload step also pointed sarif_file at the whole workspace and relied on the CLI's timestamped report filename.

Fix

A normalize step between scan and upload copies the newest report to a stable cve-lite.sarif and strips the tool's partialFingerprints with jq, so the upload action computes consistent, deterministic fingerprints instead. Alerts stay distinct through their per-CVE rule IDs. The upload now targets that exact file and is skipped gracefully if no report was produced.

Verified against a locally generated SARIF: all 64 tool fingerprints removed, all results preserved.

Note

The pull request check only settles once this lands on main and the Security workflow has run there once, establishing a baseline with consistent fingerprints.

Summary by CodeRabbit

  • Bug Fixes
    • Improved vulnerability scan report handling for more consistent results across runs.
    • Ensured security reports are uploaded only when a valid normalized report is available.

CVE Lite CLI writes its own partialFingerprints into the SARIF report,
and the values differ between runs. GitHub code scanning matches alerts
across runs by these fingerprints, so no alert ever matched: every run
warned about inconsistent fingerprints and pull requests reported all
pre-existing alerts as newly introduced. The upload also pointed at the
whole workspace and relied on the timestamped report filename.

A new normalize step copies the report to a stable filename and strips
the tool fingerprints so the upload action computes consistent ones.
Alerts stay distinct through their per-CVE rule IDs.
Copilot AI review requested due to automatic review settings July 20, 2026 17:33
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. fix Smaller bug fix or improvement labels Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The security workflow now normalizes the newest cve-lite SARIF report by removing partialFingerprints and writing cve-lite.sarif. The SARIF upload step runs only when this normalized file exists and uploads the stable filename.

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: fixing SARIF upload behavior in the security workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the GitHub Security workflow’s SARIF handling for the OWASP CVE Lite CLI so code scanning alerts remain stable across runs/branches by normalizing the report before upload.

Changes:

  • Adds a “Normalize SARIF report” step that copies the newest timestamped CVE Lite SARIF output to a stable cve-lite.sarif.
  • Strips partialFingerprints from SARIF results via jq so the upload action can compute consistent fingerprints.
  • Uploads SARIF only when a normalized report was actually produced.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

id: sarif
if: always()
run: |
file=$(ls -t cve-lite-scan-*.sarif 2>/dev/null | head -n 1)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/security.yml:
- Line 38: Update the SARIF file lookup assignment in the workflow step to
tolerate ls returning no matches under set -e and pipefail. Append a safe
fallback so file remains empty and the step continues when no
cve-lite-scan-*.sarif report is produced.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 79e78f5c-0780-493b-a0a9-e65bd2a42466

📥 Commits

Reviewing files that changed from the base of the PR and between 0b175e8 and bf6b993.

📒 Files selected for processing (1)
  • .github/workflows/security.yml

id: sarif
if: always()
run: |
file=$(ls -t cve-lite-scan-*.sarif 2>/dev/null | head -n 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Prevent step failure when no SARIF report is produced.

GitHub Actions runs bash scripts with set -e -o pipefail by default. If no cve-lite-scan-*.sarif files exist, ls will exit with a non-zero status. Due to pipefail, this causes the assignment and the entire step to fail immediately, breaking your intent to "skip gracefully when no report is produced".

Append || true to the assignment to safely catch the error and allow file to remain empty.

🐛 Proposed fix
-          file=$(ls -t cve-lite-scan-*.sarif 2>/dev/null | head -n 1)
+          file=$(ls -t cve-lite-scan-*.sarif 2>/dev/null | head -n 1) || true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
file=$(ls -t cve-lite-scan-*.sarif 2>/dev/null | head -n 1)
file=$(ls -t cve-lite-scan-*.sarif 2>/dev/null | head -n 1) || true
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/security.yml at line 38, Update the SARIF file lookup
assignment in the workflow step to tolerate ls returning no matches under set -e
and pipefail. Append a safe fallback so file remains empty and the step
continues when no cve-lite-scan-*.sarif report is produced.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Smaller bug fix or improvement size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants