-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ class HibpError(Exception): | |
|
||
class ApiError(HibpError): | ||
pass | ||
|
||
|
||
class KeepassError(HibpError): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
from typing import List | ||
|
||
from hibpcli.exceptions import KeepassError | ||
from hibpcli.password import Password | ||
from pykeepass import PyKeePass # type: ignore | ||
from pykeepass.exceptions import CredentialsError | ||
|
||
|
||
def check_passwords_from_db(path: str, master_password: str) -> List[str]: | ||
""" - """ | ||
kp = PyKeePass(path, password=master_password) | ||
return [ | ||
entry for entry in kp.entries if Password(password=entry.password).is_leaked() | ||
] | ||
try: | ||
kp = PyKeePass(path, password=master_password) | ||
except CredentialsError: | ||
raise KeepassError | ||
else: | ||
return [ | ||
entry | ||
for entry in kp.entries | ||
if Password(password=entry.password).is_leaked() | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters