Optimized cleanup for encryption

This commit is contained in:
Kevin Veen-Birkenbach 2022-12-14 00:31:46 +01:00
parent a0c17c9fd6
commit 09bb6d1e31
3 changed files with 39 additions and 7 deletions

View File

@ -27,7 +27,7 @@ python scripts/main.py --mode cleanup
``` ```
### delete decrypted data ### delete decrypted data
To delete all encrypted data execute: To delete all decrypted data execute:
```bash ```bash
python scripts/main.py --mode cleanup --file-types decrypted python scripts/main.py --mode cleanup --file-types decrypted
@ -65,7 +65,7 @@ python scripts/main.py --mode decrypt --user "<<user_id>>"
``` ```
### addtional instructions ### addtional instructions
In the [INSTRUCTIONS.md](./Instruction.md) file the master encrypter can leave additional instructions. In the [INSTRUCTIONS.md](./INSTRUCTIONS.md) file the master encrypter can leave additional instructions.
## encrypt ## encrypt
@ -74,9 +74,32 @@ In the [INSTRUCTIONS.md](./Instruction.md) file the master encrypter can leave a
python scripts/main.py --secret-holders-amount "<<amount>>" --quota "<<quota>>" --mode encrypt --master-password "<<master_password>>" --input-directory "<<input_directory>>" python scripts/main.py --secret-holders-amount "<<amount>>" --quota "<<quota>>" --mode encrypt --master-password "<<master_password>>" --input-directory "<<input_directory>>"
``` ```
### encrypt master password ### generate encryption data
To encrypt the master-password file and to create the neccessary encrypted meta data execute: To encrypt the master-password file and to create the neccessary encrypted meta data execute:
```bash ```bash
python scripts/main.py --secret-holders-amount "<<amount>>" --quota "<<quota>>" --mode encrypt --add-user-information --master-password "<<master_password>>" --meta python scripts/main.py --secret-holders-amount "<<amount>>" --quota "<<quota>>" --mode encrypt --add-user-information --master-password "<<master_password>>" --meta
``` ```
### generate encryption data with user info
To encrypt the master-password file and to create the neccessary encrypted meta data with additional user infos data execute:
```bash
python scripts/main.py --secret-holders-amount "3" --quota "50" --mode encrypt --add-user-information --master-password "<<master_password>>" --meta --add-user-information << EOL
Nutzer 1
+123456-1
test@test1.de
Addresse Nutzer 1
Zusätzliche Notizen Nutzer 1
Nutzer 2
+123456-2
test@test2.de
Addresse Nutzer 2
Zusätzliche Notizen Nutzer 2
Nutzer 3
+123456-3
test@test3.de
Addresse Nutzer 3
Zusätzliche Notizen Nutzer 3
EOL
```

View File

@ -4,13 +4,16 @@ class Cleanup():
def __init__(self,cli,paths): def __init__(self,cli,paths):
self.cli = cli self.cli = cli
self.paths = paths self.paths = paths
def getAllFilePaths(self,file_type): def getMetaFilePaths(self,file_type):
all_file_paths = [ return [
self.paths.getGroupFilesFolderPath(file_type), self.paths.getGroupFilesFolderPath(file_type),
self.paths.getUserFilesPath(file_type), self.paths.getUserFilesPath(file_type),
self.paths.getAccumulatedFilePath(file_type) self.paths.getAccumulatedFilePath(file_type)
] ]
def getAllFilePaths(self,file_type):
all_file_paths = self.getMetaFilePaths(file_type)
if file_type == Paths.TYPE_DECRYPTED: if file_type == Paths.TYPE_DECRYPTED:
all_file_paths.append(self.paths.getDecryptedMainDataStandartFolder()) all_file_paths.append(self.paths.getDecryptedMainDataStandartFolder())
return all_file_paths return all_file_paths
@ -32,6 +35,10 @@ class Cleanup():
pass pass
self.cleanupFiles(Paths.TYPE_DECRYPTED) self.cleanupFiles(Paths.TYPE_DECRYPTED)
def cleanupMetaData(self,file_type):
for folder_path in self.getMetaFilePaths(file_type):
self.deleteAllFilesInFolder(folder_path)
def deleteAll(self): def deleteAll(self):
self.cleanupFiles(Paths.TYPE_ENCRYPTED) self.cleanupFiles(Paths.TYPE_ENCRYPTED)
self.cleanupFiles(Paths.TYPE_DECRYPTED) self.cleanupFiles(Paths.TYPE_DECRYPTED)

View File

@ -166,6 +166,8 @@ try:
encrypt.addInformationToUser(user_id, label, str(input())) encrypt.addInformationToUser(user_id, label, str(input()))
encrypt.compileData() encrypt.compileData()
if args.meta_data is True: if args.meta_data is True:
print('Cleaning up encrypted meta data.')
cleanup.cleanupMetaData(Paths.TYPE_ENCRYPTED)
print("Create and encrypt meta data.") print("Create and encrypt meta data.")
encrypt.encryptMetaData() encrypt.encryptMetaData()
if args.input_directory is not None: if args.input_directory is not None: