Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeePass import/export improvement (KC-780): #1249

Merged
merged 1 commit into from
Jun 11, 2024
Merged
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
9 changes: 9 additions & 0 deletions keepercommander/importer/keepass/keepass.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def do_import(self, filename, **kwargs):
record.login_url = entry.url
if entry.notes:
record.notes = entry.notes
if entry.otp:
record.fields.append(RecordField('oneTimeCode', '', entry.otp))
if hasattr(entry, 'ctime'):
ctime = entry.ctime
if isinstance(ctime, datetime.datetime):
Expand All @@ -127,6 +129,10 @@ def do_import(self, filename, **kwargs):
field_type = ''
field_label = key
if field_label in ('TOTPSecret', 'TOTPPeriod', 'TOTPDigits', 'TOTPIssuer', 'ModifyTOTPSettings', 'ViewTOTPSettings'):
# Ignore TOTP custom fields (set via previous Keeper -> KDBX export implementation)
# if the entry's "otp" field contains the corresponding URI
if entry.otp:
continue
if field_label == 'TOTPSecret':
totp_secret = value
elif field_label == 'TOTPIssuer':
Expand Down Expand Up @@ -318,6 +324,9 @@ def do_export(self, filename, records, file_password=None, **kwargs):
if r.fields:
custom_names = {} # type: Dict[str, int]
for cf in r.fields:
if cf.type == 'oneTimeCode':
entry.otp = cf.value
continue
if cf.type and cf.label:
title = f'${cf.type}:{cf.label}'
elif cf.type:
Expand Down
Loading