moo.core.tests.test_security_random
Security audit: random module
Tests potential attack vectors when adding ‘random’ to ALLOWED_MODULES. Pass 17 focus: new module addition.
Functions
Random class dunder attributes blocked by underscore guard. |
|
SystemRandom is a Random subclass using os.urandom, has same safety props. |
|
Confirm basic random module functions work as expected. |
|
Module-level constants (BPF, LOG4, etc.) are safe numeric values. |
|
getstate() returns a plain tuple with no dangerous attributes. |
|
Confirm hasattr() on random objects checks INSPECT_ATTRIBUTES. |
|
Random instance dunder attributes blocked by underscore guard. |
|
random module exports are classes/functions/constants, not submodules. |
|
Underscore guard blocks dunder attributes on the random module. |
|
Random objects don't expose format/format_map methods. |
|
INSPECT_ATTRIBUTES guard blocks frame attrs even if they existed. |
|
Random class attributes are functions/methods/constants, not modules. |
|
Confirm random objects respect the global underscore attribute guard. |
|
seed() and setstate() manipulate module-level state safely. |