Skip to content
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
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ parking_lot = "=0.12.3"
paste = "=1.0.15"
postgres-native-tls = "=0.5.1"
prometheus = { version = "=0.13.4", default-features = false }
rand = "=0.8.5"
rand = "=0.9.0"
reqwest = { version = "=0.12.12", features = ["gzip", "json"] }
rss = { version = "=2.0.11", default-features = false, features = ["atom"] }
secrecy = "=0.10.3"
Expand Down
2 changes: 1 addition & 1 deletion crates/crates_io_smoke_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ anyhow = "=1.0.95"
bytes = "=1.10.0"
clap = { version = "=4.5.28", features = ["derive", "env", "unicode", "wrap_help"] }
crates_io_index = { path = "../crates_io_index" }
rand = "=0.8.5"
rand = "=0.9.0"
reqwest = { version = "=0.12.12", features = ["gzip", "json"] }
secrecy = "=0.10.3"
semver = { version = "=1.0.25", features = ["serde"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/crates_io_test_db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ crates_io_env_vars = { path = "../crates_io_env_vars" }
diesel = { version = "=2.2.7", features = ["postgres", "r2d2"] }
diesel-async = { version = "=0.5.2", features = ["postgres"] }
diesel_migrations = { version = "=2.2.0", features = ["postgres"] }
rand = "=0.8.5"
rand = "=0.9.0"
tracing = "=0.1.41"
url = "=2.5.4"
4 changes: 2 additions & 2 deletions crates/crates_io_test_db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ fn run_migrations(conn: &mut PgConnection) -> diesel::migration::Result<()> {
}

fn generate_name() -> String {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
std::iter::repeat(())
.map(|_| rng.sample(rand::distributions::Alphanumeric) as char)
.map(|_| rng.sample(rand::distr::Alphanumeric) as char)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

distr

ಠ_ಠ

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... seems like a pretty pointless breaking change

.take(16)
.collect()
}
8 changes: 3 additions & 5 deletions src/bin/crates-admin/populate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crates_io::{db, schema::version_downloads};
use diesel::prelude::*;
use diesel_async::scoped_futures::ScopedFutureExt;
use diesel_async::{AsyncConnection, AsyncPgConnection, RunQueryDsl};
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use rand::Rng;

#[derive(clap::Parser, Debug)]
#[command(
Expand All @@ -27,11 +26,10 @@ async fn update(opts: Opts, conn: &mut AsyncPgConnection) -> QueryResult<()> {
use diesel::dsl::*;

for id in opts.version_ids {
let mut rng = StdRng::from_entropy();
let mut dls = rng.gen_range(5_000i32..10_000);
let mut dls = rand::rng().random_range(5_000i32..10_000);

for day in 0..90 {
dls += rng.gen_range(-100..100);
dls += rand::rng().random_range(-100..100);

diesel::insert_into(version_downloads::table)
.values((
Expand Down
4 changes: 2 additions & 2 deletions src/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use lettre::transport::smtp::authentication::{Credentials, Mechanism};
use lettre::transport::smtp::AsyncSmtpTransport;
use lettre::transport::stub::AsyncStubTransport;
use lettre::{Address, AsyncTransport, Message, Tokio1Executor};
use rand::distributions::{Alphanumeric, DistString};
use rand::distr::{Alphanumeric, SampleString};
use std::sync::Arc;

pub trait Email {
Expand Down Expand Up @@ -99,7 +99,7 @@ impl Emails {
// replace it when it relays the message.
let message_id = format!(
"<{}@{}>",
Alphanumeric.sample_string(&mut rand::thread_rng(), 32),
Alphanumeric.sample_string(&mut rand::rng(), 32),
self.domain,
);

Expand Down
10 changes: 2 additions & 8 deletions src/util/token.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use diesel::{deserialize::FromSql, pg::Pg, serialize::ToSql, sql_types::Bytea};
use rand::{distributions::Uniform, rngs::OsRng, Rng};
use rand::distr::{Alphanumeric, SampleString};
use secrecy::{ExposeSecret, SecretSlice, SecretString};
use sha2::{Digest, Sha256};

Expand Down Expand Up @@ -84,13 +84,7 @@ impl ExposeSecret<str> for PlainToken {
}

fn generate_secure_alphanumeric_string(len: usize) -> String {
const CHARS: &[u8] = b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

OsRng
.sample_iter(Uniform::from(0..CHARS.len()))
.map(|idx| CHARS[idx] as char)
.take(len)
.collect()
Alphanumeric.sample_string(&mut rand::rng(), len)
}

#[cfg(test)]
Expand Down