diff options
author | Moonchild <moonchild@palemoon.org> | 2021-10-22 07:49:59 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-04-01 16:05:02 +0200 |
commit | 7c90c0205cd9fda52caf0d6b2a42f8a53c6fba37 (patch) | |
tree | c0034e58dac5a1c42be6124f22b314a0e999922d /netwerk | |
parent | a95439db61c4530afae3967e2912d6ca38f1bbda (diff) | |
download | uxp-7c90c0205cd9fda52caf0d6b2a42f8a53c6fba37.tar.gz |
Issue #1822 - Part 4: Remove URL classifier and internal blocklist errors.
This removes NS_ERROR_{TRACKING|MALWARE|PHISHING|UNWANTED|BLOCKED}_URI
that are no longer in use.
Diffstat (limited to 'netwerk')
-rw-r--r-- | netwerk/base/nsChannelClassifier.cpp | 81 | ||||
-rw-r--r-- | netwerk/base/nsChannelClassifier.h | 2 | ||||
-rw-r--r-- | netwerk/protocol/http/HttpChannelChild.cpp | 7 |
3 files changed, 1 insertions, 89 deletions
diff --git a/netwerk/base/nsChannelClassifier.cpp b/netwerk/base/nsChannelClassifier.cpp index 1c23271af7..5df60e9516 100644 --- a/netwerk/base/nsChannelClassifier.cpp +++ b/netwerk/base/nsChannelClassifier.cpp @@ -411,8 +411,7 @@ nsChannelClassifier::MarkEntryClassified(nsresult status) // Should only be called in the parent process. MOZ_ASSERT(XRE_IsParentProcess()); - // Don't cache tracking classifications because we support allowlisting. - if (status == NS_ERROR_TRACKING_URI || mIsAllowListed) { + if (mIsAllowListed) { return; } @@ -578,83 +577,12 @@ nsChannelClassifier::SetBlockedTrackingContent(nsIChannel *channel) return NS_OK; } -nsresult -nsChannelClassifier::IsTrackerWhitelisted() -{ - nsresult rv; - nsCOMPtr<nsIURIClassifier> uriClassifier = - do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - nsAutoCString tables; - Preferences::GetCString("urlclassifier.trackingWhitelistTable", &tables); - - if (tables.IsEmpty()) { - LOG(("nsChannelClassifier[%p]:IsTrackerWhitelisted whitelist disabled", - this)); - return NS_ERROR_TRACKING_URI; - } - - nsCOMPtr<nsIHttpChannelInternal> chan = do_QueryInterface(mChannel, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr<nsIURI> topWinURI; - rv = chan->GetTopWindowURI(getter_AddRefs(topWinURI)); - NS_ENSURE_SUCCESS(rv, rv); - if (!topWinURI) { - LOG(("nsChannelClassifier[%p]: No window URI", this)); - return NS_ERROR_TRACKING_URI; - } - - nsCOMPtr<nsIScriptSecurityManager> securityManager = - do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr<nsIPrincipal> chanPrincipal; - rv = securityManager->GetChannelURIPrincipal(mChannel, - getter_AddRefs(chanPrincipal)); - NS_ENSURE_SUCCESS(rv, rv); - - // Craft a whitelist URL like "toplevel.page/?resource=third.party.domain" - nsAutoCString pageHostname, resourceDomain; - rv = topWinURI->GetHost(pageHostname); - NS_ENSURE_SUCCESS(rv, rv); - rv = chanPrincipal->GetBaseDomain(resourceDomain); - NS_ENSURE_SUCCESS(rv, rv); - nsAutoCString whitelistEntry = NS_LITERAL_CSTRING("http://") + - pageHostname + NS_LITERAL_CSTRING("/?resource=") + resourceDomain; - LOG(("nsChannelClassifier[%p]: Looking for %s in the whitelist", - this, whitelistEntry.get())); - - nsCOMPtr<nsIURI> whitelistURI; - rv = NS_NewURI(getter_AddRefs(whitelistURI), whitelistEntry); - NS_ENSURE_SUCCESS(rv, rv); - - // Check whether or not the tracker is in the entity whitelist - nsAutoCString results; - rv = uriClassifier->ClassifyLocalWithTables(whitelistURI, tables, results); - NS_ENSURE_SUCCESS(rv, rv); - if (!results.IsEmpty()) { - return NS_OK; // found it on the whitelist, must not be blocked - } - - LOG(("nsChannelClassifier[%p]: %s is not in the whitelist", - this, whitelistEntry.get())); - return NS_ERROR_TRACKING_URI; -} - NS_IMETHODIMP nsChannelClassifier::OnClassifyComplete(nsresult aErrorCode) { // Should only be called in the parent process. MOZ_ASSERT(XRE_IsParentProcess()); - if (aErrorCode == NS_ERROR_TRACKING_URI && - NS_SUCCEEDED(IsTrackerWhitelisted())) { - LOG(("nsChannelClassifier[%p]:OnClassifyComplete tracker found " - "in whitelist so we won't block it", this)); - aErrorCode = NS_OK; - } - if (mSuspendedChannel) { nsAutoCString errorName; if (LOG_ENABLED()) { @@ -673,13 +601,6 @@ nsChannelClassifier::OnClassifyComplete(nsresult aErrorCode) uri->GetSpecOrDefault().get(), errorName.get())); } - // Channel will be cancelled (page element blocked) due to tracking. - // Do update the security state of the document and fire a security - // change event. - if (aErrorCode == NS_ERROR_TRACKING_URI) { - SetBlockedTrackingContent(mChannel); - } - mChannel->Cancel(aErrorCode); } LOG(("nsChannelClassifier[%p]: resuming channel %p from " diff --git a/netwerk/base/nsChannelClassifier.h b/netwerk/base/nsChannelClassifier.h index 20575f3c12..c21c1a0e0d 100644 --- a/netwerk/base/nsChannelClassifier.h +++ b/netwerk/base/nsChannelClassifier.h @@ -45,8 +45,6 @@ private: // Start is called. Returns NS_OK if and only if we will get a callback // from the classifier service. nsresult StartInternal(); - // Helper function to check a tracking URI against the whitelist - nsresult IsTrackerWhitelisted(); // Helper function to check a URI against the hostname whitelist bool IsHostnameWhitelisted(nsIURI *aUri, const nsACString &aWhitelisted); // Checks that the channel was loaded by the URI currently loaded in aDoc diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 8fcc0d203b..8594f17a2f 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -961,13 +961,6 @@ HttpChannelChild::DoOnStopRequest(nsIRequest* aRequest, nsresult aChannelStatus, LOG(("HttpChannelChild::DoOnStopRequest [this=%p]\n", this)); MOZ_ASSERT(!mIsPending); - // NB: We use aChannelStatus here instead of mStatus because if there was an - // nsCORSListenerProxy on this request, it will override the tracking - // protection's return value. - if (aChannelStatus == NS_ERROR_TRACKING_URI) { - nsChannelClassifier::SetBlockedTrackingContent(this); - } - MOZ_ASSERT(!mOnStopRequestCalled, "We should not call OnStopRequest twice"); |