Skip to content

Commit

Permalink
Fix regular expressions used in meta
Browse files Browse the repository at this point in the history
The meta feature did not work with regular expressions. This should now
be fixed.
  • Loading branch information
qtc-de committed Jan 5, 2023
1 parent 228752a commit 7fc0c39
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions qubes-keepass.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,18 @@ def contains_qube(qube_list: list, qube: str) -> bool:

for entry in qube_list:

if type(entry) == str and entry == qube:
return True
if type(entry) == str:

elif entry.fullmatch(qube):
return True
if entry == qube:
return True

elif type(entry) == re.Pattern:

if entry.fullmatch(qube):
return True

else:
raise InternalError(f'Unsupported list entry type: {type(entry)}')

return False

Expand All @@ -98,6 +105,12 @@ class MissingConfigException(Exception):
'''


class InternalError(Exception):
'''
Custom exception class.
'''


class UuidCache:
'''
The UuidCache class is responsible for tracking which credentials were used most
Expand Down Expand Up @@ -490,6 +503,7 @@ def __init__(self, item: Secret.Item, service: Secret.Service) -> None:

if Config.getboolean('regex') and self.qubes is not None:
self.qubes = list(map(re.compile, self.qubes))
self.meta = list(map(re.compile, self.meta))

def __str__(self) -> str:
'''
Expand Down Expand Up @@ -883,6 +897,11 @@ def main() -> None:
print('[-] Error message: ' + str(e))
return

except InternalError as e:
print('[-] Internal Error.')
print('[-] Error message: ' + str(e))
return

except RofiAbortedException:
print('[+] Aborted.')
return
Expand Down

0 comments on commit 7fc0c39

Please sign in to comment.