Skip to content

Conversation

jamie-taylor-rjj
Copy link
Collaborator

@jamie-taylor-rjj jamie-taylor-rjj commented Mar 29, 2025

Rationale for this PR

This PR adds the Reporting-Endpoints header, configuration for it, updates the relevant documentation, and increases the version number.

This PR closes #170

The following is a minimal code sample for the new feature:

// in Program.cs
var reportingEndpoints =
    new Dictionary<string, Uri> {
        { "standard", new Uri("https://localhost:5000/reporting-endpoint") }
    };
var secureHeadersMiddlewareConfig = SecureHeadersMiddlewareBuilder.CreateBuilder()
    .UseReportingEndpointsPolicy(reportingEndpoints)
    .Build();
app.UseSecureHeadersMiddleware(secureHeadersMiddlewareConfig);

PR Checklist

Feel free to either check the following items (by place an x inside of the square brackets) or by replacing the square brackets with a relevant emoji from the following list:

  • ✅ to indicate that you have checked something off
  • ❎ to indicate that you haven't checked something off
  • ❓ to indicate that something might not be relevant (writing tests for documentation changes, for instance)

Essential

These items are essential and must be completed for each commit. If they are not completed, the PR may not be accepted.

  • [ ✅ ] I have added tests to the OwaspHeaders.Core.Tests project
  • [ ✅ ] I have run the dotnet-format command and fixed any .editorconfig issues
  • [ ✅ ] I have ensured that the code coverage has not dropped below 65%
  • [ ✅ ] I have increased the version number in OwaspHeaders.Core.csproj (only relevant for code changes)

Optional

  • [ ✅ ] I have documented the new feature in the docs directory
  • [ ✅ ] I have provided a code sample, showing how someone could use the new code

Any Other Information

This PR adds experimental functionality. Depending on feedback, it might not be closed.

@GaProgMan GaProgMan marked this pull request as ready for review March 29, 2025 16:48
GaProgMan
GaProgMan previously approved these changes Aug 4, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements support for the experimental Reporting-Endpoints HTTP header, which allows website administrators to specify endpoints for receiving reports from the browser's Reporting API. The header is intended to work with Content Security Policy (CSP) and other security policies that can generate violation reports.

  • Adds ReportingEndpointsPolicy model with configuration and header value generation
  • Implements middleware support for the new header with UseReportingEndpointsPolicy extension method
  • Updates CSP configuration to support the modern report-to directive alongside the deprecated report-uri

Reviewed Changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Models/ReportingEndpointsPolicy.cs New model class for configuring Reporting-Endpoints header with endpoint name-to-URI mappings
src/Extensions/SecureHeadersMiddlewareBuilder.cs Adds builder method for configuring Reporting-Endpoints policy and updates CSP methods
src/Models/ContentSecurityPolicyConfiguration.cs Adds support for report-to directive and marks report-uri as obsolete
src/Extensions/StringBuilderExtensions.cs New utility method for removing trailing characters from StringBuilder
tests/OwaspHeaders.Core.Tests/CustomHeaders/ReportingEndpointsTests.cs Test coverage for the new Reporting-Endpoints functionality
docs/configuration/ReportingEndpoints.md Documentation for the experimental header with appropriate warnings

@GaProgMan
Copy link
Owner

As PR #189 will likely be merged ahead of this one, we'll need a version bump on this PR.

@jamie-taylor-rjj jamie-taylor-rjj deleted the bugfix/coep-default-header-value branch October 1, 2025 12:29
@jamie-taylor-rjj jamie-taylor-rjj restored the bugfix/coep-default-header-value branch October 1, 2025 12:32
@jamie-taylor-rjj
Copy link
Collaborator Author

Deleted the wrong branch when trying to clean up. Sorry all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Add support for CSP report-to directive
2 participants