Skip to content

Promote the Blog Content-Security-Policy to Main - #516

Merged
ptr727 merged 2 commits into
mainfrom
develop
Oct 25, 2026
Merged

ptr727 merged 2 commits into
mainfrom
develop

Conversation

@ptr727

@ptr727 ptr727 commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

This promotes develop to main:

This changes what the server sends, so the release needs a deploy to each site. Local staging has served the enforcing policy since 83a8e8c. A headless Chromium pass there over every rendered URL recorded no violation other than the 95 dead hotlinked images #513 tracks.

Closes #501

🤖 Generated with Claude Code

* Trial a Blog Content-Security-Policy as Report-Only Behind a Hash Gate

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Enforce the Blog Content-Security-Policy and Test Its Hash Gate

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Check the Shipped Caddyfile's Policy and Name the CSP Gate in Its Docs

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Test the CSP Gate's Refusals With Constructed Policy Files

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Drop the Unused Google Maps Shortcode the Blog Policy Blocks

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Check Import Maps and Speculation Rules Against the Blog Policy

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read Built Pages Strictly and Name the Script Host Form the Gate Reads

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Name Theme Settings Among What Changes the Blog's Inline Scripts

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Check Every Script Type a Browser Runs and Name the Proxy's Injected Scripts

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Name the CSP Gate Beside the URL Parity Check Wherever It Is Run

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings October 25, 2026 13:58
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 72f30449-94b3-4acc-a8cd-771a9f155d18
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.47826% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.92%. Comparing base (b13ce30) to head (5f85875).
⚠️ Report is 145 commits behind head on main.

Files with missing lines Patch % Lines
checks/check-csp-scripts.py 83.47% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #516      +/-   ##
==========================================
+ Coverage   49.70%   50.92%   +1.22%     
==========================================
  Files          10       11       +1     
  Lines        3058     3173     +115     
==========================================
+ Hits         1520     1616      +96     
- Misses       1538     1557      +19     
Flag Coverage Δ
python-3.13 50.92% <83.47%> (+1.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The CSP checker has three unresolved moderate bugs that can allow invalid or unvalidated scripts to pass the release gate.

1 open issue
What changed in this PR

Promotes the blog’s enforcing Content-Security-Policy to main, with release-time validation that rendered scripts match the configured policy.

Changes:

  • Adds CSP headers, script-hash validation, tests, documentation, and release/editor integration.
  • Removes the unused Google Maps shortcode.
  • Updates deployment and content-verification guidance.
File Description
themes/​README.md Documents CSP hash updates after theme changes.
README.md Adds the CSP gate to local site verification.
layouts/​shortcodes/​googlemaps.html Removes the unused Google Maps shortcode.
deploy/​README.md Documents the CSP, hash gate, and deployment implications.
deploy/​make-release.sh Runs CSP validation during release builds.
deploy/​Caddyfile Adds the enforcing blog CSP header.
CONTENT.md Adds the CSP gate to content verification requirements.
checks/​tests/​test_check_csp_scripts.py Tests script scanning and policy-loading behavior.
checks/​security-headers.txt Records the expected blog CSP value.
checks/​README.md Documents the new CSP check.
checks/​check-csp-scripts.py Validates scripts against the configured CSP; three moderate issues remain involving scheme-only URLs, unterminated scripts, and parameterized JavaScript MIME types.
.vscode/​tasks.json Adds CSP validation to editor tasks.

Review effort: Lite

Comment thread checks/check-csp-scripts.py Resolved
…#517)

* Require a Named Scheme Before the CSP Gate Allows a Scheme Script URL

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Report a javascript: Script URL Once and Name Scheme Sources in the Gate's Wording

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Capture an Inline Body Only for a Script Without a src

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read a Valueless src as External and Mend the Gate's Finding Wording

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Three moderate CSP validation issues remain unresolved and should be fixed before approval.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Parse MIME essence before checking executable script types

checks/​check-csp-scripts.py:95

[bug] Parse the MIME type essence before checking SCRIPT_TYPES. A valid executable tag such as <script type="text/javascript; charset=utf-8"> is currently skipped, so the gate can pass without hashing it even though the browser executes it and the enforcing CSP blocks it. Add a regression case for a JavaScript MIME type with parameters.

Medium severity Scope CSP header comparison to the blog directive

checks/​check-csp-scripts.py:161

[bug] Scope this comparison to the blog's actual Caddy header directive instead of searching the whole file. If the blog header is changed or removed while the old Content-Security-Policy "..." text remains in a comment or another site block, this substring check still loads the policy and the release gate can pass with a different header being served. Add a test for that drift and parse the blog block or otherwise ignore comments and other site blocks.

1 resolved since last review

Review effort: Lite

@ptr727

ptr727 commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Answering the two findings this round raised outside a thread.

Parse MIME essence before checking executable script types (checks/check-csp-scripts.py:95). A valid executable tag [with a JavaScript MIME type carrying parameters] is currently skipped.

Declined with evidence. The HTML standard runs a script only when its trimmed type string is an ASCII case-insensitive match for a JavaScript MIME type essence, so a value with parameters is a data block. Chromium 140 agrees, as the probe on #514 showed: text/javascript; charset=utf-8 and text/javascript;charset=utf-8 both skip, while Text/JavaScript, text/javascript, application/ecmascript, and text/javascript1.5 run. The gate checks exactly the set the browser runs: #514 (comment)

Scope CSP header comparison to the blog directive (checks/check-csp-scripts.py:161). If the blog header is changed or removed while the old text remains in a comment or another site block, this substring check still loads the policy.

Declined with evidence. That drift already fails CI. CaddyfileSyncTests.test_expected_values_are_the_caddyfile_values in checks/tests/test_check_live_urls_sample.py runs caddy adapt on deploy/Caddyfile. For each site it compares the headers Caddy sends on every response with security-headers.txt. Caddy's parser drops comments and keeps each site block's headers apart, so a changed or removed blog header fails that test whatever text remains elsewhere. The unit test job runs it on every pull request. The substring check in the gate catches a split between the two files at release time. It does not have to repeat what the sync test proves.

@ptr727
ptr727 merged commit 462e443 into main Oct 25, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Survey What Blog Posts Load Before a Blog Content-Security-Policy

2 participants