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

Ensure password slashing before validation #117

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

RenTheProgrammer
Copy link

Updated the password-checking mechanism to include wp_slash for the input password to improve security. Additionally, added a mock implementation of wp_slash in phpstan_bootstrap.php for testing purposes.

Issue Link

#116

Types of changes

  • Bug fix
  • New feature

Description

Added the function wp_slash to further protect passwords coming from json
https://developer.wordpress.org/reference/functions/wp_slash/

How has this been tested?

added nullable parameter to the TestBase->registerRandomUser to pass a password. If the parameter is not null it overrides the $password field. This prevents code duplication.

Added Two new Test Cases.

Authentication/Success

  • Added testAuthenticationEmailWithSpecialCharacterPassword to use a password with special characters.

RegisterUsers

  • Added testSuccessWithJSONBodyAndSpecialCharacterPassword to use a password with special characters.

Screenshots (optional)

image

image

image

Checklist:

  • My code is tested.
  • I wrote tests for the impacted area
  • I ran composer check-plugin locally

S2Support and others added 6 commits November 1, 2024 14:48
Updated the password-checking mechanism to include `wp_slash` for the input password to improve security. Additionally, added a mock implementation of `wp_slash` in `phpstan_bootstrap.php` for testing purposes.
Use `wp_slash` for password sanitization during user creation. Implement new tests to ensure registration and authentication work with passwords containing special characters. This ensures better security and functionality in handling complex passwords.
Use `wp_slash` for password sanitization during user creation. Implement new tests to ensure registration and authentication work with passwords containing special characters. This ensures better security and functionality in handling complex passwords.
Use `wp_slash` for password sanitization during user creation. Implement new tests to ensure registration and authentication work with passwords containing special characters. This ensures better security and functionality in handling complex passwords.
@nicumicle
Copy link
Owner

Thank you for contributing, @RenTheProgrammer.

I will check this PR later this week.

* @param string $value
* @return string
*/
public function sanitizePassword(string $value): string;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the return type, as the plugin can also be used in older PHP versions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the return types! Sorry about that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants