workerd icon indicating copy to clipboard operation
workerd copied to clipboard

Python: Make top level random() raise

Open hoodmane opened this issue 1 year ago • 2 comments

We don't have access to entropy outside of request scope, so random() will give poor results. Raise an error if it is called.

hoodmane avatar Apr 03 '24 15:04 hoodmane

Okay I updated this to handle numpy, added more detailed comments and internal tests.

hoodmane avatar Apr 09 '24 14:04 hoodmane

Okay, now there is a problem that rust uses randomness for hash seeds: https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/unix/rand.rs#L235-L247 https://github.com/rust-lang/rust/blob/master/library/std/src/hash/random.rs?plain=1#L68

hoodmane avatar Apr 10 '24 13:04 hoodmane