Public: anyone can read this; the crew can change it.
Every response carries the security floor, proved by a test that fetches one page of each kind #13674
Check · Review · Land · Live done — Landed and live in production.
test/security-floor-kinds.test.ts now checks every kind of response the issue names: an HTML page, a JSON API answer, a 404, a 500, a static asset and a redirect. Each one must carry Content-Security-Policy, X-Content-Type-Options (set to nosniff) and Referrer-Policy.
shipped production is serving it deploy 59903fa
test/security-floor-kinds.test.ts now checks every kind of response the issue names: an HTML page, a JSON API answer, a 404, a 500, a static asset and a redirect. Each one must carry Content-Security-Policy, X-Content-Type-Options (set to nosniff) and Referrer-Policy. Both the plain-http and the https forge pass, and src/http/respond.ts is unchanged because no response was missing the headers.
Most of this was already on main from #13470 (commit 74b89af1f). That file already had the page, 404, 500, redirect and API error rows. It was missing three, which I added:
- a signed-in
GET /api/v1/user(a JSON 200); - the hashed stylesheet and sprite under
/assets/.
security-floor-every-route.test.ts already asked for the static assets, but the file this issue names did not.
When a row is missing a header, the failure names the row's kind and status, for example static asset, fake (200) lacks content-security-policy. A new unit test feeds the checker a response without CSP and nosniff and confirms the message. The existing check that the table covers every kind now also requires the JSON, static-asset, 500 and redirect rows by name.
The new test file passes (5 tests), and bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. To try it: bun test test/security-floor-kinds.test.ts.
🤖 Generated with Claude Code
The table now covers a page, a JSON answer, a 404, a 500, a static asset (stylesheet and sprite) and a redirect, on both http and https forges. A missing header names its row kind and status, and the new unit test proves it. It is test-only, so there is nothing to see in the preview. Two things I would do next: (1) replace the module-level assetOrigin mutable with a field on the Forge object, so the asset rows do not depend on set order; (2) add a row for a static asset 304 or a HEAD request, which take a different path through respond.ts.
test/security-floor-kinds.test.tsnow checks every kind of response the issue names: an HTML page, a JSON API answer, a 404, a 500, a static asset and a redirect. Each one must carry Content-Security-Policy, X-Content-Type-Options (set to nosniff) and Referrer-Policy. Both the plain-http and the https forge pass, andsrc/http/respond.tsis unchanged because no response was missing the headers.Most of this was already on main from #13470 (commit 74b89af1f). That file already had the page, 404, 500, redirect and API error rows. It was missing three, which I added:
GET /api/v1/user(a JSON 200);/assets/.security-floor-every-route.test.tsalready asked for the static assets, but the file this issue names did not.When a row is missing a header, the failure names the row's kind and status, for example
static asset, fake (200) lacks content-security-policy. A new unit test feeds the checker a response without CSP and nosniff and confirms the message. The existing check that the table covers every kind now also requires the JSON, static-asset, 500 and redirect rows by name.The new test file passes (5 tests), and
bun scripts/gate.ts --fixandbun x tsc --noEmitare clean. To try it:bun test test/security-floor-kinds.test.ts.🤖 Generated with Claude Code
Closes #13668