Repository navigation
sarif: feed GitHub security-severity from Contextual Risk Score - #56
Conversation
Closes kaaval#32 Signed-off-by: Diya Maheshwari <[email protected]>
f0c5976 to
fc11c34
Compare
rrskris
left a comment
There was a problem hiding this comment.
Back for round two and it shows — this is clean work, @Diyaaa-12. 🙌 Tracking the per-rule max and setting security-severity from it is exactly right (GitHub ranks alerts by that number), the helper is well-documented, DCO's signed, CI's green. One correctness fix and it's in.
The score_cap is wrong — and that's my fault, not yours. My issue #32 said 'score cap ~15', but I gave you a bad number. The real maximum of the Contextual Risk Score is 38.9: base CRITICAL 9.5 × environment 1.5 × data 1.5 × compliance 1.3 × exposure 1.4 (see scoring.py — the score is just that product, no clamp). You can confirm it in the dashboard screenshots in the README: the top finding scores risk 38.9.
With cap = 15, everything scoring 15 or above pins to 10.0 — and in a real production/PCI context most CRITICAL and HIGH findings clear 15 easily. So a 38.9 cluster-admin binding and a 16 wildcard both emit 10.0, and GitHub can no longer order them. That quietly erases the contextual ranking that's the whole point of the tool — the thing your SARIF output exists to surface.
The fix: map against the true maximum so GitHub's ordering mirrors Kaaval's. Rather than hardcode 38.9 (which drifts if the weights ever change), the robust move is a single source of truth in scoring.py — e.g. a MAX_CONTEXTUAL_SCORE constant computed from the weight maxima (max(_SEVERITY_BASE.values()) * max(_ENV_WEIGHT.values()) * max(_DATA_CLASS_WEIGHT.values()) * 1.3 * max(_EXPOSURE_WEIGHT.values())) — then import it here as the cap default. If you'd rather keep it simple, a documented score_cap = 38.9 with a comment pointing at the formula is fine too. Your call.
Everything else is good to go. Thanks for pushing this one — and sorry for the bum number in the issue. 🙏
Addresses review on kaaval#56 — score_cap was 15.0 but the true max of the Contextual Risk Score is ~38.9 (9.5 x 1.5 x 1.5 x 1.3 x 1.4). At 15, most CRITICAL/HIGH findings in production clamped to 10.0, collapsing GitHub's contextual ordering. MAX_CONTEXTUAL_SCORE is now derived from the weight maxima in scoring.py as a single source of truth. Signed-off-by: Diya Maheshwari <[email protected]>
rrskris
left a comment
There was a problem hiding this comment.
Verified the fix: MAX_CONTEXTUAL_SCORE derived from the weight maxima in scoring.py as the single source of truth, imported as the cap default, per-rule max feeding security-severity, and the range test locks it in. I confirmed the 1.3 compliance factor against scoring.py:45. CI and DCO green. This is exactly the robust option — merging. 🎉
Thanks for the patience on round three, @Diyaaa-12 — and again, the bad cap number in #32 was mine. You'll be in the release notes.
Signed-off-by: Vamshi Krishna Santhapuri <[email protected]>
The architecture diagram still labelled SARIF as "(#1, in review)" and JUnit XML as "(#2)", and the CI-integration roadmap paragraph listed both plus the scan-diff endpoint as planned. All three have shipped (#10/#56, #81, #82). Also fixes two stale references found while verifying the above: - the `--output` flag table omitted `sarif` and `junit`, though the CLI has accepted both for several releases (`app/cli.py` choices) - `docs/api.md` did not document `GET /rbac/scan/diff` at all Prometheus /metrics (#3) and the Helm chart (#8) remain the open roadmap items, so they stay under "planned next". Signed-off-by: Vamshi Krishna Santhapuri <[email protected]>
Closes #32
What this changes
Feeds GitHub's
security-severityproperty in SARIF rule output fromKaaval's Contextual Risk Score, so the Security tab sorts alerts by what
the finding means for your cluster instead of just error/warning/note.
_contextual_score_to_security_severity()helper: scales thecontextual score (0..15 cap) to GitHub's expected 0.0-10.0 CVSS-style
string.
_print_sarif(), each rule'ssecurity-severityis set from themax contextual score across that rule's findings.
levelmapping (error/warning/note) is unchanged — security-severityis additive, per GitHub's SARIF spec.
Type
Checklist
make testpasses(exact CIS Kubernetes Benchmark version + ID, or a primary source — not
an invented ID)
hack/dev/rbac-fixtures.yamlif it's a new ruleHow you verified it
Ran
python -m pytest tests/test_cli.py -v— all 12 tests pass, includinga new
test_sarif_output_security_severity_is_validthat assertssecurity-severityis present on every rule and parses as a float in[0, 10]. Also ran
python -m app.cli scan rbac --manifests <risky_dir> --output sarifand confirmed each rule'spropertiesblock now carriessecurity-severity.