Skip to content

fix(api): sanitize batch gather escapes, admin-route authz walk, production docs gate (audit G-5, G-4, G-2) - #219

Merged
brownjuly2003-code merged 5 commits into
mainfrom
fix/audit-grok-g4-g5-g2
Jul 20, 2026
Merged

fix(api): sanitize batch gather escapes, admin-route authz walk, production docs gate (audit G-5, G-4, G-2)#219
brownjuly2003-code merged 5 commits into
mainfrom
fix/audit-grok-g4-g5-g2

Conversation

@brownjuly2003-code

Copy link
Copy Markdown
Owner

Closes the three code findings from the 2026-07-20 deep audit.

G-5 (P3, S-2 residual): /v1/batch's gather fallback echoed str(outcome) to the client for any non-BatchResult outcome — the one error path that bypassed _safe_item_error. New _unexpected_outcome_error logs the raw text server-side under the correlation id and returns a generic batch item failed (ref ...). Unit test injects an exception carrying a fake DSN and asserts none of it reaches the response.

G-4 (P3, latent): admin paths skip the auth middleware by design, so a future /v1/admin router registered without Depends(require_admin_key) would ship fully open — the existing matrix test only pins the two known router objects. Added a walk over the assembled app flagging any admin-matching route (incl. mounts) without the dependency, plus a probe test that proves the checker can fail (mutation-verified locally: stripping the dependency from admin.py turns the walk red). No runtime change.

G-2 (P3): /docs, /redoc, /openapi* are auth-exempt, which on a production deploy hands any caller the full route map without a key. New production_docs_guard middleware 404s them when app.state.profile == "production" — same policy shape as the CORS-wildcard refusal (P2-3); demo/dev unchanged. OpenAPI schema itself is untouched (no route changes).

Local: ruff check/format clean; 128 tests green across the touched surfaces (batch, admin authz matrix, docs gate, openapi auth surface, CORS, api metrics, auth fail-closed, export-openapi, production boot gate).

🤖 Generated with Claude Code

…uction docs gate (audit G-5, G-4, G-2)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

DORA Metrics

  • Window: last 30 days
  • Branch: main
  • Deployment frequency: 118 total / 27.53 per week
  • Lead time for changes: avg 0.83h / median 0.0h
  • Change failure rate: 77.12% (91/118)
  • MTTR: 20.13h across 5 incident(s)

JuliaEdom and others added 4 commits July 20, 2026 19:35
…ck (audit G-8)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…odes

Local venv lagged uv.lock (fastapi 0.135/starlette 1.0 vs locked 0.139/1.3.1), so the
flattened-routes assumption passed locally and failed on CI; venv now synced to the lock
and the walk handles both shapes. Mutation-verified again (stripped dependency turns
the walk red).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@brownjuly2003-code
brownjuly2003-code merged commit 48492a1 into main Jul 20, 2026
26 checks passed
@brownjuly2003-code
brownjuly2003-code deleted the fix/audit-grok-g4-g5-g2 branch July 20, 2026 17:58
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