1
0
Fork 0
mirror of https://codeberg.org/tyy/aspm synced 2024-12-22 20:39:29 -07:00

Apply clippy suggestions

This commit is contained in:
Tyler Beckman 2024-02-19 23:07:04 -07:00
parent 1eff198141
commit ac7785a43e
Signed by: Ty
GPG key ID: 2813440C772555A4
8 changed files with 20 additions and 20 deletions

View file

@ -6,17 +6,17 @@ pub mod utils;
#[cfg(test)] #[cfg(test)]
pub(crate) mod test_constants { pub(crate) mod test_constants {
// NOTE: This key is taken from the example keys in RFC 7517 // NOTE: This key is taken from the example keys in RFC 7517
pub(crate) static KEY: &'static str = r#" pub(crate) static KEY: &str = r#"
{"kty":"EC", {"kty":"EC",
"crv":"P-256", "crv":"P-256",
"x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4", "x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
"y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM", "y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
"d":"870MB6gfuTJ4HtUnUvYMyJpr5eUZNP4Bk43bVdj3eAE"} "d":"870MB6gfuTJ4HtUnUvYMyJpr5eUZNP4Bk43bVdj3eAE"}
"#; "#;
pub(crate) static ASPE_URI: &'static str = "aspe:example.com:452JFAI6B3KOLKBAUX3MC73DAU"; pub(crate) static ASPE_URI: &str = "aspe:example.com:452JFAI6B3KOLKBAUX3MC73DAU";
pub(crate) static PROFILE: &'static str = "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiIsImtpZCI6IjQ1MkpGQUk2QjNLT0xLQkFVWDNNQzczREFVIiwiandrIjp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiTUtCQ1ROSWNLVVNEaWkxMXlTczM1MjZpRFo4QWlUbzdUdTZLUEFxdjdENCIsInkiOiI0RXRsNlNSVzJZaUxVck41dmZ2Vkh1aHA3eDhQeGx0bVdXbGJiTTRJRnl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= Anstyle::new()
.fg_color(Some(AnstyleColor::Ansi(AnsiColor::BrightYellow))) .fg_color(Some(AnstyleColor::Ansi(AnsiColor::BrightYellow)))
.render(), .render(),
reset = Reset::default().render() reset = Reset.render()
); );
keys.remove(0) keys.remove(0)
} }
@ -56,7 +56,7 @@ impl AspmSubcommand for KeysDeleteCommand {
if !self.no_confirm { if !self.no_confirm {
// Construct styles // Construct styles
let reset = Reset::default().render(); let reset = Reset.render();
let alias_style = Anstyle::new() let alias_style = Anstyle::new()
.underline() .underline()
.fg_color(Some(anstyle::Color::Ansi(AnsiColor::BrightCyan))) .fg_color(Some(anstyle::Color::Ansi(AnsiColor::BrightCyan)))

View file

@ -84,7 +84,7 @@ impl AspmSubcommand for KeysExportCommand {
style = Anstyle::new() style = Anstyle::new()
.fg_color(Some(AnstyleColor::Ansi(AnsiColor::BrightYellow))) .fg_color(Some(AnstyleColor::Ansi(AnsiColor::BrightYellow)))
.render(), .render(),
reset = Reset::default().render() reset = Reset.render()
); );
keys.remove(0) keys.remove(0)
} }
@ -107,7 +107,7 @@ impl AspmSubcommand for KeysExportCommand {
let aes_key = hash.hash.context("Unable to derive encryption key")?; let aes_key = hash.hash.context("Unable to derive encryption key")?;
let aes_key = &aes_key.as_bytes()[0..32]; let aes_key = &aes_key.as_bytes()[0..32];
if let Ok(decrypted) = Aes256Gcm::new(&Key::<Aes256Gcm>::from_slice(aes_key)) if let Ok(decrypted) = Aes256Gcm::new(Key::<Aes256Gcm>::from_slice(aes_key))
.decrypt((&aes_key[0..12]).into(), key.cipher_text.as_slice()) .decrypt((&aes_key[0..12]).into(), key.cipher_text.as_slice())
{ {
let decrypted = AspKey::from_jwk(Jwk::from_bytes(decrypted)?)?; let decrypted = AspKey::from_jwk(Jwk::from_bytes(decrypted)?)?;

View file

@ -72,7 +72,7 @@ impl AspmSubcommand for KeysGenerateCommand {
let aes_key = hash.hash.context("Unable to derive encryption key")?; let aes_key = hash.hash.context("Unable to derive encryption key")?;
let aes_key = &aes_key.as_bytes()[0..32]; let aes_key = &aes_key.as_bytes()[0..32];
let Ok(cipher_text) = Aes256Gcm::new(&Key::<Aes256Gcm>::from_slice(aes_key)) let Ok(cipher_text) = Aes256Gcm::new(Key::<Aes256Gcm>::from_slice(aes_key))
.encrypt((&aes_key[0..12]).into(), key.jwk.to_string().as_bytes()) .encrypt((&aes_key[0..12]).into(), key.jwk.to_string().as_bytes())
else { else {
bail!("Failure encrypting key") bail!("Failure encrypting key")

View file

@ -21,7 +21,7 @@ pub enum KeyImportFormat {
Jwk, Jwk,
// Imports a PGP key from a local GPG store // Imports a PGP key from a local GPG store
#[cfg(feature = "gpg-compat")] #[cfg(feature = "gpg-compat")]
GPG, Gpg,
} }
/// Imports an ASP from raw JWK format. This only will import JWKs that have supported curves. /// Imports an ASP from raw JWK format. This only will import JWKs that have supported curves.
@ -66,7 +66,7 @@ impl AspmSubcommand for KeysImportCommand {
) )
.context("Unable to convert parsed JWK to an AspKey")?, .context("Unable to convert parsed JWK to an AspKey")?,
#[cfg(feature = "gpg-compat")] #[cfg(feature = "gpg-compat")]
KeyImportFormat::GPG => { KeyImportFormat::Gpg => {
use gpgme::{Context as GpgContext, PassphraseRequest}; use gpgme::{Context as GpgContext, PassphraseRequest};
use sequoia_openpgp::{crypto::mpi, packet::key, parse::Parse, types::Curve}; use sequoia_openpgp::{crypto::mpi, packet::key, parse::Parse, types::Curve};
use std::{io::Write, sync::Arc}; use std::{io::Write, sync::Arc};
@ -249,7 +249,7 @@ impl AspmSubcommand for KeysImportCommand {
let aes_key = &aes_key.as_bytes()[0..32]; let aes_key = &aes_key.as_bytes()[0..32];
let key = Key::<Aes256Gcm>::from_slice(aes_key); let key = Key::<Aes256Gcm>::from_slice(aes_key);
let Ok(cipher_text) = Aes256Gcm::new(&key) let Ok(cipher_text) = Aes256Gcm::new(key)
.encrypt((&aes_key[0..12]).into(), asp_key.jwk.to_string().as_bytes()) .encrypt((&aes_key[0..12]).into(), asp_key.jwk.to_string().as_bytes())
else { else {
bail!("Failure encrypting key") bail!("Failure encrypting key")

View file

@ -22,7 +22,7 @@ impl AspmSubcommand for KeysListCommand {
.context("Unable to read keys from database")?; .context("Unable to read keys from database")?;
// Construct styles // Construct styles
let reset = Reset::default().render(); let reset = Reset.render();
let header_style = Anstyle::new() let header_style = Anstyle::new()
.bold() .bold()
.underline() .underline()

View file

@ -19,14 +19,14 @@ pub trait AspmSubcommand: Parser + Sync {
} }
#[async_trait::async_trait] #[async_trait::async_trait]
pub(self) trait KeysEntityExt { trait KeysEntityExt {
type ResultEnum; type ResultEnum;
/// Queries the database for a specific key entity, first checking by fingerprint and then checking /// Queries the database for a specific key entity, first checking by fingerprint and then checking
async fn query_key(db: &DatabaseConnection, query: &str) -> anyhow::Result<Self::ResultEnum>; async fn query_key(db: &DatabaseConnection, query: &str) -> anyhow::Result<Self::ResultEnum>;
} }
pub(self) enum KeysQueryResult { enum KeysQueryResult {
None, None,
One(KeysModel), One(KeysModel),
Many(Vec<KeysModel>), Many(Vec<KeysModel>),

View file

@ -68,21 +68,21 @@ impl AspmSubcommand for ProfilesCreateCommand {
.interact() .interact()
.context("Unable to prompt on stderr")?) .context("Unable to prompt on stderr")?)
.filter(|x: &String| !x.is_empty()) .filter(|x: &String| !x.is_empty())
.map_or(Ok(None), |string: String| Url::parse(&string).context("Unable to parse avatar URL").map(|url| Some(url)))?, .map_or(Ok(None), |string: String| Url::parse(&string).context("Unable to parse avatar URL").map(Some))?,
email: Some(Input::with_theme(&theme) email: Some(Input::with_theme(&theme)
.with_prompt("If you want to add an email to this profile, enter it or an empty string") .with_prompt("If you want to add an email to this profile, enter it or an empty string")
.allow_empty(true) .allow_empty(true)
.interact() .interact()
.context("Unable to prompt on stderr")?) .context("Unable to prompt on stderr")?)
.filter(|x: &String| !x.is_empty()) .filter(|x: &String| !x.is_empty())
.map_or(Ok(None), |string: String| Email::from_string(string).context("Unable to parse email").map(|email| Some(email)))?, .map_or(Ok(None), |string: String| Email::from_string(string).context("Unable to parse email").map(Some))?,
color: Some(Input::with_theme(&theme) color: Some(Input::with_theme(&theme)
.with_prompt("If you want to add a color to this profile, enter it in hex format (#AABBCC) or an empty string") .with_prompt("If you want to add a color to this profile, enter it in hex format (#AABBCC) or an empty string")
.allow_empty(true) .allow_empty(true)
.interact() .interact()
.context("Unable to prompt on stderr")?) .context("Unable to prompt on stderr")?)
.filter(|x: &String| !x.is_empty()) .filter(|x: &String| !x.is_empty())
.map_or(Ok(None), |hex: String| HexColor::from_str(&hex).context("Unable to parse color code").map(|color| Some(color)))?, .map_or(Ok(None), |hex: String| HexColor::from_str(&hex).context("Unable to parse color code").map(Some))?,
}; };
dbg!(profile); dbg!(profile);