Test Content Security Policy without breaking your site
๐งช Report-Only Mode Active: CSP violations are logged but not blocked!
This allows you to test CSP policies before enforcing them in production.
๐ Report-Only CSP Configuration
Content-Security-Policy-Report-Only:
default-src 'self'; // Would block: external resources
script-src 'self'; // Would block: inline scripts, external scripts
style-src 'self'; // Would block: inline styles, external stylesheets
img-src 'self' data: https:; // Would allow: same-origin, data URLs, HTTPS images
report-uri #csp-violation-report // Send violations to this endpoint
๐ฏ What Report-Only Mode Does:
โ Allows everything to execute - No functionality breaks
๐ Reports violations - Logs what would be blocked
๐ Identifies issues - Shows where CSP would cause problems
๐ Collects data - Gathers statistics for policy refinement
๐ Safe testing - Perfect for production testing
0
Total Violations
0
Script Violations
0
Style Violations
0
Unique Sources
๐ฏ Generate Test Violations
These actions will trigger CSP violations (but still execute in Report-Only mode):
1. Inline Script Violation
2. External Script Violation
3. Inline Style Violation
4. eval() Violation
5. Event Handler Violation
๐ Real-time Violation Monitoring
CSP violations are automatically detected and logged below:
๐งช Report-Only CSP monitoring active
Violations will appear here as they occur
๐ CSP Deployment Strategy
Phase 1: Report-Only Testing (Current)
# Step 1: Deploy with Report-Only header
Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self'; report-uri /csp-violations
# Step 2: Monitor violations for 1-2 weeks
# Step 3: Analyze patterns and adjust policy
Phase 2: Policy Refinement
# Common adjustments based on violations:
# Allow specific external scripts
script-src 'self' https://trusted-cdn.com https://analytics.google.com
# Allow inline styles (if needed)
style-src 'self' 'unsafe-inline'
# Allow data URLs for images
img-src 'self' data: https:
# Final policy example:
Content-Security-Policy-Report-Only:
default-src 'self';
script-src 'self' https://trusted-cdn.com;
style-src 'self' 'unsafe-inline';
img-src 'self' data: https:;
report-uri /csp-violations
Phase 3: Gradual Enforcement
# Step 1: Switch to enforcement mode for small percentage
Content-Security-Policy: [refined-policy]; report-uri /csp-violations
# Step 2: Monitor for new violations
# Step 3: Gradually increase enforcement percentage
# Step 4: Full deployment once stable
๐ฏ Analysis Checklist:
๐ Volume patterns: Which violations are most common?
๐ Source analysis: Which external resources are needed?
โฐ Timing patterns: When do violations occur most?
๐ฅ User impact: Which violations affect functionality?
๐ก๏ธ Security vs usability: Balance protection with user experience