codeburn/tests/providers
iamtoruk 09965f93ae fix(dsh): cap zstd decode, coerce usage fields, scope the snap read
Security audit follow-ups on the DeepSeek Harness provider.

- **Decompression bomb.** Every zstd frame was decoded with no output bound, so
  a 16 KB crafted log expanded to ~916 MB of RSS (a 65 KB one declares 2 GB).
  Each frame now decodes under a 64 MB per-call cap, and the caps chain into a
  running per-file budget of MAX_SESSION_FILE_BYTES: a frame is given only the
  bytes the file has left, so node throws ERR_BUFFER_TOO_LARGE without
  allocating past the cap. The throw propagates out of the existing skip path,
  which discards the whole file rather than counting the frames read before the
  bomb, so a crafted tail cannot poison a partial total. The discovery header
  read takes the same per-frame cap. Measured on a 65 KB / 2 GB bomb: 916 MB
  -> 67 MB peak, zero calls emitted, one notice.
  Lines are still materialized eagerly; the byte budget bounds that, and making
  the read lazy would change readEventLines' contract for no further bound.
- **Usage type confusion.** Token fields were read with `?? 0` and never
  type-checked, so a string or array inputTokens flowed into the global totals
  and the persisted cache, where `0 + [1, 2]` becomes "01,2". They now go
  through numberOrZero (copilot.ts semantics: finite, positive, else 0).
  All-zero calls are still skipped.
- **Snap over-scope.** The personal-files read entry is `$HOME/.dsh/sessions`
  rather than all of `$HOME/.dsh`; the provider reads nothing else.
- **Third-party notice.** scanZstdFrames is transcribed from
  @deepseek-ai/dsh-session-persistence-jsonl. The published npm package is
  BSD-3-Clause (Copyright (c) 2026, DeepSeek) while the monorepo source
  declares MIT for the same package; THIRD_PARTY_NOTICES.md reproduces the
  stricter of the two and ships via package.json `files`.
2026-08-17 17:28:41 -07:00
..
antigravity.test.ts
claude-config-dirs.test.ts
cline-cli.test.ts
cline.test.ts
codebuff.test.ts
codewhale.test.ts
codex-resume.test.ts
codex.test.ts
copilot-skills.test.ts
copilot.test.ts
crush.test.ts
cursor-agent.test.ts
cursor-bubble-dedup.test.ts
cursor-large-db-cap.test.ts
cursor-real-tokens.test.ts
cursor-workspace-breakdown.test.ts
cursor.test.ts
devin.test.ts
droid.test.ts
dsh.test.ts
forge.test.ts
gemini.test.ts
grok.test.ts
hermes.test.ts
ibm-bob.test.ts
kilo-code.test.ts
kimi.test.ts
kimicode.test.ts
kiro.test.ts
lingtai-tui.test.ts
mistral-vibe.test.ts
mux.test.ts
omp.test.ts
open-design.test.ts
openclaude.test.ts
openclaw.test.ts
opencode-file.test.ts
opencode.test.ts
pi.test.ts
quickdesk.test.ts
roo-code.test.ts
vercel-gateway.test.ts
vscode-cline-parser.test.ts
warp.test.ts
zcode.test.ts
zed.test.ts
zerostack.test.ts