Skip to content

Commit

Permalink
refactor: use the Rules::deserialize_from API in exec_scan.
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Jan 23, 2024
1 parent 42dd9d4 commit c94d41a
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions yara-x-cli/src/commands/scan.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::cmp::min;
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Mutex;
Expand Down Expand Up @@ -120,16 +119,10 @@ pub fn exec_scan(args: &ArgMatches) -> anyhow::Result<()> {

let rules_path = rules_path.next().unwrap();

let mut file = File::open(rules_path)
let file = File::open(rules_path)
.with_context(|| format!("can not open {:?}", &rules_path))?;

let mut data = Vec::new();

File::read_to_end(&mut file, &mut data)
.with_context(|| format!("can not read {:?}", &rules_path))?;

// TODO: implement Rules::deserialize_from reader
let rules = Rules::deserialize(data.as_slice())?;
let rules = Rules::deserialize_from(file)?;

// If the user is defining external variables, make sure that these
// variables are valid. A scanner is created only with the purpose
Expand Down

0 comments on commit c94d41a

Please sign in to comment.