Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (230001 => 230002)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2018-03-27 19:30:59 UTC (rev 230001)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2018-03-27 20:27:55 UTC (rev 230002)
@@ -338,7 +338,12 @@
void NetworkConnectionToWebProcess::cookiesForDOM(PAL::SessionID sessionID, const URL& firstParty, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies, String& cookieString, bool& secureCookiesAccessed)
{
- std::tie(cookieString, secureCookiesAccessed) = WebCore::cookiesForDOM(storageSession(sessionID), firstParty, url, frameID, pageID, includeSecureCookies);
+ auto& networkStorageSession = storageSession(sessionID);
+ std::tie(cookieString, secureCookiesAccessed) = WebCore::cookiesForDOM(networkStorageSession, firstParty, url, frameID, pageID, includeSecureCookies);
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
+ if (NetworkProcess::singleton().shouldLogCookieInformation())
+ NetworkResourceLoader::logCookieInformation("NetworkConnectionToWebProcess::cookiesForDOM", reinterpret_cast<const void*>(this), networkStorageSession, firstParty, url, emptyString(), frameID, pageID, std::nullopt);
+#endif
}
void NetworkConnectionToWebProcess::setCookiesFromDOM(PAL::SessionID sessionID, const URL& firstParty, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& cookieString)
@@ -346,10 +351,8 @@
auto& networkStorageSession = storageSession(sessionID);
WebCore::setCookiesFromDOM(networkStorageSession, firstParty, url, frameID, pageID, cookieString);
#if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
- if (NetworkProcess::singleton().shouldLogCookieInformation()) {
- auto partition = WebCore::URL(ParsedURLString, networkStorageSession.cookieStoragePartition(firstParty, url, frameID, pageID));
- NetworkResourceLoader::logCookieInformation("NetworkConnectionToWebProcess::setCookiesFromDOM", reinterpret_cast<const void*>(this), networkStorageSession, partition, url, emptyString(), frameID, pageID, std::nullopt);
- }
+ if (NetworkProcess::singleton().shouldLogCookieInformation())
+ NetworkResourceLoader::logCookieInformation("NetworkConnectionToWebProcess::setCookiesFromDOM", reinterpret_cast<const void*>(this), networkStorageSession, firstParty, url, emptyString(), frameID, pageID, std::nullopt);
#endif
}
Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (230001 => 230002)
--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp 2018-03-27 19:30:59 UTC (rev 230001)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp 2018-03-27 20:27:55 UTC (rev 230002)
@@ -740,6 +740,11 @@
return s.replace('\\', "\\\\").replace('"', "\\\"");
}
+static String escapeIDForJSON(const std::optional<uint64_t>& value)
+{
+ return value ? String::number(value.value()) : String("None");
+};
+
void NetworkResourceLoader::logCookieInformation() const
{
ASSERT(shouldLogCookieInformation());
@@ -747,39 +752,42 @@
auto networkStorageSession = WebCore::NetworkStorageSession::storageSession(sessionID());
ASSERT(networkStorageSession);
+ logCookieInformation("NetworkResourceLoader", reinterpret_cast<const void*>(this), *networkStorageSession, originalRequest().firstPartyForCookies(), originalRequest().url(), originalRequest().httpReferrer(), frameID(), pageID(), identifier());
+}
+
+static void logBlockedCookieInformation(const String& label, const void* loggedObject, const WebCore::NetworkStorageSession& networkStorageSession, const WebCore::URL& firstParty, const WebCore::URL& url, const String& referrer, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, std::optional<uint64_t> identifier)
+{
+ ASSERT(NetworkResourceLoader::shouldLogCookieInformation());
+
+ auto escapedURL = escapeForJSON(url.string());
+ auto escapedFirstParty = escapeForJSON(firstParty.string());
+ auto escapedFrameID = escapeIDForJSON(frameID);
+ auto escapedPageID = escapeIDForJSON(pageID);
+ auto escapedIdentifier = escapeIDForJSON(identifier);
+ auto escapedReferrer = escapeForJSON(referrer);
+
+#define LOCAL_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(networkStorageSession.sessionID().isAlwaysOnLoggingAllowed(), Network, "%p - %s::" fmt, loggedObject, label.utf8().data(), ##__VA_ARGS__)
#define LOCAL_LOG(str, ...) \
- RELEASE_LOG_IF_ALLOWED("logCookieInformation: pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ": " str, pageID(), frameID(), identifier(), ##__VA_ARGS__)
+ LOCAL_LOG_IF_ALLOWED("logCookieInformation: BLOCKED cookie access for pageID = %s, frameID = %s, resourceID = %s, firstParty = %s: " str, escapedPageID.utf8().data(), escapedFrameID.utf8().data(), escapedIdentifier.utf8().data(), escapedFirstParty.utf8().data(), ##__VA_ARGS__)
- auto url = ""
- if (networkStorageSession->shouldBlockCookies(originalRequest())) {
- auto escapedURL = escapeForJSON(url.string());
- auto escapedReferrer = escapeForJSON(originalRequest().httpReferrer());
-
- LOCAL_LOG(R"({ "url": "%{public}s",)", escapedURL.utf8().data());
- LOCAL_LOG(R"( "partition": "%{public}s",)", "BLOCKED");
- LOCAL_LOG(R"( "hasStorageAccess": %{public}s,)", "false");
- LOCAL_LOG(R"( "referer": "%{public}s",)", escapedReferrer.utf8().data());
- LOCAL_LOG(R"( "cookies": []})");
- return;
- }
+ LOCAL_LOG(R"({ "url": "%{public}s",)", escapedURL.utf8().data());
+ LOCAL_LOG(R"( "partition": "%{public}s",)", "BLOCKED");
+ LOCAL_LOG(R"( "hasStorageAccess": %{public}s,)", "false");
+ LOCAL_LOG(R"( "referer": "%{public}s",)", escapedReferrer.utf8().data());
+ LOCAL_LOG(R"( "cookies": [])");
+ LOCAL_LOG(R"( "})");
#undef LOCAL_LOG
-
- auto partition = WebCore::URL(ParsedURLString, networkStorageSession->cookieStoragePartition(originalRequest(), frameID(), pageID()));
- NetworkResourceLoader::logCookieInformation("NetworkResourceLoader", reinterpret_cast<const void*>(this), *networkStorageSession, partition, url, originalRequest().httpReferrer(), frameID(), pageID(), identifier());
+#undef LOCAL_LOG_IF_ALLOWED
}
-void NetworkResourceLoader::logCookieInformation(const String& label, const void* loggedObject, const WebCore::NetworkStorageSession& networkStorageSession, const WebCore::URL& partition, const WebCore::URL& url, const String& referrer, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, std::optional<uint64_t> identifier)
+static void logCookieInformationInternal(const String& label, const void* loggedObject, const WebCore::NetworkStorageSession& networkStorageSession, const WebCore::URL& partition, const WebCore::URL& url, const String& referrer, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, std::optional<uint64_t> identifier)
{
- ASSERT(shouldLogCookieInformation());
+ ASSERT(NetworkResourceLoader::shouldLogCookieInformation());
Vector<WebCore::Cookie> cookies;
if (!WebCore::getRawCookies(networkStorageSession, partition, url, frameID, pageID, cookies))
return;
- auto escapeIDForJSON = [](std::optional<uint64_t> value) {
- return value ? String::number(value.value()) : String("None");
- };
-
auto escapedURL = escapeForJSON(url.string());
auto escapedPartition = escapeForJSON(partition.string());
auto escapedReferrer = escapeForJSON(referrer);
@@ -829,6 +837,18 @@
#undef LOCAL_LOG
#undef LOCAL_LOG_IF_ALLOWED
}
+
+void NetworkResourceLoader::logCookieInformation(const String& label, const void* loggedObject, const NetworkStorageSession& networkStorageSession, const URL& firstParty, const URL& url, const String& referrer, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, std::optional<uint64_t> identifier)
+{
+ ASSERT(shouldLogCookieInformation());
+
+ if (networkStorageSession.shouldBlockCookies(firstParty, url))
+ logBlockedCookieInformation(label, loggedObject, networkStorageSession, firstParty, url, referrer, frameID, pageID, identifier);
+ else {
+ auto partition = URL(ParsedURLString, networkStorageSession.cookieStoragePartition(firstParty, url, frameID, pageID));
+ logCookieInformationInternal(label, loggedObject, networkStorageSession, partition, url, referrer, frameID, pageID, identifier);
+ }
+}
#endif
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h (230001 => 230002)
--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h 2018-03-27 19:30:59 UTC (rev 230001)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h 2018-03-27 20:27:55 UTC (rev 230002)
@@ -107,7 +107,7 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
static bool shouldLogCookieInformation();
- static void logCookieInformation(const String& label, const void* loggedObject, const WebCore::NetworkStorageSession&, const WebCore::URL& partition, const WebCore::URL&, const String& referrer, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, std::optional<uint64_t> identifier);
+ static void logCookieInformation(const String& label, const void* loggedObject, const WebCore::NetworkStorageSession&, const WebCore::URL& firstParty, const WebCore::URL&, const String& referrer, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, std::optional<uint64_t> identifier);
#endif
private: