From 5d20366e5d99fac0154c6bf8e4757f94db9a0246 Mon Sep 17 00:00:00 2001 From: finga Date: Wed, 30 Jun 2021 23:52:19 +0200 Subject: [PATCH] Fix clippy warnings --- src/main.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index c352620..12742b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -204,7 +204,7 @@ impl Hook { } } - replace_parameters(&self.command, &request.headers(), data) + replace_parameters(&self.command, request.headers(), data) } } @@ -231,7 +231,7 @@ impl Hooks { let hooks = config.hooks.iter().filter(|(name, hook)| { if let Some(ip) = &hook.ip_filter { - return accept_ip(&name, &client_ip, &ip); + accept_ip(name, client_ip, ip) } else { info!( "Allow hook `{}` from {}, no IP filter was configured", @@ -250,7 +250,7 @@ impl Hooks { let secrets = hook .secrets .iter() - .map(|secret| validate_request(&secret, &signature, &buffer)); + .map(|secret| validate_request(secret, signature, &buffer)); for secret in secrets { match secret { @@ -263,7 +263,7 @@ impl Hooks { serde_json::from_slice(&buffer).map_err(WebhookeyError::Serde)?; match hook.filter.evaluate(request, &data) { - Ok(true) => match hook.get_command(&hook_name, &request, &mut data) { + Ok(true) => match hook.get_command(hook_name, request, &mut data) { Ok(command) => { info!("Filter for `{}` matched", &hook_name); result.insert(hook_name.to_string(), command); @@ -294,7 +294,7 @@ impl FromDataSimple for Hooks { type Error = WebhookeyError; fn from_data(request: &Request, data: Data) -> data::Outcome { - match Hooks::get_commands(&request, data) { + match Hooks::get_commands(request, data) { Ok(hooks) => { if hooks.inner.is_empty() { let client_ip = &request @@ -336,9 +336,9 @@ fn accept_ip(hook_name: &str, client_ip: &IpAddr, ip: &IpFilter) -> bool { } fn validate_request(secret: &str, signature: &str, data: &[u8]) -> Result<()> { - let mut mac = Hmac::::new_varkey(&secret.as_bytes()) + let mut mac = Hmac::::new_varkey(secret.as_bytes()) .map_err(|e| anyhow!("Could not create hasher with secret: {}", e))?; - mac.update(&data); + mac.update(data); let raw_signature = hex::decode(signature.as_bytes())?; mac.verify(&raw_signature).map_err(|e| anyhow!("{}", e)) } @@ -347,7 +347,7 @@ fn get_parameter(input: &str) -> Result> { let parse: IResult<&str, Vec<&str>> = many0(alt(( delimited(tag("{{"), take_until("}}"), tag("}}")), take_until("{{"), - )))(&input); + )))(input); let (_last, result) = parse .finish() @@ -389,7 +389,7 @@ fn replace_parameters( match expr.get(0) { Some(&"header") => get_header_field(headers, &expr), - Some(pointer) => get_value_from_pointer(data, &pointer), + Some(pointer) => get_value_from_pointer(data, pointer), None => bail!("Missing expression in `{}`", input), } }, @@ -424,7 +424,7 @@ fn receive_hook<'a>(address: SocketAddr, hooks: Hooks) -> Result> { hooks.inner.iter().for_each(|(name, command)| { info!("Execute `{}` from hook `{}`", &command, &name); - match run_script::run(&command, &vec![], &ScriptOptions::new()) { + match run_script::run(command, &vec![], &ScriptOptions::new()) { Ok((status, stdout, stderr)) => { info!("Command `{}` exited with return code: {}", &command, status); trace!("Output of command `{}` on stdout: {:?}", &command, &stdout); @@ -497,7 +497,7 @@ fn main() -> Result<()> { trace!("Parsed configuration:\n{}", serde_yaml::to_string(&config)?); - if let Some(_) = cli.subcommand_matches("configtest") { + if cli.subcommand_matches("configtest").is_some() { debug!("Configtest succeded."); println!("Config is OK"); return Ok(());