Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions keepercommander/importer/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def register_command_info(aliases, command_info):
help='Maximum file attachment file. Example: 100K, 50M, 2G. Default: 10M')
export_parser.add_argument('-kp', '--keepass-file-password', dest='file_password', action='store',
help='Password for the exported file')
export_parser.add_argument('-kkf', '--keepass-key-file', dest='kbdx_key_file', action='store',
help='Keepass key file for the exported file')
export_parser.add_argument('--zip', dest='zip_archive', action='store_true',
help='Create ZIP archive for file attachments. JSON only')
export_parser.add_argument('--save-in-vault', dest='save_in_vault', action='store_true',
Expand Down
2 changes: 2 additions & 0 deletions keepercommander/importer/imp_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ def on_folder(base_folder): # type: (BaseFolderNode) -> None
file_password = kwargs.get('file_password')
if file_password:
args['file_password'] = file_password
if kwargs.get('kbdx_key_file'):
args['kbdx_key_file'] = kwargs.get('kbdx_key_file')
zip_archive = kwargs.get('zip_archive') is True
if zip_archive:
args['zip_archive'] = zip_archive
Expand Down
24 changes: 11 additions & 13 deletions keepercommander/importer/keepass/keepass.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,18 +284,15 @@ def to_keepass_value(keeper_value): # type: (any) -> str
else:
return XmlUtils.sanitize_xml_text(keeper_value)

def do_export(self, filename, records, file_password=None, **kwargs):
master_password = file_password
confirmed = True
while not master_password or not confirmed:
print('Choose password for your Keepass file')
master_password = getpass.getpass(prompt='...' + 'Keepass Password'.rjust(20) + ': ', stream=None)
print('\nRe-enter password for your Keepass file')
confirmation = getpass.getpass(prompt='...' + 'Keepass Password'.rjust(20) + ': ', stream=None)
confirmed = master_password == confirmation
retry_msg = 'The passwords you entered do not match.\nPlease try again.\n'
fail_msg = bcolors.FAIL + bcolors.BOLD + '\nALERT!\n' + retry_msg + bcolors.ENDC
not confirmed and print(fail_msg)
def do_export(self, filename, records, file_password=None, kbdx_key_file=None, **kwargs):
password = file_password or getpass.getpass(prompt='...' + 'Keepass Password'.rjust(20) + ': ', stream=None) or None
if not kbdx_key_file:
print('Press Enter if your Keepass file is not protected with a key file')
keyfile = kbdx_key_file or input('...' + 'Path to Key file'.rjust(20) + ': ') or None
if keyfile:
keyfile = os.path.expanduser(keyfile.strip("\"'"))
else:
keyfile = None

sfs = [] # type: list[SharedFolder]
rs = [] # type: list[Record]
Expand All @@ -308,7 +305,8 @@ def do_export(self, filename, records, file_password=None, **kwargs):
template_file = os.path.join(os.path.dirname(__file__), 'template.kdbx')

with PyKeePass(template_file, password='111111') as kdb:
kdb.password = master_password
kdb.password = password
kdb.keyfile = keyfile
root = kdb.root_group

for r in rs:
Expand Down