Implement Content Security Policy (CSP) Level 2: parsing, enforcement, and integration
- Parse CSP from Content-Security-Policy and Content-Security-Policy-Report-Only HTTP headers
- Parse CSP from <meta http-equiv="Content-Security-Policy"> elements
- Support all fetch directives: default-src, script-src, style-src, img-src, font-src,
connect-src, frame-src, media-src, object-src, base-uri, form-action
- Support source expressions: 'none', 'self', 'unsafe-inline', 'unsafe-eval',
nonce sources, hash sources (sha256/sha384/sha512), scheme sources, host sources
- Enforce default-src fallback for fetch directives
- Block inline scripts unless allowed by 'unsafe-inline', matching nonce, or matching hash
- Nonce/hash presence disables 'unsafe-inline' per CSP2 spec
- Multiple policies use intersection semantics (all must allow)
- Report-only policies log violations but do not block
- Integrate CSP checks into ResourceLoader.fetch_subresource
- Integrate inline script CSP checks into script_loader with nonce attribute support
- 64 unit tests covering parsing, matching, enforcement, and edge cases
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>