[codex] Add board page CSP header - #350
Draft
lovasoa wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
Content-Security-Policyto templated board HTML responses and centralize the policy string so board HTML, static assets, and SVG responses use the same header source.Root Cause
CSP was defined in
server/server.mjs, but board HTML responses are built throughserver/templating.mjs:startHtmlResponse. That path setContent-Type,Cache-Control,ETag, andVary, but never attachedContent-Security-Policy, so/boards/<name>shipped without CSP while static and SVG routes still had it.What Changed
server/security_headers.mjsas the shared CSP sourceserver/server.mjsstatic, SVG, and preview responses to use the shared CSP constantserver/templating.mjsImpact
Board HTML responses now send CSP instead of only static assets and SVG endpoints doing so.
Validation
node --test test-node/server_routes.test.jsnode --test test-node/server_routes.test.js test-node/turnstile.test.jsnpm test❌node --test test-node/*.test.jspassedplaywright testfailed in 9 specs, so lint did not runRemaining Work
The current CSP is still too strict for the browser runtime.
Evidence:
script-srcandframe-srcallowances forhttps://challenges.cloudflare.comFollow-up needed:
npm testgate after narrowing the policy