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

Unified Diff: third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp

Issue 2873223003: CSP: Measure the frequency of `postMessage` violating `connect-src` (Closed)
Patch Set: Rebase. Created 3 years, 7 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/LocalDOMWindow.cpp
diff --git a/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp b/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
index 9007394cea928f54107e772671fd1fdf9d5ceaae..d9996e754ec66e953b6d43bf7771b41b4fd16245 100644
--- a/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
+++ b/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
@@ -65,6 +65,7 @@
#include "core/frame/Settings.h"
#include "core/frame/SuspendableTimer.h"
#include "core/frame/VisualViewport.h"
+#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/html/HTMLFrameOwnerElement.h"
#include "core/input/EventHandler.h"
#include "core/inspector/ConsoleMessage.h"
@@ -703,6 +704,14 @@ void LocalDOMWindow::DispatchMessageEventWithOriginCheck(
}
}
+ KURL sender(kParsedURLString, static_cast<MessageEvent*>(event)->origin());
+ if (!document()->GetContentSecurityPolicy()->AllowConnectToSource(
+ sender, RedirectStatus::kNoRedirect,
+ SecurityViolationReportingPolicy::kSuppressReporting)) {
+ UseCounter::Count(
+ GetFrame(), UseCounter::kPostMessageIncomingWouldBeBlockedByConnectSrc);
+ }
+
DispatchEvent(event);
}
« no previous file with comments | « third_party/WebKit/Source/core/frame/DOMWindow.cpp ('k') | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698