-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error reporting in random extension #9071
Commits on Jul 20, 2022
-
Use
php_random_bytes_throw()
in Secure engine's generate()This exposes the underlying exception, improving debugging: Fatal error: Uncaught Exception: Cannot open source device in php-src/test.php:5 Stack trace: #0 php-src/test.php(5): Random\Engine\Secure->generate() #1 {main} Next RuntimeException: Random number generation failed in php-src/test.php:5 Stack trace: #0 php-src/test.php(5): Random\Engine\Secure->generate() #1 {main} thrown in php-src/test.php on line 5
Configuration menu - View commit details
-
Copy full SHA for 8daa5fe - Browse repository at this point
Copy the full SHA 8daa5feView commit details -
Use
php_random_int_throw()
in Secure engine's range()This exposes the underlying exception, improving debugging: Exception: Cannot open source device in php-src/test.php:17 Stack trace: #0 php-src/test.php(17): Random\Randomizer->getInt(1, 3) #1 {main} Next RuntimeException: Random number generation failed in php-src/test.php:17 Stack trace: #0 php-src/test.php(17): Random\Randomizer->getInt(1, 3) #1 {main}
Configuration menu - View commit details
-
Copy full SHA for b7bdf1a - Browse repository at this point
Copy the full SHA b7bdf1aView commit details -
Throw exception when a user engine returns an empty string
This improves debugging, because the actual reason for the failure is available as a previous Exception: DomainException: The returned string must not be empty in php-src/test.php:17 Stack trace: #0 php-src/test.php(17): Random\Randomizer->getBytes(123) #1 {main} Next RuntimeException: Random number generation failed in php-src/test.php:17 Stack trace: #0 php-src/test.php(17): Random\Randomizer->getBytes(123) #1 {main}
Configuration menu - View commit details
-
Copy full SHA for f93daeb - Browse repository at this point
Copy the full SHA f93daebView commit details -
Throw exception when the range selector fails to get acceptable numbe…
…rs in 50 attempts This improves debugging, because the actual reason for the failure is available as a previous Exception: RuntimeException: Failed to generate an acceptable random number in 50 attempts in php-src/test.php:17 Stack trace: #0 php-src/test.php(17): Random\Randomizer->getInt(1, 3) #1 {main} Next RuntimeException: Random number generation failed in php-src/test.php:17 Stack trace: #0 php-src/test.php(17): Random\Randomizer->getInt(1, 3) #1 {main}
Configuration menu - View commit details
-
Copy full SHA for fdfa2f3 - Browse repository at this point
Copy the full SHA fdfa2f3View commit details -
Select parameters for ->getInt() that will actually lead to unsafe behavior.
Configuration menu - View commit details
-
Copy full SHA for 12b07ce - Browse repository at this point
Copy the full SHA 12b07ceView commit details -
If an engine fails once it will be permanently poisoned by setting `->last_unsafe`. This is undesirable for the test, because it skews the results. Fix this by creating a fresh engine for each "assertion".
Configuration menu - View commit details
-
Copy full SHA for 3e18441 - Browse repository at this point
Copy the full SHA 3e18441View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8adb67a - Browse repository at this point
Copy the full SHA 8adb67aView commit details
Commits on Jul 21, 2022
-
Catch
Throwable
in user_unsafe.phptAs we print the full stringified exception we implicitly assert the type of the exception. No need to be overly specific in the catch block.
Configuration menu - View commit details
-
Copy full SHA for 3090379 - Browse repository at this point
Copy the full SHA 3090379View commit details
Commits on Jul 24, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 39b996a - Browse repository at this point
Copy the full SHA 39b996aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 734c79c - Browse repository at this point
Copy the full SHA 734c79cView commit details