Changeset 238659 in webkit


Ignore:
Timestamp:
Nov 28, 2018 8:14:02 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Consult dummy storage for HTTPS Upgrade, Apply If Appropriate
https://bugs.webkit.org/show_bug.cgi?id=192094
<rdar://problem/45851103> HTTPS Upgrade: Consult dummy storage for HTTPS Upgrade, Apply If Appropriate

Patch by Vivek Seth <v_seth@apple.com> on 2018-11-28
Reviewed by Chris Dumez.

For main page loads upgrade HTTP requests to HTTPS if the hostname belongs to a set of upgradable hostnames.

  • NetworkProcess/NetworkLoadChecker.cpp:

(WebKit::NetworkLoadChecker::applyHTTPSUpgradeIfNeeded):
(WebKit::NetworkLoadChecker::checkRequest):

  • NetworkProcess/NetworkLoadChecker.h:
  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::start):

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r238658 r238659  
     12018-11-28  Vivek Seth  <v_seth@apple.com>
     2
     3        Consult dummy storage for HTTPS Upgrade, Apply If Appropriate
     4        https://bugs.webkit.org/show_bug.cgi?id=192094
     5        <rdar://problem/45851103> HTTPS Upgrade: Consult dummy storage for HTTPS Upgrade, Apply If Appropriate
     6
     7        Reviewed by Chris Dumez.
     8
     9        For main page loads upgrade HTTP requests to HTTPS if the hostname belongs to a set of upgradable hostnames.
     10
     11        * NetworkProcess/NetworkLoadChecker.cpp:
     12        (WebKit::NetworkLoadChecker::applyHTTPSUpgradeIfNeeded):
     13        (WebKit::NetworkLoadChecker::checkRequest):
     14        * NetworkProcess/NetworkLoadChecker.h:
     15        * NetworkProcess/NetworkResourceLoader.cpp:
     16        (WebKit::NetworkResourceLoader::start):
     17
    1182018-11-28  Simon Fraser  <simon.fraser@apple.com>
    219
  • trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.cpp

    r235101 r238659  
    191191}
    192192
     193#if ENABLE(HTTPS_UPGRADE)
     194bool NetworkLoadChecker::applyHTTPSUpgradeIfNeeded(ResourceRequest& request)
     195{
     196    // Use dummy list for now.
     197    static NeverDestroyed<HashSet<String>> upgradableHosts = std::initializer_list<String> {
     198        "www.bbc.com"_s, // (source: https://whynohttps.com)
     199        "www.speedtest.net"_s, // (source: https://whynohttps.com)
     200        "www.bea.gov"_s // (source: https://pulse.cio.gov/data/domains/https.csv)
     201    };
     202
     203    auto& url = request.url();
     204
     205    // Only upgrade http urls.
     206    if (!url.protocolIs("http"))
     207        return false;
     208
     209    if (!upgradableHosts.get().contains(url.host().toString()))
     210        return false;
     211
     212    auto newURL = url;
     213    newURL.setProtocol("https"_s);
     214    request.setURL(newURL);
     215    return true;
     216
     217    return false;
     218}
     219#endif // ENABLE(HTTPS_UPGRADE)
     220
    193221void NetworkLoadChecker::checkRequest(ResourceRequest&& request, ContentSecurityPolicyClient* client, ValidationHandler&& handler)
    194222{
     223
     224#if ENABLE(HTTPS_UPGRADE)
     225    if (request.requester() == ResourceRequest::Requester::Main) {
     226        if (applyHTTPSUpgradeIfNeeded(request))
     227            ASSERT(request.url().protocolIs("https"));
     228    }
     229
     230#endif // ENABLE(HTTPS_UPGRADE)
     231
    195232    if (auto* contentSecurityPolicy = this->contentSecurityPolicy()) {
    196233        if (isRedirected()) {
  • trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.h

    r234626 r238659  
    139139    bool m_shouldCaptureExtraNetworkLoadMetrics { false };
    140140    WebCore::NetworkLoadInformation m_loadInformation;
     141
     142#if ENABLE(HTTPS_UPGRADE)
     143    static bool applyHTTPSUpgradeIfNeeded(WebCore::ResourceRequest&);
     144#endif // ENABLE(HTTPS_UPGRADE)
     145
    141146};
    142147
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp

    r238630 r238659  
    193193                return;
    194194            }
    195             if (this->canUseCache(this->originalRequest())) {
     195
     196            auto currentRequest = result.value();
     197            if (this->canUseCache(currentRequest)) {
    196198                RELEASE_LOG_IF_ALLOWED("start: Checking cache for resource (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID, m_parameters.webFrameID, m_parameters.identifier, this->isMainResource(), this->isSynchronous());
    197                 this->retrieveCacheEntry(this->originalRequest());
     199                this->retrieveCacheEntry(currentRequest);
    198200                return;
    199201            }
Note: See TracChangeset for help on using the changeset viewer.