Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp

Issue 2331213002: Add `disposition` to SecurityPolicyViolationEvent (Closed)
Patch Set: Update SecurityPolicyViolationEventInit.idl, update test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
diff --git a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
index 0c5577dcbfec8109a8dd7e6d14fb4965ff989401..3f0e51f6d3c3692054dc5c2912944fa667ab0d81 100644
--- a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
@@ -837,7 +837,7 @@ static String stripURLForUseInReport(Document* document, const KURL& url, Redire
return SecurityOrigin::create(url)->toString();
}
-static void gatherSecurityPolicyViolationEventData(SecurityPolicyViolationEventInit& init, Document* document, const String& directiveText, const String& effectiveDirective, const KURL& blockedURL, const String& header, RedirectStatus redirectStatus, ContentSecurityPolicy::ViolationType violationType, int contextLine)
+static void gatherSecurityPolicyViolationEventData(SecurityPolicyViolationEventInit& init, Document* document, const String& directiveText, const String& effectiveDirective, const KURL& blockedURL, const String& header, RedirectStatus redirectStatus, ContentSecurityPolicyHeaderType headerType, ContentSecurityPolicy::ViolationType violationType, int contextLine)
{
if (equalIgnoringCase(effectiveDirective, ContentSecurityPolicy::FrameAncestors)) {
// If this load was blocked via 'frame-ancestors', then the URL of |document| has not yet
@@ -863,6 +863,7 @@ static void gatherSecurityPolicyViolationEventData(SecurityPolicyViolationEventI
init.setViolatedDirective(directiveText);
init.setEffectiveDirective(effectiveDirective);
init.setOriginalPolicy(header);
+ init.setDisposition(headerType == ContentSecurityPolicyHeaderTypeEnforce ? "enforce" : "report");
init.setSourceFile(String());
init.setLineNumber(contextLine);
init.setColumnNumber(0);
@@ -880,7 +881,7 @@ static void gatherSecurityPolicyViolationEventData(SecurityPolicyViolationEventI
}
}
-void ContentSecurityPolicy::reportViolation(const String& directiveText, const String& effectiveDirective, const String& consoleMessage, const KURL& blockedURL, const Vector<String>& reportEndpoints, const String& header, ViolationType violationType, LocalFrame* contextFrame, RedirectStatus redirectStatus, int contextLine)
+void ContentSecurityPolicy::reportViolation(const String& directiveText, const String& effectiveDirective, const String& consoleMessage, const KURL& blockedURL, const Vector<String>& reportEndpoints, const String& header, ContentSecurityPolicyHeaderType headerType, ViolationType violationType, LocalFrame* contextFrame, RedirectStatus redirectStatus, int contextLine)
{
ASSERT(violationType == URLViolation || blockedURL.isEmpty());
@@ -902,7 +903,7 @@ void ContentSecurityPolicy::reportViolation(const String& directiveText, const S
return;
SecurityPolicyViolationEventInit violationData;
- gatherSecurityPolicyViolationEventData(violationData, document, directiveText, effectiveDirective, blockedURL, header, redirectStatus, violationType, contextLine);
+ gatherSecurityPolicyViolationEventData(violationData, document, directiveText, effectiveDirective, blockedURL, header, redirectStatus, headerType, violationType, contextLine);
// TODO(mkwst): Obviously, we shouldn't hit this check, as extension-loaded
// resources should be allowed regardless. We apparently do, however, so
@@ -927,6 +928,7 @@ void ContentSecurityPolicy::reportViolation(const String& directiveText, const S
cspReport->setString("violated-directive", violationData.violatedDirective());
cspReport->setString("effective-directive", violationData.effectiveDirective());
cspReport->setString("original-policy", violationData.originalPolicy());
+ cspReport->setString("disposition", violationData.disposition());
cspReport->setString("blocked-uri", violationData.blockedURI());
if (violationData.lineNumber())
cspReport->setInteger("line-number", violationData.lineNumber());

Powered by Google App Engine
This is Rietveld 408576698