From f4dd69706249ed23e8f8eb41b06152462d5e9be9 Mon Sep 17 00:00:00 2001 From: Robin5605 Date: Fri, 26 Jul 2024 21:10:37 -0500 Subject: [PATCH] Add each rule to the compiler instead of joining Since compiler.add_source allows for it to be called multiple times, we can simply loop over each rule and call it once for each, rather than trying to join all the rules into one big string then compiling. --- src/client/models.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/client/models.rs b/src/client/models.rs index aa560f9..e0ce547 100644 --- a/src/client/models.rs +++ b/src/client/models.rs @@ -71,15 +71,10 @@ pub struct RulesResponse { impl RulesResponse { /// Compile the rules from the response pub fn compile(&self) -> Result { - let rules_str = self - .rules - .values() - .map(String::as_ref) - .collect::>() - .join("\n"); - let mut compiler = yara_x::Compiler::new(); - compiler.add_source(rules_str.as_str())?; + for source in self.rules.values() { + compiler.add_source(source.as_str())?; + } Ok(compiler.build()) }