Bug 1055670: Disable remote lookups (r=gcp,a=lmandel)
authorMonica Chew <mmc@mozilla.com>
Tue, 19 Aug 2014 11:11:10 -0700
changeset 208345 b554afc480aa
parent 208344 8d583074b918
child 208346 fadc34768c8b
push id3834
push usermchew@mozilla.com
push date2014-08-20 21:48 +0000
treeherdermozilla-beta@b554afc480aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp, lmandel
bugs1055670
milestone32.0
Bug 1055670: Disable remote lookups (r=gcp,a=lmandel)
browser/app/profile/firefox.js
toolkit/components/downloads/ApplicationReputation.cpp
toolkit/components/downloads/test/unit/test_app_rep.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -963,17 +963,21 @@ pref("browser.safebrowsing.gethashURL", 
 pref("browser.safebrowsing.reportURL", "https://safebrowsing.google.com/safebrowsing/report?");
 pref("browser.safebrowsing.reportGenericURL", "http://%LOCALE%.phish-generic.mozilla.com/?hl=%LOCALE%");
 pref("browser.safebrowsing.reportErrorURL", "http://%LOCALE%.phish-error.mozilla.com/?hl=%LOCALE%");
 pref("browser.safebrowsing.reportPhishURL", "http://%LOCALE%.phish-report.mozilla.com/?hl=%LOCALE%");
 pref("browser.safebrowsing.reportMalwareURL", "http://%LOCALE%.malware-report.mozilla.com/?hl=%LOCALE%");
 pref("browser.safebrowsing.reportMalwareErrorURL", "http://%LOCALE%.malware-error.mozilla.com/?hl=%LOCALE%");
 
 pref("browser.safebrowsing.malware.reportURL", "https://safebrowsing.google.com/safebrowsing/diagnostic?client=%NAME%&hl=%LOCALE%&site=");
+
+// Turn off remote lookups in beta and stable channel.
+#ifndef RELEASE_BUILD
 pref("browser.safebrowsing.appRepURL", "https://sb-ssl.google.com/safebrowsing/clientreport/download?key=%GOOGLE_API_KEY%");
+#endif
 
 #ifdef MOZILLA_OFFICIAL
 // Normally the "client ID" sent in updates is appinfo.name, but for
 // official Firefox releases from Mozilla we use a special identifier.
 pref("browser.safebrowsing.id", "navclient-auto-ffox");
 #endif
 
 // Name of the about: page contributed by safebrowsing to handle display of error
--- a/toolkit/components/downloads/ApplicationReputation.cpp
+++ b/toolkit/components/downloads/ApplicationReputation.cpp
@@ -414,16 +414,24 @@ PendingLookup::LookupNext()
   if (index >= 0) {
     spec = mAllowlistSpecs[index];
     LOG(("PendingLookup::LookupNext: checking %s on allowlist", spec.get()));
     mAllowlistSpecs.RemoveElementAt(index);
     nsRefPtr<PendingDBLookup> lookup(new PendingDBLookup(this));
     return lookup->LookupSpec(spec, true);
   }
 #ifdef XP_WIN
+  // If there is no service URL for querying application reputation, abort.
+  nsCString serviceUrl;
+  NS_ENSURE_SUCCESS(Preferences::GetCString(PREF_SB_APP_REP_URL, &serviceUrl),
+                    NS_ERROR_NOT_AVAILABLE);
+  if (serviceUrl.EqualsLiteral("")) {
+    return OnComplete(false, NS_ERROR_NOT_AVAILABLE);
+  }
+
   // There are no more URIs to check against local list. If the file is not
   // eligible for remote lookup, bail.
   if (!IsBinaryFile()) {
     LOG(("Not eligible for remote lookups [this=%x]", this));
     return OnComplete(false, NS_OK);
   }
   // Send the remote query if we are on Windows.
   nsresult rv = SendRemoteQuery();
@@ -1050,24 +1058,16 @@ nsresult ApplicationReputationService::Q
   nsIApplicationReputationQuery* aQuery,
   nsIApplicationReputationCallback* aCallback) {
   nsresult rv;
   // If malware checks aren't enabled, don't query application reputation.
   if (!Preferences::GetBool(PREF_SB_MALWARE_ENABLED, false)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
-  // If there is no service URL for querying application reputation, abort.
-  nsCString serviceUrl;
-  NS_ENSURE_SUCCESS(Preferences::GetCString(PREF_SB_APP_REP_URL, &serviceUrl),
-                    NS_ERROR_NOT_AVAILABLE);
-  if (serviceUrl.EqualsLiteral("")) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
   nsCOMPtr<nsIURI> uri;
   rv = aQuery->GetSourceURI(getter_AddRefs(uri));
   NS_ENSURE_SUCCESS(rv, rv);
   // Bail if the URI hasn't been set.
   NS_ENSURE_STATE(uri);
 
   // Create a new pending lookup and start the call chain.
   nsRefPtr<PendingLookup> lookup(new PendingLookup(aQuery, aCallback));
--- a/toolkit/components/downloads/test/unit/test_app_rep.js
+++ b/toolkit/components/downloads/test/unit/test_app_rep.js
@@ -159,31 +159,16 @@ add_test(function test_nullCallback() {
     do_throw("Callback cannot be null");
   } catch (ex if ex.result == Cr.NS_ERROR_INVALID_POINTER) {
     // We don't even increment the count here, because there's no callback.
     check_telemetry(counts.total, counts.shouldBlock, counts.listCounts);
     run_next_test();
   }
 });
 
-add_test(function test_disabled() {
-  let counts = get_telemetry_counts();
-  Services.prefs.setCharPref("browser.safebrowsing.appRepURL", "");
-  gAppRep.queryReputation({
-    sourceURI: createURI("http://example.com"),
-    fileSize: 12,
-  }, function onComplete(aShouldBlock, aStatus) {
-    // We should be getting NS_ERROR_NOT_AVAILABLE if the service is disabled
-    do_check_eq(Cr.NS_ERROR_NOT_AVAILABLE, aStatus);
-    do_check_false(aShouldBlock);
-    check_telemetry(counts.total + 1, counts.shouldBlock, counts.listCounts);
-    run_next_test();
-  });
-});
-
 // Set up the local whitelist.
 add_test(function test_local_list() {
   // Construct a response with redirect urls.
   function processUpdateRequest() {
     let response = "n:1000\n";
     for (let table in gTables) {
       response += "i:" + table + "\n";
       for (let i = 0; i < gTables[table].length; ++i) {