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