mirror of
https://github.com/bitwarden/browser.git
synced 2024-09-18 02:41:15 +02:00
[PM-7875] Add log to which step parse failed on LastPass import (#9264)
* Added step info regarding where the parse accounts throw the error * standardized the step to be always set
This commit is contained in:
parent
a7aaa140fd
commit
2098f42400
@ -33,6 +33,7 @@ export class Parser {
|
|||||||
options: ParserOptions,
|
options: ParserOptions,
|
||||||
): Promise<Account> {
|
): Promise<Account> {
|
||||||
let id: string;
|
let id: string;
|
||||||
|
let step = 0;
|
||||||
try {
|
try {
|
||||||
const placeholder = "decryption failed";
|
const placeholder = "decryption failed";
|
||||||
const reader = new BinaryReader(chunk.payload);
|
const reader = new BinaryReader(chunk.payload);
|
||||||
@ -42,6 +43,7 @@ export class Parser {
|
|||||||
id = Utils.fromBufferToUtf8(this.readItem(reader));
|
id = Utils.fromBufferToUtf8(this.readItem(reader));
|
||||||
|
|
||||||
// 1: name
|
// 1: name
|
||||||
|
step = 1;
|
||||||
const name = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
const name = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
||||||
this.readItem(reader),
|
this.readItem(reader),
|
||||||
encryptionKey,
|
encryptionKey,
|
||||||
@ -49,6 +51,7 @@ export class Parser {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 2: group
|
// 2: group
|
||||||
|
step = 2;
|
||||||
const group = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
const group = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
||||||
this.readItem(reader),
|
this.readItem(reader),
|
||||||
encryptionKey,
|
encryptionKey,
|
||||||
@ -56,6 +59,7 @@ export class Parser {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 3: url
|
// 3: url
|
||||||
|
step = 3;
|
||||||
let url = Utils.fromBufferToUtf8(
|
let url = Utils.fromBufferToUtf8(
|
||||||
this.decodeHexLoose(Utils.fromBufferToUtf8(this.readItem(reader))),
|
this.decodeHexLoose(Utils.fromBufferToUtf8(this.readItem(reader))),
|
||||||
);
|
);
|
||||||
@ -66,6 +70,7 @@ export class Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4: extra (notes)
|
// 4: extra (notes)
|
||||||
|
step = 4;
|
||||||
const notes = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
const notes = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
||||||
this.readItem(reader),
|
this.readItem(reader),
|
||||||
encryptionKey,
|
encryptionKey,
|
||||||
@ -73,12 +78,14 @@ export class Parser {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 5: fav (is favorite)
|
// 5: fav (is favorite)
|
||||||
|
step = 5;
|
||||||
const isFavorite = Utils.fromBufferToUtf8(this.readItem(reader)) === "1";
|
const isFavorite = Utils.fromBufferToUtf8(this.readItem(reader)) === "1";
|
||||||
|
|
||||||
// 6: sharedfromaid (?)
|
// 6: sharedfromaid (?)
|
||||||
this.skipItem(reader);
|
this.skipItem(reader);
|
||||||
|
|
||||||
// 7: username
|
// 7: username
|
||||||
|
step = 7;
|
||||||
let username = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
let username = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
||||||
this.readItem(reader),
|
this.readItem(reader),
|
||||||
encryptionKey,
|
encryptionKey,
|
||||||
@ -86,6 +93,7 @@ export class Parser {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 8: password
|
// 8: password
|
||||||
|
step = 8;
|
||||||
let password = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
let password = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
||||||
this.readItem(reader),
|
this.readItem(reader),
|
||||||
encryptionKey,
|
encryptionKey,
|
||||||
@ -99,6 +107,7 @@ export class Parser {
|
|||||||
this.skipItem(reader);
|
this.skipItem(reader);
|
||||||
|
|
||||||
// 11: sn (is secure note)
|
// 11: sn (is secure note)
|
||||||
|
step = 11;
|
||||||
const isSecureNote = Utils.fromBufferToUtf8(this.readItem(reader)) === "1";
|
const isSecureNote = Utils.fromBufferToUtf8(this.readItem(reader)) === "1";
|
||||||
|
|
||||||
// Parse secure note
|
// Parse secure note
|
||||||
@ -214,6 +223,7 @@ export class Parser {
|
|||||||
this.skipItem(reader);
|
this.skipItem(reader);
|
||||||
|
|
||||||
// 39: totp (?)
|
// 39: totp (?)
|
||||||
|
step = 39;
|
||||||
const totp = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
const totp = await this.cryptoUtils.decryptAes256PlainWithDefault(
|
||||||
this.readItem(reader),
|
this.readItem(reader),
|
||||||
encryptionKey,
|
encryptionKey,
|
||||||
@ -227,6 +237,7 @@ export class Parser {
|
|||||||
// 42: last_credential_monitoring_stat (?)
|
// 42: last_credential_monitoring_stat (?)
|
||||||
|
|
||||||
// Adjust the path to include the group and the shared folder, if any.
|
// Adjust the path to include the group and the shared folder, if any.
|
||||||
|
step = 42;
|
||||||
const path = this.makeAccountPath(group, folder);
|
const path = this.makeAccountPath(group, folder);
|
||||||
|
|
||||||
const account = new Account();
|
const account = new Account();
|
||||||
@ -243,7 +254,12 @@ export class Parser {
|
|||||||
return account;
|
return account;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Error parsing accounts on item with ID:" + id + " errorMessage: " + err.message,
|
"Error parsing accounts on item with ID:" +
|
||||||
|
id +
|
||||||
|
" step #" +
|
||||||
|
step +
|
||||||
|
" errorMessage: " +
|
||||||
|
err.message,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user