Skip to content

Conversation

@labkey-adam
Copy link
Contributor

@labkey-adam labkey-adam commented Jan 30, 2026

Rationale

Security scanners like to see report-to directives, even though not all browsers support them. https://github.com/LabKey/internal-issues/issues/794

Related Pull Requests

Copy link
Contributor

@labkey-jeckels labkey-jeckels left a comment

Choose a reason for hiding this comment

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

Some suggestions, but not sure if they're all viable.

Comment on lines 128 to +129
public static final MimeType CSP = new MimeType("application/csp-report", false, true);
public static final MimeType CSP_REPORT = new MimeType("application/reports+json", false, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider CSP_V1 and CSP_V3 or similar, as they both seems like CSP reports.

{
// Generate the Reporting-Endpoints header value now since its value is static. Use an absolute URL so we
// always post reports to https:, even when the violating request happens to be http:
String violationEndpoint = substituteReportParams(baseServerUrl + "/admin-contentSecurityPolicyReportTo.api?${CSP.REPORT.PARAMS}");
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this use ActionURL, at least for the parts other than the substitution syntax? It could add the CSP version too, which could theoretically need URI encoding

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried, but it's quite awkward given the substitution has to be in the middle of the URL. I took another stab. I guess it's okay.

}
}

String baseServerUrl = AppProps.getInstance().getBaseServerUrl();
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work when bootstrapping a server? And what happens if the base URL is changed after startup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll check. Can probably switch to populating this lazily and any time the base server URL changes.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants