Repository navigation
Add SARIF output to CLI (#1) - #10
Conversation
rrskris
left a comment
There was a problem hiding this comment.
Thanks @Diyaaa-12 — genuinely strong first PR. 🙌 The SARIF is valid and GitHub will accept it, you added a real shape test, updated the docs, and nicely factored out _finding_rows() so #2 (JUnit) can reuse the normalization — exactly the coordination we were hoping for. A few things to tighten before merge:
Should fix
1. Rule descriptions are instance-specific — cli.py, the rules_by_id dedup in _print_sarif. Because it takes the first finding's title, the rule-level metadata comes out as e.g. "Cluster Admin Binding via ClusterRole 'wide-open'" — a specific role name leaks into what should be a general rule description. In the Security tab a rule should describe the rule, not one instance. Use a generic description per rule_type (the humanized rule_type works well) and keep the instance detail in the result message, which you already do correctly.
2. Dispatch indentation — cli.py, the if/elif/else on args.output. The bodies are indented 6 spaces; it's valid Python but not a multiple of 4 and inconsistent with the rest of the file (flake8 E111). Please bump them to 8 spaces to match.
Nits
- PEP8 blank lines: two blank lines before
_SEVERITY_TO_SARIF_LEVEL,_print_sarif,_apply_gate, and before the new test function (E302/E305). - Add a trailing newline to
test_cli.pyanddocs/ci-integration.md(W292). result.taxareferences a taxonomy that isn't declared underrun.taxonomies, so the CIS refs are technically dangling (GitHub tolerates it, so this is optional). Simplest fix: move the CIS refs intoresult.propertiesinstead oftaxa.- Docs: add
if: always()to theupload-sarifstep so findings still reach the Security tab when the gate exits 1 — that's exactly the case you most want visible.
Optional: _finding_rows() carries a SARIF-specific level field — fine to leave since #2 can ignore it; just flag it when you and @Garifallos align on the shared shape.
Once the two Should fix items are in, I'll approve the CI run and we'll merge. Really nice, well-tested work — this sets a good template for the other formatters.
|
Addressed both should-fix items and all nits:
All 10 tests passing locally. Ready for another look 🙏 |
|
Heads-up @Diyaaa-12 — the project was renamed today: Argus is now Kaaval (details pinned in Discussion #13). Nothing changes for your PR's substance, and GitHub redirects your existing remote automatically. Two small things when you push your next revision:
Also note: we now require DCO sign-off on new commits — just add |
|
@rrskris quick check before I finish this — should I also rename the |
|
Good question @Diyaaa-12 — you don't need to rename anything yourself. The rename has already fully landed on So the only thing to do is rebase your branch onto current One more thing since the rebase rewrites your commits anyway: we now require DCO sign-off, so re-commit with |
Signed-off-by: Diya Maheshwari <[email protected]>
…move CIS refs to properties Signed-off-by: Diya Maheshwari <[email protected]>
Signed-off-by: Diya Maheshwari <[email protected]>
Signed-off-by: Diya Maheshwari <[email protected]>
Signed-off-by: Diya Maheshwari <[email protected]>
b9cc822 to
7904964
Compare
|
Rebased with |
|
Also noticed the CI checks are waiting on workflow approval let me know if that needs anything from my side, otherwise just flagging in case it got missed |
rrskris
left a comment
There was a problem hiding this comment.
Thanks for the fast turnaround @Diyaaa-12 — the structure is right where we want it: _finding_rows() is exactly the seam #2 (JUnit) needs, the shape test is solid, and the gate-semantics assertion at the end is a thoughtful touch. CI is green (the workflow-approval wait you flagged was on our side — done, nothing needed from you). Three small fixes and this is mergeable.
Your rebase question: your local origin points at your fork, and forks don't follow this repo automatically — that's why your origin/main still shows 69efa8d. Fix:
git remote add upstream https://github.com/kaaval/kaaval.git
git fetch upstream
git rebase upstream/main --signoff
(or click "Sync fork" on your fork's GitHub page first). GitHub tests your PR against the real main, so nothing was actually broken — but your local tree was pre-rename, which is exactly why the docs lines below came out with the old names.
Non-blocking follow-up (I'll file it as an issue): GitHub ranks code-scanning alerts by a security-severity property on each rule — our Contextual Risk Score is the natural feed for it, which would make the Security tab sort by our ranking. Deserves its own small PR, not this one.
| "id": row["rule_id"], | ||
| "name": row["rule_id"], | ||
| "shortDescription": {"text": _humanize_rule_type(row["rule_id"])}, | ||
| "helpUri": "https://github.com/rrskris/Kaaval", |
There was a problem hiding this comment.
https://github.com/rrskris/Kaaval doesn't exist (404) — the repo is https://github.com/kaaval/kaaval. Even better for helpUri: point it at the rule catalog, https://github.com/kaaval/kaaval/blob/main/docs/rbac-rules.md — that's the "tell me more about this rule" link GitHub shows next to each alert.
| "tool": { | ||
| "driver": { | ||
| "name": "Kaaval", | ||
| "informationUri": "https://github.com/rrskris/Kaaval", |
There was a problem hiding this comment.
Same here — informationUri should be https://github.com/kaaval/kaaval.
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) | ||
| sys.exit(main()) No newline at end of file |
There was a problem hiding this comment.
The file lost its trailing newline in this revision — please restore it (newline after sys.exit(main())).
| ## GitHub Actions — SARIF upload to Security tab | ||
|
|
||
| \`\`\`yaml | ||
| - name: Run Argus RBAC scan |
There was a problem hiding this comment.
This new section was written against the pre-rename tree — Run Argus RBAC scan → Run Kaaval RBAC scan here, and --context-file argus.yaml → kaaval.yaml on line 220. (The rest of the file was renamed on main already; only these new lines need it.)
| @@ -1,5 +1,5 @@ | |||
| """ | |||
| Unit tests for the headless CLI — manifest→graph parsing, context loading, | |||
| Unit tests for the headless CLI -- manifest to graph parsing, context loading, | |||
There was a problem hiding this comment.
Please restore the original docstring (— manifest→graph parsing) — the em-dash and arrow are intentional and the file is UTF-8, so there was no encoding issue. Keeps the diff focused on SARIF.
Signed-off-by: Vamshi Krishna Santhapuri <[email protected]> # Conflicts: # control-plane/app/cli.py # control-plane/tests/test_cli.py
|
Heads-up @Diyaaa-12 — #39 (PolicyReport output) landed on Your branch history is intact — just |
…, fix new docs lines, revert docstring Signed-off-by: Diya Maheshwari <[email protected]>
|
All four review items addressed:
All 11 tests passing locally, verified the file is proper UTF-8 with Ready for another look |
rrskris
left a comment
There was a problem hiding this comment.
All five items addressed and verified against the actual files — helpUri now points at the rule catalog, informationUri at the repo, trailing newline restored, the new docs section uses Kaaval/kaaval.yaml, and the docstring is back to the original. CI green across the board. Genuinely nice first contribution, @Diyaaa-12 — the _finding_rows() factoring is exactly the seam the JUnit work (#2) needed. Merging. 🎉
|
Merged — and this is a milestone worth marking: Kaaval's first community-contributed feature is live. 🎉 Thank you, @Diyaaa-12. SARIF output means anyone running Kaaval in a GitHub Actions pipeline now gets findings right in their Security tab, ranked by contextual score. You've also unblocked the next one: the |
|
Thank you so much, this really means a lot! 🙏 Glad the _finding_rows() refactor turns out to be useful for the JUnit XML work too, happy it lines up well. |
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]>
What this changes
Adds a
sarifoutput mode to the CLI so RBAC scan findings can be uploaded toGitHub's Security tab via
github/codeql-action/upload-sarif. Each finding ismapped to a SARIF 2.1.0
result(ruleId=rule_type, level derived fromseverity, message from the remediation action), with one
ruleper uniquerule_typeundertool.driver.rules, and CIS benchmark refs surfaced intaxa. Also factors out a shared_finding_rows()helper so the JUnit XMLformatter in #2 can reuse the same finding→row normalization instead of
duplicating it.
Closes #1
Type
Checklist
make testpasses (ran viapytest tests/test_cli.py— nomakeavailable locally on Windows, used pytest directly)(exact CIS Kubernetes Benchmark version + ID, or a primary source — not
an invented ID)
hack/dev/rbac-fixtures.yamlif it's a new ruleupload-sarifsnippet)How you verified it
Ran:
python -m app.cli scan rbac --manifests hack/dev/rbac-fixtures.yaml --output sarif
— produced valid SARIF 2.1.0 output:
$schema/versionpresent, onetool.driver.rulesentry per distinctrule_type(10 rules for the existingfixtures), and one
results[]entry per finding with correctruleId,level(error/warning per severity),message.text,locations, and CIStaxarefs.Also ran:
pytest tests/test_cli.py -v
— 10/10 passing, including a new
test_sarif_output_is_valid_shapetestasserting
$schema,version,runs[0].tool.driver.rules, andruns[0].resultsare present and correctly shaped.