diff --git a/ghost-core/src/yara_engine.rs b/ghost-core/src/yara_engine.rs index b79751f..4a37dc4 100644 --- a/ghost-core/src/yara_engine.rs +++ b/ghost-core/src/yara_engine.rs @@ -149,23 +149,21 @@ impl DynamicYaraEngine { .and_then(|s| s.to_str()) .unwrap_or("default"); - match compiler.add_rules_str_with_namespace(&content, namespace) { - Ok(_) => { - log::info!("Compiled YARA rule: {}", rule_file.display()); - - self.rule_metadata.push(YaraRuleMetadata { - name: namespace.to_string(), - file_path: rule_file.display().to_string(), - threat_level: ThreatLevel::Medium, - last_updated: SystemTime::now(), - }); - - rule_count += 1; - } - Err(e) => { - log::error!("Failed to compile {}: {}", rule_file.display(), e); - } + if let Err(e) = compiler.add_rules_str(&content) { + log::error!("Failed to compile {}: {}", rule_file.display(), e); + continue; } + + log::info!("Compiled YARA rule: {}", rule_file.display()); + + self.rule_metadata.push(YaraRuleMetadata { + name: namespace.to_string(), + file_path: rule_file.display().to_string(), + threat_level: ThreatLevel::Medium, + last_updated: SystemTime::now(), + }); + + rule_count += 1; } Err(e) => { log::error!("Failed to read {}: {}", rule_file.display(), e); @@ -179,7 +177,7 @@ impl DynamicYaraEngine { }); } - // Compile all the added rules + // Compile all the added rules - this consumes the compiler let compiled_rules = compiler .compile_rules() .map_err(|e| GhostError::Configuration { @@ -188,6 +186,8 @@ impl DynamicYaraEngine { self.compiled_rules = Some(compiled_rules); + self.compiled_rules = Some(compiled_rules); + log::info!("Successfully compiled {} YARA rules", rule_count); Ok(rule_count) }