Skip to content

fix: close the defects a seventh audit found - #8

Merged
dinhdev666 merged 1 commit into
mainfrom
fix/close-seventh-audit
Nov 24, 2026
Merged

dinhdev666 merged 1 commit into
mainfrom
fix/close-seventh-audit

Conversation

@dinhdev666

Copy link
Copy Markdown
Owner

A seventh audit of the gateway, the engine, the dashboard and the docs. Each fix has a test that fails without it.

Security / auth

  • The gateway key hook compared request.url against /v1/, but the router decodes each segment before matching: POST /%76%31/chat/completions reached the handler with no credential (404 where every plain spelling answered 401). src/http/request-path.js now decodes segment by segment, after the query is stripped.
  • SESSION_FREE_PATHS was compared against the target as it arrived while the router runs with ignoreTrailingSlash, so POST /api/auth/login/ could never succeed and POST /api/auth/logout/ answered 401 without clearing the stale cookie.
  • An unknown command-line option was ignored and the router booted; it is now refused with exit 2.

Wrong numbers

  • GET /metrics reported every provider as enabled (the gauge read a field liveStats() never sets).
  • /api/overview drew a green dot on a disabled provider while the KPI in the same payload read 0 available.
  • hasUsageOption was re-derived from the raw body, so "true" and 1 were recorded as "not asked".

Resource handling

  • The CSV export hijacked the reply and never handed the connection back, so socket.gatewayBusy stayed set and later parser errors on that socket got a bare close (invariant 14).
  • A streaming client that stopped reading was warned about and abandoned; the response is now destroyed when the deadline expires.

Dead code and lying comments

  • authRequirement() (never called, with a comment claiming a test asserted it), an unreachable URL-validation branch, and three comments that stated the opposite of their code.

Docs and dashboard

  • README no longer lists not_found as an error code; CONTRIBUTING.md no longer claims merge commits are judged on GitHub's generated title.
  • METRICS_ENABLED was a runtime key in no Settings group (the page discarded it); the Logs body disclosure carries aria-expanded; two hard-coded strings moved into the copy table.

Verified: pnpm run check, typecheck, test:web (17), test:unit (483 checks), SMOKE_SLOW=1 pnpm test:smoke (394 checks), pnpm run build. Docker image not built - no Docker here.

A seventh audit of the gateway, the engine, the dashboard and the docs found
ten defects; each fix below has a test that fails without it.

The gateway key hook compared `request.url` against `/v1/`. The router splits
the raw target on `/` and decodes each segment before it matches, so
`POST /%76%31/chat/completions` is the completion route while the raw string
carries the escapes: the hook matched nothing and the request reached the
handler with no credential (`404 endpoint_not_available` where every plain
spelling answered `401`). `src/http/request-path.js` now decodes segment by
segment, after the query is stripped so an escaped `?` cannot fabricate one,
and leaves an undecodable segment as it arrived rather than throwing on a
public route.

- `GET /metrics` reported every provider as enabled: the gauge was derived from
  a field `liveStats()` never set, so `enabled - available` - the "how many are
  unhealthy" expression - read 1 for a fleet with nothing enabled.
- `/api/overview` built its health row from `snapshot.available`, which ignores
  `enabled`, and drew a green dot on a disabled provider beside a KPI in the
  same payload that read 0 available.
- The CSV export hijacks the reply and returned without handing the connection
  back, so `socket.gatewayBusy` stayed set and every later parser error on that
  keep-alive socket got a bare close instead of the documented envelope.
- `SESSION_FREE_PATHS` was compared against the target as it arrived, while the
  router runs with `ignoreTrailingSlash`: `POST /api/auth/login/` could never
  succeed and `POST /api/auth/logout/` answered 401 without clearing the stale
  cookie it exists to clear.
- A streaming client that stopped reading was warned about and then abandoned:
  `noteGone()` stops writing and nothing closed the response, so the socket
  stayed open with the unwritten bytes buffered and the client hung until its
  own timeout. The deadline now destroys it.
- `hasUsageOption` was re-derived from the raw body with `=== true`, so the
  spellings `parseBool` accepts (`"true"`, `1`) were recorded as "not asked".
- An unknown command-line option was silently ignored and the router booted; it
  is now refused with exit 2 and the usage line.
- `authRequirement()` was dead code whose comment claimed a test asserted it;
  the URL validator carried an unreachable branch; three comments stated the
  opposite of their code (the queue's release contract, `cooldownMs` on a
  classification, and a method that does not exist by that name).
- The README listed `not_found` as an error `code` the router never sends, and
  CONTRIBUTING.md claimed merge commits are judged on GitHub's generated title
  when the checker excludes them on purpose.
- `METRICS_ENABLED` was a runtime key that appeared in no Settings group, so the
  dashboard discarded the row and the endpoint could not be switched from the
  UI. The Logs drawer's body disclosure carried its state only as a rotated
  chevron, with no `aria-expanded`, and printed `yes`/`no` where the copy table
  has `Yes`/`No`; the Models badge kept its own copy of `default`.

Verified: `pnpm run check`, `pnpm run typecheck`, `pnpm run test:web` (17),
`pnpm test:unit` (483 checks), `SMOKE_SLOW=1 pnpm test:smoke` (394 checks),
`pnpm run build`. The Docker image was not built - no Docker here.
@dinhdev666
dinhdev666 merged commit 1660108 into main Nov 24, 2026
6 checks passed
@dinhdev666
dinhdev666 deleted the fix/close-seventh-audit branch November 24, 2026 06:25
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