Fully support keepassxc-cli options #1047 #1049
Reference in New Issue
Block a user
Delete Branch "gautamaggarwal2810/borgmatic:issue1047"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is first draft for issue #1047. Please review and suggest changes if any.
I am not sure if yubikey option should be implemented as boolean flag or not. But on googling,I found that when modeling YubiKey usage in a configuration file or schema that doesnt need device details, it might be represented as a boolean instead of string.However if that needs to change,please let me know.
Thanks for doing this!
@@ -2683,6 +2683,16 @@ properties:description: |Command to use instead of "keepassxc-cli".example: /usr/local/bin/keepassxc-clikey-file:Underscore instead of dash here. (Convention for option names.)
@@ -2686,0 +2689,4 @@Path to a key file for unlocking the KeePassXC database.example: /path/to/keyfileyubikey:type: booleanIf you look at the help for
keepassxc-cli show, this looks like it should be a string rather than a bool.@@ -18,2 +18,3 @@try:(database_path, attribute_name) = credential_parametersdatabase_path, attribute_name = credential_parameters[:2]extra_args = credential_parameters[2:] # Handle additional arguments like --key-file or --yubikeyI don't think this should be necessary since you've got key file and yubikey option in config. If you want to support arbitrary extra arguments though, I'd recommend doing that with a dedicated config option for that purpose.
@@ -43,2 +39,3 @@)).rstrip(os.linesep)+ tuple(extra_args) # Append extra arguments)I might've missed it, but I don't see where your new config options are used here so they impact the constructed command.
Added all suggested changes.Please review.
@@ -119,0 +193,4 @@'execute_command_and_capture_output').with_args(('keepassxc-cli',In the documentation, the database and the entry have to be defined at the end of the command:
I've tested with the order you've generated. It's working. For now.
Nothing guarantees that the order will not be enforced later.
You might want to generate the command as it is described in the documentation.
Ok I will get right to it !!
The latest commit generates command as per documentation.All tests were successful.Please let me know if any more changes are required.
A few minor notes, but I think this is just about done! Thank you!
@@ -2686,0 +2691,4 @@yubikey:type: stringdescription: |Path or identifier for the YubiKey to use for unlocking the KeePassXC database.I don't think this is quite right. If I'm reading the
--helpcorrectly, this isn't ever a path. Check out thekeepassxc-cli showhelp for details.@@ -17,3 +17,3 @@'''try:(database_path, attribute_name) = credential_parametersdatabase_path, attribute_name = credential_parameters[:2]Adding
[:2]means that we'll no longer error if the user adds too many credential parameters; we'll just silently ignore extra ones. But it seems like erroring would be preferable...?Let me know if you disagree.
I think u are right. I have made changes accordingly in final commit.
@@ -45,0 +33,4 @@+ (('--key-file', hook_config['key_file']) if 'key_file' in hook_config else ())+ (('--yubikey', hook_config['yubikey']) if 'yubikey' in hook_config else ())+ (expanded_database_path, attribute_name) # Ensure database & entry are last)Looks great!
@@ -119,0 +216,4 @@credential_parameters=('database.kdbx', 'mypassword'),)== 'password')Nice tests!
I don't know that this last one is strictly necessary though. But I also don't feel strongly if you want to leave it.
Thank you. I have created some differentiation from earlier tests for the last test by testing only for slot in yubikey string value so that you might be inclined to accept it 😄
As far as I'm concerned, this is ready to merge! Please remove the "WIP" prefix when you're ready.
WIP: Fully support keepassxc-cli options #1047to Fully support keepassxc-cli options #1047Thank you for doing this work!
@@ -43,2 +32,2 @@)).rstrip(os.linesep)+ ('show', '--show-protected', '--attributes', 'Password')+ (('--key-file', hook_config['key_file']) if 'key_file' in hook_config else ())FYI this errored when
keepassxc:was completely omitted from configuration (which is a valid way to use the hook). So I changed it to first check thathook_configis set at all.@@ -2686,0 +2694,4 @@YubiKey slot and optional serial number used to access the KeePassXC database.Format: "<slot[:serial]>", where:- <slot> is the YubiKey slot number (e.g., `1` or `2`).- <serial> (optional) is the YubiKey's serial number (e.g., `1:7370001`).FYI some of these lines are too long and tests complained, so I word-wrapped the lines. In the future, please make sure you run the full
toxsuite of tests so it catches things like this for you. Thanks!