Skip to content

Commit the CSP Browser Trial as a Repeatable Check - #519

Merged
ptr727 merged 4 commits into
developfrom
feature/518-csp-browser-check
Oct 25, 2026
Merged

ptr727 merged 4 commits into
developfrom
feature/518-csp-browser-check

Conversation

@ptr727

@ptr727 ptr727 commented Oct 25, 2026

Copy link
Copy Markdown
Owner

For #518.

Summary

The blog's Content-Security-Policy went live after a headless Chromium pass, but that pass was a scratch script. This commits it as checks/check-csp-browser.py.

  • Host half, standard library. It reads the Playwright image pin from the new checks/browser/Dockerfile and derives the pip version from that image's tag. It then runs the container with --network host and the host's uv mounted, and folds the probe's JSON-line records into findings.
  • Probe half, in the container. It loads each page, scrolls to the end, clicks the code-copy buttons, and types a query on /search/. It records every securitypolicyviolation event.
  • Gate. A run fails on any violation that checks/csp-browser-allow.txt does not list, and on any page that does not answer 200. On a run over the default list it also fails on an allow entry that nothing matched. The two dead-hotlink origins from Settle the Dead Hotlinked Images on Eight Archived Posts #513 are the only entries.
  • One pin. Dependabot's docker entry now covers /checks/caddy and /checks/browser through directories. The Playwright package follows the image tag, so the two cannot drift.
  • Docs. OPERATIONS.md "Local Verification" says when the check runs (a CSP change, or a theme or layout change that adds a resource) and how. It runs by hand on the local mirrors. deploy/README.md and checks/README.md name the check.

This PR carries the comments label because it edits the Dependabot header comment and the checks/pyproject.toml header comment.

Verification

  • checks/: ruff check, ruff format, and mypy are clean, and the unit suite passes. The new tests cover the host half: pin parsing, list and allow-list reading, origin reduction, summarizing, main, command construction, and the probe runner.
  • Full run against the local staging mirror: PASS over 328 pages. The allowed blocks were 94 img-src on docs.google.com and 1 on www.elcolighting.com, which matches Settle the Dead Hotlinked Images on Eight Archived Posts #513's survey.
  • A run over a few pages with an empty allow list failed as expected and named the docs.google.com block.
  • The prose gate is clean with --allow-comments, and so is its sentence-length check. markdownlint, editorconfig-checker, and cspell are clean through docker_lint.py.

Local review

The pass ran at the frontier tier over three rounds, and the receipt covers the head.

  • Round 1.
    • Fixed: the stale "standard library alone" pyproject comment.
    • Fixed: a dead scheme: branch. Chromium reports a non-HTTP(S) blockedURI as the bare scheme, so the branch could never match, and OPERATIONS.md now says how to write such an entry.
    • Fixed: a #-comment skip that made this reader of golden-urls.txt disagree with the other two readers.
    • Fixed: a docstring wrap, and the python3 row in deploy/README.md.
    • Declined: consolidating the origin reduction with check-csp-scripts.py. The gates in checks/ are standalone and loaded by path, and after the fix above the overlap is one urlsplit line. The reviewer accepted the decline in round 2.
  • Round 2. Fixed: the python3 row's "Needed for" cell.
  • Round 3. No findings.

🤖 Generated with Claude Code

ptr727 and others added 3 commits October 25, 2026 08:25
The blog policy shipped after a headless Chromium pass that no committed tool could repeat. check-csp-browser.py loads every rendered page of a running mirror in the Playwright image checks/browser/Dockerfile pins, and fails on any securitypolicyviolation that csp-browser-allow.txt does not list. The Playwright package is installed at the image tag's version, so Dependabot moves one pin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Oct 25, 2026
Copilot AI lite review requested due to automatic review settings October 25, 2026 15:34
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Oct 25, 2026
@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: 6fa8b301-7bdf-4e40-ac89-e8dd87723f9c
  • 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.

@ptr727

ptr727 commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 9675c450417527e7aaf467e1927ba1f85bcd99ac, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.82192% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.24%. Comparing base (5f85875) to head (0254285).

Files with missing lines Patch % Lines
checks/check-csp-browser.py 80.82% 28 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #519      +/-   ##
===========================================
+ Coverage    50.92%   52.24%   +1.31%     
===========================================
  Files           11       12       +1     
  Lines         3173     3319     +146     
===========================================
+ Hits          1616     1734     +118     
- Misses        1557     1585      +28     
Flag Coverage Δ
python-3.13 52.24% <80.82%> (+1.31%) ⬆️

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 probe runner lets a timeout or a missing docker binary escape as a traceback instead of the intended FAIL: refusal, which needs a fix before merge.

2 open issues
What changed in this PR

This PR turns a one-off headless Chromium pass into a repeatable check, checks/check-csp-browser.py. The check loads each page of a running mirror in a Playwright container. It scrolls each page, clicks the code-copy buttons, and types a search query. It then reports every Content-Security-Policy violation the browser records. A run fails on any violation not listed in checks/csp-browser-allow.txt, or on any page that does not return 200. The Playwright image pin lives in checks/browser/Dockerfile, and Dependabot tracks it. The docs say when to run the check, which is by hand against the local mirrors.

Changes:

  • Adds the browser check: a host half that starts the container and folds its output into findings, and a probe half that runs inside the container.
  • Adds an allow list with the two dead hotlinked image origins from issue #513, and a Dependabot entry that tracks the browser image pin.
  • Documents the check in OPERATIONS.md, deploy/README.md, and checks/README.md, and adds unit tests for the host half.
File Description
OPERATIONS.md Documents when the browser check runs (CSP or layout changes), how to run it, and its rules.
deploy/​README.md Adds the new tools (uv, Docker use) to the tool table and links the check from the CSP section.
checks/​tests/​test_check_csp_browser.py Unit tests for the host half: pin parsing, list reading, origin reduction, summaries, command construction, and the probe runner.
checks/​README.md Adds the new check to the list of checks and its link definitions.
checks/​pyproject.toml Corrects the header comment, which no longer says the gates are standard library only, and adds a mypy override for Playwright.
checks/​csp-browser-allow.txt Lists the two known dead hotlinked image origins, each with its reason.
checks/​check-csp-browser.py The new gate: reads the pin and the lists, runs the container, and reports violations and failed page loads.
checks/​browser/​Dockerfile Pins the Playwright base image by version tag and digest.
.github/​dependabot.yml Tracks checks/browser with checks/caddy for Docker updates on both branches.

Review effort: Lite

Comment thread checks/check-csp-browser.py Resolved
Comment thread deploy/README.md Resolved
@ptr727

ptr727 commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 02542859e9d58e31318f63789cc1fdd5554ca539, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@ptr727
ptr727 merged commit cbe8e97 into develop Oct 25, 2026
12 checks passed
@ptr727
ptr727 deleted the feature/518-csp-browser-check branch October 25, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants