Skip to content

Fix #40: --version flag; Fix #2: JUnit XML output - #81

Merged
rrskris merged 1 commit into
kaaval:mainfrom
donkk11:fix/cli-version-and-junit
Jul 18, 2026
Merged

rrskris merged 1 commit into
kaaval:mainfrom
donkk11:fix/cli-version-and-junit

Conversation

@donkk11

@donkk11 donkk11 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • CLI: add a --version flag #40 — kaaval --version now prints a real version, sourced from one place (app/__init__.py's __version__). Also fixes the stale hardcoded "1.0.0" in main.py (FastAPI app + /health endpoint) the issue called out — both now read the same constant.
  • Add JUnit XML output to the CLI (GitLab/Jenkins) #2 — --output junit emits JUnit XML, built on the same _finding_rows normalizer SARIF already uses. A clean scan emits one passing <testcase> rather than an empty suite (avoids the report looking broken in CI).

Verified (not assumed)

Ran locally against a real python3.11 venv with the actual dependencies installed:

  • python -m app.cli --version → kaaval 1.1.0, exit 0
  • --output junit against hack/dev/rbac-fixtures.yaml → 20 real findings as 20 <failure> testcases; parsed back with xml.etree.ElementTree to confirm well-formed XML
  • --output junit against a clean manifest → 1 passing testcase, tests="1" failures="0"

Test plan

  • CI green
  • Maintainer spot-check of the JUnit output shape against their GitLab/Jenkins consumers

🤖 Generated with Claude Code

- app/__init__.py: single __version__ = "1.1.0" source of truth
- cli.py: --version prints "kaaval 1.1.0", exits before subcommand check
- main.py: FastAPI app version + /health endpoint now read __version__
  instead of two separate hardcoded "1.0.0" strings (the stale hardcode
  kaaval#40 called out)
- cli.py: --output junit emits JUnit XML via _finding_rows (the same
  normalized-row helper SARIF already uses) so GitLab CI / Jenkins render
  findings in their native test-report panes; a clean scan emits one
  passing testcase instead of an empty suite

Verified locally (python3.11 venv, real deps installed, not assumed):
- `python -m app.cli --version` -> "kaaval 1.1.0", exit 0
- `--output junit` against hack/dev/rbac-fixtures.yaml -> 20 real
  findings as 20 <failure> testcases, well-formed (parsed back with
  xml.etree.ElementTree)
- `--output junit` against a clean manifest -> 1 passing testcase,
  tests="1" failures="0"

Co-Authored-By: Claude <[email protected]>
Signed-off-by: KK Nkama <[email protected]>
@donkk11

donkk11 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

Merged the lesson from #45 straight into the next one, @rrskris 🙏

#40 and #2 are both done — this PR.

  • --version now prints a real version (kaaval 1.1.0), sourced from one place so it can't go stale again the way the 1.0.0 hardcode had.
  • --output junit is in, using the same row-normalizer SARIF already relies on. A clean scan emits one passing testcase instead of an empty suite.

Same discipline as last time — I didn't just say it works. I had a second, independent model (Codex) check it from scratch, with no access to my reasoning, just the branch. It reproduced everything itself and landed on the same result — and along the way it caught something I'd missed: hack/dev/rbac-fixtures.yaml's own comment says safe-viewer "must produce ZERO findings," but the scanner actually flags it with a Segmentation Violation. Unrelated to this PR, but a real mismatch between the fixture's docs and current behavior — flagging it in case it's worth a look.

One thing before you review: I noticed #2 is still assigned to @Garifallos from a couple weeks back, with no PR from them yet. I don't want to step on that — happy to have this PR stand as reference/backup if they're still working on it, or happy for it to just land if they've moved on. Your call, whichever's kinder to everyone's time.

@rrskris rrskris left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified locally, not just read: kaaval --version → kaaval 1.1.0 exit 0; --output junit against hack/dev/rbac-fixtures.yaml → 20 findings as well-formed <failure> testcases (parsed back with ElementTree); clean manifest → tests="1" failures="0" single passing case — the empty-suite-looks-broken guard is a thoughtful touch. Single-sourcing the version and catching the stale 1.0.0 in both main.py spots was exactly what #40 wanted. Full suite green at 62.59% coverage.

One gap, and it's on the house: no shape tests for the new emitter — SARIF and PolicyReport each have one, and JUnit deserves the same lock. Merging now and pushing the two tests (junit shape + --version) as a follow-up credited to this PR, so the next change to _finding_rows can't silently break your output. Two solid issues closed in one PR — thanks @donkk11. 🎉

@rrskris
rrskris merged commit 20c11e4 into kaaval:main Jul 18, 2026
7 checks passed
rrskris added a commit that referenced this pull request Jul 18, 2026
Follow-up to #81 as promised in review: locks the JUnit emitter's shape
(testsuite counts, classname prefix, failure message/body, clean-scan
single passing case) and the single-sourced --version output, matching
the coverage SARIF and PolicyReport already have. Credits @donkk11 in
the changelog.

Signed-off-by: Vamshi Krishna Santhapuri <[email protected]>
rrskris added a commit that referenced this pull request Jul 26, 2026
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]>
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.

2 participants