fix compiler warnings
This commit is contained in:
		| @@ -2,10 +2,6 @@ use std::error::Error; | ||||
| use std::time::Duration; | ||||
|  | ||||
| use once_cell::sync::OnceCell; | ||||
| use rfd::{ | ||||
|     MessageDialog, | ||||
|     MessageLevel, | ||||
| }; | ||||
| use sqlx::{ | ||||
|     SqlitePool, | ||||
|     sqlite::SqlitePoolOptions, | ||||
|   | ||||
| @@ -1,13 +0,0 @@ | ||||
| use ssh_key::private::PrivateKey; | ||||
|  | ||||
|  | ||||
| fn main() { | ||||
|     // let passphrase = std::env::var("PRIVKEY_PASSPHRASE").unwrap(); | ||||
|     let p = AsRef::<std::path::Path>::as_ref("/home/joe/.ssh/test"); | ||||
|     let privkey = PrivateKey::read_openssh_file(p) | ||||
|         .unwrap(); | ||||
|         // .decrypt(passphrase.as_bytes()) | ||||
|         // .unwrap(); | ||||
|  | ||||
|     dbg!(String::from_utf8_lossy(&privkey.to_bytes().unwrap())); | ||||
| } | ||||
| @@ -1,6 +1,12 @@ | ||||
| use std::path::{Path, PathBuf}; | ||||
|  | ||||
| use sysinfo::{System, SystemExt, Pid, PidExt, Process, ProcessExt}; | ||||
| use sysinfo::{ | ||||
|     System, | ||||
|     SystemExt, | ||||
|     Pid, | ||||
|     PidExt, | ||||
|     ProcessExt | ||||
| }; | ||||
| use serde::{Serialize, Deserialize}; | ||||
|  | ||||
| use crate::errors::*; | ||||
|   | ||||
| @@ -1,12 +1,10 @@ | ||||
| use serde::{Serialize, Deserialize}; | ||||
| use sqlx::{ | ||||
|     Encode, | ||||
|     FromRow, | ||||
|     Sqlite, | ||||
|     SqlitePool, | ||||
|     sqlite::SqliteRow, | ||||
|     Transaction, | ||||
|     Type, | ||||
|     types::Uuid, | ||||
| }; | ||||
| use tokio_stream::StreamExt; | ||||
|   | ||||
| @@ -26,6 +26,7 @@ use super::{ | ||||
|  | ||||
|  | ||||
| #[derive(Debug, Clone, FromRow)] | ||||
| #[allow(dead_code)] | ||||
| struct CredentialRow { | ||||
|     id: Uuid, | ||||
|     name: String, | ||||
| @@ -111,15 +112,15 @@ impl CredentialRecord { | ||||
|         Ok(Self::from_parts(row, credential)) | ||||
|     } | ||||
|  | ||||
|     pub async fn load(id: &Uuid, crypto: &Crypto, pool: &SqlitePool) -> Result<Self, LoadCredentialsError> { | ||||
|         let row: CredentialRow = sqlx::query_as("SELECT * FROM credentials WHERE id = ?") | ||||
|             .bind(id) | ||||
|             .fetch_optional(pool) | ||||
|             .await? | ||||
|             .ok_or(LoadCredentialsError::NoCredentials)?; | ||||
|     // pub async fn load(id: &Uuid, crypto: &Crypto, pool: &SqlitePool) -> Result<Self, LoadCredentialsError> { | ||||
|     //     let row: CredentialRow = sqlx::query_as("SELECT * FROM credentials WHERE id = ?") | ||||
|     //         .bind(id) | ||||
|     //         .fetch_optional(pool) | ||||
|     //         .await? | ||||
|     //         .ok_or(LoadCredentialsError::NoCredentials)?; | ||||
|  | ||||
|         Self::load_credential(row, crypto, pool).await | ||||
|     } | ||||
|     //     Self::load_credential(row, crypto, pool).await | ||||
|     // } | ||||
|  | ||||
|     pub async fn load_default(credential_type: &str, crypto: &Crypto, pool: &SqlitePool) -> Result<Self, LoadCredentialsError> { | ||||
|         let row: CredentialRow = sqlx::query_as( | ||||
|   | ||||
| @@ -97,24 +97,4 @@ impl AppSession { | ||||
|             Self::Unlocked {crypto, ..} => Ok(crypto), | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pub fn try_encrypt(&self, data: &[u8]) -> Result<(XNonce, Vec<u8>), GetCredentialsError> { | ||||
|         let crypto = match self { | ||||
|             Self::Empty => return Err(GetCredentialsError::Empty), | ||||
|             Self::Locked {..} => return Err(GetCredentialsError::Locked), | ||||
|             Self::Unlocked {crypto, ..} => crypto, | ||||
|         }; | ||||
|         let res = crypto.encrypt(data)?; | ||||
|         Ok(res) | ||||
|     } | ||||
|  | ||||
|     pub fn try_decrypt(&self, nonce: XNonce, data: &[u8]) -> Result<Vec<u8>, GetCredentialsError> { | ||||
|         let crypto = match self { | ||||
|             Self::Empty => return Err(GetCredentialsError::Empty), | ||||
|             Self::Locked {..} => return Err(GetCredentialsError::Locked), | ||||
|             Self::Unlocked {crypto, ..} => crypto, | ||||
|         }; | ||||
|         let res = crypto.decrypt(&nonce, data)?; | ||||
|         Ok(res) | ||||
|     } | ||||
| } | ||||
| @@ -1,5 +1,4 @@ | ||||
| use std::fmt::{self, Formatter}; | ||||
| use std::path::PathBuf; | ||||
|  | ||||
| use chacha20poly1305::XNonce; | ||||
| use serde::{ | ||||
| @@ -9,7 +8,6 @@ use serde::{ | ||||
|     Serializer, | ||||
| }; | ||||
| use serde::ser::{ | ||||
|     self, | ||||
|     Error as SerError, | ||||
|     SerializeStruct, | ||||
| }; | ||||
|   | ||||
| @@ -44,12 +44,12 @@ pub async fn load_bytes(pool: &SqlitePool, name: &str) -> Result<Option<Vec<u8>> | ||||
| } | ||||
|  | ||||
|  | ||||
| pub async fn delete(pool: &SqlitePool, name: &str) -> Result<(), sqlx::Error> { | ||||
|     sqlx::query!("DELETE FROM kv WHERE name = ?", name) | ||||
|         .execute(pool) | ||||
|         .await?; | ||||
|     Ok(()) | ||||
| } | ||||
| // pub async fn delete(pool: &SqlitePool, name: &str) -> Result<(), sqlx::Error> { | ||||
| //     sqlx::query!("DELETE FROM kv WHERE name = ?", name) | ||||
| //         .execute(pool) | ||||
| //         .await?; | ||||
| //     Ok(()) | ||||
| // } | ||||
|  | ||||
|  | ||||
| pub async fn delete_multi(pool: &SqlitePool, names: &[&str]) -> Result<(), sqlx::Error> {     | ||||
|   | ||||
| @@ -19,7 +19,6 @@ use tokio_stream::StreamExt; | ||||
| use tokio::sync::oneshot; | ||||
|  | ||||
| use crate::clientinfo; | ||||
| use crate::credentials::{Credential, SshKey}; | ||||
| use crate::errors::*; | ||||
| use crate::ipc::{Approval, RequestNotification}; | ||||
| use crate::state::AppState; | ||||
| @@ -129,7 +128,7 @@ async fn sign_request(req: SignRequest, app_handle: AppHandle, client_pid: u32) | ||||
|     }; | ||||
|  | ||||
|     let res = proceed.await; | ||||
|     if let Err(e) = &res { | ||||
|     if let Err(_) = &res { | ||||
|         state.unregister_request(request_id).await; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -273,11 +273,12 @@ impl AppState { | ||||
|     pub async fn get_aws_default(&self) -> Result<AwsBaseCredential, GetCredentialsError> { | ||||
|         let app_session = self.app_session.read().await; | ||||
|         let crypto = app_session.try_get_crypto()?; | ||||
|         let record = CredentialRecord::load_default("aws", crypto, &self.pool).await?; | ||||
|         let creds = match record.credential { | ||||
|             Credential::AwsBase(b) => Ok(b), | ||||
|             _ => Err(LoadCredentialsError::NoCredentials) | ||||
|         }?; | ||||
|         let creds = AwsBaseCredential::load_default(crypto, &self.pool).await?; | ||||
|         // let record = CredentialRecord::load_default("aws", crypto, &self.pool).await?; | ||||
|         // let creds = match record.credential { | ||||
|         //     Credential::AwsBase(b) => Ok(b), | ||||
|         //     _ => Err(LoadCredentialsError::NoCredentials) | ||||
|         // }?; | ||||
|         Ok(creds) | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user