Skip to content

Commit

Permalink
load yara rules from dir
Browse files Browse the repository at this point in the history
  • Loading branch information
daschr committed May 30, 2024
1 parent 45214dc commit 08c8e79
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/yara_rulset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@ impl YaraRuleset {
}

pub fn update_yara_rules(&self, yara_rules_loc: &Path) -> Result<(), AnalyzerError> {
let compiler: Compiler = Compiler::new()?;
let compiler = compiler.add_rules_file(yara_rules_loc)?;
let mut compiler: Compiler = Compiler::new()?;

if yara_rules_loc.is_file() {
compiler.add_rules_file(yara_rules_loc)?;
} else {
for p in std::fs::read_dir(yara_rules_loc)? {
let p = p?.path();
if p.is_file() {
compiler.add_rules_file(p)?;
}
}
}

let yara_rules = compiler.compile_rules()?;

Expand Down

0 comments on commit 08c8e79

Please sign in to comment.