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

Ruleset: prevent false positives on polyfill code #2

Merged
merged 1 commit into from
Oct 8, 2018

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Oct 7, 2018

When notifying the polyfill repos about the polyfill rulesets, I came across this issue and figured we could fix that.


When PHPCompatibility(PasswordCompat) is run over the code in the password_compat repo itself, it will detect some non-issues.

FILE: password_compat\lib\password.php
------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 1 LINE
------------------------------------------------------------------------------------------
 105 | ERROR | Extension 'mcrypt' is deprecated since PHP 7.1 and removed since PHP 7.2;
     |       | Use openssl (preferred) or pecl/mcrypt once available instead
     |       | (PHPCompatibility.Extensions.RemovedExtensions.mcryptDeprecatedRemoved)
 105 | ERROR | Function mcrypt_create_iv() is deprecated since PHP 7.1 and removed since
     |       | PHP 7.2; Use random_bytes() or OpenSSL instead
     |       | (PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_create_ivDeprecatedRemoved)
 105 | ERROR | The constant "MCRYPT_DEV_URANDOM" is deprecated since PHP 7.1 and removed
     |       | since PHP 7.2
     |       | (PHPCompatibility.Constants.RemovedConstants.mcrypt_dev_urandomDeprecatedRemoved)
------------------------------------------------------------------------------------------

The code in the lib/password.php file is all wrapped within defined() and/or function_exists() conditions and will never be executed on PHP 5.5+ as the functionality being polyfilled is by then provided natively by PHP.

This simple change prevents these non-issues from being reported.

This fix does rely on people having installed the code in a directory called password_compat or, for composer installs password-compat.

When `PHPCompatibility(PasswordCompat)` is run over the code in the `password_compat` repo itself, it will detect some non-issues.

```
FILE: password_compat\lib\password.php
------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 1 LINE
------------------------------------------------------------------------------------------
 105 | ERROR | Extension 'mcrypt' is deprecated since PHP 7.1 and removed since PHP 7.2;
     |       | Use openssl (preferred) or pecl/mcrypt once available instead
     |       | (PHPCompatibility.Extensions.RemovedExtensions.mcryptDeprecatedRemoved)
 105 | ERROR | Function mcrypt_create_iv() is deprecated since PHP 7.1 and removed since
     |       | PHP 7.2; Use random_bytes() or OpenSSL instead
     |       | (PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_create_ivDeprecatedRemoved)
 105 | ERROR | The constant "MCRYPT_DEV_URANDOM" is deprecated since PHP 7.1 and removed
     |       | since PHP 7.2
     |       | (PHPCompatibility.Constants.RemovedConstants.mcrypt_dev_urandomDeprecatedRemoved)
------------------------------------------------------------------------------------------
```

The code in the `lib/password.php` file is all wrapped within `defined()` and/or `function_exists()` conditions and will never be executed on PHP 5.5+ as the functionality being polyfilled is by then provided natively by PHP.

This simple change prevents these non-issues from being reported.

This fix does rely on people having installed the code in a directory called `password_compat` or, for composer installs `password-compat`.
@jrfnl jrfnl added this to the 1.x Next milestone Oct 7, 2018
@jrfnl jrfnl requested a review from wimg October 7, 2018 23:15
@wimg wimg merged commit 66064cf into master Oct 8, 2018
@wimg wimg deleted the feature/prevent-false-positives-on-polyfill-code branch October 8, 2018 23:19
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.

None yet

2 participants