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

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

Issue 1486993002: Report "inline" or "eval" for non-fetch CSP violations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 cb2a42ea2bf70b3d84f72c2792319eea1db45e52..6aec61a2858bb5664918cc3455741de74ac9c24c 100644
--- a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
@@ -724,8 +724,9 @@ 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, LocalFrame* contextFrame)
+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)
{
+ ASSERT(violationType == FetchViolation || blockedURL.isEmpty());
ASSERT((m_executionContext && !contextFrame) || (equalIgnoringCase(effectiveDirective, ContentSecurityPolicy::FrameAncestors) && contextFrame));
// FIXME: Support sending reports from worker.
@@ -768,7 +769,17 @@ 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("blocked-uri", violationData.blockedURI());
+ switch (violationType) {
+ case EvalViolation:
+ cspReport->setString("blocked-uri", "eval");
philipj_slow 2015/12/01 13:11:55 The string "eval" doesn't appear in any of the add
+ break;
+ case FetchViolation:
+ cspReport->setString("blocked-uri", violationData.blockedURI());
+ break;
+ case InlineViolation:
+ cspReport->setString("blocked-uri", "inline");
+ break;
+ }
if (!violationData.sourceFile().isEmpty() && violationData.lineNumber()) {
cspReport->setString("source-file", violationData.sourceFile());
cspReport->setNumber("line-number", violationData.lineNumber());

Powered by Google App Engine
This is Rietveld 408576698