phpcs-security-audit icon indicating copy to clipboard operation
phpcs-security-audit copied to clipboard

$utils::is_token_false_positive is fiddly and unstable

Open jrfnl opened this issue 5 years ago • 1 comments

The Utils::is_token_false_positive() method required sniffs to pass two tokens. The second token is calculated, not retrieved via token walking and may therefore be incorrect.

The method basically expects code to be written like so:

$_SERVER['key'];

... but all of the below are valid PHP and would fail the check because of the token calculation:

$_SERVER ['key'];
$_SERVER[ 'key' ];
$_SERVER[/*comment*/ 'key' ];
... etc...

jrfnl avatar Mar 12 '20 01:03 jrfnl

I have a fix ready for this, but would like to pull it accompanied by unit tests - see #57.

jrfnl avatar Mar 12 '20 01:03 jrfnl