From da509bd208336bccc556d65b407c27505cf75d2c Mon Sep 17 00:00:00 2001 From: epi Date: Wed, 15 Feb 2023 19:39:27 -0600 Subject: [PATCH] clippy --- src/banner/container.rs | 26 +++++++++++++------------- src/config/tests.rs | 2 +- src/config/utils.rs | 2 +- src/event_handlers/outputs.rs | 10 +++++----- src/extractor/container.rs | 4 ++-- src/extractor/tests.rs | 2 +- src/filters/tests.rs | 2 +- src/heuristics.rs | 6 +++--- src/main.rs | 8 ++++---- src/nlp/document.rs | 2 +- src/scan_manager/menu.rs | 11 +++++------ src/scan_manager/scan_container.rs | 6 +++--- src/scan_manager/state.rs | 2 +- src/scan_manager/tests.rs | 25 ++++++++++++------------- src/scan_manager/utils.rs | 2 +- src/scanner/limit_heap.rs | 2 +- src/scanner/requester.rs | 8 ++++---- src/statistics/container.rs | 2 +- src/traits.rs | 2 +- src/url.rs | 8 ++++---- src/utils.rs | 18 ++++++++---------- tests/test_main.rs | 2 +- tests/test_policies.rs | 10 +++++----- tests/test_scan_manager.rs | 6 +++--- tests/test_scanner.rs | 8 ++++---- 25 files changed, 86 insertions(+), 90 deletions(-) diff --git a/src/banner/container.rs b/src/banner/container.rs index 4520a0d..e7f60e3 100644 --- a/src/banner/container.rs +++ b/src/banner/container.rs @@ -233,7 +233,7 @@ impl Banner { headers.push(BannerEntry::new( "🤯", "Header", - &format!("{}: {}", name, value), + &format!("{name}: {value}"), )); } @@ -441,7 +441,7 @@ by Ben "epi" Risher {} ver: {}"#, let top = "───────────────────────────┬──────────────────────"; - format!("{}\n{}", artwork, top) + format!("{artwork}\n{top}") } /// get a fancy footer for the banner @@ -455,7 +455,7 @@ by Ben "epi" Risher {} ver: {}"#, style("Scan Management Menu").bright().yellow(), ); - format!("{}\n{}\n{}", bottom, instructions, addl_section) + format!("{bottom}\n{instructions}\n{addl_section}") } /// Makes a request to the given url, expecting to receive a JSON response that contains a field @@ -508,11 +508,11 @@ by Ben "epi" Risher {} ver: {}"#, // begin with always printed items for target in &self.targets { - writeln!(&mut writer, "{}", target)?; + writeln!(&mut writer, "{target}")?; } for denied_url in &self.url_denylist { - writeln!(&mut writer, "{}", denied_url)?; + writeln!(&mut writer, "{denied_url}")?; } writeln!(&mut writer, "{}", self.threads)?; @@ -551,27 +551,27 @@ by Ben "epi" Risher {} ver: {}"#, } for header in &self.headers { - writeln!(&mut writer, "{}", header)?; + writeln!(&mut writer, "{header}")?; } for filter in &self.filter_size { - writeln!(&mut writer, "{}", filter)?; + writeln!(&mut writer, "{filter}")?; } for filter in &self.filter_similar { - writeln!(&mut writer, "{}", filter)?; + writeln!(&mut writer, "{filter}")?; } for filter in &self.filter_word_count { - writeln!(&mut writer, "{}", filter)?; + writeln!(&mut writer, "{filter}")?; } for filter in &self.filter_line_count { - writeln!(&mut writer, "{}", filter)?; + writeln!(&mut writer, "{filter}")?; } for filter in &self.filter_regex { - writeln!(&mut writer, "{}", filter)?; + writeln!(&mut writer, "{filter}")?; } if config.extract_links { @@ -583,7 +583,7 @@ by Ben "epi" Risher {} ver: {}"#, } for query in &self.queries { - writeln!(&mut writer, "{}", query)?; + writeln!(&mut writer, "{query}")?; } if !config.output.is_empty() { @@ -675,7 +675,7 @@ by Ben "epi" Risher {} ver: {}"#, "New Version Available", "https://github.com/epi052/feroxbuster/releases/latest", ); - writeln!(&mut writer, "{}", update)?; + writeln!(&mut writer, "{update}")?; } writeln!(&mut writer, "{}", self.footer())?; diff --git a/src/config/tests.rs b/src/config/tests.rs index 6f945a9..778ece4 100644 --- a/src/config/tests.rs +++ b/src/config/tests.rs @@ -482,7 +482,7 @@ fn config_report_and_exit_works() { fn as_str_returns_string_with_newline() { let config = Configuration::new().unwrap(); let config_str = config.as_str(); - println!("{}", config_str); + println!("{config_str}"); assert!(config_str.starts_with("Configuration {")); assert!(config_str.ends_with("}\n")); assert!(config_str.contains("replay_codes:")); diff --git a/src/config/utils.rs b/src/config/utils.rs index 81d2c7a..5929f70 100644 --- a/src/config/utils.rs +++ b/src/config/utils.rs @@ -72,7 +72,7 @@ pub(super) fn wordlist() -> String { /// default user-agent pub(super) fn user_agent() -> String { - format!("feroxbuster/{}", VERSION) + format!("feroxbuster/{VERSION}") } /// default recursion depth diff --git a/src/event_handlers/outputs.rs b/src/event_handlers/outputs.rs index 0275f6a..94428a8 100644 --- a/src/event_handlers/outputs.rs +++ b/src/event_handlers/outputs.rs @@ -274,7 +274,7 @@ impl TermOutHandler { self.tx_file .send(Command::Report(resp.clone())) .with_context(|| { - fmt_err(&format!("Could not send {} to file handler", resp)) + fmt_err(&format!("Could not send {resp} to file handler")) })?; } } @@ -394,11 +394,11 @@ impl TermOutHandler { if !filename.is_empty() { // append rules for suffix in ["~", ".bak", ".bak2", ".old", ".1"] { - self.add_new_url_to_vec(url, &format!("{}{}", filename, suffix), &mut urls); + self.add_new_url_to_vec(url, &format!("{filename}{suffix}"), &mut urls); } // vim swap rule - self.add_new_url_to_vec(url, &format!(".{}.swp", filename), &mut urls); + self.add_new_url_to_vec(url, &format!(".{filename}.swp"), &mut urls); // replace original extension rule let parts: Vec<_> = filename @@ -432,7 +432,7 @@ mod tests { config, receiver: rx, }; - println!("{:?}", foh); + println!("{foh:?}"); } #[tokio::test(flavor = "multi_thread", worker_threads = 1)] @@ -451,7 +451,7 @@ mod tests { handles: Some(handles), }; - println!("{:?}", toh); + println!("{toh:?}"); tx.send(Command::Exit).unwrap(); } diff --git a/src/extractor/container.rs b/src/extractor/container.rs index c63dfa8..a1b123c 100644 --- a/src/extractor/container.rs +++ b/src/extractor/container.rs @@ -362,7 +362,7 @@ impl<'a> Extractor<'a> { // this isn't the last index of the parts array // ex: /buried/misc/stupidfile.php // this block skips the file but sees all parent folders - possible_path = format!("{}/", possible_path); + possible_path = format!("{possible_path}/"); } paths.push(possible_path); // good sub-path found @@ -395,7 +395,7 @@ impl<'a> Extractor<'a> { let new_url = old_url .join(link) - .with_context(|| format!("Could not join {} with {}", old_url, link))?; + .with_context(|| format!("Could not join {old_url} with {link}"))?; if old_url.domain() != new_url.domain() || old_url.host() != new_url.host() { // domains/ips are not the same, don't scan things that aren't part of the original diff --git a/src/extractor/tests.rs b/src/extractor/tests.rs index b485cd0..50bcad2 100644 --- a/src/extractor/tests.rs +++ b/src/extractor/tests.rs @@ -312,7 +312,7 @@ async fn request_robots_txt_without_proxy() -> Result<()> { let resp = extractor.make_extract_request("/robots.txt").await?; assert!(matches!(resp.status(), &StatusCode::OK)); - println!("{}", resp); + println!("{resp}"); assert_eq!(resp.content_length(), 14); assert_eq!(mock.hits(), 1); Ok(()) diff --git a/src/filters/tests.rs b/src/filters/tests.rs index f65258c..98b7a25 100644 --- a/src/filters/tests.rs +++ b/src/filters/tests.rs @@ -156,7 +156,7 @@ fn wildcard_should_filter_when_dynamic_wildcard_found() { method: "GET".to_owned(), }; - println!("resp: {:?}: filter: {:?}", resp, filter); + println!("resp: {resp:?}: filter: {filter:?}"); assert!(filter.should_filter_response(&resp)); } diff --git a/src/heuristics.rs b/src/heuristics.rs index d17061b..a08779f 100644 --- a/src/heuristics.rs +++ b/src/heuristics.rs @@ -310,12 +310,12 @@ impl HeuristicTests { ) { if e.to_string().contains(":SSL") { ferox_print( - &format!("Could not connect to {} due to SSL errors (run with -k to ignore), skipping...", target_url), + &format!("Could not connect to {target_url} due to SSL errors (run with -k to ignore), skipping..."), &PROGRESS_PRINTER, ); } else { ferox_print( - &format!("Could not connect to {}, skipping...", target_url), + &format!("Could not connect to {target_url}, skipping..."), &PROGRESS_PRINTER, ); } @@ -343,7 +343,7 @@ impl HeuristicTests { // so, instead of `directory_listing("http://localhost") -> None` we get // `directory_listing("http://localhost/") -> Some(DirListingResult)` if there is // directory listing beyond the redirect - format!("{}/", target_url) + format!("{target_url}/") } else { target_url.to_string() }; diff --git a/src/main.rs b/src/main.rs index adf20af..9c6326f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,7 +49,7 @@ fn get_unique_words_from_wordlist(path: &str) -> Result>> { log::trace!("enter: get_unique_words_from_wordlist({})", path); let mut trimmed_word = false; - let file = File::open(path).with_context(|| format!("Could not open {}", path))?; + let file = File::open(path).with_context(|| format!("Could not open {path}"))?; let reader = BufReader::new(file); @@ -182,7 +182,7 @@ async fn get_targets(handles: Arc) -> Result> { if !target.starts_with("http") && !target.starts_with("https") { // --url hackerone.com - *target = format!("https://{}", target); + *target = format!("https://{target}"); } } @@ -469,7 +469,7 @@ async fn wrapped_main(config: Arc) -> Result<()> { Ok(_) => {} Err(e) => { clean_up(handles, tasks).await?; - bail!(fmt_err(&format!("Failed while scanning: {}", e))); + bail!(fmt_err(&format!("Failed while scanning: {e}"))); } } @@ -536,7 +536,7 @@ fn main() -> Result<()> { { let future = wrapped_main(config.clone()); if let Err(e) = runtime.block_on(future) { - eprintln!("{}", e); + eprintln!("{e}"); // the code below is to facilitate testing tests/test_banner entries. Since it's an // integration test, normal test detection (cfg!(test), etc...) won't work. So, in diff --git a/src/nlp/document.rs b/src/nlp/document.rs index dfebd29..6a0244d 100644 --- a/src/nlp/document.rs +++ b/src/nlp/document.rs @@ -85,7 +85,7 @@ impl Document { // at this point, we have a non-empty Text element with a non-script|style parent; // now we can return the trimmed up string - return Some(format!("{} ", trimmed)); + return Some(format!("{trimmed} ")); } // not an Element node diff --git a/src/scan_manager/menu.rs b/src/scan_manager/menu.rs index cbd2e58..9d85024 100644 --- a/src/scan_manager/menu.rs +++ b/src/scan_manager/menu.rs @@ -116,8 +116,8 @@ impl Menu { let padded_name = pad_str(&name, longest, Alignment::Center, None); - let header = format!("{}\n{}\n{}", border, padded_name, border); - let footer = format!("{}\n{}", commands, border); + let header = format!("{border}\n{padded_name}\n{border}"); + let footer = format!("{commands}\n{border}"); Self { header, @@ -174,7 +174,7 @@ impl Menu { .to_string() .parse::() .unwrap_or_else(|e| { - self.println(&format!("Found non-numeric input: {}: {:?}", e, value)); + self.println(&format!("Found non-numeric input: {e}: {value:?}")); 0 }) } @@ -198,7 +198,7 @@ impl Menu { if range.len() != 2 { // expecting [1, 4] or similar, if a 0 was used, we'd be left with a vec of size 1 - self.println(&format!("Found invalid range of scans: {}", value)); + self.println(&format!("Found invalid range of scans: {value}")); continue; } @@ -290,8 +290,7 @@ impl Menu { /// Given a url, confirm with user that we should cancel pub(super) fn confirm_cancellation(&self, url: &str) -> char { self.println(&format!( - "You sure you wanna cancel this scan: {}? [Y/n]", - url + "You sure you wanna cancel this scan: {url}? [Y/n]" )); self.term.read_char().unwrap_or('n') diff --git a/src/scan_manager/scan_container.rs b/src/scan_manager/scan_container.rs index 22e8f6b..d3118bb 100644 --- a/src/scan_manager/scan_container.rs +++ b/src/scan_manager/scan_container.rs @@ -271,7 +271,7 @@ impl FeroxScans { for (idx, _) in &matches { for scan in guard.iter() { let slice = url.index(0..*idx); - if slice == scan.url || format!("{}/", slice).as_str() == scan.url { + if slice == scan.url || format!("{slice}/").as_str() == scan.url { log::trace!("enter: get_base_scan_by_url -> {}", scan); return Some(scan.clone()); } @@ -336,7 +336,7 @@ impl FeroxScans { } // we're only interested in displaying directory scans, as those are // the only ones that make sense to be stopped - let scan_msg = format!("{:3}: {}", i, scan); + let scan_msg = format!("{i:3}: {scan}"); self.menu.println(&scan_msg); printed += 1; } @@ -360,7 +360,7 @@ impl FeroxScans { if num >= u_scans.len() { // usize can't be negative, just need to handle exceeding bounds self.menu - .println(&format!("The number {} is not a valid choice.", num)); + .println(&format!("The number {num} is not a valid choice.")); sleep(menu_pause_duration); continue; } diff --git a/src/scan_manager/state.rs b/src/scan_manager/state.rs index d34aee7..5276131 100644 --- a/src/scan_manager/state.rs +++ b/src/scan_manager/state.rs @@ -58,7 +58,7 @@ impl FeroxState { impl FeroxSerialize for FeroxState { /// Simply return debug format of FeroxState to satisfy as_str fn as_str(&self) -> String { - format!("{:?}", self) + format!("{self:?}") } /// Simple call to produce a JSON string using the given FeroxState diff --git a/src/scan_manager/tests.rs b/src/scan_manager/tests.rs index eaa3f7d..c83cb63 100644 --- a/src/scan_manager/tests.rs +++ b/src/scan_manager/tests.rs @@ -317,7 +317,7 @@ fn ferox_responses_serialize() { // responses has a response now // serialized should be a list of responses - let expected = format!("[{}]", json_response); + let expected = format!("[{json_response}]"); let serialized = serde_json::to_string(&responses).unwrap(); assert_eq!(expected, serialized); @@ -426,11 +426,11 @@ fn feroxstates_feroxserialize_implementation() { let json_state = ferox_state.as_json().unwrap(); - println!("echo '{}'|jq", json_state); // for debugging, if the test fails, can see what's going on + println!("echo '{json_state}'|jq"); // for debugging, if the test fails, can see what's going on for expected in [ r#""scans""#, - &format!(r#""id":"{}""#, saved_id), + &format!(r#""id":"{saved_id}""#), r#""url":"https://spiritanimal.com""#, r#""scan_type":"Directory""#, r#""status":"NotStarted""#, @@ -456,7 +456,7 @@ fn feroxstates_feroxserialize_implementation() { r#""json":false"#, r#""output":"""#, r#""debug_log":"""#, - &format!(r#""user_agent":"feroxbuster/{}""#, VERSION), + &format!(r#""user_agent":"feroxbuster/{VERSION}""#), r#""random_agent":false"#, r#""redirects":false"#, r#""insecure":false"#, @@ -570,26 +570,26 @@ fn feroxscan_display() { errors: Default::default(), }; - let not_started = format!("{}", scan); + let not_started = format!("{scan}"); assert!(predicate::str::contains("not started") .and(predicate::str::contains("localhost")) .eval(¬_started)); scan.set_status(ScanStatus::Complete).unwrap(); - let complete = format!("{}", scan); + let complete = format!("{scan}"); assert!(predicate::str::contains("complete") .and(predicate::str::contains("localhost")) .eval(&complete)); scan.set_status(ScanStatus::Cancelled).unwrap(); - let cancelled = format!("{}", scan); + let cancelled = format!("{scan}"); assert!(predicate::str::contains("cancelled") .and(predicate::str::contains("localhost")) .eval(&cancelled)); scan.set_status(ScanStatus::Running).unwrap(); - let running = format!("{}", scan); + let running = format!("{scan}"); assert!(predicate::str::contains("running") .and(predicate::str::contains("localhost")) .eval(&running)); @@ -637,8 +637,7 @@ fn menu_print_header_and_footer() { let menu_cmd_res_1 = MenuCmdResult::Url(String::from("http://localhost")); let menu_cmd_res_2 = MenuCmdResult::NumCancelled(2); println!( - "{:?}{:?}{:?}{:?}", - menu_cmd_1, menu_cmd_2, menu_cmd_res_1, menu_cmd_res_2 + "{menu_cmd_1:?}{menu_cmd_2:?}{menu_cmd_res_1:?}{menu_cmd_res_2:?}" ); menu.clear_screen(); menu.print_header(); @@ -656,9 +655,9 @@ fn menu_get_command_input_from_user_returns_cancel() { let force = idx % 2 == 0; let full_cmd = if force { - format!("{} -f {}\n", cmd, idx) + format!("{cmd} -f {idx}\n") } else { - format!("{} {}\n", cmd, idx) + format!("{cmd} {idx}\n") }; let result = menu.get_command_input_from_user(&full_cmd).unwrap(); @@ -683,7 +682,7 @@ fn menu_get_command_input_from_user_returns_add() { for cmd in ["add", "Addd", "a", "A", "None"] { let test_url = "http://happyfuntimes.commmm"; - let full_cmd = format!("{} {}\n", cmd, test_url); + let full_cmd = format!("{cmd} {test_url}\n"); if cmd != "None" { let result = menu.get_command_input_from_user(&full_cmd).unwrap(); diff --git a/src/scan_manager/utils.rs b/src/scan_manager/utils.rs index 068c6c3..1844957 100644 --- a/src/scan_manager/utils.rs +++ b/src/scan_manager/utils.rs @@ -41,7 +41,7 @@ pub async fn start_max_time_thread(handles: Arc) { log::trace!("exit: start_max_time_thread"); #[cfg(test)] - panic!("{:?}", handles); + panic!("{handles:?}"); #[cfg(not(test))] let _ = TermInputHandler::sigint_handler(handles.clone()); } diff --git a/src/scanner/limit_heap.rs b/src/scanner/limit_heap.rs index 61ac018..beb2116 100644 --- a/src/scanner/limit_heap.rs +++ b/src/scanner/limit_heap.rs @@ -41,7 +41,7 @@ impl Debug for LimitHeap { "LimitHeap {{ original: {}, current: {}, inner: [{}...] }}", self.original, self.current, self.inner[0] ); - write!(f, "{}", msg) + write!(f, "{msg}") } } diff --git a/src/scanner/requester.rs b/src/scanner/requester.rs index f0bb92f..3822a11 100644 --- a/src/scanner/requester.rs +++ b/src/scanner/requester.rs @@ -239,7 +239,7 @@ impl Requester { atomic_store!(self.policy_data.remove_limit, false); self.ferox_scan .progress_bar() - .set_message(&format!("=> 🚦 removed rate limiter 🚀")); + .set_message("=> 🚦 removed rate limiter 🚀"); } else if create_limiter { // create_limiter is really just used for unit testing situations, it's true anytime // during actual execution @@ -323,7 +323,7 @@ impl Requester { let pb = self.ferox_scan.progress_bar(); let num_skipped = pb.length().saturating_sub(pb.position()) as usize; - let styled_trigger = style(format!("{:?}", trigger)).red(); + let styled_trigger = style(format!("{trigger:?}")).red(); pb.set_message(&format!( "=> 💀 too many {} ({}) 💀 bailing", @@ -591,7 +591,7 @@ mod tests { let scans = handles.ferox_scans().unwrap(); for _ in 0..num_errors { - scans.increment_error(format!("{}/", url).as_str()); + scans.increment_error(format!("{url}/").as_str()); } } @@ -604,7 +604,7 @@ mod tests { ) { let scans = handles.ferox_scans().unwrap(); for _ in 0..num_errors { - scans.increment_status_code(format!("{}/", url).as_str(), code); + scans.increment_status_code(format!("{url}/").as_str(), code); } } diff --git a/src/statistics/container.rs b/src/statistics/container.rs index 780e517..eb8bd23 100644 --- a/src/statistics/container.rs +++ b/src/statistics/container.rs @@ -668,7 +668,7 @@ impl Stats { /// This is only ever called when resuming a scan from disk pub fn merge_from(&self, filename: &str) -> Result<()> { let file = File::open(filename) - .with_context(|| fmt_err(&format!("Could not open {}", filename)))?; + .with_context(|| fmt_err(&format!("Could not open {filename}")))?; let reader = BufReader::new(file); let state: serde_json::Value = serde_json::from_reader(reader)?; diff --git a/src/traits.rs b/src/traits.rs index 5543959..3800951 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -52,7 +52,7 @@ impl Display for dyn FeroxFilter { style(&filter.original_url).cyan() ) } else { - write!(f, "Filter: {:?}", self) + write!(f, "Filter: {self:?}") } } } diff --git a/src/url.rs b/src/url.rs index 7621ec5..5a9ef03 100644 --- a/src/url.rs +++ b/src/url.rs @@ -90,7 +90,7 @@ impl FeroxUrl { // // in order to resolve the issue, we check if the word from the wordlist is a parsable URL // and if so, don't do any further processing - let message = format!("word ({}) from wordlist is a URL, skipping...", word); + let message = format!("word ({word}) from wordlist is a URL, skipping..."); log::warn!("{}", message); log::trace!("exit: format -> Err({})", message); bail!(message); @@ -122,9 +122,9 @@ impl FeroxUrl { // We handle the special case of forward slash // That allow us to treat it as an extension with a particular format if ext == "/" { - format!("{}/", word) + format!("{word}/") } else { - format!("{}.{}", word, ext) + format!("{word}.{ext}") } } else { String::from(word) @@ -483,7 +483,7 @@ mod tests { let handles = Arc::new(Handles::for_testing(None, None).0); let url = FeroxUrl::from_string("http://localhost", handles); for ext in ["rocks", "fun"] { - let to_check = format!("http://localhost/upload/ferox.{}", ext); + let to_check = format!("http://localhost/upload/ferox.{ext}"); assert_eq!( url.format("//upload/ferox", Some(ext)).unwrap(), reqwest::Url::parse(&to_check[..]).unwrap() diff --git a/src/utils.rs b/src/utils.rs index 16de58f..754b2e5 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -41,7 +41,7 @@ pub fn open_file(filename: &str) -> Result> { .create(true) .append(true) .open(filename) - .with_context(|| fmt_err(&format!("Could not open {}", filename)))?; + .with_context(|| fmt_err(&format!("Could not open {filename}")))?; let writer = BufWriter::new(file); // std io @@ -104,7 +104,7 @@ pub fn ferox_print(msg: &str, bar: &ProgressBar) { bar.println(msg); } else { let stripped = strip_ansi_codes(msg); - println!("{}", stripped); + println!("{stripped}"); } } @@ -265,19 +265,17 @@ pub fn create_report_string( ) -> String { if matches!(output_level, OutputLevel::Silent) { // --silent used, just need the url - format!("{}\n", url) + format!("{url}\n") } else { // normal printing with status and sizes let color_status = status_colorizer(status); if status.contains("MSG") { format!( - "{} {:>8} {:>9} {:>9} {:>9} {}\n", - color_status, method, line_count, word_count, content_length, url + "{color_status} {method:>8} {line_count:>9} {word_count:>9} {content_length:>9} {url}\n" ) } else { format!( - "{} {:>8} {:>8}l {:>8}w {:>8}c {}\n", - color_status, method, line_count, word_count, content_length, url + "{color_status} {method:>8} {line_count:>8}l {word_count:>8}w {content_length:>8}c {url}\n" ) } } @@ -423,7 +421,7 @@ fn should_deny_absolute(url_to_test: &Url, denier: &Url, handles: Arc) // to a scanned url that is also a parent of the given url for ferox_scan in handles.ferox_scans()?.get_active_scans() { let scanner = Url::parse(ferox_scan.url().trim_end_matches('/')) - .with_context(|| format!("Could not parse {} as a url", ferox_scan))?; + .with_context(|| format!("Could not parse {ferox_scan} as a url"))?; if let Some(scan_host) = scanner.host() { // same domain/ip check we perform on the denier above @@ -521,14 +519,14 @@ pub fn slugify_filename(url: &str, prefix: &str, suffix: &str) -> String { .as_secs(); let altered_prefix = if !prefix.is_empty() { - format!("{}-", prefix) + format!("{prefix}-") } else { String::new() }; let slug = url.replace("://", "_").replace(['/', '.'], "_"); - let filename = format!("{}{}-{}.{}", altered_prefix, slug, ts, suffix); + let filename = format!("{altered_prefix}{slug}-{ts}.{suffix}"); log::trace!("exit: slugify -> {}", filename); filename diff --git a/tests/test_main.rs b/tests/test_main.rs index 6a1ba62..6db6a60 100644 --- a/tests/test_main.rs +++ b/tests/test_main.rs @@ -127,7 +127,7 @@ fn main_parallel_spawns_children() -> Result<(), Box> { ); let contents = read_to_string(outfile).unwrap(); - println!("contents: {}", contents); + println!("contents: {contents}"); assert!(contents.contains("parallel branch && wrapped main")); // exits parallel branch diff --git a/tests/test_policies.rs b/tests/test_policies.rs index 68a223d..f1d2adb 100644 --- a/tests/test_policies.rs +++ b/tests/test_policies.rs @@ -92,7 +92,7 @@ fn auto_bail_cancels_scan_with_timeouts() { .parse::() .unwrap(); - println!("expected: {}", total_expected); + println!("expected: {total_expected}"); // without bailing, should be 6180; after bail decreases significantly assert!(total_expected < 5000); } @@ -161,7 +161,7 @@ fn auto_bail_cancels_scan_with_403s() { let str_msg = message.as_str().unwrap_or_default().to_string(); if str_msg.starts_with("Stats") { - println!("{}", str_msg); + println!("{str_msg}"); let re = Regex::new("total_expected: ([0-9]+),").unwrap(); assert!(re.is_match(&str_msg)); let total_expected = re @@ -171,7 +171,7 @@ fn auto_bail_cancels_scan_with_403s() { .map_or("", |m| m.as_str()) .parse::() .unwrap(); - println!("total_expected: {}", total_expected); + println!("total_expected: {total_expected}"); assert!(total_expected < 5000); } } @@ -243,7 +243,7 @@ fn auto_bail_cancels_scan_with_429s() { let str_msg = message.as_str().unwrap_or_default().to_string(); if str_msg.starts_with("Stats") { - println!("{}", str_msg); + println!("{str_msg}"); let re = Regex::new("total_expected: ([0-9]+),").unwrap(); assert!(re.is_match(&str_msg)); let total_expected = re @@ -253,7 +253,7 @@ fn auto_bail_cancels_scan_with_429s() { .map_or("", |m| m.as_str()) .parse::() .unwrap(); - println!("total_expected: {}", total_expected); + println!("total_expected: {total_expected}"); assert!(total_expected < 5000); } } diff --git a/tests/test_scan_manager.rs b/tests/test_scan_manager.rs index 067684c..b59c7e7 100644 --- a/tests/test_scan_manager.rs +++ b/tests/test_scan_manager.rs @@ -29,7 +29,7 @@ fn resume_scan_works() { srv.url("/js"), srv.url("/js") ); - let scans = format!(r#""scans":[{},{}]"#, complete_scan, incomplete_scan); + let scans = format!(r#""scans":[{complete_scan},{incomplete_scan}]"#); let config = format!( r#""config": {{"type":"configuration","wordlist":"{}","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,"silent":false,"quiet":false,"json":false,"output":"","debug_log":"","user_agent":"feroxbuster/1.9.0","redirects":false,"insecure":false,"extensions":[],"headers":{{}},"queries":[],"no_recursion":false,"extract_links":false,"add_slash":false,"stdin":false,"depth":2,"scan_limit":1,"filter_size":[],"filter_line_count":[],"filter_word_count":[],"filter_regex":[],"dont_filter":false}}"#, @@ -42,7 +42,7 @@ fn resume_scan_works() { r#"{{"type":"response","url":"{}","path":"/js/css","wildcard":true,"status":301,"content_length":173,"line_count":10,"word_count":16,"headers":{{"server":"nginx/1.16.1"}}}}"#, srv.url("/js/css") ); - let responses = format!(r#""responses":[{}]"#, response); + let responses = format!(r#""responses":[{response}]"#); // not scanned because /js is not complete, and /js/stuff response is not known let not_scanned_yet = srv.mock(|when, then| { @@ -63,7 +63,7 @@ fn resume_scan_works() { then.status(200).body("two words"); }); - let state_file_contents = format!("{{{},{},{}}}", scans, config, responses); + let state_file_contents = format!("{{{scans},{config},{responses}}}"); let (tmp_dir2, state_file) = setup_tmp_directory(&[state_file_contents], "state-file").unwrap(); Command::cargo_bin("feroxbuster") diff --git a/tests/test_scanner.rs b/tests/test_scanner.rs index 90cb375..e3e6d11 100644 --- a/tests/test_scanner.rs +++ b/tests/test_scanner.rs @@ -454,7 +454,7 @@ fn scanner_single_request_scan_with_debug_logging() { .unwrap(); let contents = std::fs::read_to_string(outfile).unwrap(); - println!("{}", contents); + println!("{contents}"); assert!(contents.starts_with("Configuration {")); assert!(contents.contains("TRC")); assert!(contents.contains("DBG")); @@ -492,7 +492,7 @@ fn scanner_single_request_scan_with_debug_logging_as_json() { .unwrap(); let contents = std::fs::read_to_string(outfile).unwrap(); - println!("{}", contents); + println!("{contents}"); assert!(contents.starts_with("{\"type\":\"configuration\"")); assert!(contents.contains("\"level\":\"TRACE\"")); assert!(contents.contains("\"level\":\"DEBUG\"")); @@ -676,7 +676,7 @@ fn add_discovered_extension_updates_bars_and_stats() { .success(); let contents = std::fs::read_to_string(file_path).unwrap(); - println!("{}", contents); + println!("{contents}"); assert!(contents.contains("discovered new extension: php")); assert!(contents.contains("extensions_collected: 1")); assert!(contents.contains("expected_per_scan: 6")); @@ -896,7 +896,7 @@ fn scanner_forced_recursion_ignores_normal_redirect_logic() -> Result<(), Box