From b28d6109b1e5bdcbbbc23e7dd6dc1854c161417b Mon Sep 17 00:00:00 2001 From: Alexander Mironov Date: Sun, 24 Jul 2022 19:11:53 +0300 Subject: [PATCH] make cargo clippy happy --- src/logic.rs | 18 +++++++++--------- src/main.rs | 8 ++++---- src/requests.rs | 22 +++++++++++----------- src/utils.rs | 22 +++++++++++----------- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/logic.rs b/src/logic.rs index a201e46..278f904 100644 --- a/src/logic.rs +++ b/src/logic.rs @@ -43,13 +43,13 @@ pub async fn check_parameters( stats: Statistic{amount_of_requests: 0} }; - let found_params: &HashMap = &found_params; + let found_params: &HashMap = found_params; let cloned_diffs = Arc::clone(&shared_diffs); let cloned_green_lines = Arc::clone(&shared_green_lines); async move { - let query = &make_hashmap(&chunk, config.value_size); + let query = &make_hashmap(chunk, config.value_size); let response = request(config, &mut futures_data.stats, client, query, reflections_count) .await @@ -82,25 +82,25 @@ pub async fn check_parameters( ); if !config.save_responses.is_empty() { - output_message += &format!(" [saved to {}]", save_request(config, &query, &response, param)); + output_message += &format!(" [saved to {}]", save_request(config, query, &response, param)); } writeln!(io::stdout(), "{}", output_message).ok(); } else if !config.save_responses.is_empty() { - save_request(config, &query, &response, param); + save_request(config, query, &response, param); } } } //if the amount of reflected parameters == the amount of send parameters - that means that sth went wrong //so we are trying to find a parameter that caused that } else if stable.reflections && !response.reflected_params.is_empty() { - let mut not_reflected_one: &str = &""; + let mut not_reflected_one: &str = ""; //saves the number of occurencies for each number of reflections //key: the number of reflections let mut amount_of_reflections: HashMap = HashMap::new(); - for (_, v) in &response.reflected_params { + for v in response.reflected_params.values() { if amount_of_reflections.contains_key(&v) { amount_of_reflections.insert(*v, amount_of_reflections[v] + 1); } else { @@ -130,12 +130,12 @@ pub async fn check_parameters( ); if !config.save_responses.is_empty() { - output_message += &format!(" [saved to {}]", save_request(config, &query, &response, not_reflected_one)); + output_message += &format!(" [saved to {}]", save_request(config, query, &response, not_reflected_one)); } writeln!(io::stdout(), "{}", output_message).ok(); } else if !config.save_responses.is_empty() { - save_request(config, &query, &response, not_reflected_one); + save_request(config, query, &response, not_reflected_one); } } @@ -169,7 +169,7 @@ pub async fn check_parameters( drop(diffs); let tmp_resp = - random_request(&config, &mut futures_data.stats, &client, reflections_count, max) + random_request(config, &mut futures_data.stats, client, reflections_count, max) .await .unwrap_or(ResponseData::default()); diff --git a/src/main.rs b/src/main.rs index 2eb69f5..4db85ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -308,7 +308,7 @@ async fn run() { let mut found: bool = false; for vector_params in &remaining_params { for param in vector_params { - for (found_param, _) in &found_params { + for found_param in found_params.keys() { //some strange logic in order to treat admin=1 and admin=something as the same parameters let param_key = if param.matches('=').count() == 1 { param.split('=').next().unwrap() @@ -334,7 +334,7 @@ async fn run() { max = config.max; for (k, v) in custom_parameters.iter_mut() { if !v.is_empty() { - params.push([k.as_str(), "=", &v.pop().unwrap().as_str()].concat()); + params.push([k.as_str(), "=", v.pop().unwrap().as_str()].concat()); } } if max > params.len() { @@ -367,7 +367,7 @@ async fn run() { let mut is_the_body_the_same = true; for diff in new_diffs.iter() { - if !diffs.iter().any(|i| &i==&diff) { + if !diffs.iter().any(|i| i==diff) { is_the_body_the_same = false; } } @@ -399,7 +399,7 @@ async fn run() { 0 ).await; } else { - for (param, _) in &found_params { + for param in found_params.keys() { request( &temp_config, &mut stats, diff --git a/src/requests.rs b/src/requests.rs index 18c4802..fa39f03 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -103,7 +103,7 @@ pub async fn random_request( max: usize, ) -> Option { request( - &config, + config, stats, &client, &make_hashmap( @@ -201,13 +201,13 @@ pub async fn request( let query: String = if !hashmap_query.is_empty() { if config.as_body { - make_body(&config, &hashmap_query) + make_body(config, &hashmap_query) } else if config.within_headers { - make_header_value(&config, &hashmap_query) + make_header_value(config, &hashmap_query) } else if config.headers_discovery { String::new() } else { - make_query(&config, &hashmap_query) + make_query(config, &hashmap_query) } } else { String::new() @@ -231,11 +231,11 @@ pub async fn request( } let random_query: String = if !random_query.is_empty() { if config.as_body { - make_body(&config, &random_query) + make_body(config, &random_query) } else if config.headers_discovery { - make_header_value(&config, &random_query) + make_header_value(config, &random_query) } else { - make_query(&config, &random_query) + make_query(config, &random_query) } } else { String::new() @@ -308,10 +308,10 @@ pub async fn request( let mut text = String::new(); for (key, value) in headers.iter() { - text.push_str(&key); - text.push_str(&": "); - text.push_str(&value); - text.push_str(&"\n"); + text.push_str(key); + text.push_str(": "); + text.push_str(value); + text.push_str("\n"); } text.push_str(&"\n\n"); text.push_str(&body); diff --git a/src/utils.rs b/src/utils.rs index 09ff7a0..c3c5179 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -111,7 +111,7 @@ pub fn heuristic(body: &str) -> Vec { } //remove forbidden characters from header name, otherwise reqwest throws errors -pub fn fix_headers<'a>(header: &'a str) -> Option { +pub fn fix_headers(header: &str) -> Option { lazy_static! { static ref RE: Regex = Regex::new(r"[^!-'*+\-\.0-9a-zA-Z^-`|~]").unwrap(); } @@ -135,13 +135,13 @@ pub fn generate_request(config: &Config, initial_query: &HashMap let query: String = if !hashmap_query.is_empty() { if config.as_body { - make_body(&config, &hashmap_query) + make_body(config, &hashmap_query) } else if config.within_headers { - make_header_value(&config, &hashmap_query) + make_header_value(config, &hashmap_query) } else if config.headers_discovery { String::new() } else { - make_query(&config, &hashmap_query) + make_query(config, &hashmap_query) } } else { String::new() @@ -198,7 +198,7 @@ pub async fn generate_data(config: &Config, stats: &mut Statistic, client: &Clie writeln!(io::stdout(), "Request:\n{}", req).ok(); let response = - request(config, stats, client, &query, 0) + request(config, stats, client, query, 0) .await?; writeln!( @@ -451,8 +451,8 @@ pub fn create_output(config: &Config, stats: &Statistic, found_params: HashMap, response: } } - return filename + filename } //beautify json before comparing responses @@ -556,5 +556,5 @@ pub fn beautify_json(json: &str) -> String { //same with html pub fn beautify_html(html: &str) -> String { - html.replace(">", ">\n") + html.replace('>', ">\n") } \ No newline at end of file