From e316712eb09647405984713ed3e1acfb2d6fed49 Mon Sep 17 00:00:00 2001 From: evidencebp Date: Wed, 25 Sep 2024 14:32:05 +0300 Subject: [PATCH 1/9] src\views\setup.py line-too-long Line was one letter too long --- src/views/setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/views/setup.py b/src/views/setup.py index d1f91dd..1055b7c 100644 --- a/src/views/setup.py +++ b/src/views/setup.py @@ -39,7 +39,8 @@ def initialize(salt): print("Your vault has been created and encrypted with your master key.") print("Your unique salt is: %s " % (salt)) print( - "Write it down. If you lose your config file you will need it to unlock your vault.") + "Write it down." + + " If you lose your config file you will need it to unlock your vault.") return True From bb863afd472d0e125b0ace974758223467bced9c Mon Sep 17 00:00:00 2001 From: evidencebp Date: Wed, 25 Sep 2024 14:43:06 +0300 Subject: [PATCH 2/9] src\tools\troubleshoot_db.py simplifiable-if-expression if result_proxy.fetchall() == [(123,)] can result in only True or False, the external condition is not needed. However, if result_proxy.fetchall() might return Noe, the external condition can translate it to False. The external condition hurt readability since it takes a bit to verify what it does. bool is a simpler implementation See https://stackoverflow.com/questions/76094401/the-if-expression-can-be-replaced-with-test-simplifiable-if-expression --- src/tools/troubleshoot_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/troubleshoot_db.py b/src/tools/troubleshoot_db.py index b732c22..84047f5 100644 --- a/src/tools/troubleshoot_db.py +++ b/src/tools/troubleshoot_db.py @@ -78,7 +78,7 @@ def attempt_dummy_encrypted_db(db_path): connection.execute(text('CREATE TABLE foo (a int)')) connection.execute(text('INSERT INTO foo (a) VALUES (123)')) result_proxy = connection.execute(text('SELECT * FROM foo')) - return True if result_proxy.fetchall() == [(123,)] else False + return bool(result_proxy.fetchall() == [(123,)]) def verify_if_dummy_db_is_encrypted(db_path): From 07f4b18d4027a674b004654689cf4e2134f9a008 Mon Sep 17 00:00:00 2001 From: evidencebp Date: Wed, 25 Sep 2024 16:04:32 +0300 Subject: [PATCH 3/9] src\views\menu.py broad-exception-caught Code deliberately catches Exception, after catching KeyboardInterrupt. However, looking at the protected code it seems that no other exception can be raised. Hence, instead of narrowing the exception, I removed it. --- src/views/menu.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/views/menu.py b/src/views/menu.py index cc49ce0..7f46be4 100644 --- a/src/views/menu.py +++ b/src/views/menu.py @@ -32,8 +32,6 @@ def get_input(message='', secure=False, lowercase=False, check_timer=True, non_l input_ = input_.lower() except KeyboardInterrupt: return False - except Exception: # Other Exception - return False return input_ From 8208e6c8b23ccf2ea27eb2c5598538850edb1129 Mon Sep 17 00:00:00 2001 From: evidencebp Date: Wed, 25 Sep 2024 16:09:13 +0300 Subject: [PATCH 4/9] src\lib\Config.py line-too-long Made the long, yet readable, comment shorter --- src/lib/Config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/Config.py b/src/lib/Config.py index 0933dc4..9a22bd0 100644 --- a/src/lib/Config.py +++ b/src/lib/Config.py @@ -34,7 +34,8 @@ def set_default_config_file(self): self.config['MAIN'] = { 'version': '2.00', - 'keyVersion': '1', # Will be used to support legacy key versions if the algorithm changes + 'keyVersion': '1', # Will be used to support legacy key versions + # if the algorithm changes 'salt': self.generate_random_salt(), 'clipboardTTL': '15', 'hideSecretTTL': '5', From 83653ea0a1fc71ac98c9187c7cee05f2204700bb Mon Sep 17 00:00:00 2001 From: evidencebp Date: Wed, 25 Sep 2024 16:14:49 +0300 Subject: [PATCH 5/9] src\modules\autocomplete.py broad-exception-caught Code deliberately catches Exception, after catching KeyboardInterrupt. However, looking at the protected code it seems that no other exception can be raised. Hence, instead of narrowing the exception, I removed it. --- src/modules/autocomplete.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/modules/autocomplete.py b/src/modules/autocomplete.py index 8478bf7..e4420fc 100644 --- a/src/modules/autocomplete.py +++ b/src/modules/autocomplete.py @@ -70,5 +70,3 @@ def get_input_autocomplete(message=''): return input(message).strip() except KeyboardInterrupt: return False - except Exception: # Other Exception - return False From c0221bb940088c26d85f5a8e50600bd254acdbf6 Mon Sep 17 00:00:00 2001 From: evidencebp Date: Wed, 25 Sep 2024 17:01:56 +0300 Subject: [PATCH 6/9] src\modules\misc.py broad-exception-caught Exception is too wide. os.path.exists does not throw exceptions. os.makedirs might throw OSError (e.g., in a bad path). See https://stackoverflow.com/questions/2383816/how-can-i-make-an-error-verifiy-with-os-makedirs-in-python As extra safety, though the code checks just before for the directory, catch it too in case a different process will be able to create it before. --- src/modules/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/misc.py b/src/modules/misc.py index a0f4067..2ee52d7 100644 --- a/src/modules/misc.py +++ b/src/modules/misc.py @@ -42,7 +42,7 @@ def create_directory_if_missing(dir_): return True return False - except Exception: + except (OSError, FileExistsError): import sys print() From 37b976240ff381f0dc575310451377ba6b2b9353 Mon Sep 17 00:00:00 2001 From: evidencebp Date: Wed, 25 Sep 2024 17:06:56 +0300 Subject: [PATCH 7/9] src\views\categories.py superfluous-parens Replaced (True) to True --- src/views/categories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/categories.py b/src/views/categories.py index 5626a89..f5e6a81 100644 --- a/src/views/categories.py +++ b/src/views/categories.py @@ -267,7 +267,7 @@ def main_menu(): Categories menu """ - while (True): + while True: # Clear screen clear_screen() From ec0c0b7f118fa86508f9b71b253c67a8ca396d74 Mon Sep 17 00:00:00 2001 From: evidencebp Date: Wed, 25 Sep 2024 17:17:43 +0300 Subject: [PATCH 8/9] src\views\import_export.py line-too-long Made a readable comment line shorter --- src/views/import_export.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/views/import_export.py b/src/views/import_export.py index 7689387..bf676f9 100644 --- a/src/views/import_export.py +++ b/src/views/import_export.py @@ -102,7 +102,8 @@ def import_from_json(path=None, rows=None): def import_items(rows): """ Import items at the following format: - [{'name': '...', 'url': '...', 'login': '...', 'password': '...', 'notes': '...', 'category': '...'}] + [{'name': '...', 'url': '...', 'login': '...' + , 'password': '...', 'notes': '...', 'category': '...'}] """ for row in rows: From 1901c96edb20164969619482f24375d836c9c986 Mon Sep 17 00:00:00 2001 From: evidencebp Date: Wed, 25 Sep 2024 17:19:39 +0300 Subject: [PATCH 9/9] src\views\migration.py line-too-long Made the line shorter. Since the string is also formatted, parenthesis are added for operations precedence. --- src/views/migration.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/views/migration.py b/src/views/migration.py index 5ebff48..3f29570 100644 --- a/src/views/migration.py +++ b/src/views/migration.py @@ -84,7 +84,8 @@ def migrate(vault_path, config_path, new_vault_path=None): print() print('The migration is now complete!') print('Restart the application to use Vault 2.') - print('Your old vault is stored in `%s`. You can discard this file after ensuring that all your data was migrated properly.' % (vault_path)) + print('Your old vault is stored in `%s`. You can discard this file after ensuring that all your data was migrated properly.' + % (vault_path)) print('Your new vault is stored in `%s`.' % (new_vault_path)) print()