diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-04-06 21:42:35 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-04-06 21:42:35 -0400 |
commit | 8b655f36b868cb023dcdd1ff712de80a59ccbdb1 (patch) | |
tree | dce0912bb14147346ee0fa35f1b971f6364a51bc | |
parent | ca02ec8ca2b24ae7997de80b662cfd3635d75e9e (diff) | |
download | rbw-8b655f36b868cb023dcdd1ff712de80a59ccbdb1.tar.gz rbw-8b655f36b868cb023dcdd1ff712de80a59ccbdb1.zip |
clippy
-rw-r--r-- | src/actions.rs | 6 | ||||
-rw-r--r-- | src/api.rs | 14 | ||||
-rw-r--r-- | src/bin/agent.rs | 2 | ||||
-rw-r--r-- | src/dirs.rs | 3 | ||||
-rw-r--r-- | src/identity.rs | 6 | ||||
-rw-r--r-- | src/lib.rs | 5 | ||||
-rw-r--r-- | src/pinentry.rs | 6 |
7 files changed, 28 insertions, 14 deletions
diff --git a/src/actions.rs b/src/actions.rs index 0998abc..f9b1354 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -7,9 +7,9 @@ pub async fn login( let client = crate::api::Client::new_self_hosted("https://bitwarden.tozt.net"); - let iterations = client.prelogin(&email).await?; + let iterations = client.prelogin(email).await?; let identity = - crate::identity::Identity::new(&email, &password, iterations)?; + crate::identity::Identity::new(email, password, iterations)?; let (access_token, _refresh_token, protected_key) = client .login(&identity.email, &identity.master_password_hash) @@ -25,7 +25,7 @@ pub async fn unlock( protected_key: String, ) -> Result<(Vec<u8>, Vec<u8>)> { let identity = - crate::identity::Identity::new(&email, &password, iterations)?; + crate::identity::Identity::new(email, password, iterations)?; let protected_key = crate::cipherstring::CipherString::new(&protected_key)?; @@ -76,15 +76,23 @@ pub struct Client { identity_url_base: String, } -impl Client { - #[allow(dead_code)] - pub fn new() -> Self { +impl Default for Client { + fn default() -> Self { Self { api_url_base: "https://api.bitwarden.com".to_string(), identity_url_base: "https://identity.bitwarden.com".to_string(), } } +} + +impl Client { + #[allow(dead_code)] + #[must_use] + pub fn new() -> Self { + Self::default() + } + #[must_use] pub fn new_self_hosted(base_url: &str) -> Self { Self { api_url_base: format!("{}/api", base_url), diff --git a/src/bin/agent.rs b/src/bin/agent.rs index b83243e..6b73f56 100644 --- a/src/bin/agent.rs +++ b/src/bin/agent.rs @@ -1,5 +1,3 @@ -extern crate rbw; - use fs2::FileExt as _; use std::io::Write as _; use tokio::io::AsyncBufReadExt as _; diff --git a/src/dirs.rs b/src/dirs.rs index 177ea58..3eb5804 100644 --- a/src/dirs.rs +++ b/src/dirs.rs @@ -1,13 +1,16 @@ +#[must_use] pub fn config_dir() -> std::path::PathBuf { let project_dirs = directories::ProjectDirs::from("", "", "rbw").unwrap(); project_dirs.config_dir().to_path_buf() } +#[must_use] pub fn cache_dir() -> std::path::PathBuf { let project_dirs = directories::ProjectDirs::from("", "", "rbw").unwrap(); project_dirs.cache_dir().to_path_buf() } +#[must_use] pub fn runtime_dir() -> std::path::PathBuf { let project_dirs = directories::ProjectDirs::from("", "", "rbw").unwrap(); project_dirs.runtime_dir().unwrap().to_path_buf() diff --git a/src/identity.rs b/src/identity.rs index 85b4853..69294ca 100644 --- a/src/identity.rs +++ b/src/identity.rs @@ -9,7 +9,7 @@ pub struct Identity { impl Identity { pub fn new(email: &str, password: &str, iterations: u32) -> Result<Self> { - let mut key = vec![0u8; 32]; + let mut key = vec![0_u8; 32]; pbkdf2::pbkdf2::<hmac::Hmac<sha2::Sha256>>( password.as_bytes(), email.as_bytes(), @@ -17,7 +17,7 @@ impl Identity { &mut key, ); - let mut hash = vec![0u8; 32]; + let mut hash = vec![0_u8; 32]; pbkdf2::pbkdf2::<hmac::Hmac<sha2::Sha256>>( &key, password.as_bytes(), @@ -30,7 +30,7 @@ impl Identity { hkdf.expand(b"enc", &mut key) .map_err(|_| Error::HkdfExpand)?; - let mut mac_key = vec![0u8; 32]; + let mut mac_key = vec![0_u8; 32]; hkdf.expand(b"mac", &mut mac_key) .map_err(|_| Error::HkdfExpand)?; @@ -1,3 +1,8 @@ +#![warn(clippy::pedantic)] +#![warn(clippy::nursery)] +#![allow(clippy::missing_errors_doc)] +#![allow(clippy::similar_names)] + pub mod actions; pub mod api; pub mod cipherstring; diff --git a/src/pinentry.rs b/src/pinentry.rs index aced54f..ff778e7 100644 --- a/src/pinentry.rs +++ b/src/pinentry.rs @@ -47,10 +47,10 @@ pub async fn getpin( crate::error::FailedToParsePinentryUtf8 { out: out.clone() }, )?; for line in out_str.lines() { - if line.starts_with("OK") { - continue; - } else if line.starts_with("D ") { + if line.starts_with("D ") { return Ok(line[2..line.len()].to_string()); + } else if !line.starts_with("OK") { + break; } } |