Skip to content

Add review_sarif for SARIF 2.1.0 CI code scanning - #171

Open
thongtuehuu-cyber wants to merge 1 commit into
prooflinedev:mainfrom
thongtuehuu-cyber:feat/review-sarif
Open

thongtuehuu-cyber wants to merge 1 commit into
prooflinedev:mainfrom
thongtuehuu-cyber:feat/review-sarif

Conversation

@thongtuehuu-cyber

Copy link
Copy Markdown

Summary

Add proofline.review_sarif(outcome, *, include_resolved=False) to render a ReviewOutcome as a deterministic SARIF 2.1.0 document ready for GitHub Code Scanning (github/codeql-action/upload-sarif) and other SARIF-compatible CI consumers.

Why & Who This Helps

  • Teams running Proofline in GitHub Actions want findings surfaced directly in the Security / Code Scanning tab alongside existing checks without writing custom glue scripts.
  • Preserves Proofline's core evidence-completeness contract: runs[0].invocations[0].executionSuccessful is true only when outcome.status == "COMPLETED" and outcome.gaps is empty. Any INCOMPLETE, FAILED, STOPPED, TIMED_OUT, or gap-bearing review sets executionSuccessful: false and emits structured toolExecutionNotifications so CI never misinterprets an incomplete run as zero risk.

How It Was Built

  • Added proofline/sarif.py (zero new dependencies, strictly typed, compliant with scripts/contracts.py vocabulary rules):
    • Maps ENV-lane assessments and CODE-lane fallback findings (CustomerFinding) with severity (SERIOUS/HIGH -> error, WARNING/MEDIUM -> warning), rule IDs (rule_refs or proofline/<risk_domain>), primary repository_file locations + relatedLocations, and retained finding_fingerprint (partialFingerprints, omitted when absent — never synthesized).
    • Omits RESOLVED findings by default (include_resolved=True opts in), omits [withheld: environment value] findings with an explicit warning notification, and rejects .. path traversal in artifact URIs.
    • Sorts rules and results deterministically for byte-stable output.
  • Exported review_sarif from proofline/__init__.py.
  • Added unit tests in tests/test_sarif.py covering ENV findings, include_resolved, incomplete/gap notifications, CODE-lane fallback, withheld findings, path traversal rejection, and input validation.

Verification

  • python scripts/generate.py --check (exit 0)
  • python scripts/contracts.py (exit 0)
  • python -m ruff check . & python -m ruff format --check . (exit 0)
  • python -m mypy proofline scripts — 0 issues in 254 source files (exit 0)
  • python -m pytest -q — 240 passed (exit 0)

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant