From 45b4bb48a1c7543a4e4822e8e71ab117d10aad99 Mon Sep 17 00:00:00 2001 From: Vincent Thiberville Date: Mon, 9 Dec 2024 01:26:49 +0100 Subject: [PATCH] chore: fix new clippy warnings --- boreal-parser/src/nom_recipes.rs | 2 +- boreal/src/matcher/base64.rs | 4 ++-- boreal/src/matcher/mod.rs | 8 ++++++-- boreal/src/memory.rs | 4 ++-- boreal/tests/it/utils.rs | 4 ++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/boreal-parser/src/nom_recipes.rs b/boreal-parser/src/nom_recipes.rs index c88b5635..4997c148 100644 --- a/boreal-parser/src/nom_recipes.rs +++ b/boreal-parser/src/nom_recipes.rs @@ -136,7 +136,7 @@ fn singleline_comment(input: Input) -> ParseResult<()> { pub(crate) fn map_res<'a, O1, O2, F, G>( mut parser: F, mut f: G, -) -> impl FnMut(Input<'a>) -> ParseResult +) -> impl FnMut(Input<'a>) -> ParseResult<'a, O2> where F: Parser, O1, Error>, G: FnMut(O1) -> Result, diff --git a/boreal/src/matcher/base64.rs b/boreal/src/matcher/base64.rs index 0cd88127..2eebf479 100644 --- a/boreal/src/matcher/base64.rs +++ b/boreal/src/matcher/base64.rs @@ -20,8 +20,8 @@ const DEFAULT_ALPHABET: &[u8; 64] = /// /// How this work is that every byte from the resulting base64 string that is involved with /// padding is removed from the returned value. -pub fn encode_base64(s: &[u8], alphabet: &Option<[u8; 64]>, offset: usize) -> Option> { - let alphabet = alphabet.as_ref().unwrap_or(DEFAULT_ALPHABET); +pub fn encode_base64(s: &[u8], alphabet: Option<&[u8; 64]>, offset: usize) -> Option> { + let alphabet = alphabet.unwrap_or(DEFAULT_ALPHABET); let mut res = Vec::with_capacity(s.len() * 4 / 3); diff --git a/boreal/src/matcher/mod.rs b/boreal/src/matcher/mod.rs index 466578e8..5fd93c91 100644 --- a/boreal/src/matcher/mod.rs +++ b/boreal/src/matcher/mod.rs @@ -220,7 +220,9 @@ impl Matcher { if base64.ascii { for lit in &old_literals { for offset in 0..=2 { - if let Some(lit) = base64::encode_base64(lit, &base64.alphabet, offset) { + if let Some(lit) = + base64::encode_base64(lit, base64.alphabet.as_ref(), offset) + { // Fullword is not compatible with base64 modifiers, hence ordering of // literals is not required. if base64.wide { @@ -233,7 +235,9 @@ impl Matcher { } else { for lit in &old_literals { for offset in 0..=2 { - if let Some(lit) = base64::encode_base64(lit, &base64.alphabet, offset) { + if let Some(lit) = + base64::encode_base64(lit, base64.alphabet.as_ref(), offset) + { literals.push(string_to_wide(&lit)); } } diff --git a/boreal/src/memory.rs b/boreal/src/memory.rs index 9ec6d6f6..a8ea146f 100644 --- a/boreal/src/memory.rs +++ b/boreal/src/memory.rs @@ -49,8 +49,8 @@ impl<'a> Memory<'a> { pub(crate) fn new_fragmented( obj: Box, params: MemoryParams, - ) -> Memory { - Memory::Fragmented(Fragmented { obj, params }) + ) -> Self { + Self::Fragmented(Fragmented { obj, params }) } } diff --git a/boreal/tests/it/utils.rs b/boreal/tests/it/utils.rs index c79a6f25..d2c716d5 100644 --- a/boreal/tests/it/utils.rs +++ b/boreal/tests/it/utils.rs @@ -618,7 +618,7 @@ macro_rules! define_symbol_scanner_method { }; } -impl<'a> Scanner<'a> { +impl Scanner<'_> { #[track_caller] pub fn check(&mut self, mem: &[u8], expected_res: bool) { self.check_boreal(mem, expected_res); @@ -1115,7 +1115,7 @@ struct YaraBlocks<'a> { regions: &'a [(usize, Option<&'a [u8]>)], } -impl<'a> yara::MemoryBlockIterator for YaraBlocks<'a> { +impl yara::MemoryBlockIterator for YaraBlocks<'_> { fn first(&mut self) -> Option { self.current = 0; self.next()