mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 07:48:57 +00:00
Merge pull request #839 from PR0M3TH3AN/codex/fix-graceful-failure-on-decryption-error
Handle configuration decryption errors gracefully
This commit is contained in:
@@ -409,11 +409,13 @@ class EncryptionManager:
|
|||||||
if return_kdf:
|
if return_kdf:
|
||||||
return data, kdf
|
return data, kdf
|
||||||
return data
|
return data
|
||||||
except (InvalidToken, InvalidTag, JSONDecodeError) as e:
|
except (InvalidToken, InvalidTag) as e:
|
||||||
logger.error(
|
msg = f"Failed to decrypt or parse data from {file_path}: {e}"
|
||||||
f"FATAL: Could not decrypt or parse data from {file_path}: {e}",
|
logger.error(msg)
|
||||||
exc_info=True,
|
raise InvalidToken(msg) from e
|
||||||
)
|
except JSONDecodeError as e:
|
||||||
|
msg = f"Failed to parse JSON data from {file_path}: {e}"
|
||||||
|
logger.error(msg)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def get_encrypted_index(self) -> Optional[bytes]:
|
def get_encrypted_index(self) -> Optional[bytes]:
|
||||||
|
@@ -4420,6 +4420,15 @@ class PasswordManager:
|
|||||||
else:
|
else:
|
||||||
logging.warning("Password verification failed.")
|
logging.warning("Password verification failed.")
|
||||||
return is_correct
|
return is_correct
|
||||||
|
except InvalidToken as e:
|
||||||
|
logging.error(f"Failed to decrypt config: {e}")
|
||||||
|
print(
|
||||||
|
colored(
|
||||||
|
"Error: Could not decrypt configuration. The password may be incorrect or the file may be corrupted.",
|
||||||
|
"red",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error verifying password: {e}", exc_info=True)
|
logging.error(f"Error verifying password: {e}", exc_info=True)
|
||||||
print(colored(f"Error: Failed to verify password: {e}", "red"))
|
print(colored(f"Error: Failed to verify password: {e}", "red"))
|
||||||
|
Reference in New Issue
Block a user