Skip to content

feat: add RBAC scan diff endpoint - #82

Merged
rrskris merged 1 commit into
kaaval:mainfrom
floze-the-genius:agent/rbac-scan-diff
Jul 19, 2026
Merged

rrskris merged 1 commit into
kaaval:mainfrom
floze-the-genius:agent/rbac-scan-diff

Conversation

@floze-the-genius

Copy link
Copy Markdown
Contributor

What this changes

  • adds diff_latest_scans(db) over the two newest persisted RBAC scans
  • keys findings by (rule_type, role.name, binding.name)
  • exposes authenticated GET /rbac/scan/diff
  • returns stable empty diff data when fewer than two scans exist
  • adds unit and API regressions for added, resolved, unchanged, empty, missing, and duplicate-key cases

Closes #4.

Type

  • New detection rule / finding source
  • Bug fix
  • Feature
  • Docs
  • Refactor / chore

Checklist

  • make test passes
  • Added/updated tests for the behavior change
  • New rule ships with a remediation and a verified benchmark citation (not applicable: no new rule)
  • Added a fixture to hack/dev/rbac-fixtures.yaml if it's a new rule (not applicable)
  • Docs updated (not applicable: endpoint contract is covered by OpenAPI and issue scope)
  • Conventional commit messages

How you verified it

  • KAAVAL_ADMIN_PASSWORD=test-admin-password make test - 75 passed
  • CI-equivalent backend gate with PostgreSQL 16 and coverage - 75 passed, 63.60% coverage (60% required)
  • focused regression suite - 7 passed
  • npm run lint - 0 errors (7 existing hook dependency warnings)
  • npm run build - production build and TypeScript passed
  • targeted Ruff, Mypy, compileall, and git diff --check passed

AI assistance

Implemented with OpenAI Codex. I reviewed the diff and validated all behavior and checks listed above.

@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.

Thanks — this is a clean implementation of #4, and it matches the issue spec exactly (same key tuple, stable empty-diff contract).

Verified locally on your branch: full suite 75 passed. The fake-session unit tests plus the API-level contract tests are exactly the shape I want for service-layer features.

One product nuance I noticed, not a blocker: because findings are keyed by (rule_type, role.name, binding.name), a finding whose severity escalates between scans (e.g. HIGH → CRITICAL on the same role/binding) lands in unchanged_count — so severity escalations won't surface as "new". That's fine for v1 of this endpoint; I'll file a follow-up issue for a severity_changed bucket.

CI needs my manual approval since this is your first PR here — kicking that off now. Once it's green this merges. Appreciated!

@floze-the-genius

Copy link
Copy Markdown
Contributor Author

Thanks for the approval. The remaining CI, DCO, and CodeQL workflows are still in action_required because this is a first-time-contributor fork. Could a maintainer approve runs 29659430459, 29659430394, and 29659430429 when convenient? No code changes are pending from my side.

@rrskris

rrskris commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Done — runs approved for this PR (and your #100, plus girosole60's PRs while I was at it). CI is running now; once it's green this merges. Thanks for the patience, and for picking up #99 so quickly.

@rrskris
rrskris merged commit 370e98a into kaaval:main Jul 19, 2026
7 checks passed
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]>
rrskris added a commit that referenced this pull request Aug 5, 2026
@floze-the-genius shipped three PRs, but only the bugfix (#100) appeared in the
changelog — the two features it built on, GET /rbac/scan/diff (#82) and the
kaaval doctor preflight (#80), were missing entirely. Anyone reading the release
notes would see the fix to a feature whose arrival was never recorded.

Scope of each entry was taken from the merge commits rather than the issue
titles: #80 adds the CLI command and typed health results on top of the deep
health checks that #75 already provided, so it is credited for the wrapper it
actually wrote, not for the checks themselves.

Prep for the v1.2.0 release notes, so the credit ships in the release rather
than as a later correction.

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.

Add GET /rbac/scan/diff (alert on new findings only)

2 participants