mirror of
https://github.com/epi052/feroxbuster.git
synced 2026-06-03 23:11:12 -03:00
clippy and tests
This commit is contained in:
@@ -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.6.1)]:USER_AGENT: ' \
|
||||
'--user-agent=[Sets the User-Agent (default: feroxbuster/2.6.1)]:USER_AGENT: ' \
|
||||
'-a+[Sets the User-Agent (default: feroxbuster/2.6.2)]:USER_AGENT: ' \
|
||||
'--user-agent=[Sets the User-Agent (default: feroxbuster/2.6.2)]:USER_AGENT: ' \
|
||||
'*-x+[File extension(s) to search for (ex: -x php -x pdf js)]:FILE_EXTENSION: ' \
|
||||
'*--extensions=[File extension(s) to search for (ex: -x php -x pdf js)]:FILE_EXTENSION: ' \
|
||||
'*-m+[Which HTTP request method(s) should be sent (default: GET)]:HTTP_METHODS: ' \
|
||||
|
||||
@@ -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.6.1)')
|
||||
[CompletionResult]::new('--user-agent', 'user-agent', [CompletionResultType]::ParameterName, 'Sets the User-Agent (default: feroxbuster/2.6.1)')
|
||||
[CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Sets the User-Agent (default: feroxbuster/2.6.2)')
|
||||
[CompletionResult]::new('--user-agent', 'user-agent', [CompletionResultType]::ParameterName, 'Sets the User-Agent (default: feroxbuster/2.6.2)')
|
||||
[CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'File extension(s) to search for (ex: -x php -x pdf js)')
|
||||
[CompletionResult]::new('--extensions', 'extensions', [CompletionResultType]::ParameterName, 'File extension(s) to search for (ex: -x php -x pdf js)')
|
||||
[CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'Which HTTP request method(s) should be sent (default: GET)')
|
||||
|
||||
@@ -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.6.1)'
|
||||
cand --user-agent 'Sets the User-Agent (default: feroxbuster/2.6.1)'
|
||||
cand -a 'Sets the User-Agent (default: feroxbuster/2.6.2)'
|
||||
cand --user-agent 'Sets the User-Agent (default: feroxbuster/2.6.2)'
|
||||
cand -x 'File extension(s) to search for (ex: -x php -x pdf js)'
|
||||
cand --extensions 'File extension(s) to search for (ex: -x php -x pdf js)'
|
||||
cand -m 'Which HTTP request method(s) should be sent (default: GET)'
|
||||
|
||||
@@ -2,7 +2,6 @@ use super::*;
|
||||
use crate::filters::EmptyFilter;
|
||||
use crate::{filters::FeroxFilters, CommandSender, FeroxChannel, Joiner};
|
||||
use anyhow::Result;
|
||||
use std::io::Empty;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{
|
||||
mpsc::{self, UnboundedReceiver},
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
use super::*;
|
||||
use crate::config::Configuration;
|
||||
use crate::{
|
||||
filters::{
|
||||
LinesFilter, RegexFilter, SimilarityFilter, SizeFilter, StatusCodeFilter, WordsFilter,
|
||||
},
|
||||
progress::PROGRESS_PRINTER,
|
||||
scan_manager::{FeroxState, PAUSE_SCAN},
|
||||
scanner::RESPONSES,
|
||||
|
||||
@@ -6,7 +6,7 @@ pub struct EmptyFilter {}
|
||||
|
||||
impl FeroxFilter for EmptyFilter {
|
||||
/// `EmptyFilter` always returns false
|
||||
fn should_filter_response(&self, response: &FeroxResponse) -> bool {
|
||||
fn should_filter_response(&self, _response: &FeroxResponse) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
use super::{
|
||||
utils::create_similarity_filter, LinesFilter, RegexFilter, SimilarityFilter, SizeFilter,
|
||||
StatusCodeFilter, WordsFilter,
|
||||
};
|
||||
use crate::{
|
||||
event_handlers::Handles,
|
||||
response::FeroxResponse,
|
||||
skip_fail,
|
||||
utils::{fmt_err, logged_request},
|
||||
Command::AddFilter,
|
||||
DEFAULT_METHOD, SIMILARITY_THRESHOLD,
|
||||
utils::create_similarity_filter, LinesFilter, RegexFilter, SizeFilter, StatusCodeFilter,
|
||||
WordsFilter,
|
||||
};
|
||||
use crate::{event_handlers::Handles, skip_fail, utils::fmt_err, Command::AddFilter};
|
||||
use anyhow::Result;
|
||||
use fuzzyhash::FuzzyHash;
|
||||
use regex::Regex;
|
||||
use reqwest::Url;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// add all user-supplied filters to the (already started) filters handler
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! contains all of feroxbuster's filters
|
||||
use ::regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::any::Any;
|
||||
use std::fmt::Debug;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use super::*;
|
||||
use ::regex::Regex;
|
||||
use serde::{ser::SerializeStruct, Deserializer, Serializer};
|
||||
|
||||
/// Simple implementor of FeroxFilter; used to filter out responses based on a given regular
|
||||
/// expression; specified using -X|--filter-regex
|
||||
|
||||
@@ -17,7 +17,6 @@ use tokio::{
|
||||
};
|
||||
use tokio_util::codec::{FramedRead, LinesCodec};
|
||||
|
||||
use feroxbuster::event_handlers::Command::AddFilter;
|
||||
use feroxbuster::scan_manager::ScanType;
|
||||
use feroxbuster::{
|
||||
banner::{Banner, UPDATE_URL},
|
||||
|
||||
@@ -2,10 +2,9 @@ use super::scan::ScanType;
|
||||
use super::*;
|
||||
use crate::event_handlers::Handles;
|
||||
use crate::filters::{
|
||||
EmptyFilter, FeroxFilters, LinesFilter, RegexFilter, SimilarityFilter, SizeFilter,
|
||||
StatusCodeFilter, WildcardFilter, WordsFilter,
|
||||
EmptyFilter, LinesFilter, RegexFilter, SimilarityFilter, SizeFilter, StatusCodeFilter,
|
||||
WildcardFilter, WordsFilter,
|
||||
};
|
||||
use crate::scan_manager::MenuCmd::Add;
|
||||
use crate::traits::FeroxFilter;
|
||||
use crate::utils::{create_report_string, ferox_print};
|
||||
use crate::Command::AddFilter;
|
||||
@@ -22,7 +21,6 @@ use anyhow::Result;
|
||||
use console::style;
|
||||
use reqwest::StatusCode;
|
||||
use serde::{ser::SerializeSeq, Serialize, Serializer};
|
||||
use std::alloc::handle_alloc_error;
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
convert::TryInto,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use crate::filters::FeroxFilters;
|
||||
use crate::{
|
||||
config::{Configuration, OutputLevel},
|
||||
event_handlers::Handles,
|
||||
@@ -370,7 +371,15 @@ fn feroxstates_feroxserialize_implementation() {
|
||||
let response: FeroxResponse = serde_json::from_str(json_response).unwrap();
|
||||
RESPONSES.insert(response);
|
||||
|
||||
let ferox_state = FeroxState::new(Arc::new(ferox_scans), Arc::new(config), &RESPONSES, stats);
|
||||
let filters = Arc::new(FeroxFilters::default());
|
||||
|
||||
let ferox_state = FeroxState::new(
|
||||
Arc::new(ferox_scans),
|
||||
Arc::new(config),
|
||||
&RESPONSES,
|
||||
stats,
|
||||
filters,
|
||||
);
|
||||
|
||||
let expected_strs = predicates::str::contains("scans: FeroxScans").and(
|
||||
predicate::str::contains("config: Configuration")
|
||||
@@ -602,9 +611,9 @@ fn menu_print_header_and_footer() {
|
||||
menu.show_progress_bars();
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// ensure command parsing from user input results int he correct MenuCmd returned
|
||||
fn menu_get_command_input_from_user_returns_cancel() {
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
|
||||
async fn menu_get_command_input_from_user_returns_cancel() {
|
||||
let menu = Menu::new();
|
||||
|
||||
for (idx, cmd) in ["cancel", "Cancel", "c", "C"].iter().enumerate() {
|
||||
@@ -616,7 +625,7 @@ fn menu_get_command_input_from_user_returns_cancel() {
|
||||
format!("{} {}\n", cmd, idx)
|
||||
};
|
||||
|
||||
let result = menu.get_command_input_from_user(&full_cmd).unwrap();
|
||||
let result = menu.get_command_input_from_user(&full_cmd).await.unwrap();
|
||||
|
||||
assert!(matches!(result, MenuCmd::Cancel(_, _)));
|
||||
|
||||
@@ -631,9 +640,9 @@ fn menu_get_command_input_from_user_returns_cancel() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// ensure command parsing from user input results int he correct MenuCmd returned
|
||||
fn menu_get_command_input_from_user_returns_add() {
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
|
||||
async fn menu_get_command_input_from_user_returns_add() {
|
||||
let menu = Menu::new();
|
||||
|
||||
for cmd in ["add", "Addd", "a", "A", "None"] {
|
||||
@@ -641,14 +650,14 @@ fn menu_get_command_input_from_user_returns_add() {
|
||||
let full_cmd = format!("{} {}\n", cmd, test_url);
|
||||
|
||||
if cmd != "None" {
|
||||
let result = menu.get_command_input_from_user(&full_cmd).unwrap();
|
||||
let result = menu.get_command_input_from_user(&full_cmd).await.unwrap();
|
||||
assert!(matches!(result, MenuCmd::Add(_)));
|
||||
|
||||
if let MenuCmd::Add(url) = result {
|
||||
assert_eq!(url, test_url);
|
||||
}
|
||||
} else {
|
||||
assert!(menu.get_command_input_from_user(&full_cmd).is_none());
|
||||
assert!(menu.get_command_input_from_user(&full_cmd).await.is_none());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@ use indicatif::ProgressBar;
|
||||
use lazy_static::lazy_static;
|
||||
use tokio::sync::Semaphore;
|
||||
|
||||
use crate::filters::{create_similarity_filter, EmptyFilter, SimilarityFilter};
|
||||
use crate::progress::PROGRESS_PRINTER;
|
||||
use crate::utils::ferox_print;
|
||||
use crate::filters::{create_similarity_filter, SimilarityFilter};
|
||||
use crate::Command::AddFilter;
|
||||
use crate::{
|
||||
event_handlers::{
|
||||
@@ -68,7 +66,7 @@ async fn check_for_user_input(
|
||||
}
|
||||
}
|
||||
Some(MenuCmdResult::Filter(mut filter)) => {
|
||||
let url = if let Some(SimilarityFilter { hash, threshold }) =
|
||||
let url = if let Some(SimilarityFilter { hash, threshold: _ }) =
|
||||
filter.as_any().downcast_ref::<SimilarityFilter>()
|
||||
{
|
||||
hash.to_owned()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! collection of all traits used
|
||||
use crate::response::FeroxResponse;
|
||||
use anyhow::Result;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::Serialize;
|
||||
use std::any::Any;
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user