mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-13 10:16:12 +02:00
Rework Encryption to enable future support of other encryption methods (#1602)
- initial pass through to rework encryption into separate module - little more cleanup - rename function, fix some linting issues - more cleaning - fix password bug in encryption - fix linting issue - more cleanup - move prompt into prompt.py - more cleanup - update the upgrade process for new encryption classes - general cleanup - turn into enum instead of strings - store status code so tests don't fail - standardize the load and store methods in journals - get rid of old PlainJournal class - typing cleanup - more cleanup - format - fix linting issue - Fix obscure Windows line ending issue with decode See https://bugs.python.org/issue40863 - fix for python 3.11 - add more typing - don't use class variables because that's not what we want - fix more type hints - jrnlv1 encryption doesn't support encryption anymore (it's deprecated) - keep logic for password attemps inside the class that uses it - take out old line of code - add some more logging - update logging statements - clean up logging statements - run linters - fix typo - Fix for new test from develop branch There was a new test added for re-encrypting a journal. This updates the refactor to match the old (previously untested) behavior of jrnl. Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
parent
e6e08e5d3e
commit
fcc8d8e3fa
19 changed files with 437 additions and 267 deletions
|
@ -1,6 +1,7 @@
|
|||
# Copyright © 2012-2022 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from jrnl import Journal
|
||||
|
@ -8,7 +9,6 @@ from jrnl import __version__
|
|||
from jrnl.config import is_config_json
|
||||
from jrnl.config import load_config
|
||||
from jrnl.config import scope_config
|
||||
from jrnl.EncryptedJournal import EncryptedJournal
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgStyle
|
||||
|
@ -132,7 +132,17 @@ def upgrade_jrnl(config_path: str) -> None:
|
|||
old_journal = Journal.open_journal(
|
||||
journal_name, scope_config(config, journal_name), legacy=True
|
||||
)
|
||||
all_journals.append(EncryptedJournal.from_journal(old_journal))
|
||||
|
||||
logging.debug(f"Clearing encryption method for '{journal_name}' journal")
|
||||
|
||||
# Update the encryption method
|
||||
new_journal = Journal.Journal.from_journal(old_journal)
|
||||
new_journal.config["encrypt"] = "jrnlv2"
|
||||
new_journal._get_encryption_method()
|
||||
# Copy over password (jrnlv1 only supported password-based encryption)
|
||||
new_journal.encryption_method.password = old_journal.encryption_method.password
|
||||
|
||||
all_journals.append(new_journal)
|
||||
|
||||
for journal_name, path in plain_journals.items():
|
||||
print_msg(
|
||||
|
@ -149,7 +159,7 @@ def upgrade_jrnl(config_path: str) -> None:
|
|||
old_journal = Journal.open_journal(
|
||||
journal_name, scope_config(config, journal_name), legacy=True
|
||||
)
|
||||
all_journals.append(Journal.PlainJournal.from_journal(old_journal))
|
||||
all_journals.append(Journal.Journal.from_journal(old_journal))
|
||||
|
||||
# loop through lists to validate
|
||||
failed_journals = [j for j in all_journals if not j.validate_parsing()]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue