See what your Content-Security-Policy blocks, in one feed
Add report-uri http://localhost:8000/csp/<project> to your Content-Security-Policy header. Each time the browser blocks something, it sends a report to Buggregator, and you see the page, the blocked URL, the directive and the full policy. Start with the Report-Only header: the browser reports but blocks nothing.
Steps
1. Start Buggregator
docker run --pull always \
-p 127.0.0.1:8000:8000 \
ghcr.io/buggregator/server:latest2. Add report-uri to your policy
Use Content-Security-Policy-Report-Only while you write the policy. shop is the project; leave out /shop for the default project.
Content-Security-Policy-Report-Only: default-src 'self'; report-uri http://localhost:8000/csp/shopIn nginx, for example:
add_header Content-Security-Policy-Report-Only "default-src 'self'; report-uri http://localhost:8000/csp/shop";3. Check it with curl
Send one report by hand to see how it looks.
curl -X POST http://localhost:8000/csp/shop \
-H 'Content-Type: application/csp-report' \
-d '{"csp-report":{"document-uri":"https://shop.test/checkout","effective-directive":"script-src-elem","blocked-uri":"https://cdn.example.com/x.js","disposition":"enforce"}}'4. Open the pages of your site
Click through the site in the browser. Then open http://localhost:8000. The feed gets one card per report request: the page, then one line per report, for example «script-src-elem blocked https://cdn.example.com/x.js». Report-only violations get a badge. The event page shows the directive, the blocked resource, the file with line and column, the code sample, the full policy and the raw report. CSP reports in the menu lists only these events.
Why it works
With report-uri, the browser POSTs each violation as JSON to the address you give, from any page. Buggregator accepts these reports at /csp, answers the browser's CORS check, and stores each request as one event. Unlike report-to, report-uri also works over plain http, for example from http://buggregator:8000 in Docker. A report body may be at most 1 MB.
Docs: docs.buggregator.dev/config/csp.html#report-uri-works-everywhere
Requires Buggregator v2.13.0+
Related tips
- CSP
Catch browser deprecation reports before a feature breaks
Name Buggregator as the default Reporting API endpoint. The browser's deprecation and intervention reports land in the same feed as CSP violations.
- CSP
See what your Laravel CSP blocks
Set CSP_REPORT_URI in spatie/laravel-csp to Buggregator. Every Content Security Policy violation shows up in one feed while you write the policy.
- CSP
See what your Symfony CSP blocks
Point NelmioSecurityBundle's report-uri at Buggregator in dev. Each CSP violation shows the directive, the blocked URL and the page it happened on.
- HTTP
See a webhook's payload before you write the handler
Point the webhook URL at Buggregator with http-dump in the URL. See the headers, body and files it sends, plus a cURL command to send it again.
Checked on with Buggregator v2.13.0