Commit Graph

193 Commits

Author SHA1 Message Date
Jonathan White
7e1b16250c Performed project-wide code formatting
* Updated format CMake command to properly
ignore new directories and files
* Added output when command is run
* Resolves #2623
2019-01-28 22:38:59 -05:00
Carlo Teubner
94430c300b CLI: fix missing check for correct credentials (#2629)
* CLI: fix missing check for correct credentials

Before this fix, most/all CLI commands had incorrect behaviour when bad
credentials were supplied: they would carry on regardless, with
potentially catastrophic results.  In particular, the "add" subcommand
seemed to corrupt the database.  "ls" would always report an empty
database.  Haven't tested any others.

Also fixed a related missing check specific to the "merge" subcommand.
2019-01-21 14:24:29 -05:00
louib
726bbb2d94 We should output to stderr on EXIT_FAILURE (#2558)
Making sure we use stderr to output the help
message when there is an invalid number of
arguments, or when there's any error related
to the arguments.
2019-01-16 12:32:06 -05:00
Sami Vänttinen
b6bb2ca06a Fix macOS makefiles for cli and proxy (#2580) 2019-01-16 11:03:11 -05:00
JTL
dd5665c656 Multiple macOS fixes and include keepassxc-cli in DMG (#2165)
* Fixes including keepassxc-cli when building KeePassXC dmg on Mac.
resolves #1697
* Fix Qt search path and Properties display on macOS
* Simplify packaging POST_BUILD fixups
* Various fixes to get cli to run on macos
* Correct cli tests on macOS
* Several macOS related GUI test fixes
2018-12-28 18:32:25 -05:00
louib
8ac9d0a131 Add create command to keepassxc-cli (#2540)
* Add tests for CLI::Create
2018-12-19 23:10:46 -05:00
louib
cb3c4893dc Move unlockDatabase to CLI/Utils (#2539)
Move unlockDatabase from Database to to cli/Utils
2018-12-11 16:49:51 +01:00
Gianluca Recchia
fc930bae69
Restore correct formatting
Many lines were not conformant with the project's formatting rules.
This patch should fix all formatting and whitespace issues in the code
base.
A clang-format directive was put around the connect() calls containing
SIGNALs and SLOTs whose signatures would be denormalized because of the
formatting rules.
2018-11-28 18:29:15 -05:00
louib
49b82ea6a2 Global const for KeyFileOption (CLI) (#2505) 2018-11-28 16:15:15 -05:00
louib
fff0f11b33 Adding --quiet option to the CLI. (#2507) 2018-11-28 11:24:12 -05:00
Janek Bevendorff
d612cad09a
Refactor Database and Database widgets (#2491)
The Database, DatabaseWidget, and DatabaseTabWidget classes share many responsibilities in inconsistent ways resulting in impenetrable and unmaintainable code and a diverse set of bugs and architecture restrictions. This patch reworks the architecture, responsibilities of, and dependencies between these classes.

The core changes are:

* Move loading and saving logic from widgets into the Database class
* Get rid of the DatabaseManagerStruct and move all the information contained in it into the Database
* Let database objects keep track of modifications and dirty/clean state instead of handing this to external widgets
* Move GUI interactions for loading and saving from the DatabaseTabWidget into the DatabaseWidget (resolves #2494 as a side-effect)
* Heavily clean up DatabaseTabWidget and degrade it to a slightly glorified QTabWidget
* Use QSharedPointers for all Database objects
* Remove the modifiedImmediate signal and replace it with a markAsModified() method
* Implement proper tabName() method instead of reading back titles from GUI widgets (resolves #1389 and its duplicates #2146 #855)
* Fix unwanted AES-KDF downgrade if database uses Argon2 and has CustomData
* Improve code

This patch is also the first major step towards solving issues #476 and #2322.
2018-11-22 11:47:31 +01:00
louib
f06742cf41 CLI Merge: Only save database file when modified. (#2466)
* Merge: detect if database was changed.
* Adding unit test.
* Only saving on change.
2018-11-09 21:59:16 -05:00
Felix Fontein
a7dd9f19f4 CLI: add commands to show and copy TOTP to clipboard (#2454)
* Add CLI commands show --totp and totp-clip for handling TOTPs, resolves #2429.
* Adding tests for new CLI TOTP commands
* Update keepassxc-cli man page.
2018-11-09 21:58:42 -05:00
louib
c339470496 Updating CLI man page authorship (#2456) 2018-11-09 19:15:50 -05:00
louib
91160c5f36 Document list -R option. 2018-11-09 19:10:16 -05:00
Gianluca Recchia
e06eae423e
Add missing 'override' for overridden functions 2018-10-31 15:16:04 +01:00
Gianluca Recchia
da9afd3f6f
Reduce number of unneeded copies
This patch aims at reducing the number of copies for obejcts that could
be referenced rather than copied, because they're not modified during
the computation.
2018-10-31 15:16:04 +01:00
Gianluca Recchia
a67a574b89
Reduce function call overhead
The arg() function of the QString class has a variable length argument
which allows to reduce the number of chained calls to the same function.
With proper formatting, readability is not affected.
2018-10-31 14:23:06 +01:00
Gianluca Recchia
09fbb6d35a
Remove redundant headers from the build system
Headers are not to be placed amongst the source files in the CMake
script. The preprocessor and the linker will take care of glue all the
files together. Also, the "include_directories()" statement at the top
of the file already tells CMake where to look for all the needed
header files.
2018-10-31 14:19:01 +01:00
Jonathan White
fa687f246e
Fix issues with group functions (#2410) 2018-10-30 08:42:35 -04:00
Janek Bevendorff
7263dcddfe
Fix stdin/stdout encoding on Windows. (#2425)
QTextStream uses the system default locale, but this breaks in
various situations: (1) It does not work on the native Windows shell
(cmd.exe, Powershell), since the default Windows locale is Windows-1252,
but the shell uses Windows-850. (2) It also breaks on *nix systems where
the locale is Latin1 or C, which is the case for most CI systems or
build servers.

We allow overriding the detected codec by setting the ENCODING_OVERRIDE
environment variable, but otherwise prefer Windows-850 on Windows and
UTF-8 on any other system, even if LANG is set to something else.

This resolves #2413
2018-10-28 19:55:00 +01:00
Janek Bevendorff
77adbef401 Reformat CMakeLists.txt files 2018-10-19 22:16:44 +02:00
Janek Bevendorff
0ca7fd369a Implement review feedback 2018-10-19 22:16:44 +02:00
Janek Bevendorff
113c8eb702 Add CLI tests and improve coding style and i18n
The CLI module was lacking unit test coverage and showed some severe
coding style violations, which this patch addresses.

In addition, all uses of qCritical() with untranslatble raw char*
sequences were removed in favor of proper locale strings. These are
written to STDERR through QTextStreams and support output
redirection for testing purposes. With this change, error messages don't
depend on the global Qt logging settings and targets anymore and go
directly to the terminal or into a file if needed.

This patch also fixes a bug discovered during unit test development,
where the extract command would just dump the raw XML contents without
decrypting embedded Salsa20-protected values first, making the XML
export mostly useless, since passwords are scrambled.

Lastly, all CLI commands received a dedicated -h/--help option.
2018-10-19 21:49:54 +02:00
vi-n
4ff63c2bf5 Add a CLI option to list elements recursively (#2345) 2018-10-03 19:18:34 +02:00
Jonathan White
c1e9f45df9 Introduce synchronize merge method
* Create history-based merging that keeps older data in history instead of discarding or deleting it
* Extract merge logic into the Merger class
* Allows special merge behavior
* Improve handling of deletion and changes on groups
* Enable basic change tracking while merging
* Prevent unintended timestamp changes while merging
* Handle differences in timestamp precision
* Introduce comparison operators to allow for more sophisticated comparisons (ignore special properties, ...)
* Introduce Clock class to handle datetime across the app

Merge Strategies:
* Default (use inherited/fallback method)
* Duplicate (duplicate conflicting nodes, apply all deletions)
* KeepLocal (use local values, but apply all deletions)
* KeepRemote (use remote values, but apply all deletions)
* KeepNewer (merge history only)
* Synchronize (merge history, newest value stays on top, apply all deletions)
2018-09-30 09:36:39 -04:00
Janek Bevendorff
e443cde452 Add a new database settings wizard
This patch implements a new database wizard to guide users through the process
of setting up a new database and choosing sane encryption settings.

It also reimplements the master key settings to be more
user-friendly. Users can now add, change, or remove individual composite
key components instead of having to set all components at once. This
avoids confusion about a password being reset if the user only wants to
add a key file.

With these changes comes a major refactor of how database composite keys and key
components are handled. Copying of keys is prohibited and each key
exists only once in memory and is referenced via shared pointers. GUI
components for changing individual keys are encapsulated into separate
classes to be more reusable. The password edit and generator widgets
have also been refactored to be more reusable.
2018-09-25 21:12:47 +02:00
Jonathan White
ca27fb06d5
Merge branch 'master'
Conflicts:
	INSTALL.md
	release-tool
	src/browser/BrowserOptionDialog.cpp
	src/browser/BrowserService.cpp
	src/browser/BrowserService.h
	src/browser/NativeMessagingBase.h
	src/browser/NativeMessagingHost.h
	src/core/Uuid.cpp
	src/gui/DatabaseTabWidget.cpp
	src/gui/DatabaseWidget.cpp
	src/gui/EditWidget.cpp
	src/gui/MainWindow.cpp
	src/gui/MainWindow.ui
	src/proxy/NativeMessagingHost.h
	src/sshagent/ASN1Key.cpp
2018-08-24 09:42:38 -04:00
Jonathan White
41ebc10c03 Corrects ordering of command/opts in cli manpage 2018-07-25 12:59:55 +02:00
seregaxvm
e124f17c64 Add advanced password generator features (#1841)
* Split between simple and advanced features
* Finetune password character groups
* Support for hex passwords
2018-06-10 22:37:09 -04:00
Louis-Bertrand Varin
8324d03f0a Formatting the code. 2018-03-31 16:01:30 -04:00
thez3ro
1bfbb9242c
fix cli commands, translations and codestyle 2018-02-07 17:35:20 +01:00
thez3ro
33b95836b9
update cli manpage 2018-02-07 17:35:20 +01:00
thez3ro
4782b20d61
renamed passgen to generate and use diceware default wordcount 2018-02-07 17:35:20 +01:00
thez3ro
e57a2e0fa9
add default charset when not specified
explicitly state the wordcount default value
2018-02-07 17:35:20 +01:00
thez3ro
e9612ee9e6
use default password lenght + minor fixes 2018-02-07 17:35:20 +01:00
thez3ro
27f8aa095a
add diceware and passgen to the cli interface 2018-02-07 17:35:20 +01:00
Janek Bevendorff
8da3efa2c2 Add disambiguation info to source strings 2018-01-21 15:54:46 +01:00
Janek Bevendorff
871332ecf0 Add warning when using legacy key file formats. 2018-01-14 18:26:28 -05:00
Janek Bevendorff
a6ddc22fb8
Refactor database readers/writers and XML handling
* Refactor Kdbx*Reader
* Refactor KdbxWriter
* Refactor KdbxXmlReader
* Refactor KdbxXmlWriter
2018-01-13 14:24:58 -05:00
Jonathan White
542ee42313
Add Argon2Kdf and enable parameters in db settings
Note: This implementation is not yet connected to the
database itself and will corrupt existing kdbx3 db's.

* Implemented memory and parallelism parameters for Argon2Kdf
* Using libargon2; libsodium does not support Argon2d algorithm
* Moved basic rounds parameter into Kdf class
* Reimplemented benchmark algorithm; previous was utterly broken
2018-01-13 14:23:30 -05:00
Aleksa Sarai
9f8943c89b keepassxc-cli show: resolve references in output (#1280)
* core: database: make UUID searching case-insensitive

4c4d8a5e84 ("Implement search for reference placeholder based on
fields other than ID") changed the semantics of searching-by-reference
in KeePassXC. Unforuntately it contained a bug where it implicitly
became case-sensitive to UUIDs, which broke existing databases that used
references (especially since the default reference format uses a
different case to the UUID used while searching).

The tests didn't catch this because ->toHex() preserves the case that it
was provided, they have been updated to check that UUIDs are case
insensitive.

* cli: show: resolve references in output

Previously, `keepassxc-cli show` would not resolve references. This
would make it quite hard to script around its output (since there's not
interface to resolve references manually either). Fix this by using
resolveMultiplePlaceholders as with all other users of ->password() and
related entry fields.

Fixes: keepassxreboot/keepassxc#1260

* tests: entry: add tests for ref-cloned entries

This ensures that the most "intuitive" current usage of references
(through the clone feature of the GUI) remains self-consistent and
always produces the correct results. In addition, explicitly test that
case insensitivity works as expected. These should avoid similar
regressions in reference handling in the future.

* http: resolve references in AccessControlDialog

The access control dialog previously would not show the "real" username
or "real" title when asking for permission to give access to entries.
Fix this by resolving it, as we do in many other places.

Fixes: keepassxreboot/keepassxc#1269


Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2017-12-17 10:44:12 -05:00
Aleksa Sarai
8e231dfa95 cli: show: add --attributes flag (#1289)
In order for scripting to be much simpler with `keepassxc-cli show`,
provide a simple --attributesk API which effectively is just a CLI
interface for entry->attributes()->value(...). This allows for more
extensibility and prevents changes in our output formatting from
breaking existing users of keepassxc-cli (if they use --attributes).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2017-12-16 19:14:39 -05:00
louib
8b1c8f69f7
Removing password output from Estimate. (#1281)
* Removing password output from Estimate.

* clang-format
2017-12-14 20:22:59 -05:00
louib
471e684151
Rename EntropyMeter -> Estimate (#1250)
* EntropyMeter -> Estimate
* Cleaning estimate
* Documentation
* clang-formatting /cli
2017-12-04 09:46:23 -05:00
Yen Chi Hsuan
5a18b8de77 Use CMake's variable instead of hardcoded path to install man pages 2017-09-24 09:26:25 -04:00
louib
6e1fd0694f CLI : basic entry manipulation commands. (#919)
* CLI : basic entry manipulation commands.

* Code review.
2017-09-06 09:14:41 -04:00
Louis-Bertrand Varin
0987521cd3 Adding reporting bugs section. 2017-08-22 17:16:59 -04:00
louib
8b46feb085 Adding manpage 2017-08-22 09:57:10 -04:00
louib
b2107b5e27 Adding Locate command. (#829)
* Adding Locate command.

* Adding group searching in locate
2017-08-05 12:20:26 -04:00
louib
b4dcfd650a Normalizing translated messages in Extract. 2017-08-01 17:04:47 -04:00
Yen Chi Hsuan
23b818f9e6 Support --key-file in keepassxc-cli extract (#824) 2017-08-01 16:57:19 -04:00
louib
1d30283514 Feature : --key-file option for CLI (#816)
* removing readFromLine

* Removing gui-prompt

* execute uses an arg list.

* Testing with key-file

* Fixing the -a option in EntropyMeter.
2017-07-25 13:41:52 -04:00
louib
1edabc4b3c Feature : Clip command using native programs. (#792)
* Adding a timeout option
* Using native apps.
* Renaming PasswordInput -> Utils
2017-07-22 19:40:30 -04:00
louib
3b23e68540 Refactoring : Introducing Command class for CLI commands (#778) 2017-07-17 15:16:53 -04:00
Julian Andres Klode
34ff6d5f6b Change from ZXCVBN_FOUND to ZXCVBN_LIBRARIES to be aligned with other libraries 2017-06-28 15:19:09 +02:00
Gianfranco Costamagna
640b09c6b2 Add code to detect a system library for zxcvbn, with fallback to the embedded one in case it is not found 2017-06-28 15:13:57 +02:00
louib
fdbed324f7 Outputing newline after password prompt. (#659) 2017-06-22 16:25:24 -04:00
louib
95baf25648 failure when showing help (#658) 2017-06-21 19:09:44 -04:00
louib
48ea024d7e Adding support for listing a group. (#652)
* Adding support for listing a group.

* added findGroupByPath

* Removing useless asserts.

* Code review.
2017-06-21 17:34:49 -04:00
Weslly
400073c7cc Disable stdin echo when entering passwords on cli 2017-06-21 11:15:59 -03:00
louib
344235b1e1 Fix CLI help and version options. (#650)
* Correct handling of --help and --version

* Moving arguments building up.

* Only manipulating argv is the command is valid.

* Not a failure when --help

* Not using showVersion()
2017-06-19 11:09:19 -04:00
louib
b75b9fb7d6 Adding gui prompt to List command. (#643) 2017-06-18 14:43:02 -04:00
Louis-Bertrand Varin
46f7d97176 Using saveToFile in Merge command. 2017-06-14 20:00:09 -04:00
thez3ro
a53b111182
Update and fix copyright headers 2017-06-14 15:54:43 +02:00
louib
dcc8094ce4 Add the GUI prompt option to the merge command. (#589) 2017-05-25 13:07:24 -04:00
louib
c3bd5d21aa Adding a GUI prompt for password. (#587) 2017-05-22 17:53:41 -04:00
louib
54ad927044 Moving print group in Group class. (#586) 2017-05-21 13:05:44 -04:00
louib
a2e82dc883 Feature : clip command (#578) 2017-05-19 14:04:11 -04:00
thez3ro
558c75a452
Add ASAN to keepassxc-cli 2017-03-16 18:41:12 +01:00
Louis-Bertrand Varin
a661c17eca Adding group uuid to list. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
fd9d372e6a Adding second prompt for merge. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
cf23343911 Using openDatabaseFile in List. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
780e23301b Using openDatabaseFile in Merge. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
993f90cb2c Extracting openDatabaseFile. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
db1bf88934 Handling entry not found. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
15c2727a1d Adding the show command. 2017-03-16 10:09:50 -04:00
thez3ro
e01e9715b9 text for inserting password 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
98911af396 Fixed indentation. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
f579345059 Change cli commands description. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
64dfada038 Adding available commands. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
7ca475f968 Add list to keepassxc-cli 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
7636a559f9 Remove unused imports. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
b85941531d Keepass -> KeePass. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
782d1f17d1 Using ++argv 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
e1e8f33f67 Install path on Mac. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
805600ad44 Installing keepassxc-cli executable. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
342d49d050 Missing zxcvbn dependency. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
992d8a90c7 Migrate entropy-meter to keepassxc-cli 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
9b92e7f8e8 Use EXIT_FAILURE/SUCCESS 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
bf9b23539e Add dependency + adjust styling. 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
9cfc862b07 Disable core dumps (keepassxc-cli). 2017-03-16 10:09:50 -04:00
Louis-Bertrand Varin
52991f3d66 Add first keepassxc-cli version. 2017-03-16 10:09:50 -04:00