зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1351147 - Use fullhash instead of prefix in OnClassifyComplete r=francois
In order to optionally report the full hash back to Google, we need to keep it around in the callback. While a prefix is not the same as a full hash (multiple full hashes can map to the same prefix), in this case, the callback will only be called when the full hash matches. MozReview-Commit-ID: F4WSLZpYrXB --HG-- extra : rebase_source : da3b16b00729d0aa6ff1765a135b751fcf44c012
This commit is contained in:
Родитель
1079b29408
Коммит
651c28ca53
|
@ -10,7 +10,7 @@ namespace dom {
|
||||||
struct ClassifierInfo {
|
struct ClassifierInfo {
|
||||||
nsCString list;
|
nsCString list;
|
||||||
nsCString provider;
|
nsCString provider;
|
||||||
nsCString prefix;
|
nsCString fullhash;
|
||||||
};
|
};
|
||||||
|
|
||||||
union MaybeInfo {
|
union MaybeInfo {
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
if (aInfo.type() == MaybeInfo::TClassifierInfo) {
|
if (aInfo.type() == MaybeInfo::TClassifierInfo) {
|
||||||
mCallback->OnClassifyComplete(aResult, aInfo.get_ClassifierInfo().list(),
|
mCallback->OnClassifyComplete(aResult, aInfo.get_ClassifierInfo().list(),
|
||||||
aInfo.get_ClassifierInfo().provider(),
|
aInfo.get_ClassifierInfo().provider(),
|
||||||
aInfo.get_ClassifierInfo().prefix());
|
aInfo.get_ClassifierInfo().fullhash());
|
||||||
}
|
}
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,12 @@ public:
|
||||||
NS_IMETHOD OnClassifyComplete(nsresult aErrorCode,
|
NS_IMETHOD OnClassifyComplete(nsresult aErrorCode,
|
||||||
const nsACString& aList,
|
const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix)
|
const nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
if (mIPCOpen) {
|
if (mIPCOpen) {
|
||||||
ClassifierInfo info = ClassifierInfo(nsCString(aList),
|
ClassifierInfo info = ClassifierInfo(nsCString(aList),
|
||||||
nsCString(aProvider),
|
nsCString(aProvider),
|
||||||
nsCString(aPrefix));
|
nsCString(aFullHash));
|
||||||
Unused << BaseProtocol::Send__delete__(this, info, aErrorCode);
|
Unused << BaseProtocol::Send__delete__(this, info, aErrorCode);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -804,10 +804,10 @@ nsChannelClassifier::SetBlockedContent(nsIChannel *channel,
|
||||||
nsresult aErrorCode,
|
nsresult aErrorCode,
|
||||||
const nsACString& aList,
|
const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix)
|
const nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(!aList.IsEmpty());
|
NS_ENSURE_ARG(!aList.IsEmpty());
|
||||||
NS_ENSURE_ARG(!aPrefix.IsEmpty());
|
NS_ENSURE_ARG(!aFullHash.IsEmpty());
|
||||||
|
|
||||||
// Can be called in EITHER the parent or child process.
|
// Can be called in EITHER the parent or child process.
|
||||||
nsCOMPtr<nsIParentChannel> parentChannel;
|
nsCOMPtr<nsIParentChannel> parentChannel;
|
||||||
|
@ -815,7 +815,7 @@ nsChannelClassifier::SetBlockedContent(nsIChannel *channel,
|
||||||
if (parentChannel) {
|
if (parentChannel) {
|
||||||
// This channel is a parent-process proxy for a child process request.
|
// This channel is a parent-process proxy for a child process request.
|
||||||
// Tell the child process channel to do this instead.
|
// Tell the child process channel to do this instead.
|
||||||
parentChannel->SetClassifierMatchedInfo(aList, aProvider, aPrefix);
|
parentChannel->SetClassifierMatchedInfo(aList, aProvider, aFullHash);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,7 +824,7 @@ nsChannelClassifier::SetBlockedContent(nsIChannel *channel,
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (classifiedChannel) {
|
if (classifiedChannel) {
|
||||||
classifiedChannel->SetMatchedInfo(aList, aProvider, aPrefix);
|
classifiedChannel->SetMatchedInfo(aList, aProvider, aFullHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<mozIDOMWindowProxy> win;
|
nsCOMPtr<mozIDOMWindowProxy> win;
|
||||||
|
@ -914,20 +914,20 @@ public:
|
||||||
explicit IsTrackerWhitelistedCallback(T* aClosure,
|
explicit IsTrackerWhitelistedCallback(T* aClosure,
|
||||||
const nsACString& aList,
|
const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix,
|
const nsACString& aFullHash,
|
||||||
nsIURI* aWhitelistURI)
|
nsIURI* aWhitelistURI)
|
||||||
: mClosure(aClosure)
|
: mClosure(aClosure)
|
||||||
, mWhitelistURI(aWhitelistURI)
|
, mWhitelistURI(aWhitelistURI)
|
||||||
, mList(aList)
|
, mList(aList)
|
||||||
, mProvider(aProvider)
|
, mProvider(aProvider)
|
||||||
, mPrefix(aPrefix)
|
, mFullHash(aFullHash)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHOD OnClassifyComplete(nsresult /*aErrorCode*/,
|
NS_IMETHOD OnClassifyComplete(nsresult /*aErrorCode*/,
|
||||||
const nsACString& aLists, // Only this matters.
|
const nsACString& aLists, // Only this matters.
|
||||||
const nsACString& /*aProvider*/,
|
const nsACString& /*aProvider*/,
|
||||||
const nsACString& /*aPrefix*/) override
|
const nsACString& /*aFullHash*/) override
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
if (aLists.IsEmpty()) {
|
if (aLists.IsEmpty()) {
|
||||||
|
@ -944,7 +944,7 @@ public:
|
||||||
rv = NS_OK;
|
rv = NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = mClosure->OnClassifyCompleteInternal(rv, mList, mProvider, mPrefix);
|
rv = mClosure->OnClassifyCompleteInternal(rv, mList, mProvider, mFullHash);
|
||||||
mClosure = nullptr;
|
mClosure = nullptr;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -958,7 +958,7 @@ private:
|
||||||
// The following 3 values are for forwarding the callback.
|
// The following 3 values are for forwarding the callback.
|
||||||
nsCString mList;
|
nsCString mList;
|
||||||
nsCString mProvider;
|
nsCString mProvider;
|
||||||
nsCString mPrefix;
|
nsCString mFullHash;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class is designed to get the results of checking blacklist and whitelist.
|
// This class is designed to get the results of checking blacklist and whitelist.
|
||||||
|
@ -981,7 +981,7 @@ public:
|
||||||
nsresult OnClassifyCompleteInternal(nsresult aErrorCode,
|
nsresult OnClassifyCompleteInternal(nsresult aErrorCode,
|
||||||
const nsACString& aList,
|
const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix);
|
const nsACString& aFullHash);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~IsTrackerBlacklistedCallback() = default;
|
~IsTrackerBlacklistedCallback() = default;
|
||||||
|
@ -996,7 +996,7 @@ NS_IMPL_ISUPPORTS(IsTrackerBlacklistedCallback, nsIURIClassifierCallback)
|
||||||
IsTrackerBlacklistedCallback::OnClassifyComplete(nsresult aErrorCode,
|
IsTrackerBlacklistedCallback::OnClassifyComplete(nsresult aErrorCode,
|
||||||
const nsACString& aLists,
|
const nsACString& aLists,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix)
|
const nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
nsresult status = aLists.IsEmpty() ? NS_OK : NS_ERROR_TRACKING_URI;
|
nsresult status = aLists.IsEmpty() ? NS_OK : NS_ERROR_TRACKING_URI;
|
||||||
bool tpEnabled = mChannelClassifier->ShouldEnableTrackingProtection();
|
bool tpEnabled = mChannelClassifier->ShouldEnableTrackingProtection();
|
||||||
|
@ -1011,7 +1011,7 @@ IsTrackerBlacklistedCallback::OnClassifyComplete(nsresult aErrorCode,
|
||||||
// when tracking protection is enabled, so we can just return here.
|
// when tracking protection is enabled, so we can just return here.
|
||||||
if (NS_SUCCEEDED(status) || tpEnabled) {
|
if (NS_SUCCEEDED(status) || tpEnabled) {
|
||||||
return mChannelCallback->OnClassifyComplete(
|
return mChannelCallback->OnClassifyComplete(
|
||||||
status, aLists, aProvider, aPrefix);
|
status, aLists, aProvider, aFullHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIChannel> channel = mChannelClassifier->GetChannel();
|
nsCOMPtr<nsIChannel> channel = mChannelClassifier->GetChannel();
|
||||||
|
@ -1027,7 +1027,7 @@ IsTrackerBlacklistedCallback::OnClassifyComplete(nsresult aErrorCode,
|
||||||
nsCOMPtr<nsIURI> whitelistURI = mChannelClassifier->CreateWhiteListURI();
|
nsCOMPtr<nsIURI> whitelistURI = mChannelClassifier->CreateWhiteListURI();
|
||||||
nsCOMPtr<nsIURIClassifierCallback> callback =
|
nsCOMPtr<nsIURIClassifierCallback> callback =
|
||||||
new IsTrackerWhitelistedCallback<IsTrackerBlacklistedCallback>(
|
new IsTrackerWhitelistedCallback<IsTrackerBlacklistedCallback>(
|
||||||
this, aLists, aProvider, aPrefix, whitelistURI);
|
this, aLists, aProvider, aFullHash, whitelistURI);
|
||||||
|
|
||||||
// If IsTrackerWhitelisted has failed, it means the uri is not in whitelist.
|
// If IsTrackerWhitelisted has failed, it means the uri is not in whitelist.
|
||||||
if (NS_FAILED(mChannelClassifier->IsTrackerWhitelisted(whitelistURI, callback))) {
|
if (NS_FAILED(mChannelClassifier->IsTrackerWhitelisted(whitelistURI, callback))) {
|
||||||
|
@ -1047,7 +1047,7 @@ IsTrackerBlacklistedCallback::OnClassifyComplete(nsresult aErrorCode,
|
||||||
status = NS_OK;
|
status = NS_OK;
|
||||||
|
|
||||||
return mChannelCallback->OnClassifyComplete(
|
return mChannelCallback->OnClassifyComplete(
|
||||||
status, aLists, aProvider, aPrefix);
|
status, aLists, aProvider, aFullHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnClassifyCompleteInternal() will be called once we know
|
// OnClassifyCompleteInternal() will be called once we know
|
||||||
|
@ -1059,7 +1059,7 @@ nsresult
|
||||||
IsTrackerBlacklistedCallback::OnClassifyCompleteInternal(nsresult aErrorCode,
|
IsTrackerBlacklistedCallback::OnClassifyCompleteInternal(nsresult aErrorCode,
|
||||||
const nsACString& aLists,
|
const nsACString& aLists,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix)
|
const nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
LOG(("IsTrackerBlacklistedCallback[%p]:OnClassifyCompleteInternal"
|
LOG(("IsTrackerBlacklistedCallback[%p]:OnClassifyCompleteInternal"
|
||||||
" status=0x%" PRIx32,
|
" status=0x%" PRIx32,
|
||||||
|
@ -1067,7 +1067,7 @@ IsTrackerBlacklistedCallback::OnClassifyCompleteInternal(nsresult aErrorCode,
|
||||||
|
|
||||||
if (NS_SUCCEEDED(aErrorCode)) {
|
if (NS_SUCCEEDED(aErrorCode)) {
|
||||||
return mChannelCallback->OnClassifyComplete(
|
return mChannelCallback->OnClassifyComplete(
|
||||||
aErrorCode, aLists, aProvider, aPrefix);
|
aErrorCode, aLists, aProvider, aFullHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(mChannelClassifier->ShouldEnableTrackingAnnotation());
|
MOZ_ASSERT(mChannelClassifier->ShouldEnableTrackingAnnotation());
|
||||||
|
@ -1089,7 +1089,7 @@ IsTrackerBlacklistedCallback::OnClassifyCompleteInternal(nsresult aErrorCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
return mChannelCallback->OnClassifyComplete(
|
return mChannelCallback->OnClassifyComplete(
|
||||||
NS_OK, aLists, aProvider, aPrefix);
|
NS_OK, aLists, aProvider, aFullHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of unnamed namespace/
|
} // end of unnamed namespace/
|
||||||
|
@ -1165,7 +1165,7 @@ NS_IMETHODIMP
|
||||||
nsChannelClassifier::OnClassifyComplete(nsresult aErrorCode,
|
nsChannelClassifier::OnClassifyComplete(nsresult aErrorCode,
|
||||||
const nsACString& aList,
|
const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix)
|
const nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
// Should only be called in the parent process.
|
// Should only be called in the parent process.
|
||||||
MOZ_ASSERT(XRE_IsParentProcess());
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
|
@ -1174,7 +1174,7 @@ nsChannelClassifier::OnClassifyComplete(nsresult aErrorCode,
|
||||||
nsCOMPtr<nsIURI> whitelistURI = CreateWhiteListURI();
|
nsCOMPtr<nsIURI> whitelistURI = CreateWhiteListURI();
|
||||||
nsCOMPtr<nsIURIClassifierCallback> callback =
|
nsCOMPtr<nsIURIClassifierCallback> callback =
|
||||||
new IsTrackerWhitelistedCallback<nsChannelClassifier>(
|
new IsTrackerWhitelistedCallback<nsChannelClassifier>(
|
||||||
this, aList, aProvider, aPrefix, whitelistURI);
|
this, aList, aProvider, aFullHash, whitelistURI);
|
||||||
if (whitelistURI &&
|
if (whitelistURI &&
|
||||||
NS_SUCCEEDED(IsTrackerWhitelisted(whitelistURI, callback))) {
|
NS_SUCCEEDED(IsTrackerWhitelisted(whitelistURI, callback))) {
|
||||||
// OnClassifyCompleteInternal() will be called once we know
|
// OnClassifyCompleteInternal() will be called once we know
|
||||||
|
@ -1183,14 +1183,14 @@ nsChannelClassifier::OnClassifyComplete(nsresult aErrorCode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return OnClassifyCompleteInternal(aErrorCode, aList, aProvider, aPrefix);
|
return OnClassifyCompleteInternal(aErrorCode, aList, aProvider, aFullHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsChannelClassifier::OnClassifyCompleteInternal(nsresult aErrorCode,
|
nsChannelClassifier::OnClassifyCompleteInternal(nsresult aErrorCode,
|
||||||
const nsACString& aList,
|
const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix)
|
const nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
if (mSuspendedChannel) {
|
if (mSuspendedChannel) {
|
||||||
nsAutoCString errorName;
|
nsAutoCString errorName;
|
||||||
|
@ -1214,7 +1214,7 @@ nsChannelClassifier::OnClassifyCompleteInternal(nsresult aErrorCode,
|
||||||
// protection or Safe Browsing.
|
// protection or Safe Browsing.
|
||||||
// Do update the security state of the document and fire a security
|
// Do update the security state of the document and fire a security
|
||||||
// change event.
|
// change event.
|
||||||
SetBlockedContent(mChannel, aErrorCode, aList, aProvider, aPrefix);
|
SetBlockedContent(mChannel, aErrorCode, aList, aProvider, aFullHash);
|
||||||
|
|
||||||
mChannel->Cancel(aErrorCode);
|
mChannel->Cancel(aErrorCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
nsresult OnClassifyCompleteInternal(nsresult aErrorCode,
|
nsresult OnClassifyCompleteInternal(nsresult aErrorCode,
|
||||||
const nsACString& aList,
|
const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix);
|
const nsACString& aFullHash);
|
||||||
|
|
||||||
// Check a tracking URI against the local blacklist and whitelist.
|
// Check a tracking URI against the local blacklist and whitelist.
|
||||||
// Returning NS_OK means the check will be processed
|
// Returning NS_OK means the check will be processed
|
||||||
|
@ -96,7 +96,7 @@ public:
|
||||||
nsresult aErrorCode,
|
nsresult aErrorCode,
|
||||||
const nsACString& aList,
|
const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix);
|
const nsACString& aFullHash);
|
||||||
static nsresult NotifyTrackingProtectionDisabled(nsIChannel *aChannel);
|
static nsresult NotifyTrackingProtectionDisabled(nsIChannel *aChannel);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,12 @@ interface nsIClassifiedChannel : nsISupports
|
||||||
* Name of the Safe Browsing list that matched (e.g. goog-phish-shavar).
|
* Name of the Safe Browsing list that matched (e.g. goog-phish-shavar).
|
||||||
* @param aProvider
|
* @param aProvider
|
||||||
* Name of the Safe Browsing provider that matched (e.g. google)
|
* Name of the Safe Browsing provider that matched (e.g. google)
|
||||||
* @param aPrefix
|
* @param aFullHash
|
||||||
* Hash prefix of URL that matched Safe Browsing list.
|
* Full hash of URL that matched Safe Browsing list.
|
||||||
*/
|
*/
|
||||||
void setMatchedInfo(in ACString aList,
|
void setMatchedInfo(in ACString aList,
|
||||||
in ACString aProvider,
|
in ACString aProvider,
|
||||||
in ACString aPrefix);
|
in ACString aFullHash);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the list that matched
|
* Name of the list that matched
|
||||||
|
@ -40,8 +40,8 @@ interface nsIClassifiedChannel : nsISupports
|
||||||
readonly attribute ACString matchedProvider;
|
readonly attribute ACString matchedProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash prefix of URL that matched
|
* Full hash of URL that matched
|
||||||
*/
|
*/
|
||||||
readonly attribute ACString matchedPrefix;
|
readonly attribute ACString matchedFullHash;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,12 +40,12 @@ interface nsIParentChannel : nsIStreamListener
|
||||||
* Name of the list that matched
|
* Name of the list that matched
|
||||||
* @param aProvider
|
* @param aProvider
|
||||||
* Name of provider that matched
|
* Name of provider that matched
|
||||||
* @param aPrefix
|
* @param aFullHash
|
||||||
* String represents hash prefix that matched
|
* String represents full hash that matched
|
||||||
*/
|
*/
|
||||||
[noscript] void setClassifierMatchedInfo(in ACString aList,
|
[noscript] void setClassifierMatchedInfo(in ACString aList,
|
||||||
in ACString aProvider,
|
in ACString aProvider,
|
||||||
in ACString aPrefix);
|
in ACString aFullHash);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to notify the HttpChannelChild that the resource being loaded
|
* Called to notify the HttpChannelChild that the resource being loaded
|
||||||
|
|
|
@ -34,13 +34,13 @@ interface nsIURIClassifierCallback : nsISupports
|
||||||
* Name of the list that matched
|
* Name of the list that matched
|
||||||
* @param aProvider
|
* @param aProvider
|
||||||
* Name of provider that matched
|
* Name of provider that matched
|
||||||
* @param aPrefix
|
* @param aFullHash
|
||||||
* Hash prefix of URL that matched
|
* Full hash of URL that matched
|
||||||
*/
|
*/
|
||||||
void onClassifyComplete(in nsresult aErrorCode,
|
void onClassifyComplete(in nsresult aErrorCode,
|
||||||
in ACString aList,
|
in ACString aList,
|
||||||
in ACString aProvider,
|
in ACString aProvider,
|
||||||
in ACString aPrefix);
|
in ACString aFullHash);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -52,7 +52,7 @@ DataChannelParent::NotifyTrackingResource()
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DataChannelParent::SetClassifierMatchedInfo(const nsACString& aList,
|
DataChannelParent::SetClassifierMatchedInfo(const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix)
|
const nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
// nothing to do
|
// nothing to do
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -52,7 +52,7 @@ FileChannelParent::NotifyTrackingResource()
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
FileChannelParent::SetClassifierMatchedInfo(const nsACString& aList,
|
FileChannelParent::SetClassifierMatchedInfo(const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix)
|
const nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
// nothing to do
|
// nothing to do
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -581,7 +581,7 @@ FTPChannelParent::NotifyTrackingResource()
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
FTPChannelParent::SetClassifierMatchedInfo(const nsACString& aList,
|
FTPChannelParent::SetClassifierMatchedInfo(const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix)
|
const nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
// One day, this should probably be filled in.
|
// One day, this should probably be filled in.
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -429,7 +429,9 @@ HttpBackgroundChannelChild::RecvSetClassifierMatchedInfo(const ClassifierInfo& i
|
||||||
|
|
||||||
// SetClassifierMatchedInfo has no order dependency to OnStartRequest.
|
// SetClassifierMatchedInfo has no order dependency to OnStartRequest.
|
||||||
// It this be handled as soon as possible
|
// It this be handled as soon as possible
|
||||||
mChannelChild->ProcessSetClassifierMatchedInfo(info.list(), info.provider(), info.prefix());
|
mChannelChild->ProcessSetClassifierMatchedInfo(info.list(),
|
||||||
|
info.provider(),
|
||||||
|
info.fullhash());
|
||||||
|
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,10 +400,9 @@ HttpBackgroundChannelParent::OnNotifyTrackingResource()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
HttpBackgroundChannelParent::OnSetClassifierMatchedInfo(
|
HttpBackgroundChannelParent::OnSetClassifierMatchedInfo(const nsACString& aList,
|
||||||
const nsACString& aList,
|
const nsACString& aProvider,
|
||||||
const nsACString& aProvider,
|
const nsACString& aFullHash)
|
||||||
const nsACString& aPrefix)
|
|
||||||
{
|
{
|
||||||
LOG(("HttpBackgroundChannelParent::OnSetClassifierMatchedInfo [this=%p]\n", this));
|
LOG(("HttpBackgroundChannelParent::OnSetClassifierMatchedInfo [this=%p]\n", this));
|
||||||
AssertIsInMainProcess();
|
AssertIsInMainProcess();
|
||||||
|
@ -421,7 +420,7 @@ HttpBackgroundChannelParent::OnSetClassifierMatchedInfo(
|
||||||
&HttpBackgroundChannelParent::OnSetClassifierMatchedInfo,
|
&HttpBackgroundChannelParent::OnSetClassifierMatchedInfo,
|
||||||
aList,
|
aList,
|
||||||
aProvider,
|
aProvider,
|
||||||
aPrefix),
|
aFullHash),
|
||||||
NS_DISPATCH_NORMAL);
|
NS_DISPATCH_NORMAL);
|
||||||
|
|
||||||
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
|
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
|
||||||
|
@ -431,7 +430,7 @@ HttpBackgroundChannelParent::OnSetClassifierMatchedInfo(
|
||||||
|
|
||||||
ClassifierInfo info;
|
ClassifierInfo info;
|
||||||
info.list() = aList;
|
info.list() = aList;
|
||||||
info.prefix() = aPrefix;
|
info.fullhash() = aFullHash;
|
||||||
info.provider() = aProvider;
|
info.provider() = aProvider;
|
||||||
|
|
||||||
return SendSetClassifierMatchedInfo(info);
|
return SendSetClassifierMatchedInfo(info);
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
// To send SetClassifierMatchedInfo message over background channel.
|
// To send SetClassifierMatchedInfo message over background channel.
|
||||||
bool OnSetClassifierMatchedInfo(const nsACString& aList,
|
bool OnSetClassifierMatchedInfo(const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix);
|
const nsACString& aFullHash);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||||
|
|
|
@ -3690,21 +3690,21 @@ HttpBaseChannel::GetMatchedProvider(nsACString& aProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HttpBaseChannel::GetMatchedPrefix(nsACString& aPrefix)
|
HttpBaseChannel::GetMatchedFullHash(nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
aPrefix = mMatchedPrefix;
|
aFullHash = mMatchedFullHash;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HttpBaseChannel::SetMatchedInfo(const nsACString& aList,
|
HttpBaseChannel::SetMatchedInfo(const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix) {
|
const nsACString& aFullHash) {
|
||||||
NS_ENSURE_ARG(!aList.IsEmpty());
|
NS_ENSURE_ARG(!aList.IsEmpty());
|
||||||
|
|
||||||
mMatchedList = aList;
|
mMatchedList = aList;
|
||||||
mMatchedProvider = aProvider;
|
mMatchedProvider = aProvider;
|
||||||
mMatchedPrefix = aPrefix;
|
mMatchedFullHash = aFullHash;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -664,7 +664,7 @@ protected:
|
||||||
// Classified channel's matched information
|
// Classified channel's matched information
|
||||||
nsCString mMatchedList;
|
nsCString mMatchedList;
|
||||||
nsCString mMatchedProvider;
|
nsCString mMatchedProvider;
|
||||||
nsCString mMatchedPrefix;
|
nsCString mMatchedFullHash;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_DEFINE_STATIC_IID_ACCESSOR(HttpBaseChannel, HTTP_BASE_CHANNEL_IID)
|
NS_DEFINE_STATIC_IID_ACCESSOR(HttpBaseChannel, HTTP_BASE_CHANNEL_IID)
|
||||||
|
|
|
@ -1164,7 +1164,7 @@ HttpChannelChild::DoOnStopRequest(nsIRequest* aRequest, nsresult aChannelStatus,
|
||||||
aChannelStatus == NS_ERROR_BLOCKED_URI ||
|
aChannelStatus == NS_ERROR_BLOCKED_URI ||
|
||||||
aChannelStatus == NS_ERROR_HARMFUL_URI ||
|
aChannelStatus == NS_ERROR_HARMFUL_URI ||
|
||||||
aChannelStatus == NS_ERROR_PHISHING_URI) {
|
aChannelStatus == NS_ERROR_PHISHING_URI) {
|
||||||
nsCString list, provider, prefix;
|
nsCString list, provider, fullhash;
|
||||||
|
|
||||||
nsresult rv = GetMatchedList(list);
|
nsresult rv = GetMatchedList(list);
|
||||||
NS_ENSURE_SUCCESS_VOID(rv);
|
NS_ENSURE_SUCCESS_VOID(rv);
|
||||||
|
@ -1172,10 +1172,10 @@ HttpChannelChild::DoOnStopRequest(nsIRequest* aRequest, nsresult aChannelStatus,
|
||||||
rv = GetMatchedProvider(provider);
|
rv = GetMatchedProvider(provider);
|
||||||
NS_ENSURE_SUCCESS_VOID(rv);
|
NS_ENSURE_SUCCESS_VOID(rv);
|
||||||
|
|
||||||
rv = GetMatchedPrefix(prefix);
|
rv = GetMatchedFullHash(fullhash);
|
||||||
NS_ENSURE_SUCCESS_VOID(rv);
|
NS_ENSURE_SUCCESS_VOID(rv);
|
||||||
|
|
||||||
nsChannelClassifier::SetBlockedContent(this, aChannelStatus, list, provider, prefix);
|
nsChannelClassifier::SetBlockedContent(this, aChannelStatus, list, provider, fullhash);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(!mOnStopRequestCalled,
|
MOZ_ASSERT(!mOnStopRequestCalled,
|
||||||
|
@ -1818,7 +1818,7 @@ HttpChannelChild::FlushedForDiversion()
|
||||||
void
|
void
|
||||||
HttpChannelChild::ProcessSetClassifierMatchedInfo(const nsCString& aList,
|
HttpChannelChild::ProcessSetClassifierMatchedInfo(const nsCString& aList,
|
||||||
const nsCString& aProvider,
|
const nsCString& aProvider,
|
||||||
const nsCString& aPrefix)
|
const nsCString& aFullHash)
|
||||||
{
|
{
|
||||||
LOG(("HttpChannelChild::ProcessSetClassifierMatchedInfo [this=%p]\n", this));
|
LOG(("HttpChannelChild::ProcessSetClassifierMatchedInfo [this=%p]\n", this));
|
||||||
MOZ_ASSERT(OnSocketThread());
|
MOZ_ASSERT(OnSocketThread());
|
||||||
|
@ -1828,7 +1828,7 @@ HttpChannelChild::ProcessSetClassifierMatchedInfo(const nsCString& aList,
|
||||||
NewRunnableMethod<const nsCString, const nsCString, const nsCString>
|
NewRunnableMethod<const nsCString, const nsCString, const nsCString>
|
||||||
("HttpChannelChild::SetMatchedInfo",
|
("HttpChannelChild::SetMatchedInfo",
|
||||||
this, &HttpChannelChild::SetMatchedInfo,
|
this, &HttpChannelChild::SetMatchedInfo,
|
||||||
aList, aProvider, aPrefix),
|
aList, aProvider, aFullHash),
|
||||||
NS_DISPATCH_NORMAL);
|
NS_DISPATCH_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ private:
|
||||||
void ProcessNotifyTrackingResource();
|
void ProcessNotifyTrackingResource();
|
||||||
void ProcessSetClassifierMatchedInfo(const nsCString& aList,
|
void ProcessSetClassifierMatchedInfo(const nsCString& aList,
|
||||||
const nsCString& aProvider,
|
const nsCString& aProvider,
|
||||||
const nsCString& aPrefix);
|
const nsCString& aFullHash);
|
||||||
|
|
||||||
|
|
||||||
void DoOnStartRequest(nsIRequest* aRequest, nsISupports* aContext);
|
void DoOnStartRequest(nsIRequest* aRequest, nsISupports* aContext);
|
||||||
|
|
|
@ -1732,12 +1732,12 @@ HttpChannelParent::NotifyTrackingProtectionDisabled()
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HttpChannelParent::SetClassifierMatchedInfo(const nsACString& aList,
|
HttpChannelParent::SetClassifierMatchedInfo(const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix)
|
const nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
LOG(("HttpChannelParent::SetClassifierMatchedInfo [this=%p]\n", this));
|
LOG(("HttpChannelParent::SetClassifierMatchedInfo [this=%p]\n", this));
|
||||||
if (!mIPCClosed) {
|
if (!mIPCClosed) {
|
||||||
MOZ_ASSERT(mBgParent);
|
MOZ_ASSERT(mBgParent);
|
||||||
Unused << mBgParent->OnSetClassifierMatchedInfo(aList, aProvider, aPrefix);
|
Unused << mBgParent->OnSetClassifierMatchedInfo(aList, aProvider, aFullHash);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1289,9 +1289,9 @@ nsUrlClassifierLookupCallback::HandleResults()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (classifyCallback) {
|
if (classifyCallback) {
|
||||||
nsCString prefixString;
|
nsCString fullHashString;
|
||||||
result.hash.fixedLengthPrefix.ToString(prefixString);
|
result.hash.complete.ToString(fullHashString);
|
||||||
classifyCallback->HandleResult(result.mTableName, prefixString);
|
classifyCallback->HandleResult(result.mTableName, fullHashString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1378,7 +1378,7 @@ private:
|
||||||
|
|
||||||
struct ClassifyMatchedInfo {
|
struct ClassifyMatchedInfo {
|
||||||
nsCString table;
|
nsCString table;
|
||||||
nsCString prefix;
|
nsCString fullhash;
|
||||||
Provider provider;
|
Provider provider;
|
||||||
nsresult errorCode;
|
nsresult errorCode;
|
||||||
};
|
};
|
||||||
|
@ -1413,27 +1413,27 @@ nsUrlClassifierClassifyCallback::HandleEvent(const nsACString& tables)
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCString provider = matchedInfo ? matchedInfo->provider.name : EmptyCString();
|
nsCString provider = matchedInfo ? matchedInfo->provider.name : EmptyCString();
|
||||||
nsCString prefix = matchedInfo ? matchedInfo->prefix : EmptyCString();
|
nsCString fullhash = matchedInfo ? matchedInfo->fullhash : EmptyCString();
|
||||||
nsCString table = matchedInfo ? matchedInfo->table : EmptyCString();
|
nsCString table = matchedInfo ? matchedInfo->table : EmptyCString();
|
||||||
|
|
||||||
mCallback->OnClassifyComplete(response, table, provider, prefix);
|
mCallback->OnClassifyComplete(response, table, provider, fullhash);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsUrlClassifierClassifyCallback::HandleResult(const nsACString& aTable,
|
nsUrlClassifierClassifyCallback::HandleResult(const nsACString& aTable,
|
||||||
const nsACString& aPrefix)
|
const nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
LOG(("nsUrlClassifierClassifyCallback::HandleResult [%p, table %s prefix %s]",
|
LOG(("nsUrlClassifierClassifyCallback::HandleResult [%p, table %s full hash %s]",
|
||||||
this, PromiseFlatCString(aTable).get(), PromiseFlatCString(aPrefix).get()));
|
this, PromiseFlatCString(aTable).get(), PromiseFlatCString(aFullHash).get()));
|
||||||
|
|
||||||
if (NS_WARN_IF(aTable.IsEmpty()) || NS_WARN_IF(aPrefix.IsEmpty())) {
|
if (NS_WARN_IF(aTable.IsEmpty()) || NS_WARN_IF(aFullHash.IsEmpty())) {
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassifyMatchedInfo* matchedInfo = mMatchedArray.AppendElement();
|
ClassifyMatchedInfo* matchedInfo = mMatchedArray.AppendElement();
|
||||||
matchedInfo->table = aTable;
|
matchedInfo->table = aTable;
|
||||||
matchedInfo->prefix = aPrefix;
|
matchedInfo->fullhash = aFullHash;
|
||||||
|
|
||||||
nsCOMPtr<nsIUrlClassifierUtils> urlUtil =
|
nsCOMPtr<nsIUrlClassifierUtils> urlUtil =
|
||||||
do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID);
|
do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID);
|
||||||
|
|
|
@ -48,7 +48,7 @@ var inputDatas = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
function hashPrefix(str) {
|
function hash(str) {
|
||||||
function bytesFromString(str1) {
|
function bytesFromString(str1) {
|
||||||
let converter =
|
let converter =
|
||||||
Cc["@mozilla.org/intl/scriptableunicodeconverter"]
|
Cc["@mozilla.org/intl/scriptableunicodeconverter"]
|
||||||
|
@ -64,7 +64,7 @@ function hashPrefix(str) {
|
||||||
hasher.init(hasher.SHA256);
|
hasher.init(hasher.SHA256);
|
||||||
hasher.update(data, data.length);
|
hasher.update(data, data.length);
|
||||||
|
|
||||||
return hasher.finish(false).slice(0, 4);
|
return hasher.finish(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var testDatas = [
|
var testDatas = [
|
||||||
|
@ -73,8 +73,8 @@ var testDatas = [
|
||||||
expect: { error: Cr.NS_ERROR_BLOCKED_URI,
|
expect: { error: Cr.NS_ERROR_BLOCKED_URI,
|
||||||
table: "mochi-block-simple",
|
table: "mochi-block-simple",
|
||||||
provider: "",
|
provider: "",
|
||||||
prefix: (function() {
|
fullhash: (function() {
|
||||||
return hashPrefix("malware.example.com/");
|
return hash("malware.example.com/");
|
||||||
})(),
|
})(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -83,8 +83,8 @@ var testDatas = [
|
||||||
expect: { error: Cr.NS_ERROR_MALWARE_URI,
|
expect: { error: Cr.NS_ERROR_MALWARE_URI,
|
||||||
table: "mochi1-malware-simple",
|
table: "mochi1-malware-simple",
|
||||||
provider: "mozilla",
|
provider: "mozilla",
|
||||||
prefix: (function() {
|
fullhash: (function() {
|
||||||
return hashPrefix("malware1.example.com/");
|
return hash("malware1.example.com/");
|
||||||
})(),
|
})(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -93,8 +93,8 @@ var testDatas = [
|
||||||
expect: { error: Cr.NS_ERROR_MALWARE_URI,
|
expect: { error: Cr.NS_ERROR_MALWARE_URI,
|
||||||
table: "mochi2-malware-simple",
|
table: "mochi2-malware-simple",
|
||||||
provider: "mozilla",
|
provider: "mozilla",
|
||||||
prefix: (function() {
|
fullhash: (function() {
|
||||||
return hashPrefix("malware2.example.com/");
|
return hash("malware2.example.com/");
|
||||||
})(),
|
})(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -103,8 +103,8 @@ var testDatas = [
|
||||||
expect: { error: Cr.NS_ERROR_MALWARE_URI,
|
expect: { error: Cr.NS_ERROR_MALWARE_URI,
|
||||||
table: "mochig3-malware-simple",
|
table: "mochig3-malware-simple",
|
||||||
provider: "google",
|
provider: "google",
|
||||||
prefix: (function() {
|
fullhash: (function() {
|
||||||
return hashPrefix("malware3.example.com/");
|
return hash("malware3.example.com/");
|
||||||
})(),
|
})(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -159,11 +159,11 @@ function runTest() {
|
||||||
let test = testDatas.shift();
|
let test = testDatas.shift();
|
||||||
let uri = ios.newURI(test.url);
|
let uri = ios.newURI(test.url);
|
||||||
let prin = ssm.createCodebasePrincipal(uri, {});
|
let prin = ssm.createCodebasePrincipal(uri, {});
|
||||||
SpecialPowers.doUrlClassify(prin, null, false, function(errorCode, table, provider, prefix) {
|
SpecialPowers.doUrlClassify(prin, null, false, function(errorCode, table, provider, fullhash) {
|
||||||
is(errorCode, test.expect.error, `Test url ${test.url} correct error`);
|
is(errorCode, test.expect.error, `Test url ${test.url} correct error`);
|
||||||
is(table, test.expect.table, `Test url ${test.url} correct table`);
|
is(table, test.expect.table, `Test url ${test.url} correct table`);
|
||||||
is(provider, test.expect.provider, `Test url ${test.url} correct provider`);
|
is(provider, test.expect.provider, `Test url ${test.url} correct provider`);
|
||||||
is(prefix, btoa(test.expect.prefix), `Test url ${test.url} correct prefix`);
|
is(fullhash, btoa(test.expect.fullhash), `Test url ${test.url} correct full hash`);
|
||||||
runNextTest();
|
runNextTest();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -423,7 +423,7 @@ NS_IMETHODIMP nsExtProtocolChannel::NotifyTrackingProtectionDisabled()
|
||||||
|
|
||||||
NS_IMETHODIMP nsExtProtocolChannel::SetClassifierMatchedInfo(const nsACString& aList,
|
NS_IMETHODIMP nsExtProtocolChannel::SetClassifierMatchedInfo(const nsACString& aList,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsACString& aPrefix)
|
const nsACString& aFullHash)
|
||||||
{
|
{
|
||||||
// nothing to do
|
// nothing to do
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче