Bug 1862410 - Removing unused LoginReputation service and updating link to Chromium's safe browsing protobuf r=dimi,webdriver-reviewers,perftest-reviewers,devtools-reviewers,geckoview-reviewers,jonalmeida,owlish
Differential Revision: https://phabricator.services.mozilla.com/D192464
This commit is contained in:
@@ -653,7 +653,6 @@ _ZN4uuid6parser28_$LT$impl$u20$uuid..Uuid$GT$9parse_str17hef8066f10442e30fE
|
||||
?s_HashKey@?$nsTHashtable@V?$nsBaseHashtableET@VnsStringHashKey@@PAUMiscContainer@@@@@@KAIPBX@Z
|
||||
?s_MatchEntry@?$nsTHashtable@V?$nsBaseHashtableET@VnsStringHashKey@@V?$UniquePtr@URawServoSelectorList@@V?$DefaultDelete@URawServoSelectorList@@@mozilla@@@mozilla@@@@@@KA_NPBUPLDHashEntryHdr@@PBX@Z
|
||||
?GetOrCreate@nsRFPService@mozilla@@SAPAV12@XZ
|
||||
?OnComplete@LoginReputationParent@dom@mozilla@@UAG?AW4nsresult@@W44@I@Z
|
||||
?GetSpoofedPresentedFrames@nsRFPService@mozilla@@SAINII@Z
|
||||
?Release@nsUUIDGenerator@@UAGKXZ
|
||||
??0AutoSuppressEventHandlingAndSuspend@dom@mozilla@@QAE@PAVBrowsingContextGroup@12@@Z
|
||||
|
||||
@@ -658,7 +658,6 @@ ZN4uuid6parser28_$LT$impl$u20$uuid..Uuid$GT$9parse_str17hd6e937141c32aa4eE
|
||||
?DetermineOffsetFromReference@?$RangeBoundaryBase@V?$nsCOMPtr@VnsINode@@@@V?$nsCOMPtr@VnsIContent@@@@@mozilla@@AEBAXXZ
|
||||
?s_HashKey@?$nsTHashtable@V?$nsBaseHashtableET@VnsStringHashKey@@PEAUMiscContainer@@@@@@KAIPEBX@Z
|
||||
?GetOrCreate@nsRFPService@mozilla@@SAPEAV12@XZ
|
||||
?OnComplete@LoginReputationParent@dom@mozilla@@UEAA?AW4nsresult@@W44@I@Z
|
||||
?GetSpoofedPresentedFrames@nsRFPService@mozilla@@SAINII@Z
|
||||
?Release@nsUUIDGenerator@@UEAAKXZ
|
||||
??0AutoSuppressEventHandlingAndSuspend@dom@mozilla@@QEAA@PEAVBrowsingContextGroup@12@@Z
|
||||
|
||||
@@ -10,7 +10,6 @@ add_task(async function () {
|
||||
await pushPref("browser.safebrowsing.blockedURIs.enabled", false);
|
||||
await pushPref("browser.safebrowsing.downloads.enabled", false);
|
||||
await pushPref("browser.safebrowsing.malware.enabled", false);
|
||||
await pushPref("browser.safebrowsing.passwords.enabled", false);
|
||||
await pushPref("browser.safebrowsing.phishing.enabled", false);
|
||||
await pushPref("privacy.query_stripping.enabled", false);
|
||||
await pushPref("extensions.systemAddon.update.enabled", false);
|
||||
|
||||
@@ -22,7 +22,6 @@ user_pref("datareporting.healthreport.uploadEnabled", false);
|
||||
user_pref("browser.safebrowsing.phishing.enabled", false);
|
||||
user_pref("browser.safebrowsing.malware.enabled", false);
|
||||
user_pref("browser.safebrowsing.blockedURIs.enabled", false);
|
||||
user_pref("browser.safebrowsing.passwords.enabled", false);
|
||||
user_pref("privacy.trackingprotection.annotate_channels", false);
|
||||
user_pref("privacy.trackingprotection.enabled", false);
|
||||
user_pref("privacy.trackingprotection.pbmode.enabled", false);
|
||||
|
||||
@@ -59,8 +59,7 @@ public class ContentBlocking {
|
||||
"googpub-phish-proto",
|
||||
"goog-malware-proto",
|
||||
"goog-unwanted-proto",
|
||||
"goog-harmful-proto",
|
||||
"goog-passwordwhite-proto")
|
||||
"goog-harmful-proto")
|
||||
.updateUrl(
|
||||
"https://safebrowsing.googleapis.com/v4/threatListUpdates:fetch?$ct=application/x-protobuf&key=%GOOGLE_SAFEBROWSING_API_KEY%&$httpMethod=POST")
|
||||
.getHashUrl(
|
||||
|
||||
@@ -1536,12 +1536,6 @@
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
# Password protection
|
||||
- name: browser.safebrowsing.passwords.enabled
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# Phishing protection
|
||||
- name: browser.safebrowsing.phishing.enabled
|
||||
type: bool
|
||||
|
||||
@@ -3326,9 +3326,6 @@ pref("urlclassifier.malwareTable", "goog-malware-proto,goog-unwanted-proto,mozte
|
||||
pref("urlclassifier.downloadAllowTable", "goog-downloadwhite-proto");
|
||||
pref("urlclassifier.downloadBlockTable", "goog-badbinurl-proto");
|
||||
|
||||
// Tables for login reputation
|
||||
pref("urlclassifier.passwordAllowTable", "goog-passwordwhite-proto");
|
||||
|
||||
// Tables for anti-tracking features
|
||||
pref("urlclassifier.trackingAnnotationTable", "moztest-track-simple,ads-track-digest256,social-track-digest256,analytics-track-digest256,content-track-digest256");
|
||||
pref("urlclassifier.trackingAnnotationWhitelistTable", "moztest-trackwhite-simple,mozstd-trackwhite-digest256,google-trackwhite-digest256");
|
||||
@@ -3353,7 +3350,7 @@ pref("urlclassifier.features.emailtracking.datacollection.blocklistTables", "bas
|
||||
pref("urlclassifier.features.emailtracking.datacollection.allowlistTables", "mozstd-trackwhite-digest256");
|
||||
|
||||
// These tables will never trigger a gethash call.
|
||||
pref("urlclassifier.disallow_completions", "goog-downloadwhite-digest256,base-track-digest256,mozstd-trackwhite-digest256,content-track-digest256,mozplugin-block-digest256,mozplugin2-block-digest256,goog-passwordwhite-proto,ads-track-digest256,social-track-digest256,analytics-track-digest256,base-fingerprinting-track-digest256,content-fingerprinting-track-digest256,base-cryptomining-track-digest256,content-cryptomining-track-digest256,fanboyannoyance-ads-digest256,fanboysocial-ads-digest256,easylist-ads-digest256,easyprivacy-ads-digest256,adguard-ads-digest256,social-tracking-protection-digest256,social-tracking-protection-facebook-digest256,social-tracking-protection-linkedin-digest256,social-tracking-protection-twitter-digest256,base-email-track-digest256,content-email-track-digest256");
|
||||
pref("urlclassifier.disallow_completions", "goog-downloadwhite-digest256,base-track-digest256,mozstd-trackwhite-digest256,content-track-digest256,mozplugin-block-digest256,mozplugin2-block-digest256,ads-track-digest256,social-track-digest256,analytics-track-digest256,base-fingerprinting-track-digest256,content-fingerprinting-track-digest256,base-cryptomining-track-digest256,content-cryptomining-track-digest256,fanboyannoyance-ads-digest256,fanboysocial-ads-digest256,easylist-ads-digest256,easyprivacy-ads-digest256,adguard-ads-digest256,social-tracking-protection-digest256,social-tracking-protection-facebook-digest256,social-tracking-protection-linkedin-digest256,social-tracking-protection-twitter-digest256,base-email-track-digest256,content-email-track-digest256");
|
||||
|
||||
// Workaround for Google Recaptcha
|
||||
pref("urlclassifier.trackingAnnotationSkipURLs", "google.com/recaptcha/,*.google.com/recaptcha/");
|
||||
@@ -3411,7 +3408,7 @@ pref("browser.safebrowsing.provider.google.advisoryName", "Google Safe Browsing"
|
||||
|
||||
// Google Safe Browsing provider
|
||||
pref("browser.safebrowsing.provider.google4.pver", "4");
|
||||
pref("browser.safebrowsing.provider.google4.lists", "goog-badbinurl-proto,goog-downloadwhite-proto,goog-phish-proto,googpub-phish-proto,goog-malware-proto,goog-unwanted-proto,goog-harmful-proto,goog-passwordwhite-proto");
|
||||
pref("browser.safebrowsing.provider.google4.lists", "goog-badbinurl-proto,goog-downloadwhite-proto,goog-phish-proto,googpub-phish-proto,goog-malware-proto,goog-unwanted-proto,goog-harmful-proto");
|
||||
pref("browser.safebrowsing.provider.google4.updateURL", "https://safebrowsing.googleapis.com/v4/threatListUpdates:fetch?$ct=application/x-protobuf&key=%GOOGLE_SAFEBROWSING_API_KEY%&$httpMethod=POST");
|
||||
pref("browser.safebrowsing.provider.google4.gethashURL", "https://safebrowsing.googleapis.com/v4/fullHashes:find?$ct=application/x-protobuf&key=%GOOGLE_SAFEBROWSING_API_KEY%&$httpMethod=POST");
|
||||
pref("browser.safebrowsing.provider.google4.reportURL", "https://safebrowsing.google.com/safebrowsing/diagnostic?site=");
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "UrlClassifierFeatureEmailTrackingProtection.h"
|
||||
#include "UrlClassifierFeatureFingerprintingAnnotation.h"
|
||||
#include "UrlClassifierFeatureFingerprintingProtection.h"
|
||||
#include "UrlClassifierFeatureLoginReputation.h"
|
||||
#include "UrlClassifierFeaturePhishingProtection.h"
|
||||
#include "UrlClassifierFeatureSocialTrackingAnnotation.h"
|
||||
#include "UrlClassifierFeatureSocialTrackingProtection.h"
|
||||
@@ -40,7 +39,6 @@ void UrlClassifierFeatureFactory::Shutdown() {
|
||||
UrlClassifierFeatureEmailTrackingProtection::MaybeShutdown();
|
||||
UrlClassifierFeatureFingerprintingAnnotation::MaybeShutdown();
|
||||
UrlClassifierFeatureFingerprintingProtection::MaybeShutdown();
|
||||
UrlClassifierFeatureLoginReputation::MaybeShutdown();
|
||||
UrlClassifierFeaturePhishingProtection::MaybeShutdown();
|
||||
UrlClassifierFeatureSocialTrackingAnnotation::MaybeShutdown();
|
||||
UrlClassifierFeatureSocialTrackingProtection::MaybeShutdown();
|
||||
@@ -133,12 +131,6 @@ void UrlClassifierFeatureFactory::GetPhishingProtectionFeatures(
|
||||
UrlClassifierFeaturePhishingProtection::MaybeCreate(aFeatures);
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsIUrlClassifierFeature*
|
||||
UrlClassifierFeatureFactory::GetFeatureLoginReputation() {
|
||||
return UrlClassifierFeatureLoginReputation::MaybeGetOrCreate();
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsIUrlClassifierFeature>
|
||||
UrlClassifierFeatureFactory::GetFeatureByName(const nsACString& aName) {
|
||||
@@ -214,12 +206,6 @@ UrlClassifierFeatureFactory::GetFeatureByName(const nsACString& aName) {
|
||||
return feature.forget();
|
||||
}
|
||||
|
||||
// Login reputation
|
||||
feature = UrlClassifierFeatureLoginReputation::GetIfNameMatches(aName);
|
||||
if (feature) {
|
||||
return feature.forget();
|
||||
}
|
||||
|
||||
// PhishingProtection features
|
||||
feature = UrlClassifierFeaturePhishingProtection::GetIfNameMatches(aName);
|
||||
if (feature) {
|
||||
@@ -297,12 +283,6 @@ void UrlClassifierFeatureFactory::GetFeatureNames(nsTArray<nsCString>& aArray) {
|
||||
aArray.AppendElement(name);
|
||||
}
|
||||
|
||||
// Login reputation
|
||||
name.Assign(UrlClassifierFeatureLoginReputation::Name());
|
||||
if (!name.IsEmpty()) {
|
||||
aArray.AppendElement(name);
|
||||
}
|
||||
|
||||
// PhishingProtection features
|
||||
{
|
||||
nsTArray<nsCString> features;
|
||||
|
||||
@@ -27,8 +27,6 @@ class UrlClassifierFeatureFactory final {
|
||||
static void GetPhishingProtectionFeatures(
|
||||
nsTArray<RefPtr<nsIUrlClassifierFeature>>& aFeatures);
|
||||
|
||||
static nsIUrlClassifierFeature* GetFeatureLoginReputation();
|
||||
|
||||
static already_AddRefed<nsIUrlClassifierFeature> GetFeatureByName(
|
||||
const nsACString& aName);
|
||||
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "UrlClassifierFeatureLoginReputation.h"
|
||||
|
||||
#include "mozilla/StaticPrefs_browser.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "UrlClassifierCommon.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIChannel.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
namespace {
|
||||
|
||||
#define LOGIN_REPUTATION_FEATURE_NAME "login-reputation"
|
||||
|
||||
#define PREF_PASSWORD_ALLOW_TABLE "urlclassifier.passwordAllowTable"
|
||||
|
||||
StaticRefPtr<UrlClassifierFeatureLoginReputation> gFeatureLoginReputation;
|
||||
|
||||
} // namespace
|
||||
|
||||
UrlClassifierFeatureLoginReputation::UrlClassifierFeatureLoginReputation()
|
||||
: UrlClassifierFeatureBase(nsLiteralCString(LOGIN_REPUTATION_FEATURE_NAME),
|
||||
""_ns, // blocklist tables
|
||||
nsLiteralCString(PREF_PASSWORD_ALLOW_TABLE),
|
||||
""_ns, // blocklist pref
|
||||
""_ns, // entitylist pref
|
||||
""_ns, // blocklist pref table name
|
||||
""_ns, // entitylist pref table name
|
||||
""_ns) // exception host pref
|
||||
{}
|
||||
|
||||
/* static */ const char* UrlClassifierFeatureLoginReputation::Name() {
|
||||
return StaticPrefs::browser_safebrowsing_passwords_enabled()
|
||||
? LOGIN_REPUTATION_FEATURE_NAME
|
||||
: "";
|
||||
}
|
||||
|
||||
/* static */
|
||||
void UrlClassifierFeatureLoginReputation::MaybeShutdown() {
|
||||
UC_LOG_LEAK(("UrlClassifierFeatureLoginReputation::MaybeShutdown"));
|
||||
|
||||
if (gFeatureLoginReputation) {
|
||||
gFeatureLoginReputation->ShutdownPreferences();
|
||||
gFeatureLoginReputation = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsIUrlClassifierFeature*
|
||||
UrlClassifierFeatureLoginReputation::MaybeGetOrCreate() {
|
||||
if (!StaticPrefs::browser_safebrowsing_passwords_enabled()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!gFeatureLoginReputation) {
|
||||
gFeatureLoginReputation = new UrlClassifierFeatureLoginReputation();
|
||||
gFeatureLoginReputation->InitializePreferences();
|
||||
}
|
||||
|
||||
return gFeatureLoginReputation;
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsIUrlClassifierFeature>
|
||||
UrlClassifierFeatureLoginReputation::GetIfNameMatches(const nsACString& aName) {
|
||||
if (!aName.EqualsLiteral(LOGIN_REPUTATION_FEATURE_NAME)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIUrlClassifierFeature> self = MaybeGetOrCreate();
|
||||
return self.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureLoginReputation::ProcessChannel(
|
||||
nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
const nsTArray<nsCString>& aHashes, bool* aShouldContinue) {
|
||||
MOZ_CRASH(
|
||||
"UrlClassifierFeatureLoginReputation::ProcessChannel should never be "
|
||||
"called");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureLoginReputation::GetURIByListType(
|
||||
nsIChannel* aChannel, nsIUrlClassifierFeature::listType aListType,
|
||||
nsIUrlClassifierFeature::URIType* aURIType, nsIURI** aURI) {
|
||||
NS_ENSURE_ARG_POINTER(aChannel);
|
||||
NS_ENSURE_ARG_POINTER(aURIType);
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
MOZ_ASSERT(aListType == nsIUrlClassifierFeature::entitylist,
|
||||
"UrlClassifierFeatureLoginReputation is meant to be used just to "
|
||||
"entitylist URLs");
|
||||
*aURIType = nsIUrlClassifierFeature::URIType::entitylistURI;
|
||||
return aChannel->GetURI(aURI);
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
@@ -1,46 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_net_UrlClassifierFeatureLoginReputation_h
|
||||
#define mozilla_net_UrlClassifierFeatureLoginReputation_h
|
||||
|
||||
#include "UrlClassifierFeatureBase.h"
|
||||
|
||||
class nsIChannel;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
class UrlClassifierFeatureLoginReputation final
|
||||
: public UrlClassifierFeatureBase {
|
||||
public:
|
||||
static const char* Name();
|
||||
|
||||
static void MaybeShutdown();
|
||||
|
||||
static nsIUrlClassifierFeature* MaybeGetOrCreate();
|
||||
|
||||
static already_AddRefed<nsIUrlClassifierFeature> GetIfNameMatches(
|
||||
const nsACString& aName);
|
||||
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel,
|
||||
const nsTArray<nsCString>& aList,
|
||||
const nsTArray<nsCString>& aHashes,
|
||||
bool* aShouldContinue) override;
|
||||
|
||||
NS_IMETHOD GetURIByListType(nsIChannel* aChannel,
|
||||
nsIUrlClassifierFeature::listType aListType,
|
||||
nsIUrlClassifierFeature::URIType* aURIType,
|
||||
nsIURI** aURI) override;
|
||||
|
||||
private:
|
||||
UrlClassifierFeatureLoginReputation();
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_UrlClassifierFeatureLoginReputation_h
|
||||
@@ -41,7 +41,6 @@ UNIFIED_SOURCES += [
|
||||
"UrlClassifierFeatureFactory.cpp",
|
||||
"UrlClassifierFeatureFingerprintingAnnotation.cpp",
|
||||
"UrlClassifierFeatureFingerprintingProtection.cpp",
|
||||
"UrlClassifierFeatureLoginReputation.cpp",
|
||||
"UrlClassifierFeaturePhishingProtection.cpp",
|
||||
"UrlClassifierFeatureResult.cpp",
|
||||
"UrlClassifierFeatureSocialTrackingAnnotation.cpp",
|
||||
|
||||
@@ -125,7 +125,6 @@ const COMMON_PREFERENCES = new Map([
|
||||
["browser.safebrowsing.blockedURIs.enabled", false],
|
||||
["browser.safebrowsing.downloads.enabled", false],
|
||||
["browser.safebrowsing.malware.enabled", false],
|
||||
["browser.safebrowsing.passwords.enabled", false],
|
||||
["browser.safebrowsing.phishing.enabled", false],
|
||||
|
||||
// Disable updates to search engines.
|
||||
|
||||
@@ -130,7 +130,6 @@ function defaultProfilePreferences(
|
||||
'browser.safebrowsing.blockedURIs.enabled': false,
|
||||
'browser.safebrowsing.downloads.enabled': false,
|
||||
'browser.safebrowsing.malware.enabled': false,
|
||||
'browser.safebrowsing.passwords.enabled': false,
|
||||
'browser.safebrowsing.phishing.enabled': false,
|
||||
|
||||
// Disable updates to search engines.
|
||||
|
||||
@@ -24,7 +24,6 @@ user_pref("browser.safebrowsing.blockedURIs.enabled", false);
|
||||
user_pref("browser.safebrowsing.downloads.enabled", false);
|
||||
user_pref("browser.safebrowsing.downloads.remote.url", "http://127.0.0.1/safebrowsing-dummy/downloads");
|
||||
user_pref("browser.safebrowsing.malware.enabled", false);
|
||||
user_pref("browser.safebrowsing.passwords.enabled", false);
|
||||
user_pref("browser.safebrowsing.phishing.enabled", false);
|
||||
user_pref("browser.safebrowsing.provider.google.gethashURL", "http://127.0.0.1/safebrowsing-dummy/gethash");
|
||||
user_pref("browser.safebrowsing.provider.google.updateURL", "http://127.0.0.1/safebrowsing-dummy/update");
|
||||
|
||||
@@ -7,7 +7,6 @@ user_pref("browser.safebrowsing.blockedURIs.enabled", false);
|
||||
user_pref("browser.safebrowsing.downloads.enabled", false);
|
||||
user_pref("browser.safebrowsing.downloads.remote.url", "http://127.0.0.1/safebrowsing-dummy/gethash");
|
||||
user_pref("browser.safebrowsing.malware.enabled", false);
|
||||
user_pref("browser.safebrowsing.passwords.enabled", false);
|
||||
// Likewise for safebrowsing.
|
||||
user_pref("browser.safebrowsing.phishing.enabled", false);
|
||||
user_pref("browser.safebrowsing.provider.google.gethashURL", "http://127.0.0.1/safebrowsing-dummyg/gethash");
|
||||
|
||||
@@ -44,7 +44,6 @@ user_pref("network.http.phishy-userpass-length", 255);
|
||||
// Disable safebrowsing components
|
||||
user_pref("browser.safebrowsing.blockedURIs.enabled", false);
|
||||
user_pref("browser.safebrowsing.downloads.enabled", false);
|
||||
user_pref("browser.safebrowsing.passwords.enabled", false);
|
||||
user_pref("browser.safebrowsing.malware.enabled", false);
|
||||
user_pref("browser.safebrowsing.phishing.enabled", false);
|
||||
user_pref("browser.safebrowsing.update.enabled", false);
|
||||
|
||||
@@ -65,15 +65,6 @@ Classes = [
|
||||
'headers': ['mozilla/FinalizationWitnessService.h'],
|
||||
'init_method': 'Init',
|
||||
},
|
||||
{
|
||||
'name': 'LoginReputation',
|
||||
'cid': '{91fa9e67-1427-4ee9-8ee0-1a6ed578bee1}',
|
||||
'contract_ids': ['@mozilla.org/reputationservice/login-reputation-service;1'],
|
||||
'singleton': True,
|
||||
'type': 'mozilla::LoginReputationService',
|
||||
'headers': ['/toolkit/components/reputationservice/LoginReputation.h'],
|
||||
'constructor': 'mozilla::LoginReputationService::GetSingleton',
|
||||
},
|
||||
{
|
||||
'name': 'Alerts',
|
||||
'cid': '{a0ccaaf8-09da-44d8-b250-9ac3e93c8117}',
|
||||
|
||||
@@ -1,419 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "LoginReputation.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/Components.h"
|
||||
#include "mozilla/ErrorNames.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/net/UrlClassifierFeatureFactory.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/StaticPrefs_browser.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "nsIURIClassifier.h"
|
||||
#include "nsIUrlClassifierFeature.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
#define PREF_PP_ENABLED "browser.safebrowsing.passwords.enabled"
|
||||
|
||||
// MOZ_LOG=LoginReputation:5
|
||||
LazyLogModule gLoginReputationLogModule("LoginReputation");
|
||||
#define LR_LOG(args) \
|
||||
MOZ_LOG(gLoginReputationLogModule, mozilla::LogLevel::Debug, args)
|
||||
#define LR_LOG_ENABLED() \
|
||||
MOZ_LOG_TEST(gLoginReputationLogModule, mozilla::LogLevel::Debug)
|
||||
|
||||
static Atomic<bool> gShuttingDown(false);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// LoginWhitelist
|
||||
//
|
||||
// This class is a wrapper that encapsulate asynchronous callback API provided
|
||||
// by DBService into a MozPromise callback.
|
||||
//
|
||||
class LoginWhitelist final : public nsIUrlClassifierFeatureCallback {
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIURLCLASSIFIERFEATURECALLBACK
|
||||
|
||||
RefPtr<ReputationPromise> QueryLoginWhitelist(
|
||||
nsILoginReputationQuery* aParam);
|
||||
|
||||
LoginWhitelist() = default;
|
||||
|
||||
nsresult Shutdown();
|
||||
|
||||
private:
|
||||
~LoginWhitelist() = default;
|
||||
|
||||
// Queries that are waiting for callback from
|
||||
// ::AsyncClassifyLocalWithFeatures.
|
||||
nsTArray<UniquePtr<MozPromiseHolder<ReputationPromise>>> mQueryPromises;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(LoginWhitelist, nsIUrlClassifierFeatureCallback)
|
||||
|
||||
nsresult LoginWhitelist::Shutdown() {
|
||||
// Reject all query promise before releasing.
|
||||
for (uint8_t i = 0; i < mQueryPromises.Length(); i++) {
|
||||
mQueryPromises[i]->Reject(NS_ERROR_ABORT, __func__);
|
||||
}
|
||||
mQueryPromises.Clear();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RefPtr<ReputationPromise> LoginWhitelist::QueryLoginWhitelist(
|
||||
nsILoginReputationQuery* aParam) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsresult rv;
|
||||
UniquePtr<MozPromiseHolder<ReputationPromise>> holder =
|
||||
MakeUnique<MozPromiseHolder<ReputationPromise>>();
|
||||
RefPtr<ReputationPromise> p = holder->Ensure(__func__);
|
||||
|
||||
// Return rejected promise while there is an error.
|
||||
auto fail = MakeScopeExit([&]() { holder->Reject(rv, __func__); });
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = aParam->GetFormURI(getter_AddRefs(uri));
|
||||
if (NS_WARN_IF(NS_FAILED(rv) || !uri)) {
|
||||
return p;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURIClassifier> uriClassifier =
|
||||
mozilla::components::UrlClassifierDB::Service(&rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return p;
|
||||
}
|
||||
|
||||
// AsyncClassifyLocalWithTables API won't trigger a gethash request on
|
||||
// a full-length match, so this API call should only include local operation.
|
||||
// We don't support prefs overwrite for this classification.
|
||||
|
||||
nsCOMPtr<nsIUrlClassifierFeature> feature =
|
||||
mozilla::net::UrlClassifierFeatureFactory::GetFeatureLoginReputation();
|
||||
if (NS_WARN_IF(!feature)) {
|
||||
return p;
|
||||
}
|
||||
|
||||
nsTArray<RefPtr<nsIUrlClassifierFeature>> features;
|
||||
features.AppendElement(feature);
|
||||
|
||||
rv = uriClassifier->AsyncClassifyLocalWithFeatures(
|
||||
uri, features, nsIUrlClassifierFeature::entitylist, this);
|
||||
if (NS_FAILED(rv)) {
|
||||
return p;
|
||||
}
|
||||
|
||||
fail.release();
|
||||
mQueryPromises.AppendElement(std::move(holder));
|
||||
return p;
|
||||
}
|
||||
|
||||
nsresult LoginWhitelist::OnClassifyComplete(
|
||||
const nsTArray<RefPtr<nsIUrlClassifierFeatureResult>>& aResults) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (gShuttingDown) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
LR_LOG(("OnClassifyComplete : %s",
|
||||
aResults.IsEmpty() ? "blacklisted" : "whitelisted"));
|
||||
|
||||
UniquePtr<MozPromiseHolder<ReputationPromise>> holder =
|
||||
std::move(mQueryPromises.ElementAt(0));
|
||||
mQueryPromises.RemoveElementAt(0);
|
||||
|
||||
if (aResults.IsEmpty()) {
|
||||
// Reject if we can not find url in white list.
|
||||
holder->Reject(NS_OK, __func__);
|
||||
} else {
|
||||
holder->Resolve(nsILoginReputationVerdictType::SAFE, __func__);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// LoginReputationService
|
||||
//
|
||||
NS_IMPL_ISUPPORTS(LoginReputationService, nsILoginReputationService,
|
||||
nsIObserver)
|
||||
|
||||
LoginReputationService* LoginReputationService::gLoginReputationService =
|
||||
nullptr;
|
||||
|
||||
// static
|
||||
already_AddRefed<LoginReputationService>
|
||||
LoginReputationService::GetSingleton() {
|
||||
if (!gLoginReputationService) {
|
||||
gLoginReputationService = new LoginReputationService();
|
||||
}
|
||||
return do_AddRef(gLoginReputationService);
|
||||
}
|
||||
|
||||
LoginReputationService::LoginReputationService() {
|
||||
LR_LOG(("Login reputation service starting up"));
|
||||
}
|
||||
|
||||
LoginReputationService::~LoginReputationService() {
|
||||
LR_LOG(("Login reputation service shutting down"));
|
||||
|
||||
MOZ_ASSERT(gLoginReputationService == this);
|
||||
|
||||
gLoginReputationService = nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoginReputationService::Init() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
switch (XRE_GetProcessType()) {
|
||||
case GeckoProcessType_Default:
|
||||
LR_LOG(("Init login reputation service in parent"));
|
||||
break;
|
||||
case GeckoProcessType_Content:
|
||||
LR_LOG(("Init login reputation service in child"));
|
||||
// Login reputation service in child process will only forward request to
|
||||
// parent, return here to skip unnecessary initialization.
|
||||
return NS_OK;
|
||||
default:
|
||||
// No other process type is supported!
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// The initialization below only happens in parent process.
|
||||
Preferences::AddStrongObserver(this, PREF_PP_ENABLED);
|
||||
|
||||
// Init should only be called once.
|
||||
MOZ_ASSERT(!mLoginWhitelist);
|
||||
|
||||
mLoginWhitelist = new LoginWhitelist();
|
||||
|
||||
if (StaticPrefs::browser_safebrowsing_passwords_enabled()) {
|
||||
Enable();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult LoginReputationService::Enable() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_ASSERT(StaticPrefs::browser_safebrowsing_passwords_enabled());
|
||||
|
||||
LR_LOG(("Enable login reputation service"));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult LoginReputationService::Disable() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
LR_LOG(("Disable login reputation service"));
|
||||
|
||||
nsresult rv = mLoginWhitelist->Shutdown();
|
||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
|
||||
mQueryRequests.Clear();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult LoginReputationService::Shutdown() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(gShuttingDown);
|
||||
|
||||
// Disable will wait until worker threads are shutdown.
|
||||
Disable();
|
||||
|
||||
// Disable will only destroy worker thread, it won't null out these classes.
|
||||
// So we will null these classes in shutdown.
|
||||
mLoginWhitelist = nullptr;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoginReputationService::QueryReputation(
|
||||
nsILoginReputationQuery* aQuery,
|
||||
nsILoginReputationQueryCallback* aCallback) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aQuery);
|
||||
NS_ENSURE_ARG_POINTER(aCallback);
|
||||
|
||||
LR_LOG(("QueryReputation() [this=%p]", this));
|
||||
|
||||
if (gShuttingDown || !StaticPrefs::browser_safebrowsing_passwords_enabled()) {
|
||||
LR_LOG(("QueryReputation() abort [this=%p]", this));
|
||||
aCallback->OnComplete(NS_ERROR_ABORT,
|
||||
nsILoginReputationVerdictType::UNSPECIFIED);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// mQueryRequests is an array used to maintain the ownership of
|
||||
// |QueryRequest|. We ensure that |QueryRequest| is always valid until
|
||||
// Finish() is called or LoginReputationService is shutdown.
|
||||
auto request =
|
||||
mQueryRequests.AppendElement(MakeUnique<QueryRequest>(aQuery, aCallback));
|
||||
|
||||
return QueryLoginWhitelist(request->get());
|
||||
}
|
||||
|
||||
nsresult LoginReputationService::QueryLoginWhitelist(QueryRequest* aRequest) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aRequest);
|
||||
|
||||
if (gShuttingDown) {
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
using namespace mozilla::Telemetry;
|
||||
TimeStamp startTimeMs = TimeStamp::Now();
|
||||
|
||||
RefPtr<LoginReputationService> self = this;
|
||||
|
||||
mLoginWhitelist->QueryLoginWhitelist(aRequest->mParam)
|
||||
->Then(
|
||||
GetCurrentSerialEventTarget(), __func__,
|
||||
[self, aRequest, startTimeMs](VerdictType aResolveValue) -> void {
|
||||
// Promise is resolved if url is found in google-provided whitelist.
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aResolveValue == nsILoginReputationVerdictType::SAFE);
|
||||
|
||||
LR_LOG(("Query login whitelist [request = %p, result = SAFE]",
|
||||
aRequest));
|
||||
|
||||
AccumulateTimeDelta(LOGIN_REPUTATION_LOGIN_WHITELIST_LOOKUP_TIME,
|
||||
startTimeMs);
|
||||
|
||||
Accumulate(LOGIN_REPUTATION_LOGIN_WHITELIST_RESULT,
|
||||
nsILoginReputationVerdictType::SAFE);
|
||||
|
||||
self->Finish(aRequest, NS_OK, nsILoginReputationVerdictType::SAFE);
|
||||
},
|
||||
[self, aRequest, startTimeMs](nsresult rv) -> void {
|
||||
// Promise is rejected if url cannot be found in google-provided
|
||||
// whitelist. or there is an error.
|
||||
if (NS_FAILED(rv)) {
|
||||
if (LR_LOG_ENABLED()) {
|
||||
nsAutoCString errorName;
|
||||
mozilla::GetErrorName(rv, errorName);
|
||||
LR_LOG(
|
||||
("Error in QueryLoginWhitelist() [request = %p, rv = %s]",
|
||||
aRequest, errorName.get()));
|
||||
}
|
||||
|
||||
// Don't record the lookup time when there is an error, only
|
||||
// record the result here.
|
||||
Accumulate(LOGIN_REPUTATION_LOGIN_WHITELIST_RESULT,
|
||||
2); // 2 is error
|
||||
} else {
|
||||
AccumulateTimeDelta(LOGIN_REPUTATION_LOGIN_WHITELIST_LOOKUP_TIME,
|
||||
startTimeMs);
|
||||
|
||||
Accumulate(LOGIN_REPUTATION_LOGIN_WHITELIST_RESULT,
|
||||
nsILoginReputationVerdictType::UNSPECIFIED);
|
||||
|
||||
LR_LOG(
|
||||
("Query login whitelist cannot find the URL [request = %p]",
|
||||
aRequest));
|
||||
}
|
||||
|
||||
// Check trust-based whitelisting if we can't find the url in login
|
||||
// whitelist
|
||||
self->Finish(aRequest, rv,
|
||||
nsILoginReputationVerdictType::UNSPECIFIED);
|
||||
});
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult LoginReputationService::Finish(const QueryRequest* aRequest,
|
||||
nsresult aStatus,
|
||||
VerdictType aVerdict) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aRequest);
|
||||
|
||||
LR_LOG(("Query login reputation end [request = %p, result = %s]", aRequest,
|
||||
VerdictTypeToString(aVerdict).get()));
|
||||
|
||||
// Since we are shutting down, don't bother call back to child process.
|
||||
if (gShuttingDown) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
aRequest->mCallback->OnComplete(aStatus, aVerdict);
|
||||
|
||||
// QueryRequest may not follow the same order when we queued it in
|
||||
// ::QueryReputation because one query request may be finished earlier than
|
||||
// the other.
|
||||
uint32_t idx = 0;
|
||||
for (; idx < mQueryRequests.Length(); idx++) {
|
||||
if (mQueryRequests[idx].get() == aRequest) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(idx >= mQueryRequests.Length())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mQueryRequests.RemoveElementAt(idx);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoginReputationService::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const char16_t* aData) {
|
||||
if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
|
||||
nsDependentString data(aData);
|
||||
|
||||
if (data.EqualsLiteral(PREF_PP_ENABLED)) {
|
||||
nsresult rv = StaticPrefs::browser_safebrowsing_passwords_enabled()
|
||||
? Enable()
|
||||
: Disable();
|
||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
}
|
||||
} else if (!strcmp(aTopic, "quit-application")) {
|
||||
// Prepare to shutdown, won't allow any query request after 'gShuttingDown'
|
||||
// is set.
|
||||
gShuttingDown = true;
|
||||
} else if (!strcmp(aTopic, "profile-before-change")) {
|
||||
gShuttingDown = true;
|
||||
Shutdown();
|
||||
} else {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsCString LoginReputationService::VerdictTypeToString(VerdictType aVerdict) {
|
||||
switch (aVerdict) {
|
||||
case nsILoginReputationVerdictType::UNSPECIFIED:
|
||||
return nsCString("Unspecified");
|
||||
case nsILoginReputationVerdictType::LOW_REPUTATION:
|
||||
return nsCString("Low Reputation");
|
||||
case nsILoginReputationVerdictType::SAFE:
|
||||
return nsCString("Safe");
|
||||
case nsILoginReputationVerdictType::PHISHING:
|
||||
return nsCString("Phishing");
|
||||
default:
|
||||
return nsCString("Invalid");
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef LoginReputation_h__
|
||||
#define LoginReputation_h__
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "nsILoginReputation.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
class LoginWhitelist;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
typedef uint32_t VerdictType;
|
||||
typedef MozPromise<VerdictType, nsresult, false> ReputationPromise;
|
||||
|
||||
class LoginReputationService final : public nsILoginReputationService,
|
||||
public nsIObserver {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSILOGINREPUTATIONSERVICE
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
public:
|
||||
static already_AddRefed<LoginReputationService> GetSingleton();
|
||||
|
||||
static nsCString VerdictTypeToString(VerdictType aVerdict);
|
||||
|
||||
private:
|
||||
struct QueryRequest {
|
||||
QueryRequest(nsILoginReputationQuery* aParam,
|
||||
nsILoginReputationQueryCallback* aCallback)
|
||||
: mParam(aParam), mCallback(aCallback) {}
|
||||
|
||||
nsCOMPtr<nsILoginReputationQuery> mParam;
|
||||
nsCOMPtr<nsILoginReputationQueryCallback> mCallback;
|
||||
};
|
||||
|
||||
/**
|
||||
* Global singleton object for holding this factory service.
|
||||
*/
|
||||
static LoginReputationService* gLoginReputationService;
|
||||
|
||||
LoginReputationService();
|
||||
~LoginReputationService();
|
||||
|
||||
nsresult Enable();
|
||||
|
||||
nsresult Disable();
|
||||
|
||||
nsresult QueryLoginWhitelist(QueryRequest* aRequest);
|
||||
|
||||
// Called when a query request is finished.
|
||||
nsresult Finish(const QueryRequest* aRequest, nsresult aStatus,
|
||||
VerdictType aVerdict);
|
||||
|
||||
// Clear data and join the worker threads.
|
||||
nsresult Shutdown();
|
||||
|
||||
RefPtr<LoginWhitelist> mLoginWhitelist;
|
||||
|
||||
// Array that holds ongoing query requests which are added when
|
||||
// ::QueryReputation is called.
|
||||
nsTArray<UniquePtr<QueryRequest>> mQueryRequests;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // LoginReputation_h__
|
||||
@@ -26,7 +26,7 @@ if [ ! -f nsIApplicationReputation.idl ]; then
|
||||
fi
|
||||
|
||||
# Get the protocol buffer and compile it
|
||||
CSD_PROTO_URL="https://chromium.googlesource.com/chromium/src/+/master/components/safe_browsing/proto/csd.proto?format=TEXT"
|
||||
CSD_PROTO_URL="https://chromium.googlesource.com/chromium/src/+/main/components/safe_browsing/core/common/proto/csd.proto?format=TEXT"
|
||||
CSD_PATH="chromium/chrome/common/safe_browsing"
|
||||
|
||||
# Switch to directory with csd.proto before compiling it
|
||||
|
||||
@@ -13,7 +13,6 @@ EXPORTS.mozilla += ["ApplicationReputation.h"]
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
"nsIApplicationReputation.idl",
|
||||
"nsILoginReputation.idl",
|
||||
]
|
||||
|
||||
XPIDL_MODULE = "reputationservice"
|
||||
@@ -22,7 +21,6 @@ UNIFIED_SOURCES += [
|
||||
"ApplicationReputation.cpp",
|
||||
"ApplicationReputationTelemetryUtils.cpp",
|
||||
"chromium/chrome/common/safe_browsing/csd.pb.cc",
|
||||
"LoginReputation.cpp",
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = "xul"
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIURI;
|
||||
|
||||
webidl HTMLInputElement;
|
||||
|
||||
[scriptable, uuid(6219f9da-297e-446d-8d47-ccdd8e72a1d5)]
|
||||
interface nsILoginReputationVerdictType : nsISupports {
|
||||
|
||||
const unsigned long UNSPECIFIED = 0;
|
||||
const unsigned long SAFE = 1;
|
||||
const unsigned long LOW_REPUTATION = 2;
|
||||
const unsigned long PHISHING = 3;
|
||||
};
|
||||
|
||||
[scriptable, uuid(c21ffe59-595f-46c8-9052-fefb639e196e)]
|
||||
interface nsILoginReputationQuery : nsISupports {
|
||||
readonly attribute nsIURI formURI;
|
||||
};
|
||||
|
||||
[scriptable, uuid(b527be1e-8fbb-41d9-bee4-267a71236368)]
|
||||
interface nsILoginReputationQueryCallback : nsISupports {
|
||||
// aVerdict should be one of the const value defined in nsILoginReputationResult
|
||||
// interface.
|
||||
void onComplete(in nsresult aStatus,
|
||||
in unsigned long aVerdict);
|
||||
};
|
||||
|
||||
[scriptable, uuid(1b3f1dfe-ce3a-486b-953e-ce5ac863eff9)]
|
||||
interface nsILoginReputationService : nsISupports {
|
||||
void init();
|
||||
|
||||
// QueryReputation can only be called from parent
|
||||
void queryReputation(in nsILoginReputationQuery aQuery,
|
||||
in nsILoginReputationQueryCallback aCallback);
|
||||
};
|
||||
@@ -1,185 +0,0 @@
|
||||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const { NetUtil } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/NetUtil.sys.mjs"
|
||||
);
|
||||
|
||||
// LoginReputationService
|
||||
const gLoginRep = Cc[
|
||||
"@mozilla.org/reputationservice/login-reputation-service;1"
|
||||
].getService(Ci.nsILoginReputationService);
|
||||
|
||||
let gListManager = Cc["@mozilla.org/url-classifier/listmanager;1"].getService(
|
||||
Ci.nsIUrlListManager
|
||||
);
|
||||
|
||||
var gHttpServ = null;
|
||||
|
||||
const whitelistedURI = "http://foo:bar@whitelisted.com/index.htm#junk";
|
||||
const exampleURI = "http://user:password@example.com/i.html?foo=bar";
|
||||
|
||||
const LOCAL_WHITELIST_DATA = {
|
||||
tableName: "test-passwordwhite-proto",
|
||||
providerName: "test",
|
||||
updateUrl: "http://localhost:5555/safebrowsing/update?",
|
||||
gethashUrl: "",
|
||||
};
|
||||
|
||||
add_task(async function test_setup() {
|
||||
// Enable login reputation service
|
||||
Services.prefs.setBoolPref("browser.safebrowsing.passwords.enabled", true);
|
||||
gLoginRep.init();
|
||||
|
||||
// Setup local whitelist table.
|
||||
Services.prefs.setCharPref(
|
||||
"urlclassifier.passwordAllowTable",
|
||||
"test-passwordwhite-proto"
|
||||
);
|
||||
gListManager.registerTable(
|
||||
LOCAL_WHITELIST_DATA.tableName,
|
||||
LOCAL_WHITELIST_DATA.providerName,
|
||||
LOCAL_WHITELIST_DATA.updateUrl,
|
||||
LOCAL_WHITELIST_DATA.gethashUrl
|
||||
);
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
gListManager.unregisterTable(LOCAL_WHITELIST_DATA.tableName);
|
||||
|
||||
Services.prefs.clearUserPref("browser.safebrowsing.passwords.enabled");
|
||||
Services.prefs.clearUserPref("urlclassifier.passwordAllowTable");
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function test_setup_local_whitelist() {
|
||||
// Setup the http server for SafeBrowsing update, so we can save SAFE entries
|
||||
// to SafeBrowsing database while update.
|
||||
gHttpServ = new HttpServer();
|
||||
gHttpServ.registerDirectory("/", do_get_cwd());
|
||||
gHttpServ.registerPathHandler(
|
||||
"/safebrowsing/update",
|
||||
function (request, response) {
|
||||
response.setHeader(
|
||||
"Content-Type",
|
||||
"application/vnd.google.safebrowsing-update",
|
||||
false
|
||||
);
|
||||
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
|
||||
// The protobuf binary represention of response:
|
||||
//
|
||||
// [
|
||||
// {
|
||||
// 'threat_type': 8, // CSD_WHITELIST
|
||||
// 'response_type': 2, // FULL_UPDATE
|
||||
// 'new_client_state': 'sta\x00te', // NEW_CLIENT_STATE
|
||||
// 'checksum': { "sha256": CHECKSUM }, // CHECKSUM
|
||||
// 'additions': { 'compression_type': RAW,
|
||||
// 'prefix_size': 32,
|
||||
// 'raw_hashes': "whitelisted.com/index.htm"}
|
||||
// }
|
||||
// ]
|
||||
//
|
||||
let content =
|
||||
"\x0A\x36\x08\x08\x20\x02\x2A\x28\x08\x01\x12\x24\x08" +
|
||||
"\x20\x12\x20\x0F\xE4\x66\xBB\xDD\x34\xAB\x1E\xF7\x8F" +
|
||||
"\xDD\x9D\x8C\xF8\x9F\x4E\x42\x97\x92\x86\x02\x03\xE0" +
|
||||
"\xE9\x60\xBD\xD6\x3A\x85\xCD\x08\xD0\x3A\x06\x73\x74" +
|
||||
"\x61\x00\x74\x65\x12\x04\x08\x0C\x10\x0A";
|
||||
|
||||
response.bodyOutputStream.write(content, content.length);
|
||||
}
|
||||
);
|
||||
|
||||
gHttpServ.start(5555);
|
||||
|
||||
// Trigger the update once http server is ready.
|
||||
Services.obs.addObserver(function (aSubject, aTopic, aData) {
|
||||
if (aData.startsWith("success")) {
|
||||
run_next_test();
|
||||
} else {
|
||||
do_throw("update fail");
|
||||
}
|
||||
}, "safebrowsing-update-finished");
|
||||
gListManager.forceUpdates(LOCAL_WHITELIST_DATA.tableName);
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
return (async function () {
|
||||
await new Promise(resolve => {
|
||||
gHttpServ.stop(resolve);
|
||||
});
|
||||
})();
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function test_disable() {
|
||||
Services.prefs.setBoolPref("browser.safebrowsing.passwords.enabled", false);
|
||||
|
||||
gLoginRep.queryReputation(
|
||||
{
|
||||
formURI: NetUtil.newURI("http://example.com"),
|
||||
},
|
||||
{
|
||||
onComplete(aStatus, aVerdict) {
|
||||
Assert.equal(aStatus, Cr.NS_ERROR_ABORT);
|
||||
Assert.equal(aVerdict, Ci.nsILoginReputationVerdictType.UNSPECIFIED);
|
||||
|
||||
Services.prefs.setBoolPref(
|
||||
"browser.safebrowsing.passwords.enabled",
|
||||
true
|
||||
);
|
||||
|
||||
run_next_test();
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_test(function test_nullQuery() {
|
||||
try {
|
||||
gLoginRep.queryReputation(null, {
|
||||
onComplete(aStatus, aVerdict) {},
|
||||
});
|
||||
do_throw("Query parameter cannot be null");
|
||||
} catch (ex) {
|
||||
Assert.equal(ex.result, Cr.NS_ERROR_INVALID_POINTER);
|
||||
|
||||
run_next_test();
|
||||
}
|
||||
});
|
||||
|
||||
add_test(function test_local_whitelist() {
|
||||
gLoginRep.queryReputation(
|
||||
{
|
||||
formURI: NetUtil.newURI(whitelistedURI),
|
||||
},
|
||||
{
|
||||
onComplete(aStatus, aVerdict) {
|
||||
Assert.equal(aStatus, Cr.NS_OK);
|
||||
Assert.equal(aVerdict, Ci.nsILoginReputationVerdictType.SAFE);
|
||||
|
||||
run_next_test();
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_test(function test_notin_local_whitelist() {
|
||||
gLoginRep.queryReputation(
|
||||
{
|
||||
formURI: NetUtil.newURI(exampleURI),
|
||||
},
|
||||
{
|
||||
onComplete(aStatus, aVerdict) {
|
||||
Assert.equal(aStatus, Cr.NS_OK);
|
||||
Assert.equal(aVerdict, Ci.nsILoginReputationVerdictType.UNSPECIFIED);
|
||||
|
||||
run_next_test();
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -13,5 +13,3 @@ skip-if = os != "win"
|
||||
[test_app_rep_maclinux.js]
|
||||
skip-if = os == "win"
|
||||
run-sequentially = very high failure rate in parallel
|
||||
|
||||
[test_login_rep.js]
|
||||
|
||||
@@ -63,8 +63,8 @@ static nsIFormAutoComplete* GetFormAutoComplete() {
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION(nsFormFillController, mController, mLoginManagerAC,
|
||||
mLoginReputationService, mFocusedPopup, mPopups,
|
||||
mLastListener, mLastFormAutoComplete)
|
||||
mFocusedPopup, mPopups, mLastListener,
|
||||
mLastFormAutoComplete)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFormFillController)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIFormFillController)
|
||||
@@ -802,11 +802,6 @@ nsFormFillController::StopSearch() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsFormFillController::StartQueryLoginReputation(
|
||||
HTMLInputElement* aInput) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//// nsIFormAutoCompleteObserver
|
||||
|
||||
@@ -1024,14 +1019,6 @@ void nsFormFillController::MaybeStartControllingInput(
|
||||
if (isAutofillInput || isPwmgrInput || hasList || autocomplete) {
|
||||
StartControllingInput(aInput);
|
||||
}
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
// Trigger an asynchronous login reputation query when user focuses on the
|
||||
// password field.
|
||||
if (aInput->HasBeenTypePassword()) {
|
||||
StartQueryLoginReputation(aInput);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult nsFormFillController::HandleFocus(HTMLInputElement* aInput) {
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "nsIMutationObserver.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsILoginReputation.h"
|
||||
|
||||
class nsFormHistory;
|
||||
class nsINode;
|
||||
@@ -99,8 +98,6 @@ class nsFormFillController final : public nsIFormFillController,
|
||||
|
||||
bool IsTextControl(nsINode* aNode);
|
||||
|
||||
nsresult StartQueryLoginReputation(mozilla::dom::HTMLInputElement* aInput);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHODIMP isLoginManagerField(
|
||||
mozilla::dom::HTMLInputElement* aInput, bool* isLoginManagerField);
|
||||
|
||||
@@ -108,7 +105,6 @@ class nsFormFillController final : public nsIFormFillController,
|
||||
|
||||
nsCOMPtr<nsIAutoCompleteController> mController;
|
||||
nsCOMPtr<nsILoginAutoCompleteSearch> mLoginManagerAC;
|
||||
nsCOMPtr<nsILoginReputationService> mLoginReputationService;
|
||||
mozilla::dom::HTMLInputElement* mFocusedInput;
|
||||
|
||||
// mListNode is a <datalist> element which, is set, has the form fill
|
||||
|
||||
@@ -72,21 +72,6 @@ const FEATURES = [
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "passwords",
|
||||
list: ["urlclassifier.passwordAllowTable"],
|
||||
enabled() {
|
||||
return Services.prefs.getBoolPref(
|
||||
"browser.safebrowsing.passwords.enabled"
|
||||
);
|
||||
},
|
||||
update() {
|
||||
return Services.prefs.getBoolPref(
|
||||
"browser.safebrowsing.features.passwords.update",
|
||||
this.enabled()
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "downloads",
|
||||
list: [
|
||||
|
||||
@@ -318,16 +318,11 @@ static const struct {
|
||||
{"goog-badbinurl-proto", MALICIOUS_BINARY}, // 7
|
||||
{"goog-downloadwhite-proto", CSD_DOWNLOAD_WHITELIST}, // 9
|
||||
|
||||
// For login reputation
|
||||
{"goog-passwordwhite-proto", CSD_WHITELIST}, // 8
|
||||
|
||||
// For testing purpose.
|
||||
{"moztest-phish-proto", SOCIAL_ENGINEERING_PUBLIC}, // 2
|
||||
{"test-phish-proto", SOCIAL_ENGINEERING_PUBLIC}, // 2
|
||||
{"moztest-unwanted-proto", UNWANTED_SOFTWARE}, // 3
|
||||
{"test-unwanted-proto", UNWANTED_SOFTWARE}, // 3
|
||||
{"moztest-passwordwhite-proto", CSD_WHITELIST}, // 8
|
||||
{"test-passwordwhite-proto", CSD_WHITELIST}, // 8
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@@ -10,7 +10,6 @@ add_test(async _ => {
|
||||
"Force the cookie service to be initialized to avoid issues later. " +
|
||||
"See https://bugzilla.mozilla.org/show_bug.cgi?id=1621759#c3"
|
||||
);
|
||||
Services.prefs.setBoolPref("browser.safebrowsing.passwords.enabled", true);
|
||||
|
||||
let classifier = Cc["@mozilla.org/url-classifier/dbservice;1"].getService(
|
||||
Ci.nsIURIClassifier
|
||||
@@ -21,7 +20,6 @@ add_test(async _ => {
|
||||
{ name: "a", expectedResult: false },
|
||||
{ name: "tracking-annotation", expectedResult: true },
|
||||
{ name: "tracking-protection", expectedResult: true },
|
||||
{ name: "login-reputation", expectedResult: true },
|
||||
];
|
||||
|
||||
tests.forEach(test => {
|
||||
|
||||
@@ -11,7 +11,6 @@ function run_test() {
|
||||
equal(urlUtils.convertListNameToThreatType("goog-harmful-proto"), 4);
|
||||
equal(urlUtils.convertListNameToThreatType("goog-phish-proto"), 5);
|
||||
equal(urlUtils.convertListNameToThreatType("goog-badbinurl-proto"), 7);
|
||||
equal(urlUtils.convertListNameToThreatType("goog-passwordwhite-proto"), 8);
|
||||
equal(urlUtils.convertListNameToThreatType("goog-downloadwhite-proto"), 9);
|
||||
|
||||
try {
|
||||
@@ -37,10 +36,6 @@ function run_test() {
|
||||
equal(urlUtils.convertThreatTypeToListNames(4), "goog-harmful-proto");
|
||||
equal(urlUtils.convertThreatTypeToListNames(5), "goog-phish-proto");
|
||||
equal(urlUtils.convertThreatTypeToListNames(7), "goog-badbinurl-proto");
|
||||
equal(
|
||||
urlUtils.convertThreatTypeToListNames(8),
|
||||
"goog-passwordwhite-proto,moztest-passwordwhite-proto,test-passwordwhite-proto"
|
||||
);
|
||||
equal(urlUtils.convertThreatTypeToListNames(9), "goog-downloadwhite-proto");
|
||||
|
||||
try {
|
||||
|
||||
@@ -231,13 +231,10 @@ avoid-blacklist-and-whitelist:
|
||||
- toolkit/components/antitracking/test/browser/browser_socialtracking_save_image.js
|
||||
- toolkit/components/reputationservice/ApplicationReputation.cpp
|
||||
- toolkit/components/reputationservice/chromium/chrome/common/safe_browsing/csd.pb.h
|
||||
- toolkit/components/reputationservice/LoginReputation.cpp
|
||||
- toolkit/components/reputationservice/LoginReputation.h
|
||||
- toolkit/components/reputationservice/test/unit/head_download_manager.js
|
||||
- toolkit/components/reputationservice/test/unit/test_app_rep.js
|
||||
- toolkit/components/reputationservice/test/unit/test_app_rep_maclinux.js
|
||||
- toolkit/components/reputationservice/test/unit/test_app_rep_windows.js
|
||||
- toolkit/components/reputationservice/test/unit/test_login_rep.js
|
||||
- toolkit/components/satchel/test/test_form_autocomplete.html
|
||||
- toolkit/components/telemetry/docs/data/environment.rst
|
||||
- toolkit/components/url-classifier/nsUrlClassifierUtils.cpp
|
||||
|
||||
Reference in New Issue
Block a user