mirror of
https://github.com/bitwarden/browser
synced 2026-01-21 11:53:34 +00:00
[PM-30442] Fix cipherkey getting included in export of unencrypted json (#18206)
* Fix cipherkey being exported in unencrytped json export * Fix unencrypted json exporting with cipher key * Fix unencrypted export for org vaults --------- Co-authored-by: SmithThe4th <gsmith@bitwarden.com>
This commit is contained in:
@@ -525,6 +525,20 @@ describe("VaultExportService", () => {
|
||||
const exportedData = actual as ExportedVaultAsString;
|
||||
expectEqualFolders(UserFolders, exportedData.data);
|
||||
});
|
||||
|
||||
it("does not export the key property in unencrypted exports", async () => {
|
||||
// Create a cipher with a key property
|
||||
const cipherWithKey = generateCipherView(false);
|
||||
(cipherWithKey as any).key = "shouldBeDeleted";
|
||||
cipherService.getAllDecrypted.mockResolvedValue([cipherWithKey]);
|
||||
|
||||
const actual = await exportService.getExport(userId, "json");
|
||||
expect(typeof actual.data).toBe("string");
|
||||
const exportedData = actual as ExportedVaultAsString;
|
||||
const parsed = JSON.parse(exportedData.data);
|
||||
expect(parsed.items.length).toBe(1);
|
||||
expect(parsed.items[0].key).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
export class FolderResponse {
|
||||
|
||||
@@ -317,6 +317,7 @@ export class IndividualVaultExportService
|
||||
const cipher = new CipherWithIdExport();
|
||||
cipher.build(c);
|
||||
cipher.collectionIds = null;
|
||||
delete cipher.key;
|
||||
jsonDoc.items.push(cipher);
|
||||
});
|
||||
|
||||
|
||||
@@ -383,6 +383,7 @@ export class OrganizationVaultExportService
|
||||
decCiphers.forEach((c) => {
|
||||
const cipher = new CipherWithIdExport();
|
||||
cipher.build(c);
|
||||
delete cipher.key;
|
||||
jsonDoc.items.push(cipher);
|
||||
});
|
||||
return JSON.stringify(jsonDoc, null, " ");
|
||||
|
||||
Reference in New Issue
Block a user