Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update rand requirement from 0.8 to 0.9 #1037

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ proc-macro2-diagnostics = { version = "0.10", default-features = true }
proc-macro2 = "1"
quinn = { version = "0.11", default-features = false }
quote = "1"
rand = "0.8"
rand = "0.9"
rcgen = "0.13"
regex = "1"
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "charset", "http2", "macos-system-configuration"] }
Expand Down
10 changes: 7 additions & 3 deletions crates/core/src/http/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use mime::Mime;
use multer::{Field, Multipart};
use multimap::MultiMap;
use rand::rngs::OsRng;
use rand::RngCore;
use rand::TryRngCore;
use tempfile::Builder;
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
Expand Down Expand Up @@ -213,9 +213,13 @@ fn text_nonce() -> String {
Write::write_all(&mut cursor, &secs.to_le_bytes()).expect("write_all failed");

// Get the last bytes from random data
OsRng.fill_bytes(&mut raw[12..BYTE_LEN]);
OsRng
.try_fill_bytes(&mut raw[12..BYTE_LEN])
.expect("OsRng.try_fill_bytes failed");
} else {
OsRng.fill_bytes(&mut raw[..]);
OsRng
.try_fill_bytes(&mut raw[..])
.expect("OsRng.try_fill_bytes failed");
}

// base64 encode
Expand Down
4 changes: 2 additions & 2 deletions crates/csrf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod finder;

pub use finder::{CsrfTokenFinder, FormFinder, HeaderFinder, JsonFinder};

use rand::distributions::Standard;
use rand::distr::StandardUniform;
use rand::Rng;
use salvo_core::handler::Skipper;
use salvo_core::http::{Method, StatusCode};
Expand Down Expand Up @@ -190,7 +190,7 @@ pub trait CsrfCipher: Send + Sync + 'static {

/// Generate a random bytes.
fn random_bytes(&self, len: usize) -> Vec<u8> {
rand::thread_rng().sample_iter(Standard).take(len).collect()
rand::rng().sample_iter(StandardUniform).take(len).collect()
}
}

Expand Down
Loading