Skip to content
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

Ssl: add input validation to all methods #572

Merged
merged 1 commit into from
Oct 29, 2021

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Oct 11, 2021

None of the methods in the WpOrg\Requests\Ssl class did any input validation. This could lead to various PHP errors and becomes all the more relevant due to the new "passing null to non-nullable" deprecation notice on PHP 8.1.

This commit adds simple input validation to all methods within the WpOrg\Requests\Ssl class and will throw an WpOrg\Requests\Exception\InvalidArgument exception if a parameter does not comply with the expectations.

Note: for the $cert array parameter in the Ssl::verify_certificate() method, I considered adding an array type declaration, however, for consistency, always throwing the Requests native InvalidArgument exception seemed the better choice.

Includes adding tests for the new exception.

@jrfnl jrfnl added this to the 2.0.0 milestone Oct 11, 2021
@jrfnl jrfnl requested a review from schlessera October 11, 2021 16:00
src/Ssl.php Outdated Show resolved Hide resolved
None of the methods in the `WpOrg\Requests\Ssl` class did any input validation. This could lead to various PHP errors and becomes all the more relevant due to the new "passing null to non-nullable" deprecation notice on PHP 8.1.

This commit adds simple input validation to all methods within the `WpOrg\Requests\Ssl` class and will throw an `WpOrg\Requests\Exception\InvalidArgument` exception if a parameter does not comply with the expectations.

Note: for the `$cert` array parameter in the `Ssl::verify_certificate()` method, I considered adding an `array` type declaration, however, for consistency, always throwing the Requests native `InvalidArgument` exception seemed the better choice.

Includes adding tests for the new exception.
@jrfnl jrfnl force-pushed the feature/ssl-add-input-validation branch from 2f0da9e to 3b4950d Compare October 29, 2021 13:22
@schlessera schlessera merged commit 28879ed into develop Oct 29, 2021
@schlessera schlessera deleted the feature/ssl-add-input-validation branch October 29, 2021 13:27
@jrfnl jrfnl mentioned this pull request Nov 6, 2021
28 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants