Skip to content

Commit

Permalink
make cargo clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh1Yo committed Jul 24, 2022
1 parent 48bc3c1 commit b28d610
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
18 changes: 9 additions & 9 deletions src/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ pub async fn check_parameters(
stats: Statistic{amount_of_requests: 0}
};

let found_params: &HashMap<String, String> = &found_params;
let found_params: &HashMap<String, String> = 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
Expand Down Expand Up @@ -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<usize, usize> = 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 {
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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());

Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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() {
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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,
Expand Down
22 changes: 11 additions & 11 deletions src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub async fn random_request(
max: usize,
) -> Option<ResponseData> {
request(
&config,
config,
stats,
&client,
&make_hashmap(
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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);
Expand Down
22 changes: 11 additions & 11 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub fn heuristic(body: &str) -> Vec<String> {
}

//remove forbidden characters from header name, otherwise reqwest throws errors
pub fn fix_headers<'a>(header: &'a str) -> Option<String> {
pub fn fix_headers(header: &str) -> Option<String> {
lazy_static! {
static ref RE: Regex = Regex::new(r"[^!-'*+\-\.0-9a-zA-Z^-`|~]").unwrap();
}
Expand All @@ -135,13 +135,13 @@ pub fn generate_request(config: &Config, initial_query: &HashMap<String, String>

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()
Expand Down Expand Up @@ -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!(
Expand Down Expand Up @@ -451,8 +451,8 @@ pub fn create_output(config: &Config, stats: &Statistic, found_params: HashMap<S

if !found_params.is_empty() {

for (param, _) in &found_params {
line.push_str(&param);
for param in found_params.keys() {
line.push_str(param);
if !param.contains('=') {
line.push('=');
line.push_str(&random_line(config.value_size));
Expand Down Expand Up @@ -499,8 +499,8 @@ pub fn create_output(config: &Config, stats: &Statistic, found_params: HashMap<S

if !found_params.is_empty() {

for (param, _) in &found_params {
line.push_str(&param);
for param in found_params.keys() {
line.push_str(param);
line.push_str(", ")
}

Expand Down Expand Up @@ -541,7 +541,7 @@ pub fn save_request(config: &Config, query: &HashMap<String, String>, response:
}
}

return filename
filename
}

//beautify json before comparing responses
Expand All @@ -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")
}

0 comments on commit b28d610

Please sign in to comment.