Bug 1238142 - Harden Telemetry addon data collection. r=gfritzsche

This commit is contained in:
Alessio Placitelli 2016-01-13 06:02:00 +01:00
parent d503e8158c
commit 53d98d8518

View File

@ -264,7 +264,7 @@ function getGfxField(aPropertyName, aDefault) {
* @return {String} The substring or null if the input string is null. * @return {String} The substring or null if the input string is null.
*/ */
function limitStringToLength(aString, aMaxLength) { function limitStringToLength(aString, aMaxLength) {
if (aString === null || aString === undefined) { if (typeof(aString) !== "string") {
return null; return null;
} }
return aString.substring(0, aMaxLength); return aString.substring(0, aMaxLength);
@ -515,6 +515,9 @@ EnvironmentAddonBuilder.prototype = {
continue; continue;
} }
// Weird addon data in the wild can lead to exceptions while collecting
// the data.
try {
// Make sure to have valid dates. // Make sure to have valid dates.
let installDate = new Date(Math.max(0, addon.installDate)); let installDate = new Date(Math.max(0, addon.installDate));
let updateDate = new Date(Math.max(0, addon.updateDate)); let updateDate = new Date(Math.max(0, addon.updateDate));
@ -537,6 +540,11 @@ EnvironmentAddonBuilder.prototype = {
if (addon.signedState !== undefined) if (addon.signedState !== undefined)
activeAddons[addon.id].signedState = addon.signedState; activeAddons[addon.id].signedState = addon.signedState;
} catch (ex) {
this._environment._log.error("_getActiveAddons - An addon was discarded due to an error", ex);
continue;
}
} }
return activeAddons; return activeAddons;
@ -592,6 +600,7 @@ EnvironmentAddonBuilder.prototype = {
continue; continue;
} }
try {
// Make sure to have a valid date. // Make sure to have a valid date.
let updateDate = new Date(Math.max(0, tag.lastModifiedTime)); let updateDate = new Date(Math.max(0, tag.lastModifiedTime));
@ -605,6 +614,10 @@ EnvironmentAddonBuilder.prototype = {
mimeTypes: tag.getMimeTypes({}), mimeTypes: tag.getMimeTypes({}),
updateDay: Utils.millisecondsToDays(updateDate.getTime()), updateDay: Utils.millisecondsToDays(updateDate.getTime()),
}); });
} catch (ex) {
this._environment._log.error("_getActivePlugins - A plugin was discarded due to an error", ex);
continue;
}
} }
return activePlugins; return activePlugins;
@ -628,11 +641,16 @@ EnvironmentAddonBuilder.prototype = {
continue; continue;
} }
try {
activeGMPlugins[plugin.id] = { activeGMPlugins[plugin.id] = {
version: plugin.version, version: plugin.version,
userDisabled: plugin.userDisabled, userDisabled: plugin.userDisabled,
applyBackgroundUpdates: plugin.applyBackgroundUpdates, applyBackgroundUpdates: plugin.applyBackgroundUpdates,
}; };
} catch (ex) {
this._environment._log.error("_getActiveGMPlugins - A GMPlugin was discarded due to an error", ex);
continue;
}
} }
return activeGMPlugins; return activeGMPlugins;