1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-05 11:13:44 +00:00

Run cargo fmt

This commit is contained in:
Bernd Schoolmann
2025-08-29 15:21:08 +02:00
parent e53665bc69
commit 82efdee1b3
4 changed files with 32 additions and 9 deletions

View File

@@ -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<u8>) -> Result<Vec<u8>> {
@@ -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<bool> {
@@ -130,4 +137,4 @@ mod tests {
let result = polkit_authenticate_bitwarden_policy().await;
assert!(result.is_ok());
}
}
}

View File

@@ -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<bool> {
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<bool> {
///
/// 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));

View File

@@ -119,7 +119,12 @@ mod tests {
let value: Vec<u8> = (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
);
}
}

View File

@@ -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<u8> = (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);
}