Skip to content

Read CSP Violations From Every Frame in the Browser Trial - #522

Merged
ptr727 merged 2 commits into
developfrom
feature/csp-browser-child-frames
Oct 25, 2026
Merged

ptr727 merged 2 commits into
developfrom
feature/csp-browser-child-frames

Conversation

@ptr727

@ptr727 ptr727 commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Summary

This answers promotion #521's review. The browser probe installs its securitypolicyviolation listener through context.add_init_script, which runs in every frame, but it then read window.__csp from the main frame only. A resource blocked inside an iframe therefore never reached the report, and the check could pass while missing it. The probe now reads window.__csp || [] in each entry of page.frames. The docstring and OPERATIONS.md "Local Verification" say so.

Verification

  • I built a mock site and ran the check against it with an empty allow list. The mock serves default-src 'self'; img-src 'self' on a page holding a same-origin iframe, and the child page loads an image from another host.
    • Before the fix, the check reported PASS, which is the miss.
    • After the fix, with a second iframe from a host frame-src blocks added, it failed on both. img-src came from the child frame and frame-src from the parent. Evaluating in the blocked frame did not throw.
  • The checks/ unit suite passes, and ruff and mypy are clean. The probe half runs only in the container, so the mock run is its evidence.
  • The prose gate is clean, and so is its sentence-length check.

Local review

One frontier-tier pass, with no findings. It checked for double counting (each violation fires in exactly one document's buffer) and for a frame that throws on evaluate (that run fails loudly, and the site carries no frames today).

🤖 Generated with Claude Code

The probe read the violation buffer from the top frame only, so a resource blocked inside an iframe never reached the report.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings October 25, 2026 16:17
@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: 7dc66081-1245-4ed1-8660-05648f42f0ef
  • 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 603a1694147a8022f3d2e82932db311a7972548d, the content this pull request carries at that commit against develop, and it recorded 0 findings.

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

Violations from transient frames can still be silently omitted before collection.

1 open issue
What changed in this PR

This pull request updates the CSP browser trial to collect violations from the main document and every currently attached frame, and documents the expanded coverage.

Changes:

  • Read window.__csp from each frame in page.frames.
  • Update the probe documentation and local verification instructions.
  • Address transient-frame handling before approval.
File Reviewed change
OPERATIONS.md Documents frame-aware CSP violation collection during local verification.
checks/​check-csp-browser.py Collects CSP violations from each attached frame. Finding: violations from frames that navigate or detach before collection may be lost (moderate, 2 votes).

Review effort: Lite

Comment thread checks/check-csp-browser.py Resolved
@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.39%. Comparing base (4776b9d) to head (bdd412c).

Files with missing lines Patch % Lines
checks/check-csp-browser.py 0.00% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #522      +/-   ##
===========================================
- Coverage    52.44%   52.39%   -0.05%     
===========================================
  Files           12       12              
  Lines         3333     3336       +3     
===========================================
  Hits          1748     1748              
- Misses        1585     1588       +3     
Flag Coverage Δ
python-3.13 52.39% <0.00%> (-0.05%) ⬇️

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.

A frame that detached or navigated before the read lost its buffered violations. A context binding now carries each event to the probe the moment it fires.

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

ptr727 commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

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

@ptr727
ptr727 merged commit 7950ed6 into develop Oct 25, 2026
12 checks passed
@ptr727
ptr727 deleted the feature/csp-browser-child-frames branch October 25, 2026 17:13
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.

2 participants