Skip to content

fix(repo): harden gateway, admin, dashboard and CI after audit - #5

Merged
dinhdev666 merged 6 commits into
mainfrom
fix/audit-hardening
Dec 6, 2026
Merged

dinhdev666 merged 6 commits into
mainfrom
fix/audit-hardening

Conversation

@dinhdev666

Copy link
Copy Markdown
Owner

Full-repository audit follow-up: 62 findings across gateway, admin/db, dashboard and tooling, plus four small features. Every item is implemented, unit-tested and covered end to end.

Gateway (src/gateway/**, src/util/**)

  • retry-after capped at 1 h; monotonic provider cooldown (paired with the db change)
  • every 5xx is retryable (docs and code now agree)
  • terminal failures keep provider attribution in the log row and the x-opencode-router-* headers
  • upstream error text: control-char stripped, clamped to 500 chars, provider key scrubbed, unknown type -> api_error
  • activeRequests counted once per request for every /v1/* route (models path included)
  • raw-vs-normalized body decision via an explicit flag (no double JSON.stringify of a 128 MB body)
  • buffered response decoded once, optional upstream_response_max_bytes cap (502 upstream_response_too_large)
  • complete SSE frame boundaries (\r\n\n, \n\r\n, \r\r) and multi-line data: x_opencode stripping
  • client query string forwarded; baseUrl query preserved; identity/attribution headers allowlisted
  • invalid provider keys fail with a fixed 502 invalid_provider_credentials instead of leaking the key
  • 413 payload_too_large, 405 + Allow, reply.status() no-op fixed

Admin / db (src/admin/**, src/db/**)

  • apiKey validation (printable ASCII, length), extended SSRF ranges (CGNAT, benchmarking, IPv6 specials), scheduler/probe path now guarded
  • sync no longer prunes the catalog on an unrecognized upstream body; bare sync covers every enabled provider and records provider health
  • scheduler probe cursor (no starvation), dispose() in finally, cooldown probe guard
  • CSRF veto on session-authenticated mutations; global login cap 500 (per-IP stays 10)
  • percentiles from one ordered pass; PRAGMA busy_timeout; transactional prune/clear; model filter is a contains match; /audit + /activity validate limit
  • GET /admin/api/diagnostics (new), resilient on a partially initialized database
  • default-password startup warning

Dashboard (web/**)

  • destructive "clear logs" flow, bulk-selection pruning, success-rate placeholder, sync-picker fix, shareable log URLs + saved views
  • focus ring and --fg-subtle contrast raised above WCAG minimums, field errors/switches exposed to assistive tech, modal scroll-lock refcount, live relative timestamps
  • realtime poll in-flight/abort/order guards, stale session cleared on 401, 29 dead exports removed
  • first dashboard unit tests (pure logic extracted into web/src/lib/*)

Tooling / CI / docs

  • pnpm verify local gate; negative --self-test for both enforcement scripts wired into CI
  • check-docs now scans all of src/**, all quote styles and explicit method: options; new .env.example parity checker
  • commit linter --single <sha> (fails on merge commits) used by the all-zero CI fallback; CI smoke test passes DATA_DIR; screenshot Chrome guard hardened
  • docs/SPEC.md / docs/API.md updated for every contract change above; stale ownership table removed

Verification

pnpm verify green locally: typecheck, 436 unit tests, no doc drift, build, 108/108 e2e checks. Enforcement self-tests verified to fail when inverted.

@dinhdev666
dinhdev666 merged commit d4ebc03 into main Dec 6, 2026
3 checks passed
@dinhdev666
dinhdev666 deleted the fix/audit-hardening branch December 6, 2026 15:30
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.

1 participant