Uh oh!
There was an error while loading. Please reload this page.
Add support for W3C Reporting API - #556
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements support for the W3C Reporting API to enable standardized browser reporting for security violations and other issues.
Key changes:
- Added ReportingEndpoints header class to configure named reporting endpoints
- Added report_to directive to Content Security Policy for modern browser reporting
- Introduced new :string directive type for single token CSP values
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spec/lib/secure_headers/headers/reporting_endpoints_spec.rb | Test coverage for ReportingEndpoints header validation and generation |
| spec/lib/secure_headers/headers/content_security_policy_spec.rb | Tests for report-to directive in CSP including ordering with report-uri |
| lib/secure_headers/headers/reporting_endpoints.rb | Implementation of ReportingEndpoints header class with validation |
| lib/secure_headers/headers/policy_management.rb | Added report_to directive to CSP constants and validation logic |
| lib/secure_headers/headers/content_security_policy.rb | Added string directive type support and report_to to directive ordering |
| lib/secure_headers/configuration.rb | Registered reporting_endpoints in header class mapping |
| lib/secure_headers.rb | Required the new reporting_endpoints file |
| README.md | Documentation for W3C Reporting API usage and browser compatibility |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
7443a2d to
7373ce9CompareThere was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
7373ce9 to
6da4ee9Compare- Updated .rubocop.yml to use plugins instead of require for rubocop-performance - Auto-fixed 79 style offenses including: - Changed OrAssignment to use ||= operator - Converted class << self to def self. method definitions - Fixed hash literal brace spacing throughout specs - Manually fixed remaining GitHub/AvoidObjectSendWithDynamicMethod warning by using public_send with a disable comment for intentional dynamic dispatch in test code All rubocop checks now pass with 0 offenses.
6da4ee9 to
ea89038CompareImplements support for the W3C Reporting API (https://w3c.github.io/reporting/) to enable standardized browser reporting for security violations and other issues. Changes include: 1. New Reporting-Endpoints Header: - Added ReportingEndpoints header class to configure named reporting endpoints - Accepts hash configuration: { default: "https://example.com/reports" } - Generates header: Reporting-Endpoints: default="https://example.com/reports" 2. CSP report-to Directive: - Added report_to directive to Content Security Policy - New :string directive type for single token values - Positioned before legacy report-uri directive for clarity 3. Configuration Updates: - Registered reporting_endpoints in CONFIG_ATTRIBUTES_TO_HEADER_CLASSES - Added report_to to DIRECTIVES_3_0 (CSP Level 3) - Updated NON_FETCH_SOURCES to include report_to 4. Tests: - Complete test coverage for ReportingEndpoints header - CSP tests for report-to directive - Integration tests for both headers working together 5. Documentation: - Added W3C Reporting API section to README - Usage examples for both modern and legacy browser support - Configuration examples showing endpoint definition and CSP integration Addresses issue github#512 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
ea89038 to
23b35e7Comparetmaier
commented
Nov 19, 2025
I rebased this on #558 , since the rubocop issues reported are independent of this PR. |
tmaier
commented
Apr 1, 2026
I thin this is obsolete due to #566 |
Fixes#512
Implements support for the W3C Reporting API (https://w3c.github.io/reporting/)
to enable standardized browser reporting for security violations and other issues.
Changes include:
New Reporting-Endpoints Header:
CSP report-to Directive:
Configuration Updates:
Tests:
Documentation:
Addresses issue #512
🤖 Generated with Claude Code
All PRs:
spec/lib/secure_headers/headers/reporting_endpoints_spec.rb- Tests for Reporting-Endpoints headerspec/lib/secure_headers/headers/content_security_policy_spec.rb- Tests for CSP report-to directiveAdding a new header: Reporting-Endpoints
Is the header supported by any user agent? If so, which?
Browser compatibility: https://caniuse.com/wf-reporting
What does it do?
The
Reporting-Endpointsheader defines named endpoints where browsers can send various types of reports using the W3C Reporting API. These reports include:It replaces the deprecated
Report-Toheader with a simpler, more efficient format.What are the valid values for the header?
A comma-separated list of endpoint definitions in the format:
name="url"Examples:
default="https://example.com/reports"default="https://example.com/reports", csp="https://example.com/csp"Each endpoint must have:
Where does the specification live?
Adding a new CSP directive: report-to
Is the directive supported by any user agent? If so, which?
Browser compatibility: https://caniuse.com/mdn-http_headers_content-security-policy_report-to
What does it do?
The
report-todirective specifies the name of a reporting endpoint (defined in theReporting-Endpointsheader) where the browser should send CSP violation reports. This is the modern replacement for thereport-uridirective.Key differences from
report-uri:What are the valid values for the directive?
A single token (string) representing the endpoint name defined in the
Reporting-Endpointsheader.Examples:
report-to default- References the "default" endpointreport-to csp-endpoint- References the "csp-endpoint" endpointUnlike
report-uri(which accepts an array of URLs),report-toaccepts only a single endpoint name.Where does the specification live?
Additional Notes:
For maximum browser compatibility, both
report-to(modern) andreport-uri(legacy) can be used simultaneously:Modern browsers will use
report-toand ignorereport-uri, while older browsers will fall back toreport-uri.