mirror of
https://github.com/epi052/feroxbuster.git
synced 2026-05-28 01:11:12 -03:00
incremental push to write tests against
This commit is contained in:
@@ -1041,11 +1041,11 @@ mod tests {
|
||||
|
||||
let json_state = ferox_state.as_json();
|
||||
let expected = format!(
|
||||
r#"{{"scans":[{{"id":"{}","url":"https://spiritanimal.com","scan_type":"Directory","complete":false}}],"config":{{"type":"configuration","wordlist":"/usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt","config":"","proxy":"","replay_proxy":"","target_url":"","status_codes":[200,204,301,302,307,308,401,403,405],"replay_codes":[200,204,301,302,307,308,401,403,405],"filter_status":[],"threads":50,"timeout":7,"verbosity":0,"quiet":false,"json":false,"output":"","debug_log":"","user_agent":"feroxbuster/{}","redirects":false,"insecure":false,"extensions":[],"headers":{{}},"queries":[],"no_recursion":false,"extract_links":false,"add_slash":false,"stdin":false,"depth":4,"scan_limit":0,"filter_size":[],"filter_line_count":[],"filter_word_count":[],"filter_regex":[],"dont_filter":false,"resumed":false,"save_state":false,"time_limit":"","filter_similar":[]}},"responses":[{{"type":"response","url":"https://nerdcore.com/css","path":"/css","wildcard":true,"status":301,"content_length":173,"line_count":10,"word_count":16,"headers":{{"server":"nginx/1.16.1"}}}}]}}"#,
|
||||
r#"{{"scans":[{{"id":"{}","url":"https://spiritanimal.com","scan_type":"Directory","complete":false}}],"config":{{"type":"configuration","wordlist":"/usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt","config":"","proxy":"","replay_proxy":"","target_url":"","status_codes":[200,204,301,302,307,308,401,403,405],"replay_codes":[200,204,301,302,307,308,401,403,405],"filter_status":[],"threads":50,"timeout":7,"verbosity":0,"quiet":false,"json":false,"output":"","debug_log":"","user_agent":"feroxbuster/{}","redirects":false,"insecure":false,"extensions":[],"headers":{{}},"queries":[],"no_recursion":false,"extract_links":false,"add_slash":false,"stdin":false,"depth":4,"scan_limit":0,"filter_size":[],"filter_line_count":[],"filter_word_count":[],"filter_regex":[],"dont_filter":false,"resumed":false,"save_state":false,"time_limit":"","filter_similar":[]}},"responses":[{{"type":"response","url":"https://nerdcore.com/css","path":"/css","wildcard":true,"status":301,"content_length":173,"line_count":10,"word_count":16,"headers":{{"server":"nginx/1.16.1"}}}}]"#,
|
||||
saved_id, VERSION
|
||||
);
|
||||
println!("{}\n{}", expected, json_state);
|
||||
assert!(predicates::str::similar(expected).eval(&json_state));
|
||||
assert!(predicates::str::contains(expected).eval(&json_state));
|
||||
}
|
||||
|
||||
#[should_panic]
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// todo consider batch size for stats update/display (if display is used)
|
||||
// todo are there more metrics to capture?
|
||||
// - domains redirected to?
|
||||
// - number of borked urls?
|
||||
// - total time to run
|
||||
// todo integration test that hits some/all of the errors in make_request
|
||||
// todo create a summary report to be shown when the scan ends, should present the accumulated data in a way that makes interpretation easy
|
||||
// todo maybe a realtime status updater line as progress bar or similar
|
||||
// todo resume_scan should repopulate statistics if possible or at least update an already existing Stats
|
||||
// todo logic for determining if tuning is required
|
||||
// todo gate summary display behind --summary
|
||||
|
||||
use crate::{
|
||||
config::{CONFIGURATION, PROGRESS_PRINTER},
|
||||
@@ -159,7 +158,6 @@ impl Stats {
|
||||
|
||||
/// save an instance of `Stats` to disk
|
||||
fn save(&self) {
|
||||
PROGRESS_PRINTER.println("FUCKING SAVING");
|
||||
let buffered_file = match get_cached_file_handle(&CONFIGURATION.output) {
|
||||
Some(file) => file,
|
||||
None => {
|
||||
@@ -346,7 +344,7 @@ impl Stats {
|
||||
|
||||
let mut lines = Vec::new();
|
||||
|
||||
let padded_results = pad_str("Results", 44, Alignment::Center, None);
|
||||
let padded_results = pad_str("Scan Summary", 44, Alignment::Center, None);
|
||||
let results_header = format!("\u{0020}📊{}📊\u{0020}", padded_results);
|
||||
|
||||
lines.push(results_top.to_string());
|
||||
@@ -489,7 +487,7 @@ pub async fn spawn_statistics_handler(
|
||||
pub fn initialize() -> (Arc<Stats>, UnboundedSender<StatCommand>, JoinHandle<()>) {
|
||||
log::trace!("enter: initialize");
|
||||
|
||||
let stats_tracker = Arc::new(Stats::default());
|
||||
let stats_tracker = Arc::new(Stats::new());
|
||||
let cloned = stats_tracker.clone();
|
||||
let (tx_stats, rx_stats): FeroxChannel<StatCommand> = mpsc::unbounded_channel();
|
||||
let stats_thread =
|
||||
|
||||
Reference in New Issue
Block a user