Issue #2405 - Add a pref to disable CSP reporting.

Resolves #2405
This commit is contained in:
Moonchild 2023-12-17 22:56:04 +01:00 • committed by roytam1
commit f1f9dde29e
4 changed files with 17 additions and 2 deletions

View file

@ -827,6 +827,16 @@ nsCSPContext::SendReports(nsISupports* aBlockedContentSource,
{
NS_ENSURE_ARG_MAX(aViolatedPolicyIndex, mPolicies.Length() - 1);
if (!CSPService::sCSPReportingEnabled) {
// Reporting is pref-disabled. Don't do any actual work and return success.
nsContentUtils::ReportToConsoleNonLocalized(
NS_LITERAL_STRING("CSP violation report not sent: reports have been disabled contrary to spec."),
nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("Content Security Policy"),
nullptr);
return NS_OK;
}
dom::CSPReport report;
nsresult rv;