Skip to content

Commit

Permalink
arg DEFAULT_ENTROPY_THRESHOLD fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zcarlson-signifai committed Dec 22, 2023
1 parent ad455ad commit 913ed26
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/bin/duroc_hog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ fn main() {
Arg::new("DEFAULT_ENTROPY_THRESHOLD")
.long("default_entropy_threshold")
.action(ArgAction::Set)
.default_value("0.6")
.help("Default entropy threshold (0.6 by default)"),
)
.arg(
Expand Down Expand Up @@ -408,7 +407,7 @@ mod tests {
use std::io::Result;
use std::io::Write;
use std::process::Output;
use tempfile::{NamedTempFile, TempDir};
use tempfile::{NamedTempFile, TempDir, tempdir};

fn run_command_in_dir(dir: &TempDir, command: &str, args: &[&str]) -> Result<Output> {
let dir_path = dir.path().to_str().unwrap();
Expand All @@ -433,7 +432,7 @@ mod tests {

#[test]
fn does_not_scan_output_file() {
let temp_dir = TempDir::new().unwrap();
let temp_dir = tempdir().expect("couldn't make tempdir");

write_temp_file(
&temp_dir,
Expand All @@ -444,20 +443,20 @@ mod tests {
let cmd_args = ["-o", "output_file.txt", "."];

run_command_in_dir(&temp_dir, "duroc_hog", &cmd_args).unwrap();

run_command_in_dir(&temp_dir, "duroc_hog", &cmd_args).unwrap();

let text = read_temp_file(&temp_dir, "output_file.txt");

println!("{}", text);
temp_dir.close().expect("couldn't close tempdir");

assert!(text.contains("\"path\":\"./insecure-file.txt\""));
assert!(!text.contains("output_file.txt"));
}

#[test]
fn allowlist_json_file_prevents_output() {
let temp_dir = TempDir::new().unwrap();
let temp_dir = tempdir().expect("couldn't make tempdir");
let mut allowlist_temp_file = NamedTempFile::new().unwrap();
let json = r#"
{
Expand All @@ -480,7 +479,8 @@ mod tests {
];

let output = run_command_in_dir(&temp_dir, "duroc_hog", &cmd_args).unwrap();

assert_eq!("[]\n", str::from_utf8(&output.stdout).unwrap());
temp_dir.close().expect("couldn't close tempdir");
let prg_out = str::from_utf8(&output.stdout).unwrap();
assert_eq!("[]\n", prg_out);
}
}

0 comments on commit 913ed26

Please sign in to comment.