Compare commits
1 commit
main
...
dev-202610
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf842f53e8 |
|
|
@ -38,6 +38,7 @@ def action_db_create(
|
||||||
options = (
|
options = (
|
||||||
{
|
{
|
||||||
"key_file": None,
|
"key_file": None,
|
||||||
|
"dry_run": False,
|
||||||
}
|
}
|
||||||
|
|
|
|
||||||
(options or {})
|
(options or {})
|
||||||
|
|
@ -60,7 +61,10 @@ def action_db_create(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
),
|
||||||
|
{
|
||||||
|
"dry_run": options["dry_run"],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -69,6 +73,14 @@ def action_mkdir(
|
||||||
group_name,
|
group_name,
|
||||||
options = None
|
options = None
|
||||||
):
|
):
|
||||||
|
options = (
|
||||||
|
{
|
||||||
|
"key_file": None,
|
||||||
|
"dry_run": False,
|
||||||
|
}
|
||||||
|
|
|
||||||
|
(options or {})
|
||||||
|
)
|
||||||
__helpers_misc.shell_exec(
|
__helpers_misc.shell_exec(
|
||||||
__helpers_misc.string_coin(
|
__helpers_misc.string_coin(
|
||||||
"keepassxc-cli mkdir{{macro_auth}} {{db_path}} {{group_name}}",
|
"keepassxc-cli mkdir{{macro_auth}} {{db_path}} {{group_name}}",
|
||||||
|
|
@ -77,7 +89,10 @@ def action_mkdir(
|
||||||
"group_name": group_name,
|
"group_name": group_name,
|
||||||
"macro_auth": macro_auth(options["key_file"]),
|
"macro_auth": macro_auth(options["key_file"]),
|
||||||
}
|
}
|
||||||
)
|
),
|
||||||
|
{
|
||||||
|
"dry_run": options["dry_run"],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -87,6 +102,14 @@ def action_add(
|
||||||
member_name,
|
member_name,
|
||||||
options = None
|
options = None
|
||||||
):
|
):
|
||||||
|
options = (
|
||||||
|
{
|
||||||
|
"key_file": None,
|
||||||
|
"dry_run": False,
|
||||||
|
}
|
||||||
|
|
|
||||||
|
(options or {})
|
||||||
|
)
|
||||||
__helpers_misc.shell_exec(
|
__helpers_misc.shell_exec(
|
||||||
__helpers_misc.string_coin(
|
__helpers_misc.string_coin(
|
||||||
"keepassxc-cli add{{macro_auth}} {{db_path}} {{entry}}",
|
"keepassxc-cli add{{macro_auth}} {{db_path}} {{entry}}",
|
||||||
|
|
@ -95,7 +118,10 @@ def action_add(
|
||||||
"entry": compose_entry(group_name, member_name),
|
"entry": compose_entry(group_name, member_name),
|
||||||
"macro_auth": macro_auth(options["key_file"]),
|
"macro_auth": macro_auth(options["key_file"]),
|
||||||
}
|
}
|
||||||
)
|
),
|
||||||
|
{
|
||||||
|
"dry_run": options["dry_run"],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -105,6 +131,14 @@ def action_rm(
|
||||||
member_name,
|
member_name,
|
||||||
options = None
|
options = None
|
||||||
):
|
):
|
||||||
|
options = (
|
||||||
|
{
|
||||||
|
"key_file": None,
|
||||||
|
"dry_run": False,
|
||||||
|
}
|
||||||
|
|
|
||||||
|
(options or {})
|
||||||
|
)
|
||||||
__helpers_misc.shell_exec(
|
__helpers_misc.shell_exec(
|
||||||
__helpers_misc.string_coin(
|
__helpers_misc.string_coin(
|
||||||
"keepassxc-cli rm{{macro_auth}} {{db_path}} {{entry}}",
|
"keepassxc-cli rm{{macro_auth}} {{db_path}} {{entry}}",
|
||||||
|
|
@ -113,7 +147,10 @@ def action_rm(
|
||||||
"entry": compose_entry(group_name, member_name),
|
"entry": compose_entry(group_name, member_name),
|
||||||
"macro_auth": macro_auth(options["key_file"]),
|
"macro_auth": macro_auth(options["key_file"]),
|
||||||
}
|
}
|
||||||
)
|
),
|
||||||
|
{
|
||||||
|
"dry_run": options["dry_run"],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -125,6 +162,14 @@ def action_attachment_import(
|
||||||
attachment_path,
|
attachment_path,
|
||||||
options = None
|
options = None
|
||||||
):
|
):
|
||||||
|
options = (
|
||||||
|
{
|
||||||
|
"key_file": None,
|
||||||
|
"dry_run": False,
|
||||||
|
}
|
||||||
|
|
|
||||||
|
(options or {})
|
||||||
|
)
|
||||||
__helpers_misc.shell_exec(
|
__helpers_misc.shell_exec(
|
||||||
__helpers_misc.string_coin(
|
__helpers_misc.string_coin(
|
||||||
"keepassxc-cli attachment-import{{macro_auth}} {{db_path}} {{entry}} '{{attachment_label}}' {{attachment_path}}",
|
"keepassxc-cli attachment-import{{macro_auth}} {{db_path}} {{entry}} '{{attachment_label}}' {{attachment_path}}",
|
||||||
|
|
@ -135,5 +180,8 @@ def action_attachment_import(
|
||||||
"attachment_path": attachment_path,
|
"attachment_path": attachment_path,
|
||||||
"macro_auth": macro_auth(options["key_file"]),
|
"macro_auth": macro_auth(options["key_file"]),
|
||||||
}
|
}
|
||||||
)
|
),
|
||||||
|
{
|
||||||
|
"dry_run": options["dry_run"],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,19 @@ def directory_create(path):
|
||||||
|
|
||||||
|
|
||||||
def shell_exec(
|
def shell_exec(
|
||||||
command
|
command,
|
||||||
|
options = None
|
||||||
):
|
):
|
||||||
|
options = (
|
||||||
|
{
|
||||||
|
"dry_run": False,
|
||||||
|
}
|
||||||
|
|
|
||||||
|
(options or {})
|
||||||
|
)
|
||||||
_sys.stderr.write("\n>> %s\n" % command)
|
_sys.stderr.write("\n>> %s\n" % command)
|
||||||
|
if (options["dry_run"]):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
_os.system(command)
|
_os.system(command)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ import helpers.keepass as __helpers_keepass
|
||||||
|
|
||||||
|
|
||||||
def action_init(
|
def action_init(
|
||||||
source_directory
|
source_directory,
|
||||||
|
database_file_name
|
||||||
):
|
):
|
||||||
keepass_db_path = _os.path.join(source_directory, "private_keys.kdbx")
|
keepass_db_path = _os.path.join(source_directory, "private_keys.kdbx")
|
||||||
keepass_authfile_path = _os.path.join(source_directory, "private_keys.keyx")
|
keepass_authfile_path = _os.path.join(source_directory, "private_keys.keyx")
|
||||||
|
|
@ -37,11 +38,13 @@ def action_key_add(
|
||||||
group,
|
group,
|
||||||
name,
|
name,
|
||||||
key_path,
|
key_path,
|
||||||
|
keepass_db_path,
|
||||||
options = None
|
options = None
|
||||||
):
|
):
|
||||||
options = (
|
options = (
|
||||||
{
|
{
|
||||||
"remove_private_key": False,
|
"remove_private_key": False,
|
||||||
|
"dry_run": False,
|
||||||
}
|
}
|
||||||
|
|
|
|
||||||
(options or {})
|
(options or {})
|
||||||
|
|
@ -52,13 +55,15 @@ def action_key_add(
|
||||||
__helpers_misc.directory_create(directory_key)
|
__helpers_misc.directory_create(directory_key)
|
||||||
## transfer private key to keepass database
|
## transfer private key to keepass database
|
||||||
if True:
|
if True:
|
||||||
keepass_db_path = _os.path.join(source_directory, "private_keys.kdbx")
|
# keepass_db_path = _os.path.join(source_directory, "private_keys.kdbx")
|
||||||
keepass_authfile_path = _os.path.join(source_directory, "private_keys.keyx")
|
# keepass_authfile_path = _os.path.join(source_directory, "private_keys.keyx")
|
||||||
|
keepass_authfile_path = None # (keepass_db_path + ".auth")
|
||||||
__helpers_keepass.action_mkdir(
|
__helpers_keepass.action_mkdir(
|
||||||
keepass_db_path,
|
keepass_db_path,
|
||||||
group,
|
group,
|
||||||
{
|
{
|
||||||
"key_file": keepass_authfile_path,
|
"key_file": keepass_authfile_path,
|
||||||
|
"dry_run": options["dry_run"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
__helpers_keepass.action_add(
|
__helpers_keepass.action_add(
|
||||||
|
|
@ -67,6 +72,7 @@ def action_key_add(
|
||||||
name,
|
name,
|
||||||
{
|
{
|
||||||
"key_file": keepass_authfile_path,
|
"key_file": keepass_authfile_path,
|
||||||
|
"dry_run": options["dry_run"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
__helpers_keepass.action_attachment_import(
|
__helpers_keepass.action_attachment_import(
|
||||||
|
|
@ -77,6 +83,7 @@ def action_key_add(
|
||||||
path_key_private,
|
path_key_private,
|
||||||
{
|
{
|
||||||
"key_file": keepass_authfile_path,
|
"key_file": keepass_authfile_path,
|
||||||
|
"dry_run": options["dry_run"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
## remove private key file
|
## remove private key file
|
||||||
|
|
@ -87,7 +94,10 @@ def action_key_add(
|
||||||
{
|
{
|
||||||
"path": path_key_private,
|
"path": path_key_private,
|
||||||
}
|
}
|
||||||
)
|
),
|
||||||
|
{
|
||||||
|
"dry_run": options["dry_run"],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -273,6 +283,12 @@ def main():
|
||||||
metavar = "<action>",
|
metavar = "<action>",
|
||||||
help = "options: init | key-add | key-generate | key-remove | put",
|
help = "options: init | key-add | key-generate | key-remove | put",
|
||||||
)
|
)
|
||||||
|
argument_parser.add_argument(
|
||||||
|
"-q",
|
||||||
|
"--dry-run",
|
||||||
|
action = "store_true",
|
||||||
|
default = False,
|
||||||
|
)
|
||||||
argument_parser.add_argument(
|
argument_parser.add_argument(
|
||||||
"-s",
|
"-s",
|
||||||
"--source-directory",
|
"--source-directory",
|
||||||
|
|
@ -333,8 +349,10 @@ def main():
|
||||||
args.group,
|
args.group,
|
||||||
args.name,
|
args.name,
|
||||||
args.key_path,
|
args.key_path,
|
||||||
|
args.target_file,
|
||||||
{
|
{
|
||||||
"remove_private_key": args.remove_private_key,
|
"remove_private_key": args.remove_private_key,
|
||||||
|
"dry_run": args.dry_run,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
elif (args.action == "key-generate"):
|
elif (args.action == "key-generate"):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue