From 18f2419bd6c76775494f32a6608eadba274aa082 Mon Sep 17 00:00:00 2001 From: azivner Date: Thu, 25 Oct 2018 18:03:28 +0200 Subject: [PATCH] allow creating anonymized database from command line as well, fixes #200 --- .idea/encodings.xml | 4 ++++ src/anonymize.js | 7 +++++++ src/services/anonymization.js | 3 +++ 3 files changed, 14 insertions(+) create mode 100644 .idea/encodings.xml create mode 100644 src/anonymize.js diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 000000000..15a15b218 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/anonymize.js b/src/anonymize.js new file mode 100644 index 000000000..65f559a59 --- /dev/null +++ b/src/anonymize.js @@ -0,0 +1,7 @@ +const anonymizationService = require('./services/anonymization'); + +anonymizationService.anonymize().then(filePath => { + console.log("Anonymized file has been saved to:", filePath); + + process.exit(0); +}); \ No newline at end of file diff --git a/src/services/anonymization.js b/src/services/anonymization.js index 8db63aba8..53c614ddc 100644 --- a/src/services/anonymization.js +++ b/src/services/anonymization.js @@ -19,12 +19,15 @@ async function anonymize() { await db.run("UPDATE notes SET title = 'title', content = 'text'"); await db.run("UPDATE note_revisions SET title = 'title', content = 'text'"); await db.run("UPDATE branches SET prefix = 'prefix' WHERE prefix IS NOT NULL"); + await db.run("UPDATE images SET data = NULL"); await db.run(`UPDATE options SET value = 'anonymized' WHERE name IN ('documentSecret', 'encryptedDataKey', 'passwordVerificationHash', 'passwordVerificationSalt', 'passwordDerivedKeySalt')`); await db.run("VACUUM"); await db.close(); + + return anonymizedFile; } module.exports = {