Bug 1955294: Fix event ping for OS keystore decryption attempts r=credential-management-reviewers,mtigley
Also changed the error message property to be named `errorResult` since what we store in here is the nsresult value not a string message. Differential Revision: https://phabricator.services.mozilla.com/D242361
This commit is contained in:
@@ -401,14 +401,14 @@ export class ManageCreditCards extends ManageRecords {
|
||||
}
|
||||
|
||||
let decryptedCCNumObj = {};
|
||||
let errorMessage;
|
||||
let errorResult = 0;
|
||||
if (creditCard && creditCard["cc-number-encrypted"]) {
|
||||
try {
|
||||
decryptedCCNumObj["cc-number"] = await lazy.OSKeyStore.decrypt(
|
||||
creditCard["cc-number-encrypted"]
|
||||
);
|
||||
errorMessage = "NO_ERROR";
|
||||
} catch (ex) {
|
||||
errorResult = ex.result;
|
||||
if (ex.result == Cr.NS_ERROR_ABORT) {
|
||||
// User shouldn't be ask to reauth here, but it could happen.
|
||||
// Return here and skip opening the dialog.
|
||||
@@ -419,11 +419,10 @@ export class ManageCreditCards extends ManageRecords {
|
||||
// unencrypted credit card number.
|
||||
decryptedCCNumObj["cc-number"] = "";
|
||||
console.error(ex);
|
||||
errorMessage = ex.result;
|
||||
} finally {
|
||||
Glean.creditcard.osKeystoreDecrypt.record({
|
||||
isDecryptSuccess: errorMessage === "NO_ERROR",
|
||||
errorMessage,
|
||||
isDecryptSuccess: errorResult === 0,
|
||||
errorResult,
|
||||
trigger: "edit",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -103,6 +103,10 @@ add_task(async function test_doorhanger_not_shown_when_autofill_untouched() {
|
||||
return;
|
||||
}
|
||||
|
||||
await Services.fog.testFlushAllChildren();
|
||||
Services.fog.testResetFOG();
|
||||
Services.telemetry.clearEvents();
|
||||
|
||||
await setStorage(TEST_CREDIT_CARD_1);
|
||||
let creditCards = await getCreditCards();
|
||||
is(creditCards.length, 1, "1 credit card in storage");
|
||||
@@ -138,6 +142,17 @@ add_task(async function test_doorhanger_not_shown_when_autofill_untouched() {
|
||||
is(creditCards.length, 1, "Still 1 credit card");
|
||||
is(creditCards[0].timesUsed, 1, "timesUsed field set to 1");
|
||||
await removeAllRecords();
|
||||
|
||||
await Services.fog.testFlushAllChildren();
|
||||
let testEvents = Glean.creditcard.osKeystoreDecrypt.testGetValue();
|
||||
is(testEvents.length, 1, "Event was recorded");
|
||||
is(testEvents[0].extra.trigger, "autofill", "Trigger was correct");
|
||||
is(
|
||||
testEvents[0].extra.isDecryptSuccess,
|
||||
"true",
|
||||
"Decryption was recorded as success"
|
||||
);
|
||||
is(testEvents[0].extra.errorResult, "0", "Result was no error");
|
||||
});
|
||||
|
||||
add_task(async function test_doorhanger_not_shown_when_fill_duplicate() {
|
||||
|
||||
@@ -9,6 +9,10 @@ add_task(async function test_fill_creditCard_but_cancel_login() {
|
||||
return;
|
||||
}
|
||||
|
||||
await Services.fog.testFlushAllChildren();
|
||||
Services.fog.testResetFOG();
|
||||
Services.telemetry.clearEvents();
|
||||
|
||||
await setStorage(TEST_CREDIT_CARD_2);
|
||||
|
||||
let osKeyStoreLoginShown = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(false); // cancel
|
||||
@@ -34,4 +38,19 @@ add_task(async function test_fill_creditCard_but_cancel_login() {
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
await Services.fog.testFlushAllChildren();
|
||||
let testEvents = Glean.creditcard.osKeystoreDecrypt.testGetValue();
|
||||
is(testEvents.length, 1, "Event was recorded");
|
||||
is(testEvents[0].extra.trigger, "autofill", "Trigger was correct");
|
||||
is(
|
||||
testEvents[0].extra.isDecryptSuccess,
|
||||
"false",
|
||||
"Decryption was recorded as failed"
|
||||
);
|
||||
is(
|
||||
testEvents[0].extra.errorResult,
|
||||
Cr.NS_ERROR_ABORT.toString(),
|
||||
"Result was abort"
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1433,11 +1433,11 @@ creditcard:
|
||||
description: >
|
||||
Records if the decryption was a success or failure.
|
||||
type: boolean
|
||||
error_message:
|
||||
errorResult:
|
||||
description: >
|
||||
Records the error message.
|
||||
Records the nsresult error value.
|
||||
Likely errors include "Cr.NS_ERROR_FAILURE" and "Cr.NS_ERROR_ABORT".
|
||||
If no error then "NO_ERROR".
|
||||
If no error then 0.
|
||||
type: string
|
||||
trigger:
|
||||
description: >
|
||||
|
||||
@@ -654,20 +654,19 @@ export class FormAutofillCreditCardSection extends FormAutofillSection {
|
||||
reauth = false;
|
||||
}
|
||||
let string;
|
||||
let errorMessage;
|
||||
let errorResult = 0;
|
||||
try {
|
||||
string = await lazy.OSKeyStore.decrypt(cipherText, reauth);
|
||||
errorMessage = "NO_ERROR";
|
||||
} catch (e) {
|
||||
errorResult = e.result;
|
||||
if (e.result != Cr.NS_ERROR_ABORT) {
|
||||
throw e;
|
||||
}
|
||||
this.log.warn("User canceled encryption login");
|
||||
errorMessage = e.result;
|
||||
} finally {
|
||||
Glean.creditcard.osKeystoreDecrypt.record({
|
||||
isDecryptSuccess: errorMessage === "NO_ERROR",
|
||||
errorMessage,
|
||||
isDecryptSuccess: errorResult === 0,
|
||||
errorResult,
|
||||
trigger: "autofill",
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user