Skip to content

Commit e7fd7da

Browse files
committed
build: Migrate to Rust 2024 edition
1 parent fbb5559 commit e7fd7da

File tree

26 files changed

+235
-127
lines changed

26 files changed

+235
-127
lines changed

Cargo.lock

Lines changed: 84 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ keywords = ["authentication", "bruteforce", "wordlist"]
55
version = "0.10.0"
66
authors = ["Simone Margaritelli <evilsocket@gmail.com>"]
77
license = "GPL-3.0"
8-
edition = "2021"
8+
edition = "2024"
99
readme = "README.md"
1010
repository = "https://github.com/evilsocket/legba"
1111
homepage = "https://github.com/evilsocket/legba"
@@ -31,7 +31,7 @@ serde = { version = "1.0.188", features = ["serde_derive"] }
3131
serde_json = "1.0.107"
3232
tokio = { version = "1.36.0", features = ["full"] }
3333
itertools = "0.11.0"
34-
rand = "0.8.5"
34+
rand = "0.9.0"
3535
env_logger = "0.10.0"
3636
memory-stats = "1.1.0"
3737
human_bytes = "0.4.3"

crates/rust-url/form_urlencoded/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ pub(crate) fn encode<'a>(encoding_override: EncodingOverride<'_>, input: &'a str
398398

399399
pub(crate) fn decode_utf8_lossy(input: Cow<'_, [u8]>) -> Cow<'_, str> {
400400
// Note: This function is duplicated in `percent_encoding/lib.rs`.
401+
402+
use core::ptr;
401403
match input {
402404
Cow::Borrowed(bytes) => String::from_utf8_lossy(bytes),
403405
Cow::Owned(bytes) => {
@@ -411,7 +413,7 @@ pub(crate) fn decode_utf8_lossy(input: Cow<'_, [u8]>) -> Cow<'_, str> {
411413

412414
// First we do a debug_assert to confirm our description above.
413415
let raw_utf8: *const [u8] = utf8.as_bytes();
414-
debug_assert!(raw_utf8 == &*bytes as *const [u8]);
416+
debug_assert!(ptr::eq(raw_utf8, &*bytes as *const [u8]));
415417

416418
// Given we know the original input bytes are valid UTF-8,
417419
// and we have ownership of those bytes, we re-use them and

crates/rust-url/percent_encoding/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ impl<'a> PercentDecode<'a> {
450450
#[cfg(feature = "alloc")]
451451
fn decode_utf8_lossy(input: Cow<'_, [u8]>) -> Cow<'_, str> {
452452
// Note: This function is duplicated in `form_urlencoded/src/query_encoding.rs`.
453+
454+
use core::ptr;
453455
match input {
454456
Cow::Borrowed(bytes) => String::from_utf8_lossy(bytes),
455457
Cow::Owned(bytes) => {
@@ -463,7 +465,7 @@ fn decode_utf8_lossy(input: Cow<'_, [u8]>) -> Cow<'_, str> {
463465

464466
// First we do a debug_assert to confirm our description above.
465467
let raw_utf8: *const [u8] = utf8.as_bytes();
466-
debug_assert!(raw_utf8 == &*bytes as *const [u8]);
468+
debug_assert!(ptr::eq(raw_utf8, &*bytes as *const [u8]));
467469

468470
// Given we know the original input bytes are valid UTF-8,
469471
// and we have ownership of those bytes, we re-use them and

src/api/handlers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
use std::collections::HashMap;
22
use std::sync::LazyLock;
33

4+
use actix_web::HttpRequest;
5+
use actix_web::HttpResponse;
46
use actix_web::get;
57
use actix_web::post;
68
use actix_web::web;
7-
use actix_web::HttpRequest;
8-
use actix_web::HttpResponse;
99
use clap::CommandFactory;
1010
use clap::Parser;
1111
use serde::Serialize;
1212

13+
use crate::Options;
1314
use crate::api::SharedState;
1415
use crate::plugins;
15-
use crate::Options;
1616

1717
// nasty hack to check for plugin specific options
1818
static OPTIONS_MAP: LazyLock<HashMap<String, serde_json::Value>> = LazyLock::new(|| {

src/api/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use std::sync::Arc;
22

33
use actix_cors::Cors;
4-
use actix_web::web;
54
use actix_web::App;
65
use actix_web::HttpResponse;
76
use actix_web::HttpServer;
87
use actix_web::Result;
8+
use actix_web::web;
99
use serde::Serialize;
1010
use tokio::sync::RwLock;
1111

12-
use crate::session::Error;
1312
use crate::Options;
13+
use crate::session::Error;
1414

1515
mod handlers;
1616
mod sessions;
@@ -50,7 +50,9 @@ pub(crate) async fn start(opts: Options) -> Result<(), Error> {
5050
log::info!("starting api on http://{} ...", &address);
5151

5252
if !address.contains("localhost") && !address.contains("127.0.0.1") {
53-
log::warn!("this server does not provide any authentication and you are binding it to an external address, use with caution!");
53+
log::warn!(
54+
"this server does not provide any authentication and you are binding it to an external address, use with caution!"
55+
);
5456
}
5557

5658
if opts.api_allowed_origin.to_lowercase() == "any" {

src/api/sessions.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ use std::{
22
collections::HashMap,
33
os::unix::process::ExitStatusExt,
44
process::Stdio,
5-
sync::{atomic::AtomicU64, Arc, Mutex},
5+
sync::{Arc, Mutex, atomic::AtomicU64},
66
time::{SystemTime, UNIX_EPOCH},
77
};
88

99
use actix_web::Result;
1010
use clap::Parser;
11-
use lazy_regex::{lazy_regex, Lazy};
11+
use lazy_regex::{Lazy, lazy_regex};
1212
use regex::Regex;
1313
use serde::Serialize;
1414
use tokio::{io::AsyncBufReadExt, sync::RwLock};
@@ -18,7 +18,7 @@ static STATS_PARSER: Lazy<Regex> = lazy_regex!(
1818
);
1919
static LOOT_PARSER: Lazy<Regex> = lazy_regex!(r"(?m)^.+\[(.+)\]\s\(([^)]+)\)(\s<(.+)>)?\s(.+)");
2020

21-
use crate::{session::Error, utils::parse_multiple_targets, Options};
21+
use crate::{Options, session::Error, utils::parse_multiple_targets};
2222

2323
pub(crate) type SharedState = Arc<RwLock<Sessions>>;
2424

@@ -220,7 +220,10 @@ impl Session {
220220
*child_completed.lock().unwrap() =
221221
Some(Completion::with_status(code.code().unwrap_or(-1)));
222222
} else {
223-
log::error!("[{id}] child process {process_id} completed with code {code} (signal {:?})", code.signal());
223+
log::error!(
224+
"[{id}] child process {process_id} completed with code {code} (signal {:?})",
225+
code.signal()
226+
);
224227
*child_completed.lock().unwrap() = Some(Completion::with_error(
225228
child_out
226229
.lock()

src/creds/combinator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use itertools::Itertools;
55
use serde::{Deserialize, Serialize};
66

77
use crate::{
8-
creds::{self, expression, iterator, Credentials},
8+
creds::{self, Credentials, expression, iterator},
99
options::Options,
1010
session::Error,
1111
};

src/creds/expression.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt;
22
use std::path::Path;
33

4-
use lazy_regex::{lazy_regex, Lazy};
4+
use lazy_regex::{Lazy, lazy_regex};
55
use regex::Regex;
66
use serde::Serialize;
77

@@ -223,11 +223,11 @@ pub(crate) fn parse_expression(expr: Option<&String>) -> Expression {
223223

224224
#[cfg(test)]
225225
mod tests {
226-
use super::parse_expression;
227-
use super::Expression;
228226
use super::DEFAULT_PERMUTATIONS_CHARSET;
229227
use super::DEFAULT_PERMUTATIONS_MAX_LEN;
230228
use super::DEFAULT_PERMUTATIONS_MIN_LEN;
229+
use super::Expression;
230+
use super::parse_expression;
231231

232232
#[test]
233233
fn can_parse_none() {

src/creds/iterator/constant.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ impl std::iter::Iterator for Constant {
3939

4040
#[cfg(test)]
4141
mod tests {
42-
use crate::creds::{iterator, Expression};
42+
use crate::creds::{Expression, iterator};
4343

4444
#[test]
4545
fn can_handle_constant() {
46-
let gen = iterator::new(Expression::Constant {
46+
let iter = iterator::new(Expression::Constant {
4747
value: "hi".to_owned(),
4848
})
4949
.unwrap();
50-
let tot = gen.search_space_size();
51-
let vec: Vec<String> = gen.collect();
50+
let tot = iter.search_space_size();
51+
let vec: Vec<String> = iter.collect();
5252

5353
assert_eq!(tot, 1);
5454
assert_eq!(vec, vec!["hi".to_owned()]);

0 commit comments

Comments
 (0)