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