A policy from your pages
It reads the homepage and other pages found in its links and sitemap, one for each kind of address, up to 15 by default and 50 at most, and sorts the origins they load into directives.
An Apify Actor that reads a website's public pages and writes a ready-to-paste starting Content-Security-Policy, with server snippets that deploy it as Report-Only first. It never changes the site. It is for site owners, agencies and developers who want a first draft instead of writing one by hand.
It reads the homepage and other pages found in its links and sitemap, one for each kind of address, up to 15 by default and 50 at most, and sorts the origins they load into directives.
A SHA-256 hash for inline scripts, up to 100, so the policy does not add 'unsafe-inline' for scripts. Inline event handlers such as onclick are counted and explained.
For a short list of services, such as Google Tag Manager, Stripe.js and YouTube embeds, it adds hosts that static HTML cannot show and says why.
The policy headers the homepage sends now, and what the site loads that they would block.
Report-Only snippets for a Cloudflare _headers file, nginx, Apache and netlify.toml, plus an HTML meta tag. A meta tag cannot be Report-Only, so it always enforces.
Compatible mode allows inline styles when the site uses them. Strict mode never adds 'unsafe-inline' and warns what to move out of the HTML. Warnings also cover eval-like code and resources loaded over http.
| Input | Status | Site | Pages read | Report-Only header | Blocked by current policy | Inline scripts | Unsafe inline needed | Warnings | Error |
|---|---|---|---|---|---|---|---|---|---|
| https://redcenterstudio.com | ok | https://redcenterstudio.com | 2 | Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self' 'sha256-/aDReT... | {"count":12,"hashes":["'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg='","'sha256-LH... | true | Many different inline scripts usually means the HTML generates them per page. A hash only... |
{
"status": "ok",
"inputRef": "https://redcenterstudio.com",
"auditedAt": "2026-12-05T21:48:49.913Z",
"site": "https://redcenterstudio.com",
"pagesRead": 2,
"strictness": "compatible",
"currentPolicy": "frame-ancestors 'self'",
"currentPolicyReportOnly": null,
"currentPolicyBlocks": [],
"policy": "Content-Security-Policy: default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests",
"policyReportOnly": "Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests",
"directives": {
"default-src": [
"'self'"
],
"script-src": [
"'self'",
"'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg='",
"'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I='",
"'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ='",
"'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c='",
"'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0='",
"'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0='",
"'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8='",
"'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc='",
"'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co='",
"'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60='",
"'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg='",
"'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='"
],
"style-src": [
"'self'",
"'unsafe-inline'"
],
"img-src": [
"'self'",
"data:"
],
"connect-src": [
"'self'"
],
"object-src": [
"'none'"
],
"base-uri": [
"'self'"
],
"form-action": [
"'self'"
],
"frame-ancestors": [
"'self'"
]
},
"inlineScripts": {
"count": 12,
"hashes": [
"'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg='",
"'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc='",
"'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ='",
"'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60='",
"'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='",
"'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8='",
"'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg='",
"'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0='",
"'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I='",
"'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c='",
"'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co='",
"'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0='"
]
},
"inlineEventHandlers": 0,
"inlineStyles": 47,
"unsafeInlineNeeded": true,
"expansionsAdded": [],
"warnings": [
"Many different inline scripts usually means the HTML generates them per page. A hash only matches one exact text, so use a nonce for those."
],
"snippets": {
"cloudflareHeadersFile": "/*\n Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests",
"nginx": "add_header Content-Security-Policy-Report-Only \"default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests\" always;",
"apache": "Header always set Content-Security-Policy-Report-Only \"default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests\"",
"netlifyToml": "[[headers]]\n for = \"/*\"\n [headers.values]\n Content-Security-Policy-Report-Only = \"default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests\"",
"htmlMeta": "<!-- A meta tag always enforces: it cannot be Report-Only. frame-ancestors, report-uri and report-to do not work in a meta tag, so they are left out. Test with a header first. -->\n<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests\">"
},
"nextStep": "Deploy the Report-Only header for about a week and watch the browser console for violations, or run again with a report address to collect them. Fix or allow what is reported, then switch the header name to Content-Security-Policy to enforce. Site Watch can separately tell you about domain and certificate expiry and DNS and email record changes; it does not check Content-Security-Policy or other headers: https://redcenterstudio.com/sitewatch/"
}{
"mcpServers": {
"csp-builder": {
"url": "https://mcp.apify.com?tools=bodacious_mistral/csp-builder"
}
}
}curl -X POST "https://api.apify.com/v2/acts/bodacious_mistral~csp-builder/run-sync-get-dataset-items" \
-H "Authorization: Bearer $APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"sites":["redcenterstudio.com"]}'import { ApifyClient } from "apify-client";
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor("bodacious_mistral/csp-builder").call({
"sites": [
"redcenterstudio.com"
]
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);Site Watch checks a website from Claude: domain and SSL expiry, DNS and email security and AI crawler access, with uptime on paid plans. It does not check Content-Security-Policy or other headers. A free plan is available.
Do not start there. It is a starting point. Deploy the Report-Only header for about a week, watch for violations, fix or allow what is reported, and then enforce.
No. It reads the HTML and up to 10 stylesheets from the same site. It does not run scripts or open script files, so something a script loads later can be missing from the policy. The Report-Only period is how you catch it.
A hash matches one exact piece of text. For scripts your server builds on each request, use a fresh nonce instead.
One policy built event for each website that returns a policy row. Error rows are free, such as a homepage that cannot be reached, answers with an error status or is not HTML. Apify adds its own small start event to each run, and you can set a maximum cost per run.
Up to 50 websites per run, 3 at a time by default, with up to 50 pages and about 60 seconds for each site. Only public pages are read.