Expand description
Content Security Policy hardening plugin.
Extracts inline <style> and <script> blocks into external files
with Subresource Integrity (SRI) hashes, eliminating the need for
'unsafe-inline' in the Content-Security-Policy header.
Structs§
- CspPlugin
- Plugin that extracts inline styles/scripts to external files with SRI.
- Page
CspHashes - CSP source hashes for the inline blocks remaining on a single page (spec B4, plan §3 item 2.4).
Constants§
- DEFAULT_
CSP_ POLICY - Canonical Content-Security-Policy string emitted by the CSP plugin.
- DEFAULT_
CSP_ POLICY_ TEMPLATE - Content-Security-Policy template with
{script_hashes}and{style_hashes}slots (spec B4, v0.0.47 plan §3 item 2.4).
Functions§
- computed_
policy - Returns the canonical Content-Security-Policy string that the CSP plugin’s inline-extraction posture is designed to enforce.
- inject_
csp_ meta - Inserts a
<meta http-equiv="Content-Security-Policy" content="...">tag immediately after the<head>opening tag. - page_
inline_ hashes - Computes the CSP source hashes for every inline block on a page.
- page_
policy - Computes the per-page Content-Security-Policy for a built HTML
page, or
Nonewhen the page has no inline blocks and the globalcomputed_policyapplies unchanged (spec B4). - policy_
for_ meta - Strips the directives a
<meta>-delivered policy cannot carry. - render_
policy_ template - Renders a CSP policy template, expanding the
{script_hashes}and{style_hashes}slots into space-prefixed'sha256-…'sources.