Changeset 228111 in webkit
- Timestamp:
- Feb 5, 2018 12:03:48 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r228110 r228111 1 2018-02-02 Brent Fulgham <bfulgham@apple.com> 2 3 Improve NetworkResourceLoader logging so it can be used for 'setCookiesFromDOM' 4 https://bugs.webkit.org/show_bug.cgi?id=182455 5 <rdar://problem/36626601> 6 7 Reviewed by Chris Dumez. 8 9 After this refactoring, a convenience method I added in r227860 is no longer needed. 10 This patch removes this dead code. 11 12 * platform/network/NetworkStorageSession.h: Export 'cookieStoragePartition' so it can 13 be used in WebKit. 14 * platform/network/cf/NetworkStorageSessionCFNet.cpp: 15 (WebCore::NetworkStorageSession::hasStorageAccessForFrame): Deleted unused method. 16 1 17 2018-02-05 Antti Koivisto <antti@apple.com> 2 18 -
trunk/Source/WebCore/platform/network/NetworkStorageSession.h
r228109 r228111 102 102 WEBCORE_EXPORT bool shouldBlockCookies(const ResourceRequest&) const; 103 103 bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource) const; 104 String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const;104 WEBCORE_EXPORT String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const; 105 105 WEBCORE_EXPORT void setPrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool clearFirst); 106 106 WEBCORE_EXPORT void removePrevalentDomains(const Vector<String>& domains); 107 107 WEBCORE_EXPORT bool hasStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID) const; 108 WEBCORE_EXPORT bool hasStorageAccessForFrame(const ResourceRequest&, uint64_t frameID, uint64_t pageID) const;109 108 WEBCORE_EXPORT Vector<String> getAllStorageAccessEntries() const; 110 109 WEBCORE_EXPORT void grantStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID); -
trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp
r228109 r228111 297 297 } 298 298 299 bool NetworkStorageSession::hasStorageAccessForFrame(const ResourceRequest& request, uint64_t frameID, uint64_t pageID) const300 {301 if (!cookieStoragePartitioningEnabled)302 return false;303 304 return hasStorageAccessForFrame(getPartitioningDomain(request.url()), getPartitioningDomain(request.firstPartyForCookies()), frameID, pageID);305 }306 307 299 Vector<String> NetworkStorageSession::getAllStorageAccessEntries() const 308 300 { -
trunk/Source/WebKit/ChangeLog
r228109 r228111 1 2018-02-02 Brent Fulgham <bfulgham@apple.com> 2 3 Improve NetworkResourceLoader logging so it can be used for 'setCookiesFromDOM' 4 https://bugs.webkit.org/show_bug.cgi?id=182455 5 <rdar://problem/36626601> 6 7 Reviewed by Chris Dumez. 8 9 Refactor "logCookieInformation" so that it can be used for resource loads and DOM cookie 10 manipulation. Place the generally useful logic in a static method that can be invoked 11 from other places in the NetworkProcess. 12 13 Call the new refactored method from NetworkConnectionToWebProcess::setCookiesFromDOM so 14 we can perform logging there as well. 15 16 * NetworkProcess/NetworkConnectionToWebProcess.cpp: 17 (WebKit::NetworkConnectionToWebProcess::setCookiesFromDOM): Call the new logging method 18 (when enabled). 19 * NetworkProcess/NetworkResourceLoader.cpp: 20 (WebKit::NetworkResourceLoader::shouldLogCookieInformation): Changed to static method. 21 (WebKit::escapeForJSON): Made a static function so it could be shared between multiple 22 methods. 23 (WebKit::NetworkResourceLoader::logCookieInformation const): Refactor into two methods. 24 (WebKit::NetworkResourceLoader::logCookieInformation): Ditto. 25 (WebKit::NetworkResourceLoader::shouldLogCookieInformation const): Deleted. 26 * NetworkProcess/NetworkResourceLoader.h: 27 * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: 28 (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa): Switch to user-enabled release logging 29 to track partitioning and blocking behavior. 30 1 31 2018-02-05 John Wilander <wilander@apple.com> 2 32 -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
r227682 r228111 1 1 /* 2 * Copyright (C) 2012-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2012-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 343 343 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) 344 344 { 345 WebCore::setCookiesFromDOM(storageSession(sessionID), firstParty, url, frameID, pageID, cookieString); 345 auto& networkStorageSession = storageSession(sessionID); 346 WebCore::setCookiesFromDOM(networkStorageSession, firstParty, url, frameID, pageID, cookieString); 347 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED 348 if (NetworkProcess::singleton().shouldLogCookieInformation()) { 349 auto partition = WebCore::URL(ParsedURLString, networkStorageSession.cookieStoragePartition(firstParty, url, frameID, pageID)); 350 NetworkResourceLoader::logCookieInformation("NetworkConnectionToWebProcess::setCookiesFromDOM", reinterpret_cast<const void*>(this), networkStorageSession, partition, url, emptyString(), frameID, pageID, std::nullopt); 351 } 352 #endif 346 353 } 347 354 -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
r227991 r228111 711 711 712 712 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED 713 bool NetworkResourceLoader::shouldLogCookieInformation() const713 bool NetworkResourceLoader::shouldLogCookieInformation() 714 714 { 715 715 return NetworkProcess::singleton().shouldLogCookieInformation(); 716 } 717 718 static String escapeForJSON(String s) 719 { 720 return s.replace('\\', "\\\\").replace('"', "\\\""); 716 721 } 717 722 … … 725 730 #define LOCAL_LOG(str, ...) \ 726 731 RELEASE_LOG_IF_ALLOWED("logCookieInformation: pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ": " str, pageID(), frameID(), identifier(), ##__VA_ARGS__) 727 728 auto escapeForJSON = [](String s) {729 return s.replace('\\', "\\\\").replace('"', "\\\"");730 };731 732 732 733 auto url = originalRequest().url(); … … 742 743 return; 743 744 } 745 #undef LOCAL_LOG 744 746 745 747 auto partition = WebCore::URL(ParsedURLString, networkStorageSession->cookieStoragePartition(originalRequest(), frameID(), pageID())); 746 bool hasStorageAccessForFrame = networkStorageSession->hasStorageAccessForFrame(originalRequest(), frameID(), pageID()); 748 NetworkResourceLoader::logCookieInformation("NetworkResourceLoader", reinterpret_cast<const void*>(this), *networkStorageSession, partition, url, originalRequest().httpReferrer(), frameID(), pageID(), identifier()); 749 } 750 751 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) 752 { 753 ASSERT(shouldLogCookieInformation()); 747 754 748 755 Vector<WebCore::Cookie> cookies; 749 bool result = WebCore::getRawCookies(*networkStorageSession, partition, url, frameID(), pageID(), cookies); 750 751 if (result) { 752 auto escapedURL = escapeForJSON(url.string()); 753 auto escapedPartition = escapeForJSON(partition.string()); 754 auto escapedReferrer = escapeForJSON(originalRequest().httpReferrer()); 755 756 LOCAL_LOG(R"({ "url": "%{public}s",)", escapedURL.utf8().data()); 757 LOCAL_LOG(R"( "partition": "%{public}s",)", escapedPartition.utf8().data()); 758 LOCAL_LOG(R"( "hasStorageAccess": %{public}s,)", hasStorageAccessForFrame ? "true" : "false"); 759 LOCAL_LOG(R"( "referer": "%{public}s",)", escapedReferrer.utf8().data()); 760 LOCAL_LOG(R"( "cookies": [)"); 761 762 auto size = cookies.size(); 763 decltype(size) count = 0; 764 for (const auto& cookie : cookies) { 765 const char* trailingComma = ","; 766 if (++count == size) 767 trailingComma = ""; 768 769 auto escapedName = escapeForJSON(cookie.name); 770 auto escapedValue = escapeForJSON(cookie.value); 771 auto escapedDomain = escapeForJSON(cookie.domain); 772 auto escapedPath = escapeForJSON(cookie.path); 773 auto escapedComment = escapeForJSON(cookie.comment); 774 auto escapedCommentURL = escapeForJSON(cookie.commentURL.string()); 775 776 LOCAL_LOG(R"( { "name": "%{public}s",)", escapedName.utf8().data()); 777 LOCAL_LOG(R"( "value": "%{public}s",)", escapedValue.utf8().data()); 778 LOCAL_LOG(R"( "domain": "%{public}s",)", escapedDomain.utf8().data()); 779 LOCAL_LOG(R"( "path": "%{public}s",)", escapedPath.utf8().data()); 780 LOCAL_LOG(R"( "created": %f,)", cookie.created); 781 LOCAL_LOG(R"( "expires": %f,)", cookie.expires); 782 LOCAL_LOG(R"( "httpOnly": %{public}s,)", cookie.httpOnly ? "true" : "false"); 783 LOCAL_LOG(R"( "secure": %{public}s,)", cookie.secure ? "true" : "false"); 784 LOCAL_LOG(R"( "session": %{public}s,)", cookie.session ? "true" : "false"); 785 LOCAL_LOG(R"( "comment": "%{public}s",)", escapedComment.utf8().data()); 786 LOCAL_LOG(R"( "commentURL": "%{public}s")", escapedCommentURL.utf8().data()); 787 LOCAL_LOG(R"( }%{public}s)", trailingComma); 788 } 789 LOCAL_LOG(R"(]})"); 756 if (!WebCore::getRawCookies(networkStorageSession, partition, url, frameID, pageID, cookies)) 757 return; 758 759 auto escapeIDForJSON = [](std::optional<uint64_t> value) { 760 return value ? String::number(value.value()) : String("None"); 761 }; 762 763 auto escapedURL = escapeForJSON(url.string()); 764 auto escapedPartition = escapeForJSON(partition.string()); 765 auto escapedReferrer = escapeForJSON(referrer); 766 auto escapedFrameID = escapeIDForJSON(frameID); 767 auto escapedPageID = escapeIDForJSON(pageID); 768 auto escapedIdentifier = escapeIDForJSON(identifier); 769 bool hasStorageAccessForFrame = (frameID && pageID) ? networkStorageSession.hasStorageAccessForFrame(url.string(), partition.string(), frameID.value(), pageID.value()) : false; 770 771 #define LOCAL_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(networkStorageSession.sessionID().isAlwaysOnLoggingAllowed(), Network, "%p - %s::" fmt, loggedObject, label.utf8().data(), ##__VA_ARGS__) 772 #define LOCAL_LOG(str, ...) \ 773 LOCAL_LOG_IF_ALLOWED("logCookieInformation: pageID = %s, frameID = %s, resourceID = %s: " str, escapedPageID.utf8().data(), escapedFrameID.utf8().data(), escapedIdentifier.utf8().data(), ##__VA_ARGS__) 774 775 LOCAL_LOG(R"({ "url": "%{public}s",)", escapedURL.utf8().data()); 776 LOCAL_LOG(R"( "partition": "%{public}s",)", escapedPartition.utf8().data()); 777 LOCAL_LOG(R"( "hasStorageAccess": %{public}s,)", hasStorageAccessForFrame ? "true" : "false"); 778 LOCAL_LOG(R"( "referer": "%{public}s",)", escapedReferrer.utf8().data()); 779 LOCAL_LOG(R"( "cookies": [)"); 780 781 auto size = cookies.size(); 782 decltype(size) count = 0; 783 for (const auto& cookie : cookies) { 784 const char* trailingComma = ","; 785 if (++count == size) 786 trailingComma = ""; 787 788 auto escapedName = escapeForJSON(cookie.name); 789 auto escapedValue = escapeForJSON(cookie.value); 790 auto escapedDomain = escapeForJSON(cookie.domain); 791 auto escapedPath = escapeForJSON(cookie.path); 792 auto escapedComment = escapeForJSON(cookie.comment); 793 auto escapedCommentURL = escapeForJSON(cookie.commentURL.string()); 794 795 LOCAL_LOG(R"( { "name": "%{public}s",)", escapedName.utf8().data()); 796 LOCAL_LOG(R"( "value": "%{public}s",)", escapedValue.utf8().data()); 797 LOCAL_LOG(R"( "domain": "%{public}s",)", escapedDomain.utf8().data()); 798 LOCAL_LOG(R"( "path": "%{public}s",)", escapedPath.utf8().data()); 799 LOCAL_LOG(R"( "created": %f,)", cookie.created); 800 LOCAL_LOG(R"( "expires": %f,)", cookie.expires); 801 LOCAL_LOG(R"( "httpOnly": %{public}s,)", cookie.httpOnly ? "true" : "false"); 802 LOCAL_LOG(R"( "secure": %{public}s,)", cookie.secure ? "true" : "false"); 803 LOCAL_LOG(R"( "session": %{public}s,)", cookie.session ? "true" : "false"); 804 LOCAL_LOG(R"( "comment": "%{public}s",)", escapedComment.utf8().data()); 805 LOCAL_LOG(R"( "commentURL": "%{public}s")", escapedCommentURL.utf8().data()); 806 LOCAL_LOG(R"( }%{public}s)", trailingComma); 807 } 808 LOCAL_LOG(R"(]})"); 790 809 #undef LOCAL_LOG 791 } 810 #undef LOCAL_LOG_IF_ALLOWED 792 811 } 793 812 #endif -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h
r226226 r228111 37 37 namespace WebCore { 38 38 class BlobDataFileReference; 39 class NetworkStorageSession; 39 40 class ResourceRequest; 40 41 } … … 104 105 bool isAlwaysOnLoggingAllowed() const; 105 106 107 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED 108 static bool shouldLogCookieInformation(); 109 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 #endif 111 106 112 private: 107 113 NetworkResourceLoader(const NetworkResourceLoadParameters&, NetworkConnectionToWebProcess&, RefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply>&&); … … 136 142 137 143 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED 138 bool shouldLogCookieInformation() const;139 144 void logCookieInformation() const; 140 145 #endif -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
r227364 r228111 199 199 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 200 200 if (auto shouldBlockCookies = session.networkStorageSession().shouldBlockCookies(request)) { 201 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED 202 if (NetworkProcess::singleton().shouldLogCookieInformation()) 203 RELEASE_LOG_IF(m_session->sessionID().isAlwaysOnLoggingAllowed(), Network, "%p - NetworkDataTaskCocoa::logCookieInformation: pageID = %llu, frameID = %llu, taskID = %lu: Blocking cookies for URL %s", this, pageID, frameID, (unsigned long)[m_task taskIdentifier], nsRequest.URL.absoluteString.UTF8String); 204 #else 201 205 LOG(NetworkSession, "%llu Blocking cookies for URL %s", [m_task taskIdentifier], nsRequest.URL.absoluteString.UTF8String); 206 #endif 202 207 applyCookieBlockingPolicy(shouldBlockCookies); 203 208 } else { 204 209 auto storagePartition = session.networkStorageSession().cookieStoragePartition(request, m_frameID, m_pageID); 205 210 if (!storagePartition.isEmpty()) { 211 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED 212 if (NetworkProcess::singleton().shouldLogCookieInformation()) 213 RELEASE_LOG_IF(m_session->sessionID().isAlwaysOnLoggingAllowed(), Network, "%p - NetworkDataTaskCocoa::logCookieInformation: pageID = %llu, frameID = %llu, taskID = %lu: Partitioning cookies for URL %s", this, pageID, frameID, (unsigned long)[m_task taskIdentifier], nsRequest.URL.absoluteString.UTF8String); 214 #else 206 215 LOG(NetworkSession, "%llu Partitioning cookies for URL %s", [m_task taskIdentifier], nsRequest.URL.absoluteString.UTF8String); 216 #endif 207 217 applyCookiePartitioningPolicy(storagePartition, emptyString()); 208 218 }
Note: See TracChangeset
for help on using the changeset viewer.