Skip to content

Commit

Permalink
fix(cli): provide more context about errors while trying to read comp…
Browse files Browse the repository at this point in the history
…ile rules file
  • Loading branch information
plusvic committed Nov 23, 2023
1 parent 2c9d9fa commit 3823821
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions yara-x-cli/src/commands/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,17 @@ pub fn exec_scan(args: &ArgMatches) -> anyhow::Result<()> {
);
}

// TODO: implement Rules::deserialize_from reader
let mut file = File::open(rules_path.next().unwrap())?;
let rules_path = rules_path.next().unwrap();

let mut 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)?;
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())?;

// If the user is defining external variables, make sure that these
Expand Down

0 comments on commit 3823821

Please sign in to comment.