diff --git a/apps/desktop/desktop_native/core/src/biometric/linux.rs b/apps/desktop/desktop_native/core/src/biometric/linux.rs index 0e159e268da..d0131f160bb 100644 --- a/apps/desktop/desktop_native/core/src/biometric/linux.rs +++ b/apps/desktop/desktop_native/core/src/biometric/linux.rs @@ -55,7 +55,10 @@ impl super::BiometricTrait for BiometricLockSystem { } async fn provide_key(&self, user_id: &str, key: &[u8]) { - self.secure_memory.lock().await.put(user_id.to_string(), key); + self.secure_memory + .lock() + .await + .put(user_id.to_string(), key); } async fn unlock(&self, user_id: &str, _hwnd: Vec) -> Result> { @@ -63,7 +66,11 @@ impl super::BiometricTrait for BiometricLockSystem { return Err(anyhow!("Authentication failed")); } - self.secure_memory.lock().await.get(user_id).ok_or(anyhow!("No key found")) + self.secure_memory + .lock() + .await + .get(user_id) + .ok_or(anyhow!("No key found")) } async fn unlock_available(&self, user_id: &str) -> Result { @@ -130,4 +137,4 @@ mod tests { let result = polkit_authenticate_bitwarden_policy().await; assert!(result.is_ok()); } -} \ No newline at end of file +} diff --git a/apps/desktop/desktop_native/core/src/biometric/windows.rs b/apps/desktop/desktop_native/core/src/biometric/windows.rs index f4b94dc5b67..5d770a2d672 100644 --- a/apps/desktop/desktop_native/core/src/biometric/windows.rs +++ b/apps/desktop/desktop_native/core/src/biometric/windows.rs @@ -189,7 +189,10 @@ impl super::BiometricTrait for BiometricLockSystem { /// Get a yes/no authorization without any cryptographic backing. /// This API has better focusing behavior fn windows_hello_authenticate(message: String) -> Result { - println!("[Windows Hello] Authenticating to perform UV with message: {}", message); + println!( + "[Windows Hello] Authenticating to perform UV with message: {}", + message + ); // Windows Hello prompt must be in foreground, focused, otherwise the face or fingerprint // unlock will not work. We get the current foreground window, which will either be the // Bitwarden desktop app or the browser extension. @@ -218,7 +221,10 @@ fn windows_hello_authenticate(message: String) -> Result { /// /// Note: This API has inconsistent focusing behavior when called from another window fn windows_hello_authenticate_with_crypto(challenge: &[u8; 16]) -> Result<[u8; 32]> { - println!("[Windows Hello] Authenticating to sign challenge: {:?}", challenge); + println!( + "[Windows Hello] Authenticating to sign challenge: {:?}", + challenge + ); // Ugly hack: We need to focus the window via window focusing APIs until Microsoft releases a new API. // This is unreliable, and if it does not work, the operation may fail let stop_focusing = Arc::new(AtomicBool::new(false)); diff --git a/apps/desktop/desktop_native/core/src/secure_memory/dpapi.rs b/apps/desktop/desktop_native/core/src/secure_memory/dpapi.rs index aace607abb0..d2d51bb9cf0 100644 --- a/apps/desktop/desktop_native/core/src/secure_memory/dpapi.rs +++ b/apps/desktop/desktop_native/core/src/secure_memory/dpapi.rs @@ -119,7 +119,12 @@ mod tests { let value: Vec = (0..size).map(|i| (i % 256) as u8).collect(); store.put(key.clone(), &value); assert!(store.has(&key), "Store should have key for size {}", size); - assert_eq!(store.get(&key), Some(value), "Value mismatch for size {}", size); + assert_eq!( + store.get(&key), + Some(value), + "Value mismatch for size {}", + size + ); } } diff --git a/apps/desktop/desktop_native/core/src/secure_memory/memfd_secret.rs b/apps/desktop/desktop_native/core/src/secure_memory/memfd_secret.rs index c7057fcd332..df6286e6b89 100644 --- a/apps/desktop/desktop_native/core/src/secure_memory/memfd_secret.rs +++ b/apps/desktop/desktop_native/core/src/secure_memory/memfd_secret.rs @@ -9,7 +9,7 @@ use crate::secure_memory::SecureMemoryStore; /// data is inaccessible to other user-mode processes, and even to root in most cases. /// If arbitrary data can be executed in the kernel, the data can still be retrieved: /// https://github.com/JonathonReinhart/nosecmem -/// +/// /// Warning: There is a maximum amount of concurrent memfd_secret protected items. Only /// use this sparingly, or extend the implementation to use one secret + in-memory encryption, /// or to reserve a large protected area in which we allocate our items. @@ -97,7 +97,7 @@ pub(super) fn is_supported() -> bool { #[cfg(test)] mod tests { use super::*; - + #[test] fn test_memfd_secret_kv_store_various_sizes() { let mut store = MemfdSecretKVStore::new(); @@ -106,7 +106,12 @@ mod tests { let value: Vec = (0..size).map(|i| (i % 256) as u8).collect(); store.put(key.clone(), &value); assert!(store.has(&key), "Store should have key for size {}", size); - assert_eq!(store.get(&key), Some(value), "Value mismatch for size {}", size); + assert_eq!( + store.get(&key), + Some(value), + "Value mismatch for size {}", + size + ); // The test will not pass when we don't remove the keys, because there is a limit of concurrent memfd_secret memory spaces. store.remove(&key); }