Skip to main content

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

bash
docker run --pull always \
  -p 127.0.0.1:8000:8000 \
  ghcr.io/buggregator/server:latest

2. 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.

http
Content-Security-Policy-Report-Only: default-src 'self'; report-uri http://localhost:8000/csp/shop

In nginx, for example:

nginx
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.

bash
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.

Checked on with Buggregator v2.13.0

Setup in 60 seconds

No registration. No account. Start it and point your app at it.

1

Start Buggregator

One file, installed with one command. The web UI opens on port 8000. Prefer containers? Use the Docker tab.

$ curl -fsSL https://raw.githubusercontent.com/buggregator/server/master/scripts/install.sh | sh
$ HTTP_ADDR=127.0.0.1:8000 \
  SMTP_ADDR=127.0.0.1:1025 \
  VAR_DUMPER_ADDR=127.0.0.1:9912 \
  MONOLOG_ADDR=127.0.0.1:9913 \
  PROXY_ADDR=127.0.0.1:8080 \
  ~/.local/bin/buggregator

The script picks the file for your CPU: Intel/AMD or ARM.

One file for Linux, macOS and Windows, about 40 MB. Nothing else to install.

This run line keeps it on this computer. Without the *_ADDR settings it listens on all network interfaces

Rather not run a script? Download the file yourself

Runs on Windows, macOS and Linux, on Intel/AMD and ARM.

Prefer not to do it yourself? Your AI agent can set Buggregator up for you