1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use std::fs::create_dir_all;
use std::path::{Path, PathBuf};
use dialoguer::Confirm;
use crate::setup::config;
use crate::{TargetOpt, TestTypeOpt};
mod search;
pub(crate) async fn doit(
testtype: &TestTypeOpt,
target: &TargetOpt,
profile_path: &Path,
) -> Result<(), ()> {
info!(
"Performing test {} against {:?} from {}",
testtype,
target,
profile_path.to_str().unwrap(),
);
let (data, profile, server) = config(target, profile_path)?;
debug!("Profile -> {:?}", profile);
let result_path = PathBuf::from(&profile.results);
if !result_path.exists() {
debug!(
"Couldn't find results directory from profile: {:#?}",
result_path
);
match Confirm::new()
.with_prompt(
format!("I couldn't find the directory you told me to send results to ({:?}). Would you like to create it?",
result_path,)
)
.interact()
{
Ok(_) => match create_dir_all(result_path.as_path()) {
Ok(_) => info!("Successfully created {:#?}", result_path.canonicalize()),
Err(error) => {
error!("{:#?}", error);
return Err(());
}
},
_ => {
println!("Ok, going to quit!");
return Err(());
}
}
}
if !result_path.is_dir() {
error!("Profile: results must be a directory");
return Err(());
};
debug!("Result Path -> {}", result_path.to_str().unwrap());
match testtype {
TestTypeOpt::SearchBasic => search::basic(data, profile, server, result_path).await?,
};
info!("Test {} complete.", testtype);
Ok(())
}