aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
...
* Remove warning for missing_copy_implementations lintDaniel Mueller2020-09-01
| | | | | | | The missing_copy_implementations lint is arguably not super useful in an application crate, where no third party is consuming the type definitions. As such, this change removes it from the list of lints causing warnings.
* Update syn and proc-macro2 dependenciesRobin Krahl2020-09-05
| | | | | This change updates the syn dependency we consume to 1.0.36 and proc-macro2 to 1.0.19.
* Remove application global Result definitionDaniel Mueller2020-08-31
| | | | | | | In the past we were using an application global custom Result type definition. This makes less sense now that we switched over to using anyhow's Error and Result types. We kept that for the time being, but with this change we remove the type and use anyhow::Result instead.
* Remove no longer used error moduleDaniel Mueller2020-08-31
| | | | | | This change removes the error module. This module, and the Error type it homes, are no longer used by the application, as everything has been transitioned over to using anyhow's Error type.
* Remove no longer necessary msg parameter from try_with_* functionsDaniel Mueller2020-08-29
| | | | | | | | | With the move to using anyhow's Error type and adding contextual information at the point where we bubble up errors, we no longer require the 'msg' argument that is passed to the try_with_pin_* and authenticate functions. To that end, this change removes this parameter, concluding the switch to using anyhow.
* Use anyhow for error handlingDaniel Mueller2020-08-28
| | | | | | | | | | | This patch changes our error handling approach from the ground up: instead of having a globally used Error enum that contains variants for all possible errors, we now use anyhow's Error type. This approach is more dynamic (and not statically typed), but it allows for more fine grained error messages and overall more user-friendly error reporting. Overall it also is a net simplification. While we have one dynamic cast now, in order to be able to handle erroneous password/PIN entries correctly, that is considered a reasonable compromise.
* Update nitrokey dependency to 0.7.1Daniel Mueller2020-07-17
| | | | | | | | | This change updates the nitrokey dependency we consume to 0.7.1. With this version the crate's Error type got reworked slightly, allowing it to implement Sync and Send. It furthermore no longer duplicates information available through the source() method in its Display implementation. Both these changes will enable us to switch over to using the anyhow crate for error handling in nitrocli in the future.
* Update nitrokey-test dependency to 0.4.0Daniel Mueller2020-07-15
| | | | This change updates the nitrokey-test development dependency to 0.4.0.
* Update minimum required Rust version to 1.42.0Daniel Mueller2020-07-10
| | | | | | This change updates the minimum required version of Rust to 1.42.0. We will need this version in order to make use of the most recent version of nitrokey-test.
* Refrain from using Error::Error variant in pinentry testsDaniel Mueller2020-07-09
| | | | | | | | The pinentry tests currently expect the Error::Error variant to be reported for failures. This patch adjusts the tests to merely compare strings and ignore the exact type of error. Doing so will make it easier to switch to using anyhow for error handling.
* Remove UnwrapError test traitDaniel Mueller2020-07-09
| | | | | | This change wraps up the removal of the UnwrapError test trait. This step prepares us for the subsequent removal of the application's global Error enum type, in favor of the usage of anyhow's Error type.
* Remove unwrap_lib_err method from UnwrapError test traitDaniel Mueller2020-07-09
| | | | | This change marks the next step in getting rid of the UnwrapError test trait. Specifically, it removes its unwrap_lib_err method.
* Remove unwrap_str_err method from UnwrapError test traitDaniel Mueller2020-07-08
| | | | | | | | | | With upcoming changes we intend to move towards a model where we do not distinguish the individual error variants the program deals with in a global enum. In preparation of such a change, this patch marks a first step in removing the UnwrapError test trait, which relies on the existence of exactly such typed errors. In particular, we remove the unwrap_str_err method from it, basically falling back to just working with strings.
* Change default OTP format to base32Daniel Mueller2020-07-07
| | | | | | | | | | | An arguably unrepresentative survey of services (GitHub, Google Authenticator, and Bitbucket) seems to suggests that the base32 format is the de-facto standard format for OTP secrets. Given that it's not necessarily obvious what format a secret is in and that most services refrain from mentioning it explicitly, having the correct default format is fairly important. With this change we switch the default format from hexadecimal to base32 to accommodate for this finding.
* Fix binary-sizes.py scriptDaniel Mueller2020-07-26
| | | | | | | A while back we removed the nitrocli/ directory in the repository root. Unfortunately, we missed that the binary-sizes.py script relied on the previous directory structure. This change adjusts the script to work with the new structure.
* Correctly use doc comments in macrosDaniel Mueller2020-07-03
| | | | | | | | | | | | | | | | Our custom macros for conveniently creating types with additional meta information for working with structopt do not actually use the doc comments we have in place -- these comments are solely for in-source documentation. We are an application and as such crates.io will not automatically generate documentation. All of that does not deter rustc from complaining that doc comments are unused. In the past we tried to fudge that by adding a special allowance, #[allow(unused_doc_comments)], but that seems to have seized to work. With this change we finally give in and move the doc comment into the macro itself, where it will be used to annotate the generated type. This step should hopefully silence rustc once and for all -- at the expense of a slight decrease in readability.
* Bump version to 0.3.3v0.3.3Daniel Mueller2020-04-19
| | | | | | | | | | | This change bumps the version of the crate to 0.3.3. The following notable changes have been made since 0.3.2: - Added bash completion support via shell-complete utility program - Updated minimum required Rust version to 1.40.0 - Converted Cargo.lock to new lock file format - Bumped libc dependency to 0.2.69 - Bumped structopt dependency to 0.3.13 - Bumped various transitive dependencies to most recent versions
* Convert Cargo.lock to new lock file formatDaniel Mueller2020-04-16
| | | | | | | | | Since version 1.38.0 of Rust, Cargo has built in support for a new lock file format that aims at reducing merge conflicts of unrelated changes. Given that we require an even more recent version of Rust, it seems safe to switch over to this new format (which by now is the default for new projects anyway). This patch changes the format of Cargo.lock accordingly.
* Update transitive nitrokey dependenciesDaniel Mueller2020-04-15
| | | | | This change updates transitive dependencies of the nitrokey crate to their most recent versions.
* Update regex dependency to 1.3.7Daniel Mueller2020-04-14
| | | | | This change updates the regex crate to version 1.3.7. Transitive dependencies are updated as well.
* Update structopt dependency to 0.3.13Daniel Mueller2020-04-13
| | | | | This change updates the structopt crate to version 0.3.13. Transitive dependencies are updated as well.
* Update libc dependency to 0.2.69Daniel Mueller2020-04-12
| | | | This change updates the libc crate to version 0.2.69.
* Rename arg_defs.rs to args.rsDaniel Mueller2020-04-11
| | | | | | We have never been fully satisfied with the name arg_defs. Now that we have gotten rid of the formerly used args module, this change renames arg_defs to args.
* Merge remaining bits of args.rs into main.rsDaniel Mueller2020-04-11
| | | | | | This change removes the args module by moving all remaining functionality in it into main.rs. The result is arguably a nice consolidation of all context related definitions in a single module.
* Merge config_set function into commands.rsDaniel Mueller2020-04-11
| | | | | | As a next step moving us closer towards removing the args module, this change merges the config_set function into the existing function of the same name in the commands module.
* Merge otp_set function into commands.rsDaniel Mueller2020-04-10
| | | | | | | | | Now that we have isolated and separated out structopt specific definitions into a new module, arg_defs, args.rs is actually so small that we do not want to keep it around any longer. This change marks a first step moving us closer towards removing it. Specifically, it merges the otp_set function from args.rs into the function of the same name in commands.rs.
* Update minimum required Rust version to 1.40.0Daniel Mueller2020-04-05
| | | | | | This change updates the minimum required version of Rust to 1.40.0. Among other changes, this version stabilized std::mem::take, which is something we will use with subsequent changes.
* Add test for bash completion functionalityDaniel Mueller2020-04-05
| | | | | | | | | This change adds a test for the previously introduced bash completion functionality. To test the generated completion script, we spin up a bash instance, source the script, and then perform a completion as the shell would do it. It seems impossible to convince compgen to do the heavy lifting for us and so we invoke the completion function with the expected environment variables present.
* Add support for generating a bash completion scriptDaniel Mueller2020-04-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds support for generating a bash completion script. If sourced, the shell will provide tab completions for the program's arguments. There are two possible approaches provided by clap for going about generating shell completion functionality: either at build time, by separately generating the clap parsers out-of-band, or at run time, as an option to the main program itself. We are generally not too much in favor of a run time approach, as it means less inspectability at installation time and more overhead in the form of code crammed into the main binary. Hence, with this change we take the "build time" approach. Clap recommends hooking the generation up in build.rs, but this seems like an inflexible choice. For one, that is because it would mean unconditionally generating this file or using some user-unfriendly environment variable based approach for making the process conditional. But there is also the fact that specifying the command for which to generate the script should likely be configurable. That is a limitation of the completion script that clap generates (see https://github.com/clap-rs/clap/issues/1764). In our version we provide a utility program that emits the completion script to standard output, accepting regular command line options itself. In doing so we allow for installation time generation of the completion script or installation of the utility itself, the output of which could be sourced on demand -- depending on the user's preference.
* Move dependencies to args and commands modules into generated codeDaniel Mueller2020-04-04
| | | | | | | | | | | We are aiming to rid the arg_defs module of dependencies to the rest of the crate in an attempt to make the file fully free standing. The last remaining references into the crate are used to hook up the functionality backing the respective commands. Luckily for us, this "gluing" of functionality to types is really only required in the macro-generated code (which we do not care about as part of this exercise) and so with this change we remove the use declarations from the top of the file and reference the respective functionality in an absolute manner instead.
* Remove dependency on crate::Error from arg_defsDaniel Mueller2020-04-04
| | | | | | | | | This change removes the need to import crate::Error from the arg_defs module. By dropping this dependency we make the file more independent of the rest of the crate, which subsequently will allow us to merely include! it in another file in order to get the argument related type definitions without compilation errors due to missing symbols from the rest of the crate.
* Move PinType type into arg_defs moduleDaniel Mueller2020-04-02
| | | | | | | | The PinType struct, despite being intended for the pinentry module, is ultimately part of the argument handling definitions. Because our goal is to consolidate all of those in a single file, this change moves the definition of this type from the pinentry module into the newly introduced arg_defs.
* Factor out arg_defs.rs for argument parsing related typesDaniel Mueller2020-04-01
| | | | | | | | This change marks the first step in a restructuring of the argument handling code, the ultimate goal of which is a separation of the type definitions as used by structopt from the logic associated with it. This change in particular introduces a new module, arg_defs, that contains all those type definitions that previously resided in the args module.
* Bump version to 0.3.2v0.3.2Daniel Mueller2020-03-31
| | | | | | | | | | | | | | | | This change bumps the version of the crate to 0.3.2. The following notable changes have been made since 0.3.1: - Added the list command that lists all attached Nitrokey devices - Reworked argument handling: - Added structopt dependency in version 0.3.7 - Replaced argparse with structopt - Removed argparse dependency - Made the --verbose and --model options global - Removed vendored dependencies and moved source code into repository root - Bumped nitrokey dependency to 0.6.0 - Bumped quote dependency to 1.0.3 - Bumped syn dependency to 1.0.14
* Fix link to Nitrokey Storage device in READMEDaniel Mueller2020-03-29
| | | | | | The Nitrokey team changed the URL where details about the Nitrokey Storage device are to be found, rendering our link broken. This change updates the link to reference the new location.
* Update quote dependency to 1.0.3Daniel Mueller2020-03-25
| | | | This change updates the quote crate to version 1.0.3.
* Remove deprecated plugin_as_library lint usageDaniel Mueller2020-03-22
| | | | | | The plugin_as_library lint has been deprecated as of Rust 1.40.0. Hence, with this change we remove it from the list of lints we want to get warnings from.
* Update syn dependency to 1.0.14Daniel Mueller2020-03-16
| | | | This change updates the syn crate to version 1.0.14.
* Update nitrokey dependency to 0.6.0Robin Krahl2020-01-29
| | | | | | nitrokey 0.6.0 introduced the SerialNumber struct (instead of representing serial numbers as strings). We no longer have to manually format the serial number as SerialNumber implements Display.
* doc: Remove options from synopsis in man pageRobin Krahl2020-01-29
| | | | | | | As it is no longer required to set the global options before the command and as we will probably introduce more global options with the next releases, this patch removes the global options from the synopsis line in the man page. See issue #102 for more details.
* Make --verbose and --model options globalRobin Krahl2020-01-26
| | | | | | | | | This patch adds the attribute 'global = true' for the top-level --verbose and --model options, which ensures that they can also be set for subcommands. For example: $ nitrocli status --model pro Instead of only: $ nitrocli --model pro status
* Provide correct mutual exclusion between config set -o and -O optionsDaniel Mueller2020-01-24
| | | | | | | | | | The -o/--otp-pin and -O/--no-otp-pin options to the config set command are supposed to be mutually exclusive, with wrong usage detected by structopt. That is not the case currently, however, because the argument to structopt's conflicts_with attribute is supposed to be the resulting option and not the name of the variable capturing the result. This change fixes the problem by changing the string accordingly.
* Add unit tests for the list commandRobin Krahl2020-01-14
|
* Document the list command in the manpageRobin Krahl2020-01-14
|
* Implement list commandRobin Krahl2020-01-14
| | | | | | | | | | | | | | | This patch implements the list command that lists all attached Nitrokey devices. Currently the Nitrokey Storage does not report its serial number during HID enumeration, see [0]. So if we detect a Nitrokey Storage device, we connect to it and use the get_serial_number function to query its serial number. This can be disabled using the --no-connect option. Note that even the get_serial_number function reports a wrong serial number for the Nitrokey Storage, see [1]. [0] https://github.com/Nitrokey/nitrokey-storage-firmware/issues/88 [1] https://github.com/Nitrokey/nitrokey-storage-firmware/issues/76
* Add scaffolding for the list commandRobin Krahl2020-01-14
| | | | | This patch adds the basic scaffolding for the list command which will list all attached Nitrokey devices.
* Bump nitrokey dependency to version 0.5.1Robin Krahl2020-01-14
| | | | | | This change updates the version of the nitrokey crate that we use to 0.5.1. As part of that, it replaces occurrences of Storage::get_status with Storage::get_storage_status as the method has been renamed.
* Use symbolic default values where possibleDaniel Mueller2020-01-08
| | | | | | | | | | With the switch to using structopt for argument parsing some of the default values have become mere strings, whereas one of our earlier objectives was to have symbolic values where that is possible. As structopt works with symbolic values equally well, this change makes it use those. As a bonus, also list the possible formats for the --format option to the otp set subcommand.
* Do not declare internally used types as pubDaniel Mueller2020-01-08
| | | | | | | | With the recent patch set moving us to using structopt over argparse we introduced all new structs and enums representing subcommands and the like as public. That is unnecessary, as they are not accessed from the outside. This change adjusts the visibility accordingly.
* Remove empty Args structs for simple (sub-)commandsRobin Krahl2020-01-08
| | | | | | Since we updated the Command! macro to also allow enum variants without fields, we no longer need the empty *Args structs for commands or subcommands without arguments or options.