Repository navigation
Check Every Fetch on Both Sites Against Its Policy, and Refuse a Named Host - #533
Conversation
…d Host check-csp-scripts.py becomes check-csp.py. Beyond scripts, frames, media, and objects, it reads images, srcset candidates, posters, SVG images, each loading link, and CSS url() and @import in stylesheets, style blocks, and style attributes. It runs over the built blog and the family tree, each against its own policy, with the site's own origin read as 'self'. A policy naming a host or a network scheme fails, so every resource either site loads is its own. Part of #529. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Read @import with no space before its string, hold a fetch preload to connect-src, and read only fetch directives as naming a host. Drop the unused script_sources wrapper behind one directives() parser. Fix the stale VS Code task dependency, the CONTENT.md row, and the deploy README's remedy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
base-uri, form-action, frame-ancestors, and navigate-to each list sources, so a host there fails like one under a -src directive. Split the deploy README's hash remedy into two sentences. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
A recorded local strict-review pass covers head |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #533 +/- ##
==========================================
Coverage ? 53.24%
==========================================
Files ? 12
Lines ? 3418
Branches ? 0
==========================================
Hits ? 1820
Misses ? 1598
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Two unresolved findings remain in checks/check-csp.py, including a critical gap in report-uri host validation.
1 open issue
What changed in this PR
This pull request expands CSP validation from scripts to all statically detectable fetches across both the built blog and committed family site, while rejecting policies that name external hosts.
Changes:
- Replaces the script-only checker with
check-csp.py. - Validates images, stylesheets, fonts, media, links, preloads, CSS URLs, scripts, and both site policies.
- Updates release tooling, tests, documentation, browser-check guidance, and VS Code tasks.
| File | Description |
|---|---|
themes/README.md |
Updates theme guidance for the renamed CSP gate. |
README.md |
Documents the expanded local CSP verification. |
deploy/README.md |
Describes the two-site CSP policy and release validation. |
deploy/make-release.sh |
Runs the new CSP gate during release builds. |
CONTENT.md |
Updates content validation guidance and references. |
checks/tests/test_check_csp.py |
Adds coverage for both sites, resource types, policies, and stylesheet parsing. |
checks/README.md |
Documents the expanded CSP check. |
checks/check-csp.py |
Implements policy loading, host validation, and HTML/CSS fetch analysis. |
checks/check-csp-scripts.py |
Removes the superseded script-only gate. |
checks/check-csp-browser.py |
Updates documentation for the new static gate. |
.vscode/tasks.json |
Renames and reroutes the CSP verification task. |
Review effort: Lite
Its value is the URL violation reports go to, so a collector on another host would otherwise pass the rule that neither policy names one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
A recorded local strict-review pass covers head |

Summary
This is step 2 of #529. The release build now fails when either site loads anything from another host. Before, nothing caught the 95 dead hotlinked images that #513 restored. As decided on #529, this extends the existing CSP gate rather than adding a separate local-only check.
checks/check-csp-scripts.pybecomeschecks/check-csp.py.srcsetcandidates, posters, and SVG<image><link>that loads something, byreland byasfor a preload<style>blocks, andstyleattributes, where@importis read understyle-src, aurl()in@font-faceunderfont-src, and any otherurl()underimg-srcdefault-srccheck-url-parity.py'ssite_origin.https:, fails. That covers every-srcdirective, the navigation source lists such asform-action, andreport-uri. A scheme such asdata:names no host and stays allowed. Each policy is then the one statement of what its site may load, and it can name only the site itself.deploy/README.md"Security headers" drops the old route of adding an embed's host to its directive, since the gate now fails on any such host. The README,CONTENT.md,checks/README.md,themes/README.md,check-csp-browser.py,make-release.sh, and the VS Code tasks name the new gate.Part of #529, which closes when the promotion carrying this and #531 reaches main.
Verification
Run on server-2 at d4b1886, before 7195d75 added
report-urito the host rule, in a worktree holding this branch:The
checks/suite: 198 tests pass, and ruff, ruff format, and mypy are clean.deploy/make-release.shagainst the local staging mirror:PASS - each site's policy allows every fetch its pages make, and names no other host, with the blog's 4 inline-script hashes matched.checks/check-live-urls.sh:PASS - 1296 URLs honored.A negative run against the family tree and policy from before Serve Both Sites' Fonts From the Sites Themselves #531: the gate reports the four Google hosts in the policy and the four preconnect links on the two pages.
The hub prose gate, with this repository's excludes, reports nothing.
The local strict review ran three rounds. Its fixes cover:
@importwith no space before its stringas="fetch"held toconnect-srcsandboxread as naming no host, and the navigation source lists read as naming oneIt also raised the duplicated sibling loader, filed as Load a Hyphenated Sibling Check From One Shared Helper #532.
Declined findings
checks/check-csp.py:181,introduced, declined. The local review noted that a relativereport-uri /pathwould fail with a message calling it another host. Neither policy carriesreport-uri, and that failure is loud on trusted input rather than a silent pass, soGOVERNANCE.md"Trust Boundaries and Hardening Effort" rules out a fix. The URL-bearingreport-urithat Copilot raised is fixed in 7195d75.Deferred findings, filed
checks/fuzz-media-parsers.py,checks/tests/test_check_media_metadata.py, and this gate. Two of the three are in files this change does not touch, so the one-primitive rule moves them in a change of their own.🤖 Generated with Claude Code