Skip to content

Commit

Permalink
BadFunctions/EasyRFI: minor code simplification [2]
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrfnl committed Mar 16, 2020
1 parent cc89cb4 commit e12a51b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Security/Sniffs/BadFunctions/EasyRFISniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function register() {
$this->search = \PHP_CodeSniffer\Util\Tokens::$emptyTokens;
$this->search += \PHP_CodeSniffer\Util\Tokens::$bracketTokens;
$this->search += \PHPCS_SecurityAudit\Security\Sniffs\Utils::$staticTokens;
$this->search[T_STRING_CONCAT] = T_STRING_CONCAT;

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

0 comments on commit e12a51b

Please sign in to comment.