Bug 192937 - Move HTTPS_UPGRADE code behind a runtime flag, off by default
Summary: Move HTTPS_UPGRADE code behind a runtime flag, off by default
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-12-20 09:19 PST by Chris Dumez
Modified: 2018-12-20 16:21 PST (History)
8 users (show)

See Also:


Attachments
Patch (20.39 KB, patch)
2018-12-20 09:42 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (19.52 KB, patch)
2018-12-20 09:45 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (19.53 KB, patch)
2018-12-20 09:53 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (20.52 KB, patch)
2018-12-20 10:03 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (20.92 KB, patch)
2018-12-20 10:34 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (20.93 KB, patch)
2018-12-20 10:54 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (21.70 KB, patch)
2018-12-20 11:41 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (20.36 KB, patch)
2018-12-20 15:56 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (20.36 KB, patch)
2018-12-20 15:57 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2018-12-20 09:19:38 PST
Move HTTP_UPGRADE code behind a runtime flag, off by default and drop the build time flag.
Comment 1 Chris Dumez 2018-12-20 09:42:40 PST
Created attachment 357821 [details]
Patch
Comment 2 Chris Dumez 2018-12-20 09:45:06 PST
Created attachment 357823 [details]
Patch
Comment 3 Chris Dumez 2018-12-20 09:53:23 PST
Created attachment 357826 [details]
Patch
Comment 4 Chris Dumez 2018-12-20 10:03:26 PST
Created attachment 357827 [details]
Patch
Comment 5 Chris Dumez 2018-12-20 10:12:02 PST
make: *** No rule to make target `HTTPSUpgradeList.txt', needed by `HTTPSUpgradeList.db'.  Stop.
make: *** Waiting for unfinished jobs....
Command /bin/sh failed with exit code 2

:/
Comment 6 Chris Dumez 2018-12-20 10:15:56 PST
Comment on attachment 357827 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=357827&action=review

> Source/WebKit/DerivedSources.make:320
>  HTTPSUpgradeList.db : HTTPSUpgradeList.txt $(WebKit2)/Scripts/generate-https-upgrade-database.sh

Should this be in WebKitDerivedSourcesAdditions.make ?
Comment 7 Andy Estes 2018-12-20 10:19:48 PST
(In reply to Chris Dumez from comment #6)
> Comment on attachment 357827 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=357827&action=review
> 
> > Source/WebKit/DerivedSources.make:320
> >  HTTPSUpgradeList.db : HTTPSUpgradeList.txt $(WebKit2)/Scripts/generate-https-upgrade-database.sh
> 
> Should this be in WebKitDerivedSourcesAdditions.make ?

Yes.
Comment 8 Chris Dumez 2018-12-20 10:34:15 PST
Created attachment 357830 [details]
Patch
Comment 9 Vivek Seth 2018-12-20 10:46:27 PST
Comment on attachment 357830 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=357830&action=review

> Source/WebKit/Shared/HTTPSUpgrade/HTTPSUpgradeList.txt:1
> +www.bbc.com

Should we use a larger list of domains from the HSTS list?
Comment 10 Chris Dumez 2018-12-20 10:54:09 PST
Created attachment 357833 [details]
Patch
Comment 11 Vivek Seth 2018-12-20 11:01:37 PST
Comment on attachment 357833 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=357833&action=review

> Source/WebKit/DerivedSources.make:319
> +VPATH += $(WebKit2)/Shared/HTTPSUpgrade/

I thought we were adding this to WebKitDerivedSourcesAdditions.make. Did that not work?
Comment 12 Vivek Seth 2018-12-20 11:24:42 PST
> /Volumes/Data/EWS/WebKit/Source/WebKit/NetworkProcess/NetworkHTTPSUpgradeChecker.cpp:95> :13: error: unused variable 'bindTextResult' [-Werror,-Wunused-variable]
>         int bindTextResult = m_statement->bindText(1, WTFMove(host));
>             ^
> /Volumes/Data/EWS/WebKit/Source/WebKit/NetworkProcess/NetworkHTTPSUpgradeChecker.cpp:10> 1:13: error: unused variable 'resetResult' [-Werror,-Wunused-variable]
>         int resetResult = m_statement->reset();
>             ^
> 2 errors generated.


This was my mistake, ASSERTS are compiled out on release builds. I didn't realize unused variables would cause errors. 

Here is one solution: 

void NetworkHTTPSUpgradeChecker::query(String&& host, CompletionHandler<void(bool)>&& callback)
{
   ASSERT(isMainThread());

   if (!this->m_isSetupComplete) {
       RELEASE_LOG_IF_ALLOWED("query - database setup is not complete, ignoring query.");
       callback(false);
       return;
   }

   m_workQueue->dispatch([this, host = WTFMove(host), callback = WTFMove(callback)] () mutable {
       auto runCallbackOnMainThread = [callback = WTFMove(callback)] (bool foundHost) mutable {
           WTF::RunLoop::main().dispatch([foundHost, callback = WTFMove(callback)] () mutable {
               callback(foundHost);
           });
       };

        if (this->m_statement->bindText(1, WTFMove(host)) != SQLITE_OK) {
            ASSERT(false);
            runCallbackOnMainThread(false);
            return;
        }

        int stepResult = this->m_statement->step();
        if (stepResult != SQLITE_ROW && stepResult != SQLITE_DONE) {
            ASSERT(false);
            runCallbackOnMainThread(false);
            return;
        }

        if (this->m_statement->reset() != SQLITE_OK) {
            ASSERT(false);
            runCallbackOnMainThread(false);
            return;
        }

        bool foundHost = (stepResult == SQLITE_ROW);
        RELEASE_LOG_IF_ALLOWED("query - Ran successfully. Result = %s", (foundHost ? "true" : "false"));
        runCallbackOnMainThread(foundHost);
    });
}
Comment 13 Chris Dumez 2018-12-20 11:41:36 PST
Created attachment 357841 [details]
Patch
Comment 14 Chris Dumez 2018-12-20 11:43:09 PST
(In reply to Vivek Seth from comment #11)
> Comment on attachment 357833 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=357833&action=review
> 
> > Source/WebKit/DerivedSources.make:319
> > +VPATH += $(WebKit2)/Shared/HTTPSUpgrade/
> 
> I thought we were adding this to WebKitDerivedSourcesAdditions.make. Did
> that not work?

I haven't tried, I thought it'd be better to have a minimal db in OpenSource.
Comment 15 Vivek Seth 2018-12-20 12:14:26 PST
Comment on attachment 357833 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=357833&action=review

>>> Source/WebKit/DerivedSources.make:319
>>> +VPATH += $(WebKit2)/Shared/HTTPSUpgrade/
>> 
>> I thought we were adding this to WebKitDerivedSourcesAdditions.make. Did that not work?
> 
> I haven't tried, I thought it'd be better to have a minimal db in OpenSource.

Yeah that would be good.
Comment 16 Vivek Seth 2018-12-20 14:59:24 PST
Comment on attachment 357841 [details]
Patch

Looks good to me!
Comment 17 youenn fablet 2018-12-20 15:50:00 PST
Comment on attachment 357841 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=357841&action=review

> Source/WebKit/NetworkProcess/PingLoad.cpp:46
> +    , m_networkLoadChecker(makeUniqueRef<NetworkLoadChecker>(FetchOptions { m_parameters.options}, m_parameters.sessionID, m_parameters.webPageID, m_parameters.webFrameID, WTFMove(m_parameters.originalRequestHeaders), URL { m_parameters.request.url() }, m_parameters.sourceOrigin.copyRef(), m_parameters.preflightPolicy, false, m_parameters.request.httpReferrer()))

Not very clear what false means here.
Maybe isHTTPSUpgradeEnabled should be the last parameter and set to false by default, like requestLoadType.
Comment 18 Andy Estes 2018-12-20 15:52:23 PST
Comment on attachment 357841 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=357841&action=review

> Source/WebKit/DerivedSources.make:319
> -ifeq ($(ENABLE_HTTPS_UPGRADE),ENABLE_HTTPS_UPGRADE)
> +VPATH += $(WebKit2)/Shared/HTTPSUpgrade/

Nice

> Source/WebKit/Shared/HTTPSUpgrade/HTTPSUpgradeList.txt:3
> +www.bbc.com
> +www.speedtest.net
> +www.bea.gov

webkit.org?

> Source/WebKit/Shared/WebPreferences.yaml:42
> +   humanReadableDescription: "Automatic HTTPS upgrade for sites that support it"

For the sites that we know about, at least :)
Comment 19 Chris Dumez 2018-12-20 15:56:01 PST
Created attachment 357886 [details]
Patch
Comment 20 Chris Dumez 2018-12-20 15:57:42 PST
Created attachment 357888 [details]
Patch
Comment 21 WebKit Commit Bot 2018-12-20 16:20:29 PST
Comment on attachment 357888 [details]
Patch

Clearing flags on attachment: 357888

Committed r239474: <https://trac.webkit.org/changeset/239474>
Comment 22 WebKit Commit Bot 2018-12-20 16:20:31 PST
All reviewed patches have been landed.  Closing bug.
Comment 23 Radar WebKit Bug Importer 2018-12-20 16:21:35 PST
<rdar://problem/46887131>