Skip to content

Commit

Permalink
Bug 1522412 - P2. Remove nsIChannel.LOAD_CLASSIFY_URI flag. r=Ehsan
Browse files Browse the repository at this point in the history
nsIChannel.LOAD_CLASSIFY_URI is no longer required so we can remove it from
the codebase.
In the mean time, we add a new LOAD_BYPASS_URL_CLASSIFIER load flag for
channel creator to be able to force channel to bypass URL classifier check.
The use of the new LOAD_BYPASS_URL_CLASSIFIER flag will be addressed in
the other patches.

Differential Revision: https://phabricator.services.mozilla.com/D22111

--HG--
extra : moz-landing-system : lando
  • Loading branch information
DimiDL committed Mar 21, 2019
1 parent d97a1a7 commit 8f1caf4
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 82 deletions.
1 change: 0 additions & 1 deletion accessible/base/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ static void LogRequest(nsIRequest* aRequest) {
if (loadFlags & nsIChannel::LOAD_TARGETED) printf("targeted; ");
if (loadFlags & nsIChannel::LOAD_CALL_CONTENT_SNIFFERS)
printf("call content sniffers; ");
if (loadFlags & nsIChannel::LOAD_CLASSIFY_URI) printf("classify uri; ");
} else {
printf(" no request");
}
Expand Down
2 changes: 1 addition & 1 deletion docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10364,7 +10364,7 @@ nsresult nsDocShell::DoChannelLoad(nsIChannel* aChannel,
}

if (!aBypassClassifier) {
loadFlags |= nsIChannel::LOAD_CLASSIFY_URI;
// Keep this for later use
}

// If the user pressed shift-reload, then do not allow ServiceWorker
Expand Down
3 changes: 1 addition & 2 deletions docshell/base/nsPingListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ static void SendPing(void* aClosure, nsIContent* aContent, nsIURI* aURI,

// Don't bother caching the result of this URI load, but do not exempt
// it from Safe Browsing.
chan->SetLoadFlags(nsIRequest::INHIBIT_CACHING |
nsIChannel::LOAD_CLASSIFY_URI);
chan->SetLoadFlags(nsIRequest::INHIBIT_CACHING);

nsCOMPtr<nsIHttpChannel> httpChan = do_QueryInterface(chan);
if (!httpChan) {
Expand Down
9 changes: 1 addition & 8 deletions dom/base/Navigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,9 +1128,6 @@ bool Navigator::SendBeaconInternal(const nsAString& aUrl,
return false;
}

nsLoadFlags loadFlags =
nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI;

// No need to use CORS for sendBeacon unless it's a BLOB
nsSecurityFlags securityFlags =
aType == eBeaconTypeBlob
Expand All @@ -1140,11 +1137,7 @@ bool Navigator::SendBeaconInternal(const nsAString& aUrl,

nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannel(getter_AddRefs(channel), uri, doc, securityFlags,
nsIContentPolicy::TYPE_BEACON,
nullptr, // aPerformanceStorage
nullptr, // aLoadGroup
nullptr, // aCallbacks
loadFlags);
nsIContentPolicy::TYPE_BEACON);

if (NS_FAILED(rv)) {
aRv.Throw(rv);
Expand Down
16 changes: 8 additions & 8 deletions dom/base/nsObjectLoadingContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2310,14 +2310,14 @@ nsresult nsObjectLoadingContent::OpenChannel() {

nsContentPolicyType contentPolicyType = GetContentPolicyType();

rv = NS_NewChannel(
getter_AddRefs(chan), mURI, thisContent, securityFlags, contentPolicyType,
nullptr, // aPerformanceStorage
group, // aLoadGroup
shim, // aCallbacks
nsIChannel::LOAD_CALL_CONTENT_SNIFFERS | nsIChannel::LOAD_CLASSIFY_URI |
nsIChannel::LOAD_BYPASS_SERVICE_WORKER |
nsIRequest::LOAD_HTML_OBJECT_DATA);
rv = NS_NewChannel(getter_AddRefs(chan), mURI, thisContent, securityFlags,
contentPolicyType,
nullptr, // aPerformanceStorage
group, // aLoadGroup
shim, // aCallbacks
nsIChannel::LOAD_CALL_CONTENT_SNIFFERS |
nsIChannel::LOAD_BYPASS_SERVICE_WORKER |
nsIRequest::LOAD_HTML_OBJECT_DATA);
NS_ENSURE_SUCCESS(rv, rv);
if (inherit) {
nsCOMPtr<nsILoadInfo> loadinfo = chan->LoadInfo();
Expand Down
3 changes: 1 addition & 2 deletions dom/fetch/FetchDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,7 @@ nsresult FetchDriver::HttpFetch(
MOZ_ASSERT(mLoadGroup);
nsCOMPtr<nsIChannel> chan;

nsLoadFlags loadFlags =
nsIRequest::LOAD_BACKGROUND | bypassFlag | nsIChannel::LOAD_CLASSIFY_URI;
nsLoadFlags loadFlags = nsIRequest::LOAD_BACKGROUND | bypassFlag;
if (mDocument) {
MOZ_ASSERT(mDocument->NodePrincipal() == mPrincipal);
MOZ_ASSERT(mDocument->CookieSettings() == mCookieSettings);
Expand Down
1 change: 0 additions & 1 deletion dom/html/HTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,6 @@ class HTMLMediaElement::ChannelLoader final {
nullptr, // aCallbacks
nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE_IF_BUSY |
nsIChannel::LOAD_MEDIA_SNIFFER_OVERRIDES_CONTENT_TYPE |
nsIChannel::LOAD_CLASSIFY_URI |
nsIChannel::LOAD_CALL_CONTENT_SNIFFERS);

if (NS_FAILED(rv)) {
Expand Down
12 changes: 5 additions & 7 deletions dom/html/HTMLTrackElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,11 @@ void HTMLTrackElement::LoadResource(RefPtr<WebVTTListener>&& aWebVTTListener) {
nsCOMPtr<nsIChannel> channel;
nsCOMPtr<nsILoadGroup> loadGroup =
self->OwnerDoc()->GetDocumentLoadGroup();
nsresult rv = NS_NewChannel(
getter_AddRefs(channel), uri, static_cast<Element*>(self), secFlags,
nsIContentPolicy::TYPE_INTERNAL_TRACK,
nullptr, // PerformanceStorage
loadGroup,
nullptr, // aCallbacks
nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI);
nsresult rv = NS_NewChannel(getter_AddRefs(channel), uri,
static_cast<Element*>(self), secFlags,
nsIContentPolicy::TYPE_INTERNAL_TRACK,
nullptr, // PerformanceStorage
loadGroup);

NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));

Expand Down
5 changes: 0 additions & 5 deletions dom/jsurl/nsJSProtocolHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,11 +782,6 @@ nsJSChannel::SetLoadFlags(nsLoadFlags aLoadFlags) {
bogusLoadBackground = !loadGroupIsBackground;
}

// Classifying a javascript: URI doesn't help us, and requires
// NSS to boot, which we don't have in content processes. See
// https://bugzilla.mozilla.org/show_bug.cgi?id=617838.
aLoadFlags &= ~LOAD_CLASSIFY_URI;

// Since the javascript channel is never the actual channel that
// any data is loaded through, don't ever set the
// LOAD_DOCUMENT_URI flag on it, since that could lead to two
Expand Down
1 change: 0 additions & 1 deletion dom/media/ChannelMediaResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,6 @@ nsresult ChannelMediaResource::RecreateChannel() {
MOZ_DIAGNOSTIC_ASSERT(!mClosed);

nsLoadFlags loadFlags = nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE_IF_BUSY |
nsIChannel::LOAD_CLASSIFY_URI |
(mLoadInBackground ? nsIRequest::LOAD_BACKGROUND : 0);

MediaDecoderOwner* owner = mCallback->GetMediaOwner();
Expand Down
18 changes: 9 additions & 9 deletions dom/plugins/base/nsPluginHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3094,15 +3094,15 @@ nsresult nsPluginHost::NewPluginURLStream(
// do not add this internal plugin's channel on the
// load group otherwise this channel could be canceled
// form |nsDocShell::OnLinkClickSync| bug 166613
rv = NS_NewChannel(getter_AddRefs(channel), url, element,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
nsIContentPolicy::TYPE_OBJECT_SUBREQUEST,
nullptr, // aPerformanceStorage
nullptr, // aLoadGroup
listenerPeer,
nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI |
nsIChannel::LOAD_BYPASS_SERVICE_WORKER);
rv = NS_NewChannel(
getter_AddRefs(channel), url, element,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
nsIContentPolicy::TYPE_OBJECT_SUBREQUEST,
nullptr, // aPerformanceStorage
nullptr, // aLoadGroup
listenerPeer,
nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_BYPASS_SERVICE_WORKER);
NS_ENSURE_SUCCESS(rv, rv);

if (doc) {
Expand Down
3 changes: 1 addition & 2 deletions dom/script/ScriptLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,8 +1264,7 @@ nsresult ScriptLoader::StartLoad(ScriptLoadRequest* aRequest) {
getter_AddRefs(channel), aRequest->mURI, context,
aRequest->TriggeringPrincipal(), securityFlags, contentPolicyType,
nullptr, // aPerformanceStorage
loadGroup, prompter,
nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI);
loadGroup, prompter);

NS_ENSURE_SUCCESS(rv, rv);

Expand Down
15 changes: 2 additions & 13 deletions dom/security/nsCSPContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,26 +1039,15 @@ nsresult nsCSPContext::SendReports(
}

// try to create a new channel for every report-uri
nsLoadFlags loadFlags =
nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI;
if (doc) {
rv = NS_NewChannel(getter_AddRefs(reportChannel), reportURI, doc,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_CSP_REPORT,
nullptr, // aPerformanceStorage
nullptr, // aLoadGroup
nullptr, // aCallbacks
loadFlags);
nsIContentPolicy::TYPE_CSP_REPORT);
} else {
rv = NS_NewChannel(getter_AddRefs(reportChannel), reportURI,
mLoadingPrincipal,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_CSP_REPORT,
nullptr, // nsICookieSettings
nullptr, // PerformanceStorage
nullptr, // aLoadGroup
nullptr, // aCallbacks
loadFlags);
nsIContentPolicy::TYPE_CSP_REPORT);
}

if (NS_FAILED(rv)) {
Expand Down
1 change: 0 additions & 1 deletion dom/workers/ScriptLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ nsresult ChannelFromScriptURL(
parentDoc = nullptr;
}

aLoadFlags |= nsIChannel::LOAD_CLASSIFY_URI;
uint32_t secFlags = aIsMainScript
? nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED
: nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS;
Expand Down
3 changes: 1 addition & 2 deletions dom/xhr/XMLHttpRequestMainThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2300,8 +2300,7 @@ nsresult XMLHttpRequestMainThread::CreateChannel() {
nsCOMPtr<nsILoadGroup> loadGroup = GetLoadGroup();

nsSecurityFlags secFlags;
nsLoadFlags loadFlags =
nsIRequest::LOAD_BACKGROUND | nsIChannel::LOAD_CLASSIFY_URI;
nsLoadFlags loadFlags = nsIRequest::LOAD_BACKGROUND;
if (nsContentUtils::IsSystemPrincipal(mPrincipal)) {
// When chrome is loading we want to make sure to sandbox any potential
// result document. We also want to allow cross-origin loads.
Expand Down
1 change: 0 additions & 1 deletion image/imgLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,6 @@ static nsresult NewImageChannel(
// If all of the proxy requests are canceled then this request should be
// canceled too.
//
aLoadFlags |= nsIChannel::LOAD_CLASSIFY_URI;

nsCOMPtr<nsINode> requestingNode = do_QueryInterface(aRequestingContext);

Expand Down
8 changes: 2 additions & 6 deletions layout/style/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,9 +1436,7 @@ nsresult Loader::LoadSheet(SheetLoadData* aLoadData,
getter_AddRefs(channel), aLoadData->mURI, aLoadData->mRequestingNode,
aLoadData->mLoaderPrincipal, securityFlags, contentPolicyType,
nullptr, // Performancestorage
loadGroup,
nullptr, // aCallbacks
nsIChannel::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI);
loadGroup);
} else {
// either we are loading something inside a document, in which case
// we should always have a requestingNode, or we are loading something
Expand All @@ -1448,9 +1446,7 @@ nsresult Loader::LoadSheet(SheetLoadData* aLoadData,
nsContentUtils::GetSystemPrincipal(), securityFlags,
contentPolicyType, cookieSettings,
nullptr, // aPerformanceStorage
loadGroup,
nullptr, // aCallbacks
nsIChannel::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI);
loadGroup);
}

if (NS_FAILED(rv)) {
Expand Down
6 changes: 1 addition & 5 deletions netwerk/base/nsIChannel.idl
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,7 @@ interface nsIChannel : nsIRequest
*/
const unsigned long LOAD_CALL_CONTENT_SNIFFERS = 1 << 21;

/**
* This flag tells the channel to use URI classifier service to check
* the URI when opening the channel.
*/
const unsigned long LOAD_CLASSIFY_URI = 1 << 22;
// LOAD_BYPASS_URL_CLASSIFIER will be added

/**
* If this flag is set, the media-type content sniffer will be allowed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ function makeChannel(path, loadingPrincipal, topWindowURI) {
}
chan.QueryInterface(Ci.nsIHttpChannel);
chan.requestMethod = "GET";
chan.loadFlags |= Ci.nsIChannel.LOAD_CLASSIFY_URI;
if (topWindowURI) {
chan.QueryInterface(Ci.nsIHttpChannelInternal).setTopWindowURIIfUnknown(topWindowURI);
}
Expand Down
3 changes: 0 additions & 3 deletions toolkit/components/telemetry/app/TelemetrySend.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -1112,9 +1112,6 @@ var TelemetrySendImpl = {

this._pendingPingRequests.set(id, request);

// Prevent the request channel from running though URLClassifier (bug 1296802)
request.channel.loadFlags &= ~Ci.nsIChannel.LOAD_CLASSIFY_URI;

const monotonicStartTime = Utils.monotonicNow();
let deferred = PromiseUtils.defer();

Expand Down
3 changes: 0 additions & 3 deletions toolkit/components/telemetry/pings/CoveragePing.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ var CoveragePing = Object.freeze({
request.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
request.setRequestHeader("Date", new Date().toUTCString());

// Prevent the request channel from running though URLClassifier (bug 1296802)
request.channel.loadFlags &= ~Ci.nsIChannel.LOAD_CLASSIFY_URI;

let errorhandler = (event) => {
let failure = event.type;
log.error(`error making request to ${endpoint}: ${failure}`);
Expand Down

0 comments on commit 8f1caf4

Please sign in to comment.