mirror of
https://github.com/bitwarden/browser
synced 2026-01-02 08:33:43 +00:00
Configure clippy (#16194)
Apply the same clippy configuration as we have in sdk-internal. bitwarden/sdk-internal@49f84e6/Cargo.toml#L91-L94 Adds FIXME comments to all existing violations. unwrap is bad as those will resullt in panics and crash the application. Unused async is ignored in napi since that would require changes to the js side which I don't want to deal with.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use anyhow::Result;
|
||||
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn run_command(_value: String) -> Result<String> {
|
||||
todo!("Unix does not support autofill");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use anyhow::Result;
|
||||
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn run_command(_value: String) -> Result<String> {
|
||||
todo!("Windows does not support autofill");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use anyhow::Result;
|
||||
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn set_autostart(_autostart: bool, _params: Vec<String>) -> Result<()> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ use super::{decrypt, encrypt, windows_focus::set_focus};
|
||||
pub struct Biometric {}
|
||||
|
||||
impl super::BiometricTrait for Biometric {
|
||||
// FIXME: Remove unwraps! They panic and terminate the whole application.
|
||||
#[allow(clippy::unwrap_used)]
|
||||
async fn prompt(hwnd: Vec<u8>, message: String) -> Result<bool> {
|
||||
let h = isize::from_le_bytes(hwnd.clone().try_into().unwrap());
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ fn internal_ipc_codec<T: AsyncRead + AsyncWrite>(inner: T) -> Framed<T, LengthDe
|
||||
}
|
||||
|
||||
/// Resolve the path to the IPC socket.
|
||||
// FIXME: Remove unwraps! They panic and terminate the whole application.
|
||||
#[allow(clippy::unwrap_used)]
|
||||
pub fn path(name: &str) -> std::path::PathBuf {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
|
||||
@@ -4,22 +4,26 @@ use security_framework::passwords::{
|
||||
delete_generic_password, get_generic_password, set_generic_password,
|
||||
};
|
||||
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn get_password(service: &str, account: &str) -> Result<String> {
|
||||
let password = get_generic_password(service, account).map_err(convert_error)?;
|
||||
let result = String::from_utf8(password)?;
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn set_password(service: &str, account: &str, password: &str) -> Result<()> {
|
||||
set_generic_password(service, account, password.as_bytes())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn delete_password(service: &str, account: &str) -> Result<()> {
|
||||
delete_generic_password(service, account).map_err(convert_error)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn is_available() -> Result<bool> {
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ use windows::{
|
||||
|
||||
const CRED_FLAGS_NONE: u32 = 0;
|
||||
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn get_password(service: &str, account: &str) -> Result<String> {
|
||||
let target_name = U16CString::from_str(target_name(service, account))?;
|
||||
|
||||
@@ -46,6 +47,7 @@ pub async fn get_password(service: &str, account: &str) -> Result<String> {
|
||||
Ok(password)
|
||||
}
|
||||
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn set_password(service: &str, account: &str, password: &str) -> Result<()> {
|
||||
let mut target_name = U16CString::from_str(target_name(service, account))?;
|
||||
let mut user_name = U16CString::from_str(account)?;
|
||||
@@ -77,6 +79,7 @@ pub async fn set_password(service: &str, account: &str, password: &str) -> Resul
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn delete_password(service: &str, account: &str) -> Result<()> {
|
||||
let target_name = U16CString::from_str(target_name(service, account))?;
|
||||
|
||||
@@ -87,6 +90,7 @@ pub async fn delete_password(service: &str, account: &str) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn is_available() -> Result<bool> {
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ const SCREEN_LOCK_MONITORS: [ScreenLock; 2] = [
|
||||
},
|
||||
];
|
||||
|
||||
// FIXME: Remove unwraps! They panic and terminate the whole application.
|
||||
#[allow(clippy::unwrap_used)]
|
||||
pub async fn on_lock(tx: tokio::sync::mpsc::Sender<()>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let connection = Connection::session().await?;
|
||||
|
||||
@@ -41,6 +43,8 @@ pub async fn on_lock(tx: tokio::sync::mpsc::Sender<()>) -> Result<(), Box<dyn st
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// FIXME: Remove unwraps! They panic and terminate the whole application.
|
||||
#[allow(clippy::unwrap_used)]
|
||||
pub async fn is_lock_monitor_available() -> bool {
|
||||
let connection = Connection::session().await.unwrap();
|
||||
for monitor in SCREEN_LOCK_MONITORS {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn on_lock(_: tokio::sync::mpsc::Sender<()>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn is_lock_monitor_available() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ impl ssh_agent::Agent<peerinfo::models::PeerInfo, BitwardenSshKey>
|
||||
return false;
|
||||
}
|
||||
|
||||
let request_id = self.get_request_id().await;
|
||||
let request_id = self.get_request_id();
|
||||
let request_data = match request_parser::parse_request(data) {
|
||||
Ok(data) => data,
|
||||
Err(e) => {
|
||||
@@ -138,7 +138,7 @@ impl ssh_agent::Agent<peerinfo::models::PeerInfo, BitwardenSshKey>
|
||||
return true;
|
||||
}
|
||||
|
||||
let request_id = self.get_request_id().await;
|
||||
let request_id = self.get_request_id();
|
||||
|
||||
let mut rx_channel = self.get_ui_response_rx.lock().await.resubscribe();
|
||||
let message = SshAgentUIRequest {
|
||||
@@ -263,7 +263,7 @@ impl BitwardenDesktopAgent<BitwardenSshKey> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_request_id(&self) -> u32 {
|
||||
fn get_request_id(&self) -> u32 {
|
||||
if !self.is_running() {
|
||||
println!("[BitwardenDesktopAgent] Agent is not running, but tried to get request id");
|
||||
return 0;
|
||||
|
||||
@@ -26,6 +26,8 @@ pub struct NamedPipeServerStream {
|
||||
}
|
||||
|
||||
impl NamedPipeServerStream {
|
||||
// FIXME: Remove unwraps! They panic and terminate the whole application.
|
||||
#[allow(clippy::unwrap_used)]
|
||||
pub fn new(cancellation_token: CancellationToken, is_running: Arc<AtomicBool>) -> Self {
|
||||
let (tx, rx) = tokio::sync::mpsc::channel(16);
|
||||
tokio::spawn(async move {
|
||||
|
||||
@@ -18,7 +18,7 @@ use crate::ssh_agent::peercred_unix_listener_stream::PeercredUnixListenerStream;
|
||||
use super::{BitwardenDesktopAgent, BitwardenSshKey, SshAgentUIRequest};
|
||||
|
||||
impl BitwardenDesktopAgent<BitwardenSshKey> {
|
||||
pub async fn start_server(
|
||||
pub fn start_server(
|
||||
auth_request_tx: tokio::sync::mpsc::Sender<SshAgentUIRequest>,
|
||||
auth_response_rx: Arc<Mutex<tokio::sync::broadcast::Receiver<(u32, bool)>>>,
|
||||
) -> Result<Self, anyhow::Error> {
|
||||
|
||||
@@ -14,7 +14,7 @@ use tokio_util::sync::CancellationToken;
|
||||
use super::{BitwardenDesktopAgent, BitwardenSshKey, SshAgentUIRequest};
|
||||
|
||||
impl BitwardenDesktopAgent<BitwardenSshKey> {
|
||||
pub async fn start_server(
|
||||
pub fn start_server(
|
||||
auth_request_tx: tokio::sync::mpsc::Sender<SshAgentUIRequest>,
|
||||
auth_response_rx: Arc<Mutex<tokio::sync::broadcast::Receiver<(u32, bool)>>>,
|
||||
) -> Result<Self, anyhow::Error> {
|
||||
|
||||
Reference in New Issue
Block a user