Repository navigation
Fix #30: friendly error (exit 2) when --manifests path is missing or unreadable - #45
Conversation
rrskris
left a comment
There was a problem hiding this comment.
This is exactly the kind of error handling we want, @donkk11 — genuinely nice work. 👏
You didn't just print a friendlier message; you caught the subtle trap that Path.rglob() silently swallows EACCES during traversal, which would let an unreadable path masquerade as a clean (exit 0) scan. Probing readability explicitly with os.listdir/open is the correct fix, and the error message hits all three things a good error should — what's wrong, and the exact :z command to fix it. The tests exercising real chmod 000 conditions (with sensible skips for root / perm-less filesystems) are the right call over monkeypatching. Closes #30 cleanly.
One thing before I can merge: CI is green except DCO — your commits need a sign-off. Just run git rebase --signoff main (or git commit --amend -s if it's a single commit) and force-push; the -s adds the Signed-off-by: line the DCO check requires. Once that's green I'll merge it. Thanks for picking this up! 🙏
|
Hi @donkk11 — friendly nudge on this one. The code is approved and genuinely good (that That adds the |
8f5c9ce to
510ffbe
Compare
|
Thank you so much for the thoughtful review and the approval, @rrskris — really appreciate you taking the time, and glad the The DCO sign-off is pushed now ( Side note in case it's useful: the bug — Thanks again for the careful review — looking forward to getting this merged. 🙏 |
…ng or unreadable Wrapping root.exists() alone is insufficient: Path.rglob() swallows EACCES during traversal, so an unreadable directory would exit 0 with a false clean scan — the dangerous failure mode for a CI security gate. Adds an explicit readability probe (os.listdir on a dir, open on a file) before scanning and keeps streaming iteration. Includes regression tests exercising real chmod-000 conditions (not mocked). Built by Claude (Fable 5) under the Nkama contract; independently verified across two rounds by gpt-5.6-sol, which rejected the first version for silently reporting a clean scan on an unreadable directory and forced the fix before passing it. Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: gpt-5.6-sol <[email protected]> Signed-off-by: KK Nkama <[email protected]>
510ffbe to
fd234fa
Compare
|
One correction to make sure credit lands where it's due: I updated the commit (now The full picture — this was built by Claude (Fable 5) under the Nkama contract, then independently verified across two rounds by a separate model, gpt-5.6-sol. Round 1 was a genuine reject: it caught that an unreadable directory would silently report a clean scan (exit 0) instead of erroring — exactly the dangerous failure mode for a security-gate CLI. That forced the fix you see now, and only then did it pass verification in round 2. Didn't want the commit to read as single-model work when the adversarial check is what actually caught the bug before it reached you. Re-signed and pushed ( |
|
Merged — thank you @donkk11! 🎉 The chmod-000 regression tests were the deciding detail for me: an unreadable path silently producing exit 0 is exactly the failure a CI security gate can't afford, and now it's pinned by tests that exercise the real condition instead of mocks. You'll be credited in the next release notes. The Nkama verification story is genuinely interesting — an adversarial second-model reject catching the false-clean-scan path before review is the kind of thing I'd read a write-up on. If you're looking for a next one, #40 ( |
Follow-up to #59: the scheduled-scans docs now state the wgpolicyk8s.io CRD prerequisite with install one-liners (verified URLs) — without the CRDs the apply step fails with 'no matches for kind PolicyReport' on a fresh cluster. Fixes the stale bitnami/kubectl comment in cronjob.yaml, repairs escaped code fences and a stray list marker in the SARIF section, and adds CHANGELOG credits for #45 (@donkk11) and #59 (@Maqbool61). Signed-off-by: Vamshi Krishna Santhapuri <[email protected]>
Hi! Some honest context first: I'm not a developer by trade — I'm building an evidence-gated verification benchmark ("the Nkama way": AI work has to produce a re-runnable manifest of checks, and "blocked evidence is not success"). I came across kaaval, ran issue #30 through that workflow to see if it could genuinely help, and this is what came out — AI-assisted, then independently cross-checked by a second model. Please review critically; if it's not a fit, no hard feelings closing it.
The fix. When
--manifestspoints at a missing or unreadable path,build_graph_from_manifests()now emits a one-line error and exits2instead of surfacing a rawPermissionError/traceback — matching the format in the issue:One non-obvious gotcha worth calling out for a security scanner. Wrapping
root.exists()alone is insufficient: on a genuinely unreadable directory,Path.rglob()swallows theEACCESduring traversal, so_iter_manifest_docs()yields nothing and the CLI exits0with a false clean scan. For a CI gate, that's the dangerous failure mode — a pipeline passing because it scanned nothing. So the fix adds an explicit readability probe (os.listdiron a dir,openon a file) before scanning, and keeps the existing streaming iteration (no eagerlist()materialization).Tests. Adds
tests/test_cli_manifests_errors.py— 3 cases exercising the real conditions (missing path,chmod 000dir,chmod 000file), not monkeypatched errors, withskipif(root)guards. Full CLI suite green (12/12). Unrelated:test_login_and_self_scan(needs a live DB) also fails on a clean checkout — untouched here.Diff is small:
control-plane/app/cli.py(+readability probe) and the new test. Thanks for building kaaval — the contextual-risk-score idea is genuinely nice. Happy to adjust naming, message wording, or test placement to match your style.