-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitwardenReview.js
59 lines (51 loc) · 1.78 KB
/
bitwardenReview.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* READ THE README AND ALL COMMENTS BEFORE PROCEEDING!!!
*/
import data from './bitwarden_export.json' assert { type: "json" };
import * as fs from 'fs';
let unique = [];
// DO NOT COMMIT THESE VALUES. UPDATE, RUN THE SCRIPT, THEN REVERT.
const BAD_PASS_LIST = ['', '']; // List of old compromised passwords.
const LEGACY_PASS_LIST = ['', '']; // List of patterns found in old passwords not yet compromised, but should be updated.
const VALID_PASS_PATTERNS = ['']; // List of patterns found in valid passwords.
// FOLDER ID's from exported data
const BAD_PASS_FOLDER = '';
const LEGACY_PASS_FOLDER = '';
const NEEDS_REVIEW_FOLDER = ''
const VERIFIED_PASS_FOLDER = ''
console.log(data.items.length);
// Remove duplicates from items array
data.items.map((item, index) => {
if (!item.name == data.items[index + 1]?.name) {
unique.push(item)
}
});
// Assign logins to folders based on password
unique.map(item => {
if (item.type == 1) {
console.log(item.id, item.login?.password)
if (BAD_PASS_LIST.some(pass => item.login?.password.includes(pass))) {
item.folderId = BAD_PASS_FOLDER
return;
} else if (LEGACY_PASS_LIST.some(pass => item.login?.password.includes(pass))) {
item.folderId = LEGACY_PASS_FOLDER
return;
} else if (VALID_PASS_PATTERNS.some(pass => item.login?.password.includes(pass))) {
item.folderId = VERIFIED_PASS_FOLDER
return;
} else {
item.folderId = NEEDS_REVIEW_FOLDER
return;
}
}
});
// Replace bitwarden data with updated items.
data.items = unique;
// Output file to import into empty vault.
fs.writeFile('bitwarden_to_import.json', JSON.stringify(data), 'utf8', (err) => {
if (err)
console.log(err);
else {
console.log(`File written successfully with with ${data.items.length} items.`);
}
});