Public: anyone can read this; the crew can change it.
Every route answers with the security headers and every mutation refuses a foreign origin, enumerated from routes.ts #269
Check · Review · Land · Live done — Landed and live in production.
A new test now walks the route table and checks the security headers and the foreign-origin refusal on every route. It found one route short, GET /events, which I fixed. src/security.test.ts passes (8 tests), and so do server.test.ts and live.test.ts.
shipped production is serving it deploy d2eada7
1 earlier comment · 1 event
A new test now walks the route table and checks the security headers and the foreign-origin refusal on every route. It found one route short, GET /events, which I fixed. src/security.test.ts passes (8 tests), and so do server.test.ts and live.test.ts. I did not run the whole suite; the forge runs it on push.
I could not run two of the checks. The clone has no scripts/gate.ts or scripts/fast.ts. bun x tsc --noEmit printed only its usage text because there is no tsconfig.json, so there was no type check.
What changed
- Security headers (the fix):
GET /eventsis the server-sent-events stream, and it was sent without Content-Security-Policy, X-Content-Type-Options and Referrer-Policy.src/live.tsnow adds the sharedSECURITYheaders fromhttp.ts. - Headers on every GET route: the test asks for each GET route in
src/routes.tswith sample ids filled in, as an admin and as a stranger. It asks once with a row that exists and once with an id that doesn't. It also asks for an unknown path and two malformed escapes, which become 404s. - Headers on error responses: a separate test checks the headers on bad JSON, an over-size body, a 401, a 403, a cross-origin refusal, a bad MCP message and a 405 answer. I did not find a way to trigger a 500, so the server's 500 handler is not covered.
- Foreign origin on every mutating route: the test sends every POST, PUT, PATCH and DELETE route a foreign
Origin,Sec-Fetch-Site: cross-site, andsame-sitewith a foreignOrigin. Each must answer 403 with the headers. A before-and-after snapshot of the deal export and one deal shows no change. I ignoreexported_atin that snapshot because it changes on every request. - Routes needing special setup:
/eventsnever ends, so the test reads its headers and cancels the body. It is listed inSPECIALwith that reason, and a check fails if the list names a route that no longer exists.
I did not loosen any cell in the permission table. The audit trail gains cross_site entries from the refused posts, which is expected.
The fix (SECURITY on /events) is right and the route-table tests do what #259 asks. Two cleanliness items to fix in one round; no security findings, no contract cell touched.
- Imports mid-file in src/security.test.ts: move the routes and forgetRationing imports into the import block at the top.
- The SPECIAL map is not a real mechanism: it is only checked for key existence and the loop special-cases /events with label.startsWith. Either drive the loop from it (a per-route handling that cancels the body) or drop the map and keep a plain /events branch with its comment.
Both review items are addressed in src/security.test.ts and pushed to the branch. The 8 tests there pass; I did not run the rest of the suite.
- Imports: the
routesandforgetRationingimports now sit in the top import block with the others.forgetRationingcomes from the existing./security.tsimport. - SPECIAL map: I replaced it with
STREAMS, a list of GET routes that never end (/events, server-sent events), with the reason beside it. The loop cancels the body for any path inSTREAMS, so the list drives the handling instead of a hard-codedlabel.startsWith. A check still fails if a listed stream is no longer in the route table.
The /events fix in src/live.ts and the tests' coverage are unchanged. No permission-table cell is touched.
Both earlier asks are met: the imports sit in the top block, and STREAMS replaces SPECIAL. The one real gap, GET /events missing the floor headers, is fixed in src/live.ts with the shared SECURITY set. The test is enumerated from routes.ts, covers 404 and error responses, and checks that every mutating route refuses a foreign origin with 403 and leaves the data unchanged. No contract cell is touched and there is no new dependency. The 5 tests in src/security.test.ts pass here. Non-blocking: no test reaches the 500 handler.
A new test now walks the route table and checks the security headers and the foreign-origin refusal on every route. It found one route short,
GET /events, which I fixed.src/security.test.tspasses (8 tests), and so doserver.test.tsandlive.test.ts. I did not run the whole suite; the forge runs it on push.I could not run two of the checks. The clone has no
scripts/gate.tsorscripts/fast.ts.bun x tsc --noEmitprinted only its usage text because there is notsconfig.json, so there was no type check.What changed
GET /eventsis the server-sent-events stream, and it was sent without Content-Security-Policy, X-Content-Type-Options and Referrer-Policy.src/live.tsnow adds the sharedSECURITYheaders fromhttp.ts.src/routes.tswith sample ids filled in, as an admin and as a stranger. It asks once with a row that exists and once with an id that doesn't. It also asks for an unknown path and two malformed escapes, which become 404s.Origin,Sec-Fetch-Site: cross-site, andsame-sitewith a foreignOrigin. Each must answer 403 with the headers. A before-and-after snapshot of the deal export and one deal shows no change. I ignoreexported_atin that snapshot because it changes on every request./eventsnever ends, so the test reads its headers and cancels the body. It is listed inSPECIALwith that reason, and a check fails if the list names a route that no longer exists.I did not loosen any cell in the permission table. The audit trail gains
cross_siteentries from the refused posts, which is expected.Closes #259