зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1522210 - Fingerprinting and cryptomining classifiers must have separate nsIWebProgressListener blocking state codes - part 7 - cryptomining, r=Ehsan,johannh
Differential Revision: https://phabricator.services.mozilla.com/D17641 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
13c4d3abd6
Коммит
5f16a34f58
|
@ -85,16 +85,20 @@ var TrackingProtection = {
|
||||||
this.categoryLabel.textContent = label ? gNavigatorBundle.getString(label) : "";
|
this.categoryLabel.textContent = label ? gNavigatorBundle.getString(label) : "";
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME This must change! Fingerprinting must have its own section. See bug 1522566.
|
// FIXME This must change! Fingerprinting and cryptomining must have theirs
|
||||||
|
// own sections. See bug 1522566.
|
||||||
isBlocking(state) {
|
isBlocking(state) {
|
||||||
return (state & Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT) != 0 ||
|
return (state & Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT) != 0 ||
|
||||||
(state & Ci.nsIWebProgressListener.STATE_BLOCKED_FINGERPRINTING_CONTENT) != 0;
|
(state & Ci.nsIWebProgressListener.STATE_BLOCKED_FINGERPRINTING_CONTENT) != 0 ||
|
||||||
|
(state & Ci.nsIWebProgressListener.STATE_BLOCKED_CRYPTOMINING_CONTENT) != 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME This must change! Fingerprinting must have its own section. See bug 1522566.
|
// FIXME This must change! Fingerprinting and cryptomining must have theirs
|
||||||
|
// own sections. See bug 1522566.
|
||||||
isAllowing(state) {
|
isAllowing(state) {
|
||||||
return (state & Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT) != 0 ||
|
return (state & Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT) != 0 ||
|
||||||
(state & Ci.nsIWebProgressListener.STATE_LOADED_FINGERPRINTING_CONTENT) != 0;
|
(state & Ci.nsIWebProgressListener.STATE_LOADED_FINGERPRINTING_CONTENT) != 0 ||
|
||||||
|
(state & Ci.nsIWebProgressListener.STATE_LOADED_CRYPTOMINING_CONTENT) != 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
isDetected(state) {
|
isDetected(state) {
|
||||||
|
|
|
@ -1010,6 +1010,14 @@ class Document : public nsINode,
|
||||||
nsIWebProgressListener::STATE_BLOCKED_FINGERPRINTING_CONTENT);
|
nsIWebProgressListener::STATE_BLOCKED_FINGERPRINTING_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get cryptomining content blocked flag for this document.
|
||||||
|
*/
|
||||||
|
bool GetHasCryptominingContentBlocked() {
|
||||||
|
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||||
|
nsIWebProgressListener::STATE_BLOCKED_CRYPTOMINING_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all cookies blocked flag for this document.
|
* Get all cookies blocked flag for this document.
|
||||||
*/
|
*/
|
||||||
|
@ -1063,6 +1071,17 @@ class Document : public nsINode,
|
||||||
aHasFingerprintingContentBlocked);
|
aHasFingerprintingContentBlocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the cryptomining content blocked flag for this document.
|
||||||
|
*/
|
||||||
|
void SetHasCryptominingContentBlocked(bool aHasCryptominingContentBlocked,
|
||||||
|
const nsACString& aOriginBlocked) {
|
||||||
|
RecordContentBlockingLog(
|
||||||
|
aOriginBlocked,
|
||||||
|
nsIWebProgressListener::STATE_BLOCKED_CRYPTOMINING_CONTENT,
|
||||||
|
aHasCryptominingContentBlocked);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the all cookies blocked flag for this document.
|
* Set the all cookies blocked flag for this document.
|
||||||
*/
|
*/
|
||||||
|
@ -1159,6 +1178,25 @@ class Document : public nsINode,
|
||||||
aHasFingerprintingContentLoaded);
|
aHasFingerprintingContentLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get cryptomining content loaded flag for this document.
|
||||||
|
*/
|
||||||
|
bool GetHasCryptominingContentLoaded() {
|
||||||
|
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||||
|
nsIWebProgressListener::STATE_LOADED_CRYPTOMINING_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the cryptomining content loaded flag for this document.
|
||||||
|
*/
|
||||||
|
void SetHasCryptominingContentLoaded(bool aHasCryptominingContentLoaded,
|
||||||
|
const nsACString& aOriginBlocked) {
|
||||||
|
RecordContentBlockingLog(
|
||||||
|
aOriginBlocked,
|
||||||
|
nsIWebProgressListener::STATE_LOADED_CRYPTOMINING_CONTENT,
|
||||||
|
aHasCryptominingContentLoaded);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the sandbox flags for this document.
|
* Get the sandbox flags for this document.
|
||||||
* @see nsSandboxFlags.h for the possible flags
|
* @see nsSandboxFlags.h for the possible flags
|
||||||
|
|
|
@ -5419,6 +5419,18 @@ void nsGlobalWindowOuter::NotifyContentBlockingEvent(unsigned aEvent,
|
||||||
if (!aBlocked) {
|
if (!aBlocked) {
|
||||||
unblocked = !doc->GetHasFingerprintingContentLoaded();
|
unblocked = !doc->GetHasFingerprintingContentLoaded();
|
||||||
}
|
}
|
||||||
|
} else if (aEvent ==
|
||||||
|
nsIWebProgressListener::STATE_BLOCKED_CRYPTOMINING_CONTENT) {
|
||||||
|
doc->SetHasCryptominingContentBlocked(aBlocked, origin);
|
||||||
|
if (!aBlocked) {
|
||||||
|
unblocked = !doc->GetHasCryptominingContentBlocked();
|
||||||
|
}
|
||||||
|
} else if (aEvent ==
|
||||||
|
nsIWebProgressListener::STATE_LOADED_CRYPTOMINING_CONTENT) {
|
||||||
|
doc->SetHasCryptominingContentLoaded(aBlocked, origin);
|
||||||
|
if (!aBlocked) {
|
||||||
|
unblocked = !doc->GetHasCryptominingContentLoaded();
|
||||||
|
}
|
||||||
} else if (aEvent == nsIWebProgressListener::
|
} else if (aEvent == nsIWebProgressListener::
|
||||||
STATE_COOKIES_BLOCKED_BY_PERMISSION) {
|
STATE_COOKIES_BLOCKED_BY_PERMISSION) {
|
||||||
doc->SetHasCookiesBlockedByPermission(aBlocked, origin);
|
doc->SetHasCookiesBlockedByPermission(aBlocked, origin);
|
||||||
|
|
|
@ -239,3 +239,4 @@ XPC_MSG_DEF(NS_ERROR_UNWANTED_URI , "The URI is unwanted")
|
||||||
XPC_MSG_DEF(NS_ERROR_BLOCKED_URI , "The URI is blocked")
|
XPC_MSG_DEF(NS_ERROR_BLOCKED_URI , "The URI is blocked")
|
||||||
XPC_MSG_DEF(NS_ERROR_HARMFUL_URI , "The URI is harmful")
|
XPC_MSG_DEF(NS_ERROR_HARMFUL_URI , "The URI is harmful")
|
||||||
XPC_MSG_DEF(NS_ERROR_FINGERPRINTING_URI , "The URI is fingerprinting")
|
XPC_MSG_DEF(NS_ERROR_FINGERPRINTING_URI , "The URI is fingerprinting")
|
||||||
|
XPC_MSG_DEF(NS_ERROR_CRYPTOMINING_URI , "The URI is cryptomining")
|
||||||
|
|
|
@ -171,7 +171,7 @@ UrlClassifierCommon::NotifyChannelClassifierProtectionDisabled(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AntiTrackingCommon::eCryptomining:
|
case AntiTrackingCommon::eCryptomining:
|
||||||
// TODO: next patches...
|
event = nsIWebProgressListener::STATE_LOADED_CRYPTOMINING_CONTENT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -136,8 +136,8 @@ UrlClassifierFeatureCryptomining::ProcessChannel(nsIChannel* aChannel,
|
||||||
// This is a blocking feature.
|
// This is a blocking feature.
|
||||||
*aShouldContinue = false;
|
*aShouldContinue = false;
|
||||||
|
|
||||||
UrlClassifierCommon::SetBlockedContent(aChannel, NS_ERROR_TRACKING_URI, aList,
|
UrlClassifierCommon::SetBlockedContent(aChannel, NS_ERROR_CRYPTOMINING_URI,
|
||||||
EmptyCString(), EmptyCString());
|
aList, EmptyCString(), EmptyCString());
|
||||||
|
|
||||||
UC_LOG(
|
UC_LOG(
|
||||||
("UrlClassifierFeatureCryptomining::ProcessChannel, cancelling "
|
("UrlClassifierFeatureCryptomining::ProcessChannel, cancelling "
|
||||||
|
@ -145,12 +145,10 @@ UrlClassifierFeatureCryptomining::ProcessChannel(nsIChannel* aChannel,
|
||||||
aChannel));
|
aChannel));
|
||||||
nsCOMPtr<nsIHttpChannelInternal> httpChannel = do_QueryInterface(aChannel);
|
nsCOMPtr<nsIHttpChannelInternal> httpChannel = do_QueryInterface(aChannel);
|
||||||
|
|
||||||
// FIXME: the way we cancel the channel depends on what the UI wants to show.
|
|
||||||
// This needs to change, at some point.
|
|
||||||
if (httpChannel) {
|
if (httpChannel) {
|
||||||
Unused << httpChannel->CancelByChannelClassifier(NS_ERROR_TRACKING_URI);
|
Unused << httpChannel->CancelByChannelClassifier(NS_ERROR_CRYPTOMINING_URI);
|
||||||
} else {
|
} else {
|
||||||
Unused << aChannel->Cancel(NS_ERROR_TRACKING_URI);
|
Unused << aChannel->Cancel(NS_ERROR_CRYPTOMINING_URI);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -221,6 +221,9 @@ static const BlockingErrorCode sBlockingErrorCodes[] = {
|
||||||
{NS_ERROR_FINGERPRINTING_URI,
|
{NS_ERROR_FINGERPRINTING_URI,
|
||||||
nsIWebProgressListener::STATE_BLOCKED_FINGERPRINTING_CONTENT,
|
nsIWebProgressListener::STATE_BLOCKED_FINGERPRINTING_CONTENT,
|
||||||
"TrackerUriBlocked", NS_LITERAL_CSTRING("Tracking Protection")},
|
"TrackerUriBlocked", NS_LITERAL_CSTRING("Tracking Protection")},
|
||||||
|
{NS_ERROR_CRYPTOMINING_URI,
|
||||||
|
nsIWebProgressListener::STATE_BLOCKED_CRYPTOMINING_CONTENT,
|
||||||
|
"TrackerUriBlocked", NS_LITERAL_CSTRING("Tracking Protection")},
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -187,6 +187,15 @@ void nsSecureBrowserUIImpl::CheckForContentBlockingEvents() {
|
||||||
mEvent |= STATE_LOADED_FINGERPRINTING_CONTENT;
|
mEvent |= STATE_LOADED_FINGERPRINTING_CONTENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Has cryptomining content been blocked or loaded?
|
||||||
|
if (doc->GetHasCryptominingContentBlocked()) {
|
||||||
|
mEvent |= STATE_BLOCKED_CRYPTOMINING_CONTENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc->GetHasCryptominingContentLoaded()) {
|
||||||
|
mEvent |= STATE_LOADED_CRYPTOMINING_CONTENT;
|
||||||
|
}
|
||||||
|
|
||||||
// Other block types.
|
// Other block types.
|
||||||
if (doc->GetHasCookiesBlockedByPermission()) {
|
if (doc->GetHasCookiesBlockedByPermission()) {
|
||||||
mEvent |= STATE_COOKIES_BLOCKED_BY_PERMISSION;
|
mEvent |= STATE_COOKIES_BLOCKED_BY_PERMISSION;
|
||||||
|
|
|
@ -276,6 +276,12 @@ interface nsIWebProgressListener : nsISupports
|
||||||
* STATE_LOADED_FINGERPRINTING_CONTENT
|
* STATE_LOADED_FINGERPRINTING_CONTENT
|
||||||
* Fingerprinting content has been loaded.
|
* Fingerprinting content has been loaded.
|
||||||
*
|
*
|
||||||
|
* STATE_BLOCKED_CRYPTOMINING_CONTENT
|
||||||
|
* Cryptomining content has been blocked from loading.
|
||||||
|
*
|
||||||
|
* STATE_LOADED_CRYPTOMINING_CONTENT
|
||||||
|
* Cryptomining content has been loaded.
|
||||||
|
*
|
||||||
* STATE_BLOCKED_UNSAFE_CONTENT
|
* STATE_BLOCKED_UNSAFE_CONTENT
|
||||||
* Content which againts SafeBrowsing list has been blocked from loading.
|
* Content which againts SafeBrowsing list has been blocked from loading.
|
||||||
*
|
*
|
||||||
|
@ -296,6 +302,8 @@ interface nsIWebProgressListener : nsISupports
|
||||||
const unsigned long STATE_LOADED_TRACKING_CONTENT = 0x00002000;
|
const unsigned long STATE_LOADED_TRACKING_CONTENT = 0x00002000;
|
||||||
const unsigned long STATE_BLOCKED_FINGERPRINTING_CONTENT = 0x00000040;
|
const unsigned long STATE_BLOCKED_FINGERPRINTING_CONTENT = 0x00000040;
|
||||||
const unsigned long STATE_LOADED_FINGERPRINTING_CONTENT = 0x00000400;
|
const unsigned long STATE_LOADED_FINGERPRINTING_CONTENT = 0x00000400;
|
||||||
|
const unsigned long STATE_BLOCKED_CRYPTOMINING_CONTENT = 0x00000800;
|
||||||
|
const unsigned long STATE_LOADED_CRYPTOMINING_CONTENT = 0x00200000;
|
||||||
const unsigned long STATE_BLOCKED_UNSAFE_CONTENT = 0x00004000;
|
const unsigned long STATE_BLOCKED_UNSAFE_CONTENT = 0x00004000;
|
||||||
const unsigned long STATE_COOKIES_LOADED = 0x00008000;
|
const unsigned long STATE_COOKIES_LOADED = 0x00008000;
|
||||||
const unsigned long STATE_COOKIES_BLOCKED_BY_PERMISSION = 0x10000000;
|
const unsigned long STATE_COOKIES_BLOCKED_BY_PERMISSION = 0x10000000;
|
||||||
|
|
|
@ -808,6 +808,7 @@ with modules["URILOADER"]:
|
||||||
errors["NS_ERROR_MAYBE_TRACKING_URI"] = FAILURE(39)
|
errors["NS_ERROR_MAYBE_TRACKING_URI"] = FAILURE(39)
|
||||||
errors["NS_ERROR_TRACKING_ANNOTATION_URI"] = FAILURE(40)
|
errors["NS_ERROR_TRACKING_ANNOTATION_URI"] = FAILURE(40)
|
||||||
errors["NS_ERROR_FINGERPRINTING_URI"] = FAILURE(41)
|
errors["NS_ERROR_FINGERPRINTING_URI"] = FAILURE(41)
|
||||||
|
errors["NS_ERROR_CRYPTOMINING_URI"] = FAILURE(42)
|
||||||
# Used when "Save Link As..." doesn't see the headers quickly enough to
|
# Used when "Save Link As..." doesn't see the headers quickly enough to
|
||||||
# choose a filename. See nsContextMenu.js.
|
# choose a filename. See nsContextMenu.js.
|
||||||
errors["NS_ERROR_SAVE_LINK_AS_TIMEOUT"] = FAILURE(32)
|
errors["NS_ERROR_SAVE_LINK_AS_TIMEOUT"] = FAILURE(32)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче