Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_open_error(self):
with self.assertRaises(CredentialsIntegrityError):
database = 'test4.kdbx'
invalid_password = 'foobar'
keyfile = os.path.join(base_dir, 'test4.key')
PyKeePass(
os.path.join(base_dir, database),
password=invalid_password,
keyfile=keyfile
)
with self.assertRaises(CredentialsIntegrityError):
database = 'test4.kdbx'
password = 'password'
invalid_keyfile = os.path.join(base_dir, 'test3.key')
PyKeePass(
os.path.join(base_dir, database),
password=password,
keyfile=invalid_keyfile
)
def test_open_error(self):
with self.assertRaises(CredentialsIntegrityError):
database = 'test4.kdbx'
invalid_password = 'foobar'
keyfile = os.path.join(base_dir, 'test4.key')
PyKeePass(
os.path.join(base_dir, database),
password=invalid_password,
keyfile=keyfile
)
with self.assertRaises(CredentialsIntegrityError):
database = 'test4.kdbx'
password = 'password'
invalid_keyfile = os.path.join(base_dir, 'test3.key')
PyKeePass(
os.path.join(base_dir, database),
password=password,
keyfile=invalid_keyfile
Will ask for a password to unlock the data first. Support binary
attachments.
:param str path: Path to the KDBX file to parse.
"""
try:
from pykeepass import PyKeePass
from pykeepass.exceptions import CredentialsIntegrityError
except ImportError as error:
raise ImportError(error, name='pykeepass')
password = getpassword(path)
try:
keepass = PyKeePass(path, password=password)
except CredentialsIntegrityError as error: # pragma: no cover
raise PermissionError(error)
for kpentry in keepass.entries:
entry = self._getentry(kpentry)
entry['group'] = os.path.dirname(entry['group'])
for hentry in kpentry.history:
history = self._getentry(hentry)
history['group'] = os.path.join('History', entry['group'])
self.data.append(history)
for att in kpentry.attachments:
attachment = dict()
attachment['group'] = entry['group']
attachment['title'] = att.filename
attachment['data'] = att.data
def composite_unlock_process(self):
try:
self.database_manager = DatabaseManager(self.database_filepath, password=self.password_composite, keyfile=self.composite_keyfile_path, logging_manager=self.window.logging_manager)
GLib.idle_add(self.composite_unlock_success)
except(OSError, IndexError, ValueError, AttributeError, core.ChecksumError, CredentialsIntegrityError):
GLib.idle_add(self.composite_unlock_failure)