Skip to content

Require a Named Scheme Before the CSP Gate Allows a Scheme Script URL - #517

Merged
ptr727 merged 4 commits into
developfrom
feature/csp-scheme-sources
Oct 25, 2026
Merged

ptr727 merged 4 commits into
developfrom
feature/csp-scheme-sources

Conversation

@ptr727

@ptr727 ptr727 commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Summary

This answers the Copilot finding on promotion #516. checks/check-csp-scripts.py judged a script URL with a scheme and no host, such as data: or blob:, as 'self', and passed it. A browser allows such a URL only when script-src names its scheme.

  • allowed() requires <scheme>: in script-src for such a URL.
  • A javascript: script URL is reported once, as a javascript: URL. Only a script with no src has its body hashed, since a browser ignores the body of one that has a src.
  • The finding text, the docstring, and deploy/README.md "Security headers" name a scheme beside a host as a form the gate reads.

The live policy names no scheme source, so the gate's verdict on the current build is unchanged.

Verification

  • New unit cases cover a data: and a blob: script URL, refused under 'self' and allowed with the scheme named, and a javascript: script URL with a body. Each fails on the code before it.
  • python3 -m unittest discover -s checks/tests passes. ruff, mypy, pyright, and prose lint with sentence length are clean. The gate passes on a minified build of develop.
  • A local strict review ran before this push. Every introduced finding it raised is fixed.

Declined findings

  • A policy token in mixed case, such as Data:, or a bare https: scheme source fails the gate although a browser allows it. The failure is loud, it is on a file the maintainer writes, and deploy/README.md names the forms the gate reads.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings October 25, 2026 14:17
@ptr727

ptr727 commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

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

@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: 3dbf186e-ec4f-4f57-ae87-4fd57c265924
  • 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

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.92%. Comparing base (46628fb) to head (16a265f).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #517      +/-   ##
===========================================
+ Coverage    50.85%   50.92%   +0.07%     
===========================================
  Files           11       11              
  Lines         3168     3173       +5     
===========================================
+ Hits          1611     1616       +5     
  Misses        1557     1557              
Flag Coverage Δ
python-3.13 50.92% <100.00%> (+0.07%) ⬆️

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 unresolved moderate [P1] finding and two [P2] nit findings should be addressed before approval.

2 open issues
What changed in this PR

This pull request tightens the CSP script gate so scheme-only script URLs such as data: and blob: require an explicitly named scheme source, while handling javascript: URLs and script bodies correctly.

Changes:

  • Require matching scheme sources for hostless scheme URLs.
  • Avoid hashing bodies when a src attribute is present.
  • Add regression tests for scheme-based and javascript: URLs.
  • Document the host and scheme forms recognized by the gate.
File Summary
deploy/​README.md Documents the host and scheme source forms recognized by the CSP gate.
checks/​tests/​test_check_csp_scripts.py Adds coverage for data:, blob:, and javascript: script URLs.
checks/​check-csp-scripts.py Updates scheme matching and script-source handling. Outstanding findings: one [P1] moderate issue with valueless src attributes (2 votes), plus two [P2] nit findings regarding wording (2 votes) and the docstring (1 vote).

Review effort: Lite

Comment thread checks/check-csp-scripts.py Resolved
Comment thread checks/check-csp-scripts.py Resolved
@ptr727

ptr727 commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

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

@ptr727
ptr727 merged commit 5f85875 into develop Oct 25, 2026
12 checks passed
@ptr727
ptr727 deleted the feature/csp-scheme-sources branch October 25, 2026 14:36
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