Bug 979474 - Pin the telemetry experiments manifest, r=cviecco

This commit is contained in:
Benjamin Smedberg 2014-03-18 22:52:29 +01:00
parent 34bad224eb
commit e4e97d3ce7
2 changed files with 29 additions and 2 deletions

View File

@ -1407,3 +1407,6 @@ pref("browser.cache.auto_delete_cache_version", 1);
// Telemetry experiments settings.
pref("experiments.enabled", false);
pref("experiments.manifest.fetchIntervalSeconds", 86400);
pref("experiments.manifest.uri", "https://telemetry-experiment.cdn.mozilla.net/manifest/v1/firefox/%VERSION%/%CHANNEL%");
pref("experiments.manifest.certs.1.commonName", "*.cdn.mozilla.net");
pref("experiments.manifest.certs.1.issuerName", "CN=Cybertrust Public SureServer SV CA,O=Cybertrust Inc");

View File

@ -25,6 +25,14 @@ XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TelemetryPing",
"resource://gre/modules/TelemetryPing.jsm");
// CertUtils.jsm doesn't expose a single "CertUtils" object like a normal .jsm
// would.
XPCOMUtils.defineLazyGetter(this, "CertUtils",
function() {
var mod = {};
Cu.import("resource://gre/modules/CertUtils.jsm", mod);
return mod;
});
const FILE_CACHE = "experiments.json";
@ -41,6 +49,8 @@ const PREF_LOGGING = "logging";
const PREF_LOGGING_LEVEL = PREF_LOGGING + ".level"; // experiments.logging.level
const PREF_LOGGING_DUMP = PREF_LOGGING + ".dump"; // experiments.logging.dump
const PREF_MANIFEST_URI = "manifest.uri"; // experiments.logging.manifest.uri
const PREF_MANIFEST_CHECKCERT = "manifest.cert.checkAttributes"; // experiments.manifest.cert.checkAttributes
const PREF_MANIFEST_REQUIREBUILTIN = "manifest.cert.requireBuiltin"; // experiments.manifest.cert.requireBuiltin
const PREF_HEALTHREPORT_ENABLED = "datareporting.healthreport.service.enabled";
@ -447,7 +457,7 @@ Experiments.Experiments.prototype = {
xhr.onerror = function (e) {
gLogger.error("Experiments::httpGetRequest::onError() - Error making request to " + url + ": " + e.error);
deferred.reject(new Error("Experiments - XHR error for " + url + " - " + e.error));
}
};
xhr.onload = function (event) {
if (xhr.status !== 200 && xhr.state !== 0) {
@ -456,8 +466,22 @@ Experiments.Experiments.prototype = {
return;
}
let certs = null;
if (gPrefs.get(PREF_MANIFEST_CHECKCERT, true)) {
certs = CertUtils.readCertPrefs(PREF_BRANCH + "manifest.certs.");
}
try {
let allowNonBuiltin = !gPrefs.get(PREF_MANIFEST_REQUIREBUILTIN, true);
CertUtils.checkCert(xhr.channel, allowNonBuiltin, certs);
}
catch (e) {
gLogger.error("Experiments: manifest fetch failed certificate checks", [e]);
deferred.reject(new Error("Experiments - manifest fetch failed certificate checks: " + e));
return;
}
deferred.resolve(xhr.responseText);
}
};
if (xhr.channel instanceof Ci.nsISupportsPriority) {
xhr.channel.priority = Ci.nsISupportsPriority.PRIORITY_LOWEST;