Skip to content

Commit e12a51b

Browse files
committed
BadFunctions/EasyRFI: minor code simplification [2]
The only token which can have a `content` of `.` is the `T_STRING_CONCAT` token, so we may as well exclude it from being found.
1 parent cc89cb4 commit e12a51b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Security/Sniffs/BadFunctions/EasyRFISniff.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function register() {
2424
$this->search = \PHP_CodeSniffer\Util\Tokens::$emptyTokens;
2525
$this->search += \PHP_CodeSniffer\Util\Tokens::$bracketTokens;
2626
$this->search += \PHPCS_SecurityAudit\Security\Sniffs\Utils::$staticTokens;
27+
$this->search[T_STRING_CONCAT] = T_STRING_CONCAT;
2728

2829
return array(T_INCLUDE, T_INCLUDE_ONCE, T_REQUIRE, T_REQUIRE_ONCE);
2930
}
@@ -59,7 +60,7 @@ public function process(File $phpcsFile, $stackPtr) {
5960
if (\PHP_CodeSniffer\Config::getConfigData('ParanoiaMode') || !$utils::is_token_false_positive($tokens[$s], $tokens[$s+2])) {
6061
$phpcsFile->addError('Easy RFI detected because of direct user input with %s on %s', $s, 'ErrEasyRFI', $data);
6162
}
62-
} elseif (\PHP_CodeSniffer\Config::getConfigData('ParanoiaMode') && $tokens[$s]['content'] != '.') {
63+
} elseif (\PHP_CodeSniffer\Config::getConfigData('ParanoiaMode')) {
6364
$phpcsFile->addWarning('Possible RFI detected with %s on %s', $s, 'WarnEasyRFI', $data);
6465
}
6566
}

0 commit comments

Comments
 (0)