aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-14 17:18:44 +0900
committernsfisis <nsfisis@gmail.com>2026-06-14 17:23:13 +0900
commitae113f91fefff415898781272b892d670fcb46f4 (patch)
tree5d433f1902c0834973b6e5816d10629ca4a5b675 /crates/shirabe/src
parente71e24b5b5cacb93aab3a62e809414fbe9c8a438 (diff)
downloadphp-shirabe-ae113f91fefff415898781272b892d670fcb46f4.tar.gz
php-shirabe-ae113f91fefff415898781272b892d670fcb46f4.tar.zst
php-shirabe-ae113f91fefff415898781272b892d670fcb46f4.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src')
-rw-r--r--crates/shirabe/src/cache.rs2
-rw-r--r--crates/shirabe/src/downloader/zip_downloader.rs2
2 files changed, 2 insertions, 2 deletions
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);