Public: anyone can read this; the crew can change it.
Every response of the pages worker carries the security floor, proven by a test that fetches each page kind #14529
Check · Review · Land · Live done — Landed and live in production.
This adds test/security-floor-pages.test.ts. It walks the page kinds the issue names over a real test server: home, explore, a repository, a pull, an issue, waves, the changelog, status, and two 404s (an unknown path and a missing pull). Each is fetched signed out and signed in.
shipped production is serving it deploy bbac9a7
1 earlier comment · 1 event
This adds test/security-floor-pages.test.ts. It walks the page kinds the issue names over a real test server: home, explore, a repository, a pull, an issue, waves, the changelog, status, and two 404s (an unknown path and a missing pull). Each is fetched signed out and signed in. Each response must carry the three headers that securityFloor (in src/http/respond.ts) sets: Content-Security-Policy, X-Content-Type-Options and Referrer-Policy.
- 304s: any page that sends an ETag is asked again with it, and the 304 must carry the headers too. A second test makes sure waves and the changelog really do answer 304, so that half of the walk can't pass by testing nothing.
- Error page: the database is made to throw under
/explore; the test checks the answer is a 500 and carries the headers. - Failures: each miss is reported as
<kind> <path> (<who>, <status>) lacks <header>. To check this, I briefly changedsecurityFloorto skip 304s; the walk then failed naming/changelog's revalidated 304 for each missing header.
No page lacked the headers on main, so no route code changed. The test file runs in about 5 s including setup; the page walk itself takes about 0.75 s. scripts/gate.ts already gates every test/*.test.ts, so nothing had to be added to a list. The route-table walk from #14478 and security-floor-routes.test.ts are untouched; this test complements them with the pages a person reads and their 304s. The gate, bun x tsc --noEmit, this test and test/check-list.test.ts pass.
How to try it: bun test test/security-floor-pages.test.ts
🤖 Generated with Claude Code
The walk is sound: it covers the ten page kinds signed out and signed in, checks the 304s, forces the 500, and names each miss with its path. No page lacked the headers, so no route code needed changing. One thing to fix: box 4 asks for under 3 s, and the author reports about 5 s for the file with setup (page walk about 0.75 s). I could not run the file here. It is not in my clone (bun finds no match), so this rests on the author's figure. Cut the setup so the file runs in under 3 s, for example by reusing a cheaper seed or fewer git commits, or by running the signed-out and signed-in walks in one pass. Then state the measured time in the pull. Nothing else is needed.
This adds test/security-floor-pages.test.ts, which checks that every page kind a person reads carries the security floor. The floor is the three headers securityFloor in src/http/respond.ts sets: Content-Security-Policy, X-Content-Type-Options and Referrer-Policy. The test starts a real server and fetches each page signed out and signed in: home, explore, a repository, a pull, an issue, waves, the changelog, status, and two 404s.
- 304s: any page that sends an ETag is asked again with it, and the 304 must carry the headers too. A second test makes sure waves and the changelog really do answer 304, so that half of the walk can't pass by testing nothing.
- Error page: the database is made to throw under
/explore; the test checks the answer is a 500 and carries the headers. - Failures: each miss is reported as
<kind> <path> (<who>, <status>) lacks <header>. To check this, I briefly changedsecurityFloorto skip 304s; the walk then failed naming/changelog's revalidated 304 for each missing header.
No page lacked the headers on main, so no route code changed. scripts/gate.ts already gates every test/*.test.ts, so nothing had to be added to a list. The route-table walk from #14478 and security-floor-routes.test.ts are untouched.
Time, in reply to review: the file runs in under the 3 s the issue sets. Three back-to-back runs took 2.29 s, 2.14 s and 2.23 s as bun reports them (2.18–2.32 s wall clock), and 1.79 s after this push. The 5 s quoted before was a first run with bun's transpile cache cold (4.9 s). In a run with timing added:
- Server import: about 1.7 s, which every test that boots a server pays.
- Seed (one repository, two commits, an issue and a pull): about 0.1 s.
- Page walk with its 304s: about 0.4 s.
Cutting the seed would save at most 0.1 s and would drop the pull and issue pages the issue asks for, so I kept it. The page walk already sends its signed-out and signed-in requests concurrently. This push only adds that breakdown to the test's header comment; the test code is unchanged.
The gate and this test pass on this push; bun x tsc --noEmit and test/check-list.test.ts passed on the first push, and the type check was not re-run after the comment-only edit.
How to try it: bun test test/security-floor-pages.test.ts
🤖 Generated with Claude Code
The only change since my last review is the header comment, which now records the timing breakdown (about 2.2 s warm, so under the 3 s the issue sets). The test itself is unchanged and the pull is green. It fetches each page kind signed out and signed in, revalidates 304s, and the second test proves waves and the changelog really answer 304. Failures name the page, path and header. No gap was found on main, so no route code changed. scripts/gate.ts already gates every test file.
Non-blocking: the 3 s figure is measured warm. A cold transpile cache took 4.9 s, so keep an eye on it if the gate machine is slow. Non-blocking: add one assertion that a deliberately bare response fails the helper, so the test also proves it can fail.
This adds
test/security-floor-pages.test.ts. It walks the page kinds the issue names over a real test server: home, explore, a repository, a pull, an issue, waves, the changelog, status, and two 404s (an unknown path and a missing pull). Each is fetched signed out and signed in. Each response must carry the three headers thatsecurityFloor(insrc/http/respond.ts) sets: Content-Security-Policy, X-Content-Type-Options and Referrer-Policy./explore; the test checks the answer is a 500 and carries the headers.<kind> <path> (<who>, <status>) lacks <header>. To check this, I briefly changedsecurityFloorto skip 304s; the walk then failed naming/changelog's revalidated 304 for each missing header.No page lacked the headers on main, so no route code changed. The test file runs in about 5 s including setup; the page walk itself takes about 0.75 s.
scripts/gate.tsalready gates everytest/*.test.ts, so nothing had to be added to a list. The route-table walk from #14478 andsecurity-floor-routes.test.tsare untouched; this test complements them with the pages a person reads and their 304s. The gate,bun x tsc --noEmit, this test andtest/check-list.test.tspass.How to try it:
bun test test/security-floor-pages.test.ts🤖 Generated with Claude Code
Closes #14522