Skip to content

Commit

Permalink
some lint driven fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Jul 19, 2024
1 parent 27751aa commit b5a3e4a
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/creds/iterator/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ mod tests {
let tmppath = tmpdir.path().join(&filename);
let mut tmpfile = File::create(&tmppath).unwrap();

write!(tmpfile, "test\n").unwrap();
writeln!(tmpfile, "test").unwrap();
tmpfile.flush().unwrap();
drop(tmpfile);

Expand Down
2 changes: 1 addition & 1 deletion src/creds/iterator/wordlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mod tests {
let mut tmpwordlist = File::create(&tmppath).unwrap();

for i in 0..num_items {
write!(tmpwordlist, "item{}\n", i).unwrap();
writeln!(tmpwordlist, "item{}", i).unwrap();
expected.push(format!("item{}", i));
}
tmpwordlist.flush().unwrap();
Expand Down
12 changes: 3 additions & 9 deletions src/plugins/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,7 @@ impl HTTP {
log::debug!("status={}", status);

let content_type = if let Some(ctype) = response.headers().get(CONTENT_TYPE) {
ctype
.to_str()
.unwrap()
.to_owned()
.split(';')
.collect::<Vec<&str>>()[0]
.to_owned()
ctype.to_str().unwrap().split(';').collect::<Vec<&str>>()[0].to_owned()
} else {
String::new()
};
Expand Down Expand Up @@ -1117,9 +1111,9 @@ mod tests {
let mut http = HTTP::new(Strategy::Enumeration);
let mut opts = Options::default();

opts.http.http_success_codes = "200".to_owned();
"200".clone_into(&mut opts.http.http_success_codes);
opts.http.http_success_string = Some(HTTP_PAYLOAD_VAR.to_owned());
opts.http.http_method = "GET".to_owned();
"GET".clone_into(&mut opts.http.http_method);

let creds = Credentials {
target: String::new(),
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/http/placeholders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ pub(crate) fn interpolate(data: &str, creds: &Credentials) -> String {
let mut parsed = data.to_owned();

// undo query encoding of interpolation params
for placeholder in vec![USERNAME, PASSWORD, PAYLOAD] {
let encoded_lwr = placeholder.replace("{", "%7b").replace("}", "%7d");
let encoded_upr = placeholder.replace("{", "%7B").replace("}", "%7D");
for placeholder in [USERNAME, PASSWORD, PAYLOAD] {
let encoded_lwr = placeholder.replace('{', "%7b").replace('}', "%7d");
let encoded_upr = placeholder.replace('{', "%7B").replace('}', "%7D");

parsed = parsed
.replace(&encoded_lwr, placeholder)
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/socks5/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Plugin for Socks5 {
}

fn setup(&mut self, opts: &Options) -> Result<(), Error> {
self.remote_address = opts.socks5.socks5_address.clone();
self.remote_address.clone_from(&opts.socks5.socks5_address);
self.remote_port = opts.socks5.socks5_port;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/ssh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Plugin for SSH {

fn setup(&mut self, opts: &Options) -> Result<(), Error> {
self.mode = opts.ssh.ssh_auth_mode.clone();
self.passphrase = opts.ssh.ssh_key_passphrase.clone();
self.passphrase.clone_from(&opts.ssh.ssh_key_passphrase);
Ok(())
}

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/tcp_ports/grabbers/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub(crate) async fn http_grabber(

let headers_of_interest: Vec<&str> = opts
.tcp_ports_http_headers
.split(",")
.split(',')
.map(|s| s.trim())
.filter(|s| !s.is_empty())
.collect();
Expand All @@ -110,7 +110,7 @@ pub(crate) async fn http_grabber(
if value.contains(';') {
value = value.split(';').next().unwrap();
}
content_type = value.to_owned();
value.clone_into(&mut content_type);
}

if headers_of_interest.contains(&name.as_str()) {
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/telnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ impl Plugin for Telnet {
}

fn setup(&mut self, opts: &Options) -> Result<(), Error> {
self.user_prompt = opts.telnet.telnet_user_prompt.clone();
self.pass_prompt = opts.telnet.telnet_pass_prompt.clone();
self.shell_prompt = opts.telnet.telnet_prompt.clone();
self.user_prompt.clone_from(&opts.telnet.telnet_user_prompt);
self.pass_prompt.clone_from(&opts.telnet.telnet_pass_prompt);
self.shell_prompt.clone_from(&opts.telnet.telnet_prompt);
Ok(())
}

Expand Down
1 change: 0 additions & 1 deletion src/session/loot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ impl Loot {
};

let mut file = OpenOptions::new()
.write(true)
.create(true)
.append(true)
.open(path)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/target/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ mod tests {
let mut expected = vec![];

for i in 0..num_items {
write!(tmptargets, "127.0.0.1:{}\n", i).unwrap();
writeln!(tmptargets, "127.0.0.1:{}", i).unwrap();
expected.push(format!("127.0.0.1:{}", i));
}
tmptargets.flush().unwrap();
Expand Down Expand Up @@ -250,7 +250,7 @@ mod tests {
];

for i in 0..num_items {
write!(tmptargets, "127.0.0.1:{}\n", i).unwrap();
writeln!(tmptargets, "127.0.0.1:{}", i).unwrap();
}
tmptargets.flush().unwrap();
drop(tmptargets);
Expand Down

0 comments on commit b5a3e4a

Please sign in to comment.