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.
This commit is contained in:
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user