parent
bcd0a217d5
commit
5104c5c0f3
@ -13,7 +13,7 @@ from pykeepass.group import Group as KPGroup
|
||||
from pykeepass.entry import Entry as KPEntry
|
||||
|
||||
import folder as FolderType
|
||||
from item import Item, Types as ItemTypes
|
||||
from item import Item, ItemType, CustomFieldType
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
@ -43,7 +43,7 @@ def bitwarden_to_keepass(args):
|
||||
items = json.loads(items)
|
||||
logging.info(f'Starting to process {len(items)} items.')
|
||||
for item in items:
|
||||
if item['type'] in [ItemTypes.CARD, ItemTypes.IDENTITY]:
|
||||
if item['type'] in [ItemType.CARD, ItemType.IDENTITY]:
|
||||
logging.warning(f'Skipping credit card or identity item "{item["name"]}".')
|
||||
continue
|
||||
|
||||
@ -70,14 +70,18 @@ def bitwarden_to_keepass(args):
|
||||
|
||||
totp_secret, totp_settings = bw_item.get_totp()
|
||||
if totp_secret and totp_settings:
|
||||
entry.set_custom_property('TOTP Seed', totp_secret)
|
||||
entry.set_custom_property('TOTP Seed', totp_secret, protect=True)
|
||||
entry.set_custom_property('TOTP Settings', totp_settings)
|
||||
|
||||
uris = [uri['uri'] for uri in bw_item.get_uris()]
|
||||
set_kp_entry_urls(entry, uris)
|
||||
|
||||
for field in bw_item.get_custom_fields():
|
||||
entry.set_custom_property(field['name'], field['value'])
|
||||
entry.set_custom_property(
|
||||
field['name'],
|
||||
field['value'],
|
||||
protect=field['type'] == CustomFieldType.HIDDEN,
|
||||
)
|
||||
|
||||
for attachment in bw_item.get_attachments():
|
||||
attachment_raw = subprocess.check_output([
|
||||
|
7
item.py
7
item.py
@ -2,12 +2,16 @@ from enum import IntEnum
|
||||
from urllib.parse import urlsplit, parse_qsl
|
||||
|
||||
|
||||
class Types(IntEnum):
|
||||
class ItemType(IntEnum):
|
||||
LOGIN = 1
|
||||
SECURE_NOTE = 2
|
||||
CARD = 3
|
||||
IDENTITY = 4
|
||||
|
||||
class CustomFieldType(IntEnum):
|
||||
TEXT = 0
|
||||
HIDDEN = 1
|
||||
BOOLEAN = 2
|
||||
|
||||
class Item:
|
||||
def __init__(self, item):
|
||||
@ -53,6 +57,7 @@ class Item:
|
||||
for field in self.item['fields']:
|
||||
field['name'] = field['name'] if field['name'] is not None else ''
|
||||
field['value'] = field['value'] if field['value'] is not None else ''
|
||||
field['type'] = CustomFieldType(field['type'])
|
||||
|
||||
return self.item['fields']
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user