⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 239403 in webkit


Ignore:
Timestamp:
Dec 19, 2018, 4:07:32 PM (8 years ago)
Author:
Alan Coon
Message:

Apply patch. rdar://problem/46848447

Location:
branches/safari-606-branch
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-606-branch/Source/WebCore/ChangeLog

    r239393 r239403  
     12018-12-19  Alan Coon  <alancoon@apple.com>
     2
     3        Apply patch. rdar://problem/46848447
     4
     5    2018-12-19  Brent Fulgham  <bfulgham@apple.com>
     6
     7            Only cap lifetime of persistent cookies created client-side through document.cookie when resource load statistics is enabled
     8            https://bugs.webkit.org/show_bug.cgi?id=190687
     9            <rdar://problem/45349024>
     10
     11            Reviewed by Alex Christensen.
     12
     13            Test: http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html
     14
     15            * platform/network/NetworkStorageSession.cpp:
     16            (WebCore::NetworkStorageSession::setShouldCapLifetimeForClientSideCookies):
     17            (WebCore::NetworkStorageSession::shouldCapLifetimeForClientSideCookies const):
     18            * platform/network/NetworkStorageSession.h:
     19            * platform/network/mac/CookieJarMac.mm:
     20            (WebCore::filterCookies):
     21            (WebCore::setCookiesFromDOM): Now consults the new NetworkStorageSession's
     22            m_shouldCapLifetimeForClientSideCookies member variable before capping the
     23            lifetime of cookies.
     24
    1252018-12-19  Kocsen Chung  <kocsen_chung@apple.com>
    226
  • branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp

    r229978 r239403  
    7575}
    7676
     77void NetworkStorageSession::setShouldCapLifetimeForClientSideCookies(bool value)
     78{
     79    m_shouldCapLifetimeForClientSideCookies = value;
    7780}
     81
     82bool NetworkStorageSession::shouldCapLifetimeForClientSideCookies() const
     83{
     84    return m_shouldCapLifetimeForClientSideCookies;
     85}
     86
     87}
  • branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.h

    r232863 r239403  
    102102    WEBCORE_EXPORT String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const;
    103103    WEBCORE_EXPORT void setPrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool clearFirst);
     104    WEBCORE_EXPORT void setShouldCapLifetimeForClientSideCookies(bool);
     105    WEBCORE_EXPORT bool shouldCapLifetimeForClientSideCookies() const;
    104106    WEBCORE_EXPORT void removePrevalentDomains(const Vector<String>& domains);
    105107    WEBCORE_EXPORT bool hasStorageAccess(const String& resourceDomain, const String& firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID) const;
    … …  
    176178    HashMap<uint64_t, HashMap<uint64_t, String, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_framesGrantedStorageAccess;
    177179    HashMap<uint64_t, HashMap<String, String>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_pagesGrantedStorageAccess;
     180    bool m_shouldCapLifetimeForClientSideCookies { false };
    178181#endif
    179182
  • branches/safari-606-branch/Source/WebCore/platform/network/mac/CookieJarMac.mm

    r239393 r239403  
    146146}
    147147
    148 static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies)
     148static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies, bool shouldCapLifetime)
    149149{
    150150    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
    … …  
    167167
    168168        // Cap lifetime of persistent, client-side cookies to a week.
    169         if (![cookie isSessionOnly]) {
     169        if (shouldCapLifetime && ![cookie isSessionOnly]) {
    170170            if (!cookie.expiresDate || cookie.expiresDate.timeIntervalSinceNow > secondsPerWeek) {
    171171                RetainPtr<NSMutableDictionary<NSHTTPCookiePropertyKey, id>> properties = adoptNS([[cookie properties] mutableCopy]);
    … …  
    336336#endif
    337337
    338     RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies);
     338#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     339    RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, session.shouldCapLifetimeForClientSideCookies());
     340#else
     341    RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, false);
     342#endif
    339343    ASSERT([filteredCookies.get() count] <= 1);
    340344
  • branches/safari-606-branch/Source/WebKit/ChangeLog

    r238916 r239403  
     12018-12-19  Alan Coon  <alancoon@apple.com>
     2
     3        Apply patch. rdar://problem/46848447
     4
     5    2018-12-19  Brent Fulgham  <bfulgham@apple.com>
     6
     7            Only cap lifetime of persistent cookies created client-side through document.cookie when resource load statistics is enabled
     8            https://bugs.webkit.org/show_bug.cgi?id=190687
     9            <rdar://problem/45349024>
     10
     11            This patch adds the following:=
     12            * The WebProcessPool now tells the WebsiteDataStore when a network process has
     13            been created.
     14            * The WebsiteDataStore in turn tells the WebResourceLoadStatisticsStore when
     15            a network process has been created.
     16            * The WebResourceLoadStatisticsStore makes sure to update the network processes
     17            with its cookie policy when it's notified that a network process has been
     18            created.
     19
     20            In addition, this patch changes the following:
     21
     22            * Removes WebsiteDataStore::networkProcessDidCrash() and
     23            WebResourceLoadStatisticsStore::scheduleCookieBlockingStateReset() since
     24            the call site---WebProcessPool::ensureNetworkProcess()---now calls
     25            WebsiteDataStore::didCreateNetworkProcess() after a network process
     26            crash and the state sync for cookie blocking is triggered.
     27
     28            * NetworkProcess/NetworkProcess.cpp:
     29            (WebKit::NetworkProcess::setShouldCapLifetimeForClientSideCookies):
     30            * NetworkProcess/NetworkProcess.h:
     31            * NetworkProcess/NetworkProcess.messages.in:
     32            * UIProcess/Network/NetworkProcessProxy.cpp:
     33            (WebKit::NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies):
     34            (WebKit::NetworkProcessProxy::didSetShouldCapLifetimeForClientSideCookies):
     35            * UIProcess/Network/NetworkProcessProxy.h:
     36            * UIProcess/Network/NetworkProcessProxy.messages.in:
     37            * UIProcess/WebProcessPool.cpp:
     38            (WebKit::WebProcessPool::ensureNetworkProcess):
     39            * UIProcess/WebResourceLoadStatisticsStore.cpp:
     40            (WebKit::WebResourceLoadStatisticsStore::didCreateNetworkProcess):
     41            * UIProcess/WebResourceLoadStatisticsStore.h:
     42            * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     43            (WebKit::WebsiteDataStore::setShouldCapLifetimeForClientSideCookies):
     44            (WebKit::WebsiteDataStore::didCreateNetworkProcess):
     45            (WebKit::WebsiteDataStore::networkProcessDidCrash): Deleted.
     46            * UIProcess/WebsiteData/WebsiteDataStore.h:
     47
    1482018-12-05  Alan Coon  <alancoon@apple.com>
    249
  • branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r235702 r239403  
    427427}
    428428
     429void NetworkProcess::setShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, bool value, uint64_t contextId)
     430{
     431    if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     432        networkStorageSession->setShouldCapLifetimeForClientSideCookies(value);
     433    parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetShouldCapLifetimeForClientSideCookies(contextId), 0);
     434}
     435
    429436void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
    430437{
  • branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.h

    r235702 r239403  
    133133#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    134134    void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool shouldClearFirst, uint64_t callbackId);
     135    void setShouldCapLifetimeForClientSideCookies(PAL::SessionID, bool value, uint64_t contextId);
    135136    void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId);
    136137    void getAllStorageAccessEntries(PAL::SessionID, uint64_t contextId);
  • branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r233822 r239403  
    8686#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    8787    UpdatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID sessionID, Vector<String> domainsToPartition, Vector<String> domainsToBlock, Vector<String> domainsToNeitherPartitionNorBlock, bool shouldClearFirst, uint64_t callbackId)
     88    SetShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, bool value, uint64_t contextId)
    8889    HasStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
    8990    GetAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId)
  • branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r237535 r239403  
    445445}
    446446
     447void NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, ShouldCapLifetimeForClientSideCookies shouldCapLifetime, CompletionHandler<void()>&& completionHandler)
     448{
     449    if (!canSendMessage()) {
     450        completionHandler();
     451        return;
     452    }
     453
     454    auto callbackId = generateCallbackID();
     455    auto addResult = m_updatePartitionOrBlockCookiesCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable {
     456        completionHandler();
     457    });
     458    ASSERT_UNUSED(addResult, addResult.isNewEntry);
     459    send(Messages::NetworkProcess::SetShouldCapLifetimeForClientSideCookies(sessionID, shouldCapLifetime == ShouldCapLifetimeForClientSideCookies::Yes, callbackId), 0);
     460}
     461   
     462void NetworkProcessProxy::didSetShouldCapLifetimeForClientSideCookies(uint64_t callbackId)
     463{
     464    m_updatePartitionOrBlockCookiesCallbackMap.take(callbackId)();
     465}
     466
    447467static uint64_t nextRequestStorageAccessContextId()
    448468{
  • branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r237535 r239403  
    8080#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    8181    void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst, CompletionHandler<void()>&&);
     82    void setShouldCapLifetimeForClientSideCookies(PAL::SessionID, ShouldCapLifetimeForClientSideCookies, CompletionHandler<void()>&&);
    8283    void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
    8384    void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String>&& domains)>&&);
    … …  
    149150#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    150151    void didUpdatePartitionOrBlockCookies(uint64_t callbackId);
     152    void didSetShouldCapLifetimeForClientSideCookies(uint64_t contextId);
    151153    void storageAccessRequestResult(bool wasGranted, uint64_t contextId);
    152154    void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId);
  • branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in

    r233180 r239403  
    4949#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    5050    DidUpdatePartitionOrBlockCookies(uint64_t callbackId)
     51    DidSetShouldCapLifetimeForClientSideCookies(uint64_t callbackId)
    5152    StorageAccessRequestResult(bool wasGranted, uint64_t contextId)
    5253    AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId)
  • branches/safari-606-branch/Source/WebKit/UIProcess/WebProcessPool.cpp

    r233822 r239403  
    531531        m_didNetworkProcessCrash = false;
    532532        reinstateNetworkProcessAssertionState(*m_networkProcess);
    533         if (m_websiteDataStore)
    534             m_websiteDataStore->websiteDataStore().networkProcessDidCrash();
    535533    }
    536534
    … …  
    539537        withWebsiteDataStore->clearPendingCookies();
    540538    }
     539
     540    if (m_websiteDataStore)
     541        m_websiteDataStore->websiteDataStore().didCreateNetworkProcess();
    541542
    542543    return *m_networkProcess;
  • branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp

    r234236 r239403  
    3939#include "WebsiteDataStore.h"
    4040#include <WebCore/ResourceLoadStatistics.h>
     41#include <wtf/CallbackAggregator.h>
    4142#include <wtf/CrossThreadCopier.h>
    4243#include <wtf/NeverDestroyed.h>
    … …  
    318319}
    319320
     321void WebResourceLoadStatisticsStore::didCreateNetworkProcess()
     322{
     323    ASSERT(RunLoop::isMain());
     324
     325    postTask([this] {
     326        if (!m_memoryStore)
     327            return;
     328        m_memoryStore->updateCookiePartitioning([]() { });
     329    });
     330
     331#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     332    if (m_websiteDataStore)
     333        m_websiteDataStore->setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies::Yes, []() { });
     334#endif
     335}
     336
    320337void WebResourceLoadStatisticsStore::removeAllStorageAccess()
    321338{
  • branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h

    r234236 r239403  
    141141    void callHasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
    142142
     143     void didCreateNetworkProcess();
     144
    143145private:
    144146    explicit WebResourceLoadStatisticsStore(WebsiteDataStore&);
    … …  
    170172
    171173    WTF::Function<void(const String&)> m_statisticsTestingCallback;
     174
     175    bool m_firstNetworkProcessCreated { false };
    172176};
    173177
  • branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r234236 r239403  
    11/*
    2  * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    12451245}
    12461246
     1247void WebsiteDataStore::setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies shouldCapLifetime, CompletionHandler<void()>&& completionHandler)
     1248{
     1249    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1250
     1251    for (auto& processPool : processPools()) {
     1252        if (auto* process = processPool->networkProcess())
     1253            process->setShouldCapLifetimeForClientSideCookies(m_sessionID, shouldCapLifetime, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1254    }
     1255}
     1256
    12471257void WebsiteDataStore::hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&& completionHandler)
    12481258{
    … …  
    13251335}
    13261336#endif
    1327 
    1328 void WebsiteDataStore::networkProcessDidCrash()
    1329 {
    1330 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    1331     if (m_resourceLoadStatistics)
    1332         m_resourceLoadStatistics->scheduleCookiePartitioningStateReset();
    1333 #endif
    1334 }
    13351337
    13361338void WebsiteDataStore::webPageWasAdded(WebPageProxy& webPageProxy)
    … …  
    16241626#endif
    16251627
    1626 }
     1628void WebsiteDataStore::didCreateNetworkProcess()
     1629{
     1630#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     1631    if (m_resourceLoadStatistics)
     1632        m_resourceLoadStatistics->didCreateNetworkProcess();
     1633#endif
     1634}
     1635
     1636}
  • branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r234236 r239403  
    11/*
    2  * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    7373
    7474enum class ShouldClearFirst { No, Yes };
     75enum class ShouldCapLifetimeForClientSideCookies { No, Yes };
    7576
    7677class WebsiteDataStore : public RefCounted<WebsiteDataStore>, public WebProcessLifetimeObserver, public Identified<WebsiteDataStore>, public CanMakeWeakPtr<WebsiteDataStore>  {
    … …  
    132133#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    133134    void updatePrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst, CompletionHandler<void()>&&);
     135    void setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies, CompletionHandler<void()>&&);
    134136    void hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&&);
    135137    void getAllStorageAccessEntries(uint64_t pageID, CompletionHandler<void(Vector<String>&& domains)>&&);
    … …  
    141143    void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&);
    142144#endif
    143     void networkProcessDidCrash();
    144145    void resolveDirectoriesIfNecessary();
    145146    const String& resolvedApplicationCacheDirectory() const { return m_resolvedConfiguration.applicationCacheDirectory; }
    … …  
    185186#endif
    186187
     188    void didCreateNetworkProcess();
     189
    187190private:
    188191    explicit WebsiteDataStore(PAL::SessionID);
Note: See TracChangeset for help on using the changeset viewer.