Bug 1609649 - Strip telemetry annotations from the crashes we submit via Firefox r=chutten

Differential Revision: https://phabricator.services.mozilla.com/D60145

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gabriele Svelto 2020-01-23 21:22:11 +00:00
Родитель f8e5af7e32
Коммит 44c60cb145
2 изменённых файлов: 40 добавлений и 17 удалений

Просмотреть файл

@ -109,9 +109,13 @@ function createPendingCrashReports(howMany, accessDate) {
let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService(
Ci.nsIUUIDGenerator
);
// CrashSubmit expects there to be a ServerURL key-value
// pair in the .extra file, so we'll satisfy it.
let extraFileContents = JSON.stringify({ ServerURL: SERVER_URL });
// Some annotations are always present in the .extra file and CrashSubmit.jsm
// expects there to be a ServerURL entry, so we'll add them here.
let extraFileContents = JSON.stringify({
ServerURL: SERVER_URL,
TelemetryServerURL: "http://telemetry.mozilla.org/",
TelemetryClientId: "c69e7487-df10-4c98-ab1a-c85660feecf3",
});
return (async function() {
let uuids = [];
@ -148,6 +152,21 @@ function waitForSubmittedReports(reportIDs) {
if (dumpID == reportID) {
return true;
}
let extra = propBag.getPropertyAsInterface(
"extra",
Ci.nsIPropertyBag2
);
const blockedAnnotations = [
"ServerURL",
"TelemetryClientId",
"TelemetryServerURL",
];
for (const key of blockedAnnotations) {
Assert.ok(
!extra.hasKey(key),
"The " + key + " annotation should have been stripped away"
);
}
}
return false;
}

Просмотреть файл

@ -236,9 +236,9 @@ Submitter.prototype = {
return false;
}
let serverURL = this.extraKeyVals.ServerURL;
delete this.extraKeyVals.ServerURL;
// Override the submission URL from the environment
let envOverride = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment)
.get("MOZ_CRASHREPORTER_URL");
@ -252,9 +252,6 @@ Submitter.prototype = {
let formData = new FormData();
// add the data
delete this.extraKeyVals.ServerURL;
delete this.extraKeyVals.StackTraces;
let payload = Object.assign({}, this.extraKeyVals);
if (this.noThrottle) {
// tell the server not to throttle this, since it was manually submitted
@ -373,6 +370,22 @@ Submitter.prototype = {
}
},
readAnnotations: async function Submitter_readAnnotations(extra) {
// These annotations are used only by the crash reporter client and should
// not be submitted to Socorro.
const strippedAnnotations = [
"StackTraces",
"TelemetryClientId",
"TelemetryServerURL",
];
let decoder = new TextDecoder();
let extraData = await OS.File.read(extra);
let extraKeyVals = JSON.parse(decoder.decode(extraData));
this.extraKeyVals = { ...extraKeyVals, ...this.extraKeyVals };
strippedAnnotations.forEach(key => delete this.extraKeyVals[key]);
},
submit: async function Submitter_submit() {
if (this.recordSubmission) {
await Services.crashmanager.ensureCrashIsPresent(this.id);
@ -398,16 +411,7 @@ Submitter.prototype = {
this.dump = dump;
this.extra = extra;
this.memory = memoryExists ? memory : null;
let decoder = new TextDecoder();
let extraData = await OS.File.read(extra);
let extraKeyVals = JSON.parse(decoder.decode(extraData));
for (let key in extraKeyVals) {
if (!(key in this.extraKeyVals)) {
this.extraKeyVals[key] = extraKeyVals[key];
}
}
await this.readAnnotations(extra);
let additionalDumps = [];