From ae113f91fefff415898781272b892d670fcb46f4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 14 Jun 2026 17:18:44 +0900 Subject: feat(php-shim): implement random_int/random_bytes with fastrand PHP's random_int/random_bytes are cryptographically secure, but Composer does not rely on that property, so a non-cryptographic PRNG suffices. Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/src/cache.rs | 2 +- crates/shirabe/src/downloader/zip_downloader.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/shirabe') diff --git a/crates/shirabe/src/cache.rs b/crates/shirabe/src/cache.rs index a193d0b..636a8ed 100644 --- a/crates/shirabe/src/cache.rs +++ b/crates/shirabe/src/cache.rs @@ -267,7 +267,7 @@ impl Cache { return false; } - random_int(0, 50) == 0 + random_int(0..50) == 0 } pub fn remove(&mut self, file: &str) -> bool { diff --git a/crates/shirabe/src/downloader/zip_downloader.rs b/crates/shirabe/src/downloader/zip_downloader.rs index d4ec2ab..2eb7b94 100644 --- a/crates/shirabe/src/downloader/zip_downloader.rs +++ b/crates/shirabe/src/downloader/zip_downloader.rs @@ -307,7 +307,7 @@ impl ZipDownloader { let stat_index = if inspect_all { i } else { - random_int(0, total_files - 1) + random_int(0..total_files) }; if let Some(stat) = zip_archive.stat_index(stat_index) { let size = stat.get("size").and_then(|v| v.as_int()).unwrap_or(0); -- cgit v1.3.1