From 343e613960c17c46ac0598c6eabed65016a98cbd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2020 13:37:50 +0000 Subject: [PATCH 1/2] Bump secrecy from 0.6.0 to 0.7.0 Bumps [secrecy](https://github.com/iqlusioninc/crates) from 0.6.0 to 0.7.0. - [Release notes](https://github.com/iqlusioninc/crates/releases) - [Commits](https://github.com/iqlusioninc/crates/compare/secrecy/v0.6.0...secrecy/v0.7.0) Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- primitives/core/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c2e9cda8f31c4..c6796036494d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7759,9 +7759,9 @@ dependencies = [ [[package]] name = "secrecy" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9182278ed645df3477a9c27bfee0621c621aa16f6972635f7f795dae3d81070f" +checksum = "0673d6a6449f5e7d12a1caf424fd9363e2af3a4953023ed455e3c4beef4597c0" dependencies = [ "zeroize", ] diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index f6989a0df4f0f..5044a1d669137 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -30,7 +30,7 @@ tiny-bip39 = { version = "0.8", optional = true } regex = { version = "1.3.1", optional = true } num-traits = { version = "0.2.8", default-features = false } zeroize = { version = "1.0.0", default-features = false } -secrecy = { version = "0.6.0", default-features = false } +secrecy = { version = "0.7.0", default-features = false } lazy_static = { version = "1.4.0", default-features = false, optional = true } parking_lot = { version = "0.10.0", optional = true } sp-debug-derive = { version = "2.0.0", path = "../debug-derive" } From b10a1fd547c496b992714ce71dc330770499ea56 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 20 Nov 2020 15:06:13 +0100 Subject: [PATCH 2/2] Fix compilation errors --- client/cli/src/params/keystore_params.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/client/cli/src/params/keystore_params.rs b/client/cli/src/params/keystore_params.rs index 3c04d63144595..2ecd21cb3dd00 100644 --- a/client/cli/src/params/keystore_params.rs +++ b/client/cli/src/params/keystore_params.rs @@ -22,8 +22,7 @@ use std::fs; use std::path::PathBuf; use structopt::StructOpt; use crate::error; -use sp_core::crypto::{SecretString, Zeroize}; -use std::str::FromStr; +use sp_core::crypto::SecretString; /// default sub directory for the key store const DEFAULT_KEYSTORE_CONFIG_PATH: &'static str = "keystore"; @@ -72,21 +71,15 @@ impl KeystoreParams { let password = if self.password_interactive { #[cfg(not(target_os = "unknown"))] { - let mut password = input_keystore_password()?; - let secret = std::str::FromStr::from_str(password.as_str()) - .map_err(|()| "Error reading password")?; - password.zeroize(); - Some(secret) + let password = input_keystore_password()?; + Some(SecretString::new(password)) } #[cfg(target_os = "unknown")] None } else if let Some(ref file) = self.password_filename { - let mut password = fs::read_to_string(file) + let password = fs::read_to_string(file) .map_err(|e| format!("{}", e))?; - let secret = std::str::FromStr::from_str(password.as_str()) - .map_err(|()| "Error reading password")?; - password.zeroize(); - Some(secret) + Some(SecretString::new(password)) } else { self.password.clone() }; @@ -104,10 +97,8 @@ impl KeystoreParams { let (password_interactive, password) = (self.password_interactive, self.password.clone()); let pass = if password_interactive { - let mut password = rpassword::read_password_from_tty(Some("Key password: "))?; - let pass = Some(FromStr::from_str(&password).map_err(|()| "Error reading password")?); - password.zeroize(); - pass + let password = rpassword::read_password_from_tty(Some("Key password: "))?; + Some(SecretString::new(password)) } else { password };