зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1637163 - Redact details in WebChannel errors. r=rfkelly
Differential Revision: https://phabricator.services.mozilla.com/D79563
This commit is contained in:
Родитель
ecc38d5db8
Коммит
ee97e91066
|
@ -117,7 +117,11 @@ const EXTRA_ENGINES = ["addresses", "creditcards"];
|
|||
* doesn't have a stack trace.
|
||||
*/
|
||||
function getErrorDetails(error) {
|
||||
let details = { message: String(error), stack: null };
|
||||
// Replace anything that looks like it might be a filepath on Windows or Unix
|
||||
let cleanMessage = String(error)
|
||||
.replace(/\\.*\\/gm, "[REDACTED]")
|
||||
.replace(/\/.*\//gm, "[REDACTED]");
|
||||
let details = { message: cleanMessage, stack: null };
|
||||
|
||||
// Adapted from Console.jsm.
|
||||
if (error.stack) {
|
||||
|
|
|
@ -150,6 +150,71 @@ add_test(function test_exception_reporting() {
|
|||
channel._channelCallback(WEBCHANNEL_ID, mockMessage, mockSendingContext);
|
||||
});
|
||||
|
||||
add_test(function test_error_message_remove_profile_path() {
|
||||
const errors = {
|
||||
windows: {
|
||||
err: new Error(
|
||||
"Win error 183 during operation rename on file C:\\Users\\Some Computer\\AppData\\Roaming\\" +
|
||||
"Mozilla\\Firefox\\Profiles\\dbzjmzxa.default\\signedInUser.json (Cannot create a file)"
|
||||
),
|
||||
expected:
|
||||
"Error: Win error 183 during operation rename on file C:[REDACTED]signedInUser.json (Cannot create a file)",
|
||||
},
|
||||
unix: {
|
||||
err: new Error(
|
||||
"Unix error 28 during operation write on file /Users/someuser/Library/Application Support/" +
|
||||
"Firefox/Profiles/dbzjmzxa.default-release-7/signedInUser.json (No space left on device)"
|
||||
),
|
||||
expected:
|
||||
"Error: Unix error 28 during operation write on file [REDACTED]signedInUser.json (No space left on device)",
|
||||
},
|
||||
netpath: {
|
||||
err: new Error(
|
||||
"Win error 32 during operation rename on file \\\\SVC.LOC\\HOMEDIRS$\\USERNAME\\Mozilla\\" +
|
||||
"Firefox\\Profiles\\dbzjmzxa.default-release-7\\signedInUser.json (No space left on device)"
|
||||
),
|
||||
expected:
|
||||
"Error: Win error 32 during operation rename on file [REDACTED]signedInUser.json (No space left on device)",
|
||||
},
|
||||
mount: {
|
||||
err: new Error(
|
||||
"Win error 649 during operation rename on file C:\\SnapVolumes\\MountPoints\\" +
|
||||
"{9e399ec5-0000-0000-0000-100000000000}\\SVROOT\\Users\\username\\AppData\\Roaming\\Mozilla\\Firefox\\" +
|
||||
"Profiles\\dbzjmzxa.default-release\\signedInUser.json (The create operation failed)"
|
||||
),
|
||||
expected:
|
||||
"Error: Win error 649 during operation rename on file C:[REDACTED]signedInUser.json " +
|
||||
"(The create operation failed)",
|
||||
},
|
||||
};
|
||||
const mockMessage = {
|
||||
command: "fxaccounts:sync_preferences",
|
||||
messageId: "1234",
|
||||
};
|
||||
const channel = new FxAccountsWebChannel({
|
||||
channel_id: WEBCHANNEL_ID,
|
||||
content_uri: URL_STRING,
|
||||
});
|
||||
|
||||
let testNum = 0;
|
||||
const toTest = Object.keys(errors).length;
|
||||
for (const key in errors) {
|
||||
let error = errors[key];
|
||||
channel._channel.send = (message, context) => {
|
||||
equal(
|
||||
message.data.error.message,
|
||||
error.expected,
|
||||
"Should remove the profile path from the error message"
|
||||
);
|
||||
testNum++;
|
||||
if (testNum === toTest) {
|
||||
run_next_test();
|
||||
}
|
||||
};
|
||||
channel._sendError(error.err, mockMessage, mockSendingContext);
|
||||
}
|
||||
});
|
||||
|
||||
add_test(function test_profile_image_change_message() {
|
||||
var mockMessage = {
|
||||
command: "profile:change",
|
||||
|
|
Загрузка…
Ссылка в новой задаче