From bc321356b20a677091e8a8ce160b918c888250b3 Mon Sep 17 00:00:00 2001 From: epi Date: Sat, 25 Nov 2023 08:03:13 -0500 Subject: [PATCH 1/7] --collect-backups flag changed to accept values --- shell_completions/_feroxbuster | 4 ++-- shell_completions/_feroxbuster.ps1 | 4 ++-- shell_completions/feroxbuster.bash | 8 ++++++++ shell_completions/feroxbuster.elv | 4 ++-- src/parser.rs | 4 ++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/shell_completions/_feroxbuster b/shell_completions/_feroxbuster index 61a2a5b6..d1e699ff 100644 --- a/shell_completions/_feroxbuster +++ b/shell_completions/_feroxbuster @@ -67,6 +67,8 @@ _feroxbuster() { '--time-limit=[Limit total run time of all scans (ex\: --time-limit 10m)]:TIME_SPEC: ' \ '-w+[Path or URL of the wordlist]:FILE:_files' \ '--wordlist=[Path or URL of the wordlist]:FILE:_files' \ +'-B+[Automatically request likely backup extensions for "found" urls (default\: ~, .bak, .bak2, .old, .1)]' \ +'--collect-backups=[Automatically request likely backup extensions for "found" urls (default\: ~, .bak, .bak2, .old, .1)]' \ '*-I+[File extension(s) to Ignore while collecting extensions (only used with --collect-extensions)]:FILE_EXTENSION: ' \ '*--dont-collect=[File extension(s) to Ignore while collecting extensions (only used with --collect-extensions)]:FILE_EXTENSION: ' \ '-o+[Output file to write results to (use w/ --json for JSON entries)]:FILE:_files' \ @@ -97,8 +99,6 @@ _feroxbuster() { '--dont-filter[Don'\''t auto-filter wildcard responses]' \ '-E[Automatically discover extensions and add them to --extensions (unless they'\''re in --dont-collect)]' \ '--collect-extensions[Automatically discover extensions and add them to --extensions (unless they'\''re in --dont-collect)]' \ -'-B[Automatically request likely backup extensions for "found" urls]' \ -'--collect-backups[Automatically request likely backup extensions for "found" urls]' \ '-g[Automatically discover important words from within responses and add them to the wordlist]' \ '--collect-words[Automatically discover important words from within responses and add them to the wordlist]' \ '(--silent)*-v[Increase verbosity level (use -vv or more for greater effect. \[CAUTION\] 4 -v'\''s is probably too much)]' \ diff --git a/shell_completions/_feroxbuster.ps1 b/shell_completions/_feroxbuster.ps1 index 9be27d4a..9483ecb6 100644 --- a/shell_completions/_feroxbuster.ps1 +++ b/shell_completions/_feroxbuster.ps1 @@ -73,6 +73,8 @@ Register-ArgumentCompleter -Native -CommandName 'feroxbuster' -ScriptBlock { [CompletionResult]::new('--time-limit', 'time-limit', [CompletionResultType]::ParameterName, 'Limit total run time of all scans (ex: --time-limit 10m)') [CompletionResult]::new('-w', 'w', [CompletionResultType]::ParameterName, 'Path or URL of the wordlist') [CompletionResult]::new('--wordlist', 'wordlist', [CompletionResultType]::ParameterName, 'Path or URL of the wordlist') + [CompletionResult]::new('-B', 'B ', [CompletionResultType]::ParameterName, 'Automatically request likely backup extensions for "found" urls (default: ~, .bak, .bak2, .old, .1)') + [CompletionResult]::new('--collect-backups', 'collect-backups', [CompletionResultType]::ParameterName, 'Automatically request likely backup extensions for "found" urls (default: ~, .bak, .bak2, .old, .1)') [CompletionResult]::new('-I', 'I ', [CompletionResultType]::ParameterName, 'File extension(s) to Ignore while collecting extensions (only used with --collect-extensions)') [CompletionResult]::new('--dont-collect', 'dont-collect', [CompletionResultType]::ParameterName, 'File extension(s) to Ignore while collecting extensions (only used with --collect-extensions)') [CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Output file to write results to (use w/ --json for JSON entries)') @@ -103,8 +105,6 @@ Register-ArgumentCompleter -Native -CommandName 'feroxbuster' -ScriptBlock { [CompletionResult]::new('--dont-filter', 'dont-filter', [CompletionResultType]::ParameterName, 'Don''t auto-filter wildcard responses') [CompletionResult]::new('-E', 'E ', [CompletionResultType]::ParameterName, 'Automatically discover extensions and add them to --extensions (unless they''re in --dont-collect)') [CompletionResult]::new('--collect-extensions', 'collect-extensions', [CompletionResultType]::ParameterName, 'Automatically discover extensions and add them to --extensions (unless they''re in --dont-collect)') - [CompletionResult]::new('-B', 'B ', [CompletionResultType]::ParameterName, 'Automatically request likely backup extensions for "found" urls') - [CompletionResult]::new('--collect-backups', 'collect-backups', [CompletionResultType]::ParameterName, 'Automatically request likely backup extensions for "found" urls') [CompletionResult]::new('-g', 'g', [CompletionResultType]::ParameterName, 'Automatically discover important words from within responses and add them to the wordlist') [CompletionResult]::new('--collect-words', 'collect-words', [CompletionResultType]::ParameterName, 'Automatically discover important words from within responses and add them to the wordlist') [CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'Increase verbosity level (use -vv or more for greater effect. [CAUTION] 4 -v''s is probably too much)') diff --git a/shell_completions/feroxbuster.bash b/shell_completions/feroxbuster.bash index 2df3ed92..da23b7fd 100644 --- a/shell_completions/feroxbuster.bash +++ b/shell_completions/feroxbuster.bash @@ -233,6 +233,14 @@ _feroxbuster() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --collect-backups) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -B) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --dont-collect) COMPREPLY=($(compgen -f "${cur}")) return 0 diff --git a/shell_completions/feroxbuster.elv b/shell_completions/feroxbuster.elv index 1cf4240e..6019261c 100644 --- a/shell_completions/feroxbuster.elv +++ b/shell_completions/feroxbuster.elv @@ -70,6 +70,8 @@ set edit:completion:arg-completer[feroxbuster] = {|@words| cand --time-limit 'Limit total run time of all scans (ex: --time-limit 10m)' cand -w 'Path or URL of the wordlist' cand --wordlist 'Path or URL of the wordlist' + cand -B 'Automatically request likely backup extensions for "found" urls (default: ~, .bak, .bak2, .old, .1)' + cand --collect-backups 'Automatically request likely backup extensions for "found" urls (default: ~, .bak, .bak2, .old, .1)' cand -I 'File extension(s) to Ignore while collecting extensions (only used with --collect-extensions)' cand --dont-collect 'File extension(s) to Ignore while collecting extensions (only used with --collect-extensions)' cand -o 'Output file to write results to (use w/ --json for JSON entries)' @@ -100,8 +102,6 @@ set edit:completion:arg-completer[feroxbuster] = {|@words| cand --dont-filter 'Don''t auto-filter wildcard responses' cand -E 'Automatically discover extensions and add them to --extensions (unless they''re in --dont-collect)' cand --collect-extensions 'Automatically discover extensions and add them to --extensions (unless they''re in --dont-collect)' - cand -B 'Automatically request likely backup extensions for "found" urls' - cand --collect-backups 'Automatically request likely backup extensions for "found" urls' cand -g 'Automatically discover important words from within responses and add them to the wordlist' cand --collect-words 'Automatically discover important words from within responses and add them to the wordlist' cand -v 'Increase verbosity level (use -vv or more for greater effect. [CAUTION] 4 -v''s is probably too much)' diff --git a/src/parser.rs b/src/parser.rs index c40cab67..19056d2e 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -550,9 +550,9 @@ pub fn initialize() -> Command { Arg::new("collect_backups") .short('B') .long("collect-backups") - .num_args(0) + .num_args(0..) .help_heading("Dynamic collection settings") - .help("Automatically request likely backup extensions for \"found\" urls") + .help("Automatically request likely backup extensions for \"found\" urls (default: ~, .bak, .bak2, .old, .1)") ) .arg( Arg::new("collect_words") From b37fcc0cd3f9ca51f087815b0e4b64de1c99b66a Mon Sep 17 00:00:00 2001 From: epi Date: Sat, 25 Nov 2023 08:03:38 -0500 Subject: [PATCH 2/7] added default set of backup extensions constant --- src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index c327d5ad..1808d260 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,6 +59,11 @@ pub(crate) const DEFAULT_IGNORED_EXTENSIONS: [&str; 38] = [ "webm", "ogv", "oga", "flac", "aac", "3gp", "css", "zip", "xls", "xml", "gz", "tgz", ]; +/// Default set of extensions to search for when auto-collecting backups during scans +pub(crate) const DEFAULT_BACKUP_EXTENSIONS: [&str; 5] = [ + "~", ".bak", ".bak2", ".old", ".1" +]; + /// Default wordlist to use when `-w|--wordlist` isn't specified and not `wordlist` isn't set /// in a [ferox-config.toml](constant.DEFAULT_CONFIG_NAME.html) config file. /// From ca26bba382b5e509f67ffec35248dcb0738fa9b5 Mon Sep 17 00:00:00 2001 From: epi Date: Sat, 25 Nov 2023 08:04:35 -0500 Subject: [PATCH 3/7] tweaked cli parsing to account for changes to --collect-backups --- src/config/container.rs | 45 +++++++++++++++++++++++++++++++++++++++-- src/config/tests.rs | 9 +++++++++ src/config/utils.rs | 9 +++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/config/container.rs b/src/config/container.rs index 886b0d3c..456512c2 100644 --- a/src/config/container.rs +++ b/src/config/container.rs @@ -1,6 +1,6 @@ use super::utils::{ - depth, extract_links, ignored_extensions, methods, report_and_exit, save_state, - serialized_type, status_codes, threads, timeout, user_agent, wordlist, OutputLevel, + backup_extensions, depth, extract_links, ignored_extensions, methods, report_and_exit, + save_state, serialized_type, status_codes, threads, timeout, user_agent, wordlist, OutputLevel, RequesterPolicy, }; use crate::config::determine_output_level; @@ -318,6 +318,9 @@ pub struct Configuration { #[serde(default)] pub collect_backups: bool, + #[serde(default = "backup_extensions")] + pub backup_extensions: Vec, + /// Automatically discover important words from within responses and add them to the wordlist #[serde(default)] pub collect_words: bool, @@ -418,6 +421,7 @@ impl Default for Configuration { threads: threads(), wordlist: wordlist(), dont_collect: ignored_extensions(), + backup_extensions: backup_extensions(), } } } @@ -450,6 +454,7 @@ impl Configuration { /// - **extensions**: `None` /// - **collect_extensions**: `false` /// - **collect_backups**: `false` + /// - **backup_extensions**: [`DEFAULT_BACKUP_EXTENSIONS`](constant.DEFAULT_BACKUP_EXTENSIONS.html) /// - **collect_words**: `false` /// - **dont_collect**: [`DEFAULT_IGNORED_EXTENSIONS`](constant.DEFAULT_RESPONSE_CODES.html) /// - **methods**: [`DEFAULT_METHOD`](constant.DEFAULT_METHOD.html) @@ -836,6 +841,37 @@ impl Configuration { || came_from_cli!(args, "thorough") { config.collect_backups = true; + + println!("{:?}", came_from_cli!(args, "collect_backups")); + + if came_from_cli!(args, "collect_backups") { + if let Some(arg) = args.get_many::("collect_backups") { + let mut backup_exts = Vec::::new(); + + for ext in arg { + println!("pushing {} to backup_extensions (was {})", ext.trim(), ext); + backup_exts.push(ext.trim().to_string()); + } + + if backup_exts.is_empty() { + config.backup_extensions = backup_extensions(); + println!( + "no backup extensions specified, using defaults: {:?}", + backup_extensions() + ); + } else { + config.backup_extensions = backup_exts; + } + } else { + config.backup_extensions = backup_extensions(); + println!( + "no backup extensions specified, using defaults: {:?}", + backup_extensions() + ); + } + } else { + config.backup_extensions = backup_extensions(); + } } if came_from_cli!(args, "collect_words") @@ -1138,6 +1174,11 @@ impl Configuration { update_if_not_default!(&mut conf.timeout, new.timeout, timeout()); update_if_not_default!(&mut conf.user_agent, new.user_agent, user_agent()); + update_if_not_default!( + &mut conf.backup_extensions, + new.backup_extensions, + backup_extensions() + ); update_if_not_default!(&mut conf.random_agent, new.random_agent, false); update_if_not_default!(&mut conf.threads, new.threads, threads()); update_if_not_default!(&mut conf.depth, new.depth, depth()); diff --git a/src/config/tests.rs b/src/config/tests.rs index 8657d576..cbde9312 100644 --- a/src/config/tests.rs +++ b/src/config/tests.rs @@ -59,6 +59,7 @@ fn setup_config_test() -> Configuration { server_certs = ["/some/cert.pem", "/some/other/cert.pem"] client_cert = "/some/client/cert.pem" client_key = "/some/client/key.pem" + backup_extensions = [".save"] "#; let tmp_dir = TempDir::new().unwrap(); let file = tmp_dir.path().join(DEFAULT_CONFIG_NAME); @@ -123,6 +124,7 @@ fn default_configuration() { assert_eq!(config.server_certs, Vec::::new()); assert_eq!(config.client_cert, String::new()); assert_eq!(config.client_key, String::new()); + assert_eq!(config.backup_extensions, backup_extensions()); } #[test] @@ -459,6 +461,13 @@ fn config_reads_server_certs() { ); } +#[test] +/// parse the test config and see that the value parsed is correct +fn config_reads_backup_extensions() { + let config = setup_config_test(); + assert_eq!(config.backup_extensions, [".save"]); +} + #[test] /// parse the test config and see that the value parsed is correct fn config_reads_client_cert() { diff --git a/src/config/utils.rs b/src/config/utils.rs index 1d1e30b2..6511890c 100644 --- a/src/config/utils.rs +++ b/src/config/utils.rs @@ -1,6 +1,7 @@ use crate::{ utils::{module_colorizer, status_colorizer}, DEFAULT_IGNORED_EXTENSIONS, DEFAULT_METHOD, DEFAULT_STATUS_CODES, DEFAULT_WORDLIST, VERSION, + DEFAULT_BACKUP_EXTENSIONS }; #[cfg(not(test))] use std::process::exit; @@ -69,6 +70,14 @@ pub(super) fn ignored_extensions() -> Vec { .collect() } +/// default backup extensions to collect +pub(super) fn backup_extensions() -> Vec { + DEFAULT_BACKUP_EXTENSIONS + .iter() + .map(|s| s.to_string()) + .collect() +} + /// default wordlist pub(super) fn wordlist() -> String { String::from(DEFAULT_WORDLIST) From 6f66008a4c21ff554138628692ea3b88dc137d9c Mon Sep 17 00:00:00 2001 From: epi Date: Sat, 25 Nov 2023 08:05:04 -0500 Subject: [PATCH 4/7] changed backup collection to use new cli values; fixed bug that could hang ferox on exit --- src/event_handlers/outputs.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/event_handlers/outputs.rs b/src/event_handlers/outputs.rs index 36a5e4f7..7555ca65 100644 --- a/src/event_handlers/outputs.rs +++ b/src/event_handlers/outputs.rs @@ -209,8 +209,12 @@ impl TermOutHandler { while let Some(command) = self.receiver.recv().await { match command { Command::Report(resp) => { - self.process_response(tx_stats.clone(), resp, ProcessResponseCall::Recursive) - .await?; + if let Err(err) = self + .process_response(tx_stats.clone(), resp, ProcessResponseCall::Recursive) + .await + { + log::warn!("{}", err); + } } Command::Sync(sender) => { sender.send(true).unwrap_or_default(); @@ -400,7 +404,7 @@ impl TermOutHandler { if !filename.is_empty() { // append rules - for suffix in ["~", ".bak", ".bak2", ".old", ".1"] { + for suffix in &self.config.backup_extensions { self.add_new_url_to_vec(url, &format!("{filename}{suffix}"), &mut urls); } From 2b90fcd6741bc98cba42e13aeba8c806986bd08a Mon Sep 17 00:00:00 2001 From: epi Date: Sat, 25 Nov 2023 08:06:35 -0500 Subject: [PATCH 5/7] fmt --- src/config/utils.rs | 4 ++-- src/lib.rs | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/config/utils.rs b/src/config/utils.rs index 6511890c..f3bd3b44 100644 --- a/src/config/utils.rs +++ b/src/config/utils.rs @@ -1,7 +1,7 @@ use crate::{ utils::{module_colorizer, status_colorizer}, - DEFAULT_IGNORED_EXTENSIONS, DEFAULT_METHOD, DEFAULT_STATUS_CODES, DEFAULT_WORDLIST, VERSION, - DEFAULT_BACKUP_EXTENSIONS + DEFAULT_BACKUP_EXTENSIONS, DEFAULT_IGNORED_EXTENSIONS, DEFAULT_METHOD, DEFAULT_STATUS_CODES, + DEFAULT_WORDLIST, VERSION, }; #[cfg(not(test))] use std::process::exit; diff --git a/src/lib.rs b/src/lib.rs index 1808d260..8e170c2d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,9 +60,7 @@ pub(crate) const DEFAULT_IGNORED_EXTENSIONS: [&str; 38] = [ ]; /// Default set of extensions to search for when auto-collecting backups during scans -pub(crate) const DEFAULT_BACKUP_EXTENSIONS: [&str; 5] = [ - "~", ".bak", ".bak2", ".old", ".1" -]; +pub(crate) const DEFAULT_BACKUP_EXTENSIONS: [&str; 5] = ["~", ".bak", ".bak2", ".old", ".1"]; /// Default wordlist to use when `-w|--wordlist` isn't specified and not `wordlist` isn't set /// in a [ferox-config.toml](constant.DEFAULT_CONFIG_NAME.html) config file. From 2051424d988cb96eb8d8a1c670e50232acef0d82 Mon Sep 17 00:00:00 2001 From: epi Date: Sat, 25 Nov 2023 08:18:32 -0500 Subject: [PATCH 6/7] bumped version to 2.10.2 --- Cargo.lock | 2 +- Cargo.toml | 2 +- shell_completions/_feroxbuster | 4 ++-- shell_completions/_feroxbuster.ps1 | 4 ++-- shell_completions/feroxbuster.elv | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 551d5d29..974451c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -846,7 +846,7 @@ dependencies = [ [[package]] name = "feroxbuster" -version = "2.10.1" +version = "2.10.2" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index acaa4652..83b8f7e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "feroxbuster" -version = "2.10.1" +version = "2.10.2" authors = ["Ben 'epi' Risher (@epi052)"] license = "MIT" edition = "2021" diff --git a/shell_completions/_feroxbuster b/shell_completions/_feroxbuster index d1e699ff..b5a6659d 100644 --- a/shell_completions/_feroxbuster +++ b/shell_completions/_feroxbuster @@ -24,8 +24,8 @@ _feroxbuster() { '--replay-proxy=[Send only unfiltered requests through a Replay Proxy, instead of all requests]:REPLAY_PROXY:_urls' \ '*-R+[Status Codes to send through a Replay Proxy when found (default\: --status-codes value)]:REPLAY_CODE: ' \ '*--replay-codes=[Status Codes to send through a Replay Proxy when found (default\: --status-codes value)]:REPLAY_CODE: ' \ -'-a+[Sets the User-Agent (default\: feroxbuster/2.10.1)]:USER_AGENT: ' \ -'--user-agent=[Sets the User-Agent (default\: feroxbuster/2.10.1)]:USER_AGENT: ' \ +'-a+[Sets the User-Agent (default\: feroxbuster/2.10.2)]:USER_AGENT: ' \ +'--user-agent=[Sets the User-Agent (default\: feroxbuster/2.10.2)]:USER_AGENT: ' \ '*-x+[File extension(s) to search for (ex\: -x php -x pdf js); reads values (newline-separated) from file if input starts with an @ (ex\: @ext.txt)]:FILE_EXTENSION: ' \ '*--extensions=[File extension(s) to search for (ex\: -x php -x pdf js); reads values (newline-separated) from file if input starts with an @ (ex\: @ext.txt)]:FILE_EXTENSION: ' \ '*-m+[Which HTTP request method(s) should be sent (default\: GET)]:HTTP_METHODS: ' \ diff --git a/shell_completions/_feroxbuster.ps1 b/shell_completions/_feroxbuster.ps1 index 9483ecb6..6cf33676 100644 --- a/shell_completions/_feroxbuster.ps1 +++ b/shell_completions/_feroxbuster.ps1 @@ -30,8 +30,8 @@ Register-ArgumentCompleter -Native -CommandName 'feroxbuster' -ScriptBlock { [CompletionResult]::new('--replay-proxy', 'replay-proxy', [CompletionResultType]::ParameterName, 'Send only unfiltered requests through a Replay Proxy, instead of all requests') [CompletionResult]::new('-R', 'R ', [CompletionResultType]::ParameterName, 'Status Codes to send through a Replay Proxy when found (default: --status-codes value)') [CompletionResult]::new('--replay-codes', 'replay-codes', [CompletionResultType]::ParameterName, 'Status Codes to send through a Replay Proxy when found (default: --status-codes value)') - [CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Sets the User-Agent (default: feroxbuster/2.10.1)') - [CompletionResult]::new('--user-agent', 'user-agent', [CompletionResultType]::ParameterName, 'Sets the User-Agent (default: feroxbuster/2.10.1)') + [CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Sets the User-Agent (default: feroxbuster/2.10.2)') + [CompletionResult]::new('--user-agent', 'user-agent', [CompletionResultType]::ParameterName, 'Sets the User-Agent (default: feroxbuster/2.10.2)') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'File extension(s) to search for (ex: -x php -x pdf js); reads values (newline-separated) from file if input starts with an @ (ex: @ext.txt)') [CompletionResult]::new('--extensions', 'extensions', [CompletionResultType]::ParameterName, 'File extension(s) to search for (ex: -x php -x pdf js); reads values (newline-separated) from file if input starts with an @ (ex: @ext.txt)') [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'Which HTTP request method(s) should be sent (default: GET)') diff --git a/shell_completions/feroxbuster.elv b/shell_completions/feroxbuster.elv index 6019261c..dbdb41ca 100644 --- a/shell_completions/feroxbuster.elv +++ b/shell_completions/feroxbuster.elv @@ -27,8 +27,8 @@ set edit:completion:arg-completer[feroxbuster] = {|@words| cand --replay-proxy 'Send only unfiltered requests through a Replay Proxy, instead of all requests' cand -R 'Status Codes to send through a Replay Proxy when found (default: --status-codes value)' cand --replay-codes 'Status Codes to send through a Replay Proxy when found (default: --status-codes value)' - cand -a 'Sets the User-Agent (default: feroxbuster/2.10.1)' - cand --user-agent 'Sets the User-Agent (default: feroxbuster/2.10.1)' + cand -a 'Sets the User-Agent (default: feroxbuster/2.10.2)' + cand --user-agent 'Sets the User-Agent (default: feroxbuster/2.10.2)' cand -x 'File extension(s) to search for (ex: -x php -x pdf js); reads values (newline-separated) from file if input starts with an @ (ex: @ext.txt)' cand --extensions 'File extension(s) to search for (ex: -x php -x pdf js); reads values (newline-separated) from file if input starts with an @ (ex: @ext.txt)' cand -m 'Which HTTP request method(s) should be sent (default: GET)' From ab9a3b0fd72a22574fa5e49241e46001f392118d Mon Sep 17 00:00:00 2001 From: epi Date: Sat, 25 Nov 2023 08:18:51 -0500 Subject: [PATCH 7/7] underped cli logic --- src/config/container.rs | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/config/container.rs b/src/config/container.rs index 456512c2..1e7331ae 100644 --- a/src/config/container.rs +++ b/src/config/container.rs @@ -841,36 +841,19 @@ impl Configuration { || came_from_cli!(args, "thorough") { config.collect_backups = true; - - println!("{:?}", came_from_cli!(args, "collect_backups")); + config.backup_extensions = backup_extensions(); if came_from_cli!(args, "collect_backups") { if let Some(arg) = args.get_many::("collect_backups") { - let mut backup_exts = Vec::::new(); - - for ext in arg { - println!("pushing {} to backup_extensions (was {})", ext.trim(), ext); - backup_exts.push(ext.trim().to_string()); - } + let backup_exts = arg + .map(|ext| ext.trim().to_string()) + .collect::>(); - if backup_exts.is_empty() { - config.backup_extensions = backup_extensions(); - println!( - "no backup extensions specified, using defaults: {:?}", - backup_extensions() - ); - } else { + if !backup_exts.is_empty() { + // have at least one cli backup, override the defaults config.backup_extensions = backup_exts; } - } else { - config.backup_extensions = backup_extensions(); - println!( - "no backup extensions specified, using defaults: {:?}", - backup_extensions() - ); } - } else { - config.backup_extensions = backup_extensions(); } }