Changeset 230002 in webkit
- Timestamp:
- Mar 27, 2018 1:27:55 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r230000 r230002 1 2018-03-27 Brent Fulgham <bfulgham@apple.com> 2 3 Further refine cookie read/write logging 4 https://bugs.webkit.org/show_bug.cgi?id=184044 5 <rdar://problem/38915610> 6 7 Reviewed by Chris Dumez. 8 9 Export 'shouldBlockCookies' so that it can be accessed by the WebKit framework. 10 11 * platform/network/NetworkStorageSession.h: 12 1 13 2018-03-27 Antoine Quint <graouts@apple.com> 2 14 -
trunk/Source/WebCore/platform/network/NetworkStorageSession.h
r229978 r230002 104 104 WEBCORE_EXPORT String cookieStoragePartition(const ResourceRequest&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const; 105 105 WEBCORE_EXPORT bool shouldBlockCookies(const ResourceRequest&) const; 106 bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource) const;106 WEBCORE_EXPORT bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource) const; 107 107 WEBCORE_EXPORT String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const; 108 108 WEBCORE_EXPORT void setPrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool clearFirst); -
trunk/Source/WebKit/ChangeLog
r229998 r230002 1 2018-03-27 Brent Fulgham <bfulgham@apple.com> 2 3 Further refine cookie read/write logging 4 https://bugs.webkit.org/show_bug.cgi?id=184044 5 <rdar://problem/38915610> 6 7 Reviewed by Chris Dumez. 8 9 Cookie logging was passing the partition, rather than the first party, when logging, which 10 prevented logging in cases where partitioning or blocking was active. This patch corrects 11 these calls so that logging is generated in these cases, too. 12 13 * NetworkProcess/NetworkConnectionToWebProcess.cpp: 14 (WebKit::NetworkConnectionToWebProcess::cookiesForDOM): Call log routines if needed. 15 (WebKit::NetworkConnectionToWebProcess::setCookiesFromDOM): Ditto. 16 * NetworkProcess/NetworkResourceLoader.cpp: 17 (WebKit::escapeIDForJSON): Make available to use in multiple functions. 18 (WebKit::NetworkResourceLoader::logCookieInformation const): Revise to use shared 19 convenience functions. 20 (WebKit::logBlockedCookieInformation): Added. 21 (WebKit::logCookieInformationInternal): Added. 22 (WebKit::NetworkResourceLoader::logCookieInformation): Revise to use shared 23 convenience functions. 24 * NetworkProcess/NetworkResourceLoader.h: 25 1 26 2018-03-27 Brian Burg <bburg@apple.com> 2 27 -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
r228551 r230002 339 339 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) 340 340 { 341 std::tie(cookieString, secureCookiesAccessed) = WebCore::cookiesForDOM(storageSession(sessionID), firstParty, url, frameID, pageID, includeSecureCookies); 341 auto& networkStorageSession = storageSession(sessionID); 342 std::tie(cookieString, secureCookiesAccessed) = WebCore::cookiesForDOM(networkStorageSession, firstParty, url, frameID, pageID, includeSecureCookies); 343 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED 344 if (NetworkProcess::singleton().shouldLogCookieInformation()) 345 NetworkResourceLoader::logCookieInformation("NetworkConnectionToWebProcess::cookiesForDOM", reinterpret_cast<const void*>(this), networkStorageSession, firstParty, url, emptyString(), frameID, pageID, std::nullopt); 346 #endif 342 347 } 343 348 … … 347 352 WebCore::setCookiesFromDOM(networkStorageSession, firstParty, url, frameID, pageID, cookieString); 348 353 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED 349 if (NetworkProcess::singleton().shouldLogCookieInformation()) { 350 auto partition = WebCore::URL(ParsedURLString, networkStorageSession.cookieStoragePartition(firstParty, url, frameID, pageID)); 351 NetworkResourceLoader::logCookieInformation("NetworkConnectionToWebProcess::setCookiesFromDOM", reinterpret_cast<const void*>(this), networkStorageSession, partition, url, emptyString(), frameID, pageID, std::nullopt); 352 } 354 if (NetworkProcess::singleton().shouldLogCookieInformation()) 355 NetworkResourceLoader::logCookieInformation("NetworkConnectionToWebProcess::setCookiesFromDOM", reinterpret_cast<const void*>(this), networkStorageSession, firstParty, url, emptyString(), frameID, pageID, std::nullopt); 353 356 #endif 354 357 } -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
r229569 r230002 741 741 } 742 742 743 static String escapeIDForJSON(const std::optional<uint64_t>& value) 744 { 745 return value ? String::number(value.value()) : String("None"); 746 }; 747 743 748 void NetworkResourceLoader::logCookieInformation() const 744 749 { … … 748 753 ASSERT(networkStorageSession); 749 754 755 logCookieInformation("NetworkResourceLoader", reinterpret_cast<const void*>(this), *networkStorageSession, originalRequest().firstPartyForCookies(), originalRequest().url(), originalRequest().httpReferrer(), frameID(), pageID(), identifier()); 756 } 757 758 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) 759 { 760 ASSERT(NetworkResourceLoader::shouldLogCookieInformation()); 761 762 auto escapedURL = escapeForJSON(url.string()); 763 auto escapedFirstParty = escapeForJSON(firstParty.string()); 764 auto escapedFrameID = escapeIDForJSON(frameID); 765 auto escapedPageID = escapeIDForJSON(pageID); 766 auto escapedIdentifier = escapeIDForJSON(identifier); 767 auto escapedReferrer = escapeForJSON(referrer); 768 769 #define LOCAL_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(networkStorageSession.sessionID().isAlwaysOnLoggingAllowed(), Network, "%p - %s::" fmt, loggedObject, label.utf8().data(), ##__VA_ARGS__) 750 770 #define LOCAL_LOG(str, ...) \ 751 RELEASE_LOG_IF_ALLOWED("logCookieInformation: pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ": " str, pageID(), frameID(), identifier(), ##__VA_ARGS__) 752 753 auto url = originalRequest().url(); 754 if (networkStorageSession->shouldBlockCookies(originalRequest())) { 755 auto escapedURL = escapeForJSON(url.string()); 756 auto escapedReferrer = escapeForJSON(originalRequest().httpReferrer()); 757 758 LOCAL_LOG(R"({ "url": "%{public}s",)", escapedURL.utf8().data()); 759 LOCAL_LOG(R"( "partition": "%{public}s",)", "BLOCKED"); 760 LOCAL_LOG(R"( "hasStorageAccess": %{public}s,)", "false"); 761 LOCAL_LOG(R"( "referer": "%{public}s",)", escapedReferrer.utf8().data()); 762 LOCAL_LOG(R"( "cookies": []})"); 763 return; 764 } 771 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__) 772 773 LOCAL_LOG(R"({ "url": "%{public}s",)", escapedURL.utf8().data()); 774 LOCAL_LOG(R"( "partition": "%{public}s",)", "BLOCKED"); 775 LOCAL_LOG(R"( "hasStorageAccess": %{public}s,)", "false"); 776 LOCAL_LOG(R"( "referer": "%{public}s",)", escapedReferrer.utf8().data()); 777 LOCAL_LOG(R"( "cookies": [])"); 778 LOCAL_LOG(R"( "})"); 765 779 #undef LOCAL_LOG 766 767 auto partition = WebCore::URL(ParsedURLString, networkStorageSession->cookieStoragePartition(originalRequest(), frameID(), pageID())); 768 NetworkResourceLoader::logCookieInformation("NetworkResourceLoader", reinterpret_cast<const void*>(this), *networkStorageSession, partition, url, originalRequest().httpReferrer(), frameID(), pageID(), identifier()); 769 } 770 771 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) 772 { 773 ASSERT(shouldLogCookieInformation()); 780 #undef LOCAL_LOG_IF_ALLOWED 781 } 782 783 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) 784 { 785 ASSERT(NetworkResourceLoader::shouldLogCookieInformation()); 774 786 775 787 Vector<WebCore::Cookie> cookies; 776 788 if (!WebCore::getRawCookies(networkStorageSession, partition, url, frameID, pageID, cookies)) 777 789 return; 778 779 auto escapeIDForJSON = [](std::optional<uint64_t> value) {780 return value ? String::number(value.value()) : String("None");781 };782 790 783 791 auto escapedURL = escapeForJSON(url.string()); … … 830 838 #undef LOCAL_LOG_IF_ALLOWED 831 839 } 840 841 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) 842 { 843 ASSERT(shouldLogCookieInformation()); 844 845 if (networkStorageSession.shouldBlockCookies(firstParty, url)) 846 logBlockedCookieInformation(label, loggedObject, networkStorageSession, firstParty, url, referrer, frameID, pageID, identifier); 847 else { 848 auto partition = URL(ParsedURLString, networkStorageSession.cookieStoragePartition(firstParty, url, frameID, pageID)); 849 logCookieInformationInternal(label, loggedObject, networkStorageSession, partition, url, referrer, frameID, pageID, identifier); 850 } 851 } 832 852 #endif 833 853 -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h
r229560 r230002 108 108 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED 109 109 static bool shouldLogCookieInformation(); 110 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);110 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); 111 111 #endif 112 112
Note: See TracChangeset
for help on using the changeset viewer.