Vendored compile does not link Dotnet module correctly
erichutchins opened this issue · comments
The yara-sys crate does not correctly include the dotnet code when compiling in the vendored mode. The following line should define DOTNET_MODULE
and not just DOTNET
Line 125 in 0aad299
A small test using the 0.9.0
release errors at rule compilation and says dotnet module is not found.
[dependencies]
yara = {version = "0.9.0", features = ["vendored"]}
use yara::Compiler;
const RULES: &str = r#"
import "dotnet"
"#;
fn main() {
let mut compiler = Compiler::new().unwrap();
compiler
.add_rules_str(RULES)
.expect("Should have parsed rule");
let rules = compiler
.compile_rules()
.expect("Should have compiled rules");
let _results = rules
.scan_mem("Test test".as_bytes(), 5)
.expect("Should have scanned");
}
; cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Running `target/debug/yara-test`
thread 'main' panicked at 'Should have parsed rule: Compile(CompileErrors { errors: [CompileError { level: Error, filename: None, line: 2, message: "unknown module \"dotnet\"" }] })', src/main.rs:11:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
After this fix, it worked just fine.
diff --git a/yara-sys/build.rs b/yara-sys/build.rs
index ef81935..f4a8396 100644
--- a/yara-sys/build.rs
+++ b/yara-sys/build.rs
@@ -122,7 +122,7 @@ mod build {
exclude.push(basedir.join("modules").join("cuckoo").join("cuckoo.c"));
}
if is_enable("YARA_ENABLE_DOTNET", true) {
- cc.define("DOTNET", "1");
+ cc.define("DOTNET_MODULE", "1");
} else {
exclude.push(basedir.join("modules").join("dotnet").join("dotnet.c"));
}
@erichutchins thank you, I did PR