Public: anyone can read this; the crew can change it.

Every kind of answer carries the security floor: one test fetches a page, JSON, media, a 404, a redirect and a stream #16554

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Adds media rows to the existing security-floor test. Most of #16301 was already on main: test/security-floor-kinds.test.ts (from #13674, #15777 and #15984) already fetches a page, JSON, a 404, redirects, an SSE stream, git smart-http, the MCP endpoint and static assets.

Notes

shipped production is serving it deploy 3256dd5

opened this

Adds media rows to the existing security-floor test. Most of #16301 was already on main: test/security-floor-kinds.test.ts (from #13674, #15777 and #15984) already fetches a page, JSON, a 404, redirects, an SSE stream, git smart-http, the MCP endpoint and static assets. It checks Content-Security-Policy, X-Content-Type-Options and Referrer-Policy on each answer, and a failure names the kind that lacks a header. What it never asked for was media, nor the byte-range answers the issue's risk note points at.

What changed: the test's forge now commits a PNG, a 1.1 MB MP4 and a text file. Five rows are added, each asked over plain http and over https:

  • a picture: /media/…/logo.png, 200, image/png
  • a byte range of a small file: 206, served from memory
  • a byte range of the large file: 206, video/mp4. The file is over the media route's 1 MB limit for reading whole, so this exercises the path that streams bytes from git with Content-Range.
  • a range past the end: 416, the reply that carries Content-Range: bytes */size
  • raw text: /raw/…/notes.txt, text/plain

The coverage test now also requires 206 and 416 statuses and at least three media rows.

Nothing needed fixing. Every new row already gets the headers from securityFloor in src/http/respond.ts, including the streamed and 416 answers, so no source file changed. I put the rows in test/security-floor-kinds.test.ts instead of creating the test/security-floor.test.ts the issue names, so all the kinds stay in one table. I reused the PNG and MP4 test files from test/media.test.ts rather than writing new ones.

Checks: bun test test/security-floor-kinds.test.ts passes (6 tests). bun scripts/gate.ts --fix changed nothing and bun x tsc --noEmit is clean.

To try: bun test test/security-floor-kinds.test.ts. To see a failure name its kind, remove the content-range line in the 416 branch of src/web/pages/media.ts and add headers.delete("referrer-policy") there. The test then fails with "media, 416 range past the end (416) lacks referrer-policy".

🤖 Generated with Claude Code

Closes #16301

commented

Adds media rows to the existing security-floor test. Most of #16301 was already on main: test/security-floor-kinds.test.ts (from #13674, #15777 and #15984) already fetches a page, JSON, a 404, redirects, an SSE stream, git smart-http, the MCP endpoint and static assets. It checks Content-Security-Policy, X-Content-Type-Options and Referrer-Policy on each answer, and a failure names the kind that lacks a header. What it never asked for was media, nor the byte-range answers the issue's risk note points at.

What changed: the test's forge now commits a PNG, a 1.1 MB MP4 and a text file. Five rows are added, each asked over plain http and over https:

  • a picture: /media/…/logo.png, 200, image/png
  • a byte range of a small file: 206, served from memory
  • a byte range of the large file: 206, video/mp4. The file is over the media route's 1 MB limit for reading whole, so this exercises the path that streams bytes from git with Content-Range.
  • a range past the end: 416, the reply that carries Content-Range: bytes */size
  • raw text: /raw/…/notes.txt, text/plain

The coverage test now also requires 206 and 416 statuses and at least three media rows.

Nothing needed fixing. Every new row already gets the headers from securityFloor in src/http/respond.ts, including the streamed and 416 answers, so no source file changed. I put the rows in test/security-floor-kinds.test.ts instead of creating the test/security-floor.test.ts the issue names, so all the kinds stay in one table. I reused the PNG and MP4 test files from test/media.test.ts rather than writing new ones.

Checks: bun test test/security-floor-kinds.test.ts passes (6 tests). bun scripts/gate.ts --fix changed nothing and bun x tsc --noEmit is clean.

To try: bun test test/security-floor-kinds.test.ts. To see a failure name its kind, remove the content-range line in the 416 branch of src/web/pages/media.ts and add headers.delete("referrer-policy") there. The test then fails with "media, 416 range past the end (416) lacks referrer-policy".

🤖 Generated with Claude Code

Approved

Test-only change that adds five media rows (picture, buffered range, streamed range off git, 416, raw text) to the existing security-floor table, over http and https. Tests pass here (6 pass). The three headers were already on every answer, so no source change is needed and none is hidden. Next two things I would do: (1) the first-line comment in the file now wraps awkwardly; reflow it. (2) Assert the 416 row also carries Content-Range, so the row proves it is the real range-refusal path.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs