Skip to content

Feature : keepassxc CLI#254

Merged
TheZ3ro merged 24 commits intodevelopfrom
feature/keepassxc-cli
Mar 16, 2017
Merged

Feature : keepassxc CLI#254
TheZ3ro merged 24 commits intodevelopfrom
feature/keepassxc-cli

Conversation

@louib
Copy link
Copy Markdown
Member

@louib louib commented Feb 2, 2017

Adding a single point of entry for the command line interface. I still need to add the available commands when calling the program without a command name. The other utils could also be migrated to the new directory.

Also fixes 2 things:

  • The programs were not exiting if the Crypto::init() call was failing.
  • The merge program was returning 1 even though it succeeded.

Motivation and Context

Addresses #201

How Has This Been Tested?

Locally, by testing the 2 programs migrated.

Screenshots (if appropriate):

$ src/cli/keepassxc-cli extract
Usage: keepassxc-cli extract database
Extract and print a KeePassXC database file.

Arguments:
  database path of the database to extract.
$ src/cli/keepassxc-cli merge
Usage: keepassxc-cli merge [options] database1 database2
Merge 2 KeePassXC database files.

Options:
  -s, --same-password  use the same password for both database files.

Arguments:
  database1            path of the database to merge into.
  database2            path of the database to merge from.
$ src/cli/keepassxc-cli
Usage: src/cli/keepassxc-cli [options] command
KeepassXC command line interface.

Options:
  -h, --help     Displays this help.
  -v, --version  Displays version information.

Arguments:
  command        Name of the command to execute.
$ src/cli/keepassxc-cli -v
keepassxc-cli 2.1.0
$ src/cli/keepassxc-cli -h
Usage: src/cli/keepassxc-cli [options] command
KeepassXC command line interface.

Options:
  -h, --help     Displays this help.
  -v, --version  Displays version information.

Arguments:
  command        Name of the command to execute.
$ src/cli/keepassxc-cli fdsfsd
Invalid command fdsfsd.
Usage: src/cli/keepassxc-cli [options] command
KeepassXC command line interface.

Options:
  -h, --help     Displays this help.
  -v, --version  Displays version information.

Arguments:
  command        Name of the command to execute.

Types of changes

  • ✅ New feature (non-breaking change which adds functionality)
  • ✅ Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • ✅ I have read the CONTRIBUTING document.
  • ✅ My code follows the code style of this project.
  • ✅ All new and existing tests passed.
  • X My change requires a change to the documentation and I have updated it accordingly.

target_link_libraries(entropy-meter zxcvbn)
install(TARGETS keepassxc-cli
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now this is installing the binary in the /Applications folder on MacOs. I'll have to find a way to copy it to /usr/local/bin instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You set the destination to ${BIN_INSTALL_DIR} "declared" here https://github.com/keepassxreboot/keepassxc/blob/develop/CMakeLists.txt#L148
that is set to . and when executing make install goes to /Application

You can instead use

include(GNUInstallDirs)
${CMAKE_INSTALL_BINDIR}

Or eventually hard code the /usr/local/bin path

@louib
Copy link
Copy Markdown
Member Author

louib commented Feb 4, 2017

@TheZ3ro added the install path for MacOs. Really not sure this is the way to go, and I still have to determine the path for cli executables on windows.

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Feb 4, 2017

@louib 👍
For windows is fine every path that is in user's PATH. IDK what's the best but I think we should ship it in . along with the KeePassXC.exe


QString commandName = argv[1];

for (int i = 1; i < argc - 1; ++i) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this loop?
You might want to use ++argv; instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I added a comment and removed the loop in favor of ++argv!

@louib
Copy link
Copy Markdown
Member Author

louib commented Feb 5, 2017

@TheZ3ro I tested that the executable installs correctly on Linux. At some point we might want to list the available commands when calling keepassxc-cli alone, but I think this is good enough for a first version of the CLI.

@louib louib force-pushed the feature/keepassxc-cli branch from c36d9e4 to cf05b53 Compare February 7, 2017 23:24
@louib louib force-pushed the feature/keepassxc-cli branch from 9d72ae4 to 3aa27cc Compare February 16, 2017 02:07
@louib
Copy link
Copy Markdown
Member Author

louib commented Feb 16, 2017

@TheZ3ro Added the list command and the available commands.

Root/
  entry2 18f5af788ef856d2113fd1a9fe770325
  entry1 2c6a330e70d2709fead56db22a2aec8c
  entry3 d63adb99abda1a76160dc81157cdc8c2
Usage: ./src/cli/keepassxc-cli [options] command
KeePassXC command line interface.

Available commands:
  extract	Extract and print the content of a database.
  entropy-meter	Calculate password entropy.
  list		List database entries.
  merge		Merge 2 databases.

Options:
  -h, --help     Displays this help.
  -v, --version  Displays version information.

Arguments:
  command        Name of the command to execute.

I'd leave that as is for a first version of the CLI, so that we can clarify the scope of this feature.

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Feb 16, 2017

I was planning of implementing the list option by myself but you already did it! Nice 😄
I agree that this can be a fair initial version

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Feb 16, 2017

Maybe we can put the inserting password code in a different file. It's repeated a lot

@droidmonkey droidmonkey added this to the v2.2.0 milestone Feb 20, 2017
@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Feb 28, 2017

Any news here?

@louib
Copy link
Copy Markdown
Member Author

louib commented Feb 28, 2017

@TheZ3ro I think the last command remaining before a first version would be keepassxc show, so that we can actually retrieve a password from the command line. Otherwise, we might want to extract the password code to a different file before merging.

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Feb 28, 2017

@louib Ok I think we can wait for the merge until the show feature is implemented.

@louib
Copy link
Copy Markdown
Member Author

louib commented Mar 12, 2017

@TheZ3ro added a basic show command. for now it only handles finding the entry with the uuid. I also extracted the common code for opening a database from a filename, and placed it in the Database class.
I'd say this one is ready for merging (after code review, of course)!

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Mar 12, 2017

Ok I will review this in the next few days. Can you rebase on develop?

@louib louib force-pushed the feature/keepassxc-cli branch from e07e08b to e49e8e3 Compare March 12, 2017 19:50
@louib
Copy link
Copy Markdown
Member Author

louib commented Mar 12, 2017

@TheZ3ro done!

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Mar 15, 2017

I forgot to approve and merge this, @louib can you rebase on develop again? Thanks

@louib louib force-pushed the feature/keepassxc-cli branch from e49e8e3 to 0be1f87 Compare March 15, 2017 20:36
@louib
Copy link
Copy Markdown
Member Author

louib commented Mar 15, 2017

@TheZ3ro done!

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Mar 16, 2017

@louib argh, one more time since #394 was merged before I read this

@louib louib force-pushed the feature/keepassxc-cli branch from 0be1f87 to a661c17 Compare March 16, 2017 14:09
@louib
Copy link
Copy Markdown
Member Author

louib commented Mar 16, 2017

@TheZ3ro done!


qCritical("Invalid command %s.", qPrintable(commandName));
parser.showHelp();
return EXIT_FAILURE;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add the lsan stuff I added to src/main.cpp to avoid a huge dump of memory leak errors when compiling with our new -DWITH_ASAN=ON option.

@TheZ3ro TheZ3ro merged commit 4cccf28 into develop Mar 16, 2017
@TheZ3ro TheZ3ro deleted the feature/keepassxc-cli branch March 16, 2017 18:01
@droidmonkey
Copy link
Copy Markdown
Member

Fantastic work on this guys!

@omern1 omern1 mentioned this pull request Apr 21, 2017
droidmonkey added a commit that referenced this pull request Jun 25, 2017
- Added YubiKey 2FA integration for unlocking databases [#127]
- Added TOTP support [#519]
- Added CSV import tool [#146, #490]
- Added KeePassXC CLI tool [#254]
- Added diceware password generator [#373]
- Added support for entry references [#370, #378]
- Added support for Twofish encryption [#167]
- Enabled DEP and ASLR for in-memory protection [#371]
- Enabled single instance mode [#510]
- Enabled portable mode [#645]
- Enabled database lock on screensaver and session lock [#545]
- Redesigned welcome screen with common features and recent databases [#292]
- Multiple updates to search behavior [#168, #213, #374, #471, #603, #654]
- Added auto-type fields {CLEARFIELD}, {SPACE}, {{}, {}} [#267, #427, #480]
- Fixed auto-type errors on Linux [#550]
- Prompt user prior to executing a cmd:// URL [#235]
- Entry attributes can be protected (hidden) [#220]
- Added extended ascii to password generator [#538]
- Added new database icon to toolbar [#289]
- Added context menu entry to empty recycle bin in databases [#520]
- Added "apply" button to entry and group edit windows [#624]
- Added macOS tray icon and enabled minimize on close [#583]
- Fixed issues with unclean shutdowns [#170, #580]
- Changed keyboard shortcut to create new database to CTRL+SHIFT+N [#515]
- Compare window title to entry URLs [#556]
- Implemented inline error messages [#162]
- Ignore group expansion and other minor changes when making database "dirty" [#464]
- Updated license and copyright information on souce files [#632]
- Added contributors list to about dialog [#629]
@noplanman
Copy link
Copy Markdown

noplanman commented Jun 26, 2017

Maybe a silly question, but how do I get this CLI on a Mac?
I checked on brew but didn't find anything.

Does it need to be compiled?

@phoerious
Copy link
Copy Markdown
Member

phoerious commented Jun 26, 2017

You need to compile it. It's not part of the DMG as it only has a single entry point. We probably need some sort of bootstrap feature in the future to start the CLI from single-entry point binary such as the DMG or the Linux AppImage and Snap packages.

@tristan-k
Copy link
Copy Markdown

How do I compile keepassxc-cli from source? I would prefer a brew formula.

@tristan-k
Copy link
Copy Markdown

After doing brew install qt5 and run cmake -DWITH_TESTS=OFF .. -DCMAKE_PREFIX_PATH=/usr/local/Cellar/qt/5.9.0_1 I succeeded in compiling keepassxc-cli for Mac. Here's a copy of the binary.

@phoerious phoerious added pr: new feature Pull request adds a new feature and removed new feature labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: new feature Pull request adds a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants