From 7a2e6f222da0d2e621b8aa6824f3f6b21fcedcf0 Mon Sep 17 00:00:00 2001 From: pandaadir05 Date: Fri, 21 Nov 2025 14:32:39 +0200 Subject: [PATCH] Fix YARA compiler builder pattern usage The add_rules_str() method consumes self and returns a new Compiler, following a builder pattern. Updated to reassign the returned compiler instead of treating it as a mutable method. This fixes the compilation error when building with yara-scanning feature. --- ghost-core/src/yara_engine.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ghost-core/src/yara_engine.rs b/ghost-core/src/yara_engine.rs index fda7534..e4c4b79 100644 --- a/ghost-core/src/yara_engine.rs +++ b/ghost-core/src/yara_engine.rs @@ -171,10 +171,13 @@ impl DynamicYaraEngine { .and_then(|s| s.to_str()) .unwrap_or("default"); - if let Err(e) = compiler.add_rules_str(&content) { - log::error!("Failed to compile {}: {}", rule_file.display(), e); - continue; - } + compiler = match compiler.add_rules_str(&content) { + Ok(c) => c, + Err(e) => { + log::error!("Failed to compile {}: {}", rule_file.display(), e); + continue; + } + }; log::info!("Compiled YARA rule: {}", rule_file.display());