Skip to content

Commit

Permalink
cargo clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Emann committed Sep 4, 2024
1 parent e9c9229 commit b6961cf
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
14 changes: 7 additions & 7 deletions src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub async fn check_username(
tx.clone(),
Arc::clone(&username),
Arc::from(&site[..]),
Arc::clone(&info),
Arc::clone(info),
*timeout,
proxy.clone(),
)?;
Expand Down Expand Up @@ -127,21 +127,21 @@ pub async fn check_username(
println!("+++++++++++++++++++++");
println!("TARGET NAME : {site}");
println!("USERNAME : {username}");
println!("TARGET URL : {:?}", url_probe);
println!("TARGET URL : {url_probe:?}");
// TODO: Split this out into parts? Impl debug differently?
println!("TEST METHOD : {:?}", error_type);
println!("TEST METHOD : {error_type:?}");
println!("Results...");
println!("RESPONSE CODE : {}", status_code);
println!("RESPONSE CODE : {status_code}");
println!(">>>>> BEGIN RESPONSE TEXT");
println!("{}", resp_text);
println!("{resp_text}");
println!("<<<<< END RESPONSE TEXT");

println!("VERDICT : {:?}", status);
println!("VERDICT : {status:?}");
println!("+++++++++++++++++++++");
}

if *browse && status == QueryStatus::Claimed {
open::that(&url).inspect_err(|e| eprintln!("Failed to open browser: {}", e))?;
open::that(&url).inspect_err(|e| eprintln!("Failed to open browser: {e}"))?;
}

QueryResult {
Expand Down
12 changes: 4 additions & 8 deletions src/get_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,9 @@ pub async fn get_json_data(json_file: String) -> color_eyre::Result<String> {
}
false => {
// Reference is to a file.
let contents = std::fs::read_to_string(&json_file).wrap_err_with(|| {
format!(
"Problem while attempting to access data file '{}'",
json_file
)
})?;

contents
std::fs::read_to_string(&json_file).wrap_err_with(|| {
format!("Problem while attempting to access data file '{json_file}'")
})?
}
};

Expand All @@ -50,6 +45,7 @@ pub async fn get_json_data(json_file: String) -> color_eyre::Result<String> {

/// the default sites to check for sherlock locally
/// includes >400 websites and their error messages
#[must_use]
pub fn get_default_data() -> String {
include_str!("data.json").to_string()
}
10 changes: 5 additions & 5 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ pub fn save_results(

let output_file = match (&options.output_file, &options.output_folder) {
(Some(output_file), _) => output_file.to_string(),
(None, Some(output_folder)) => format!("{}/{}.txt", output_folder, username),
(None, None) => format!("{}.txt", username),
(None, Some(output_folder)) => format!("{output_folder}/{username}.txt"),
(None, None) => format!("{username}.txt"),
};

let mut file = File::create(&output_file)?;
Expand All @@ -62,7 +62,7 @@ pub fn save_results(
}
}

writeln!(file, "Total Websites Username Detected On: {}", total_hits)?;
writeln!(file, "Total Websites Username Detected On: {total_hits}")?;

if options.csv {
write_csv(
Expand Down Expand Up @@ -162,8 +162,8 @@ pub fn write_csv(
print_found: bool,
) -> color_eyre::Result<()> {
let csv_filename = match output_folder {
None => format!("{}.csv", username),
Some(folder) => format!("{}/{}.csv", folder, username),
None => format!("{username}.csv"),
Some(folder) => format!("{folder}/{username}.csv"),
};

let mut csv_report = File::create(csv_filename)?;
Expand Down
6 changes: 3 additions & 3 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub fn add_result_to_channel(
proxy: Option<Arc<str>>,
) -> color_eyre::Result<()> {
tokio::spawn(async move {
let encoded_username = &username.replace(" ", "%20");
let encoded_username = &username.replace(' ', "%20");
let profile_url = info.url.interpolate(encoded_username);
let url_probe = match &info.url_probe {
// There is a special URL for probing existence separate
Expand Down Expand Up @@ -105,12 +105,12 @@ async fn check_user_at_site(
let request_body = info
.request_payload
.as_ref()
.map(|payload| payload.to_string().interpolate(&username));
.map(|payload| payload.to_string().interpolate(username));

// use regex to make sure the url and username are valid for the site
if let Some(regex) = &info.regex_check {
let re = Regex::new(regex)?;
let is_match = re.is_match(&username).unwrap_or(false);
let is_match = re.is_match(username).unwrap_or(false);
if !is_match {
return Err(QueryError::InvalidUsernameError);
}
Expand Down
6 changes: 4 additions & 2 deletions src/sherlock_target_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pub enum ErrorMsg {
}

impl ErrorMsg {
#[must_use]
pub fn is_in(&self, text: &str) -> bool {
match self {
ErrorMsg::Single(msg) => text.contains(msg),
Expand All @@ -98,8 +99,8 @@ impl ErrorMsg {
impl fmt::Debug for ErrorMsg {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ErrorMsg::Single(c) => write!(f, "{}", c),
ErrorMsg::Multiple(codes) => codes.iter().fold(Ok(()), |_, c| write!(f, "{}, ", c)),
ErrorMsg::Single(c) => write!(f, "{c}"),
ErrorMsg::Multiple(codes) => codes.iter().fold(Ok(()), |_, c| write!(f, "{c}, ")),
}
}
}
Expand All @@ -112,6 +113,7 @@ pub enum ErrorCode {
}

impl ErrorCode {
#[must_use]
pub fn contains(&self, code: &u16) -> bool {
match self {
ErrorCode::Single(c) => c == code,
Expand Down
1 change: 1 addition & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use std::collections::HashMap;
/// "test.user",
/// ]);
/// ```
#[must_use]
pub fn create_username_variants(usernames: &[String]) -> Vec<String> {
let variant_symbol = "{?}";
let check_symbols = ["_", "-", "."];
Expand Down
3 changes: 2 additions & 1 deletion src/waf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
// be highly targetted. Comment at the end of each fingerprint to
// indicate target and date fingerprinted.
const WAFHIT_MSGS: [&str; 2] = [
r#".loading-spinner{visibility:hidden}body.no-js .challenge-running{display:none}body.dark{background-color:#222;color:#d9d9d9}body.dark a{color:#fff}body.dark a:hover{color:#ee730a;text-decoration:underline}body.dark .lds-ring div{border-color:#999 transparent transparent}body.dark .font-red{color:#b20f03}body.dark"#,
r".loading-spinner{visibility:hidden}body.no-js .challenge-running{display:none}body.dark{background-color:#222;color:#d9d9d9}body.dark a{color:#fff}body.dark a:hover{color:#ee730a;text-decoration:underline}body.dark .lds-ring div{border-color:#999 transparent transparent}body.dark .font-red{color:#b20f03}body.dark",
// 2024-04-09 PerimeterX / Human Security
r#"{return l.onPageView}}),Object.defineProperty(r,"perimeterxIdentifiers",{enumerable:"#,
];

#[must_use]
pub fn waf_hit(resp_text: &str) -> bool {
WAFHIT_MSGS.iter().any(|msg| resp_text.contains(msg))
}

0 comments on commit b6961cf

Please sign in to comment.