1 | <?php |
||
28 | class NonCryptoHashSniff extends AbstractFunctionCallParameterSniff |
||
29 | { |
||
30 | |||
31 | /** |
||
32 | * Functions to check for. |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $targetFunctions = array( |
||
37 | 'hash_hmac' => true, |
||
38 | 'hash_hmac_file' => true, |
||
39 | 'hash_init' => true, |
||
40 | 'hash_pbkdf2' => true, |
||
41 | ); |
||
42 | |||
43 | /** |
||
44 | * List of the non-cryptographic hashes. |
||
45 | * |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $disabledCryptos = array( |
||
49 | 'adler32' => true, |
||
50 | 'crc32' => true, |
||
51 | 'crc32b' => true, |
||
52 | 'fnv132' => true, |
||
53 | 'fnv1a32' => true, |
||
54 | 'fnv164' => true, |
||
55 | 'fnv1a64' => true, |
||
56 | 'joaat' => true, |
||
57 | ); |
||
58 | |||
59 | |||
60 | /** |
||
61 | * Do a version check to determine if this sniff needs to run at all. |
||
62 | * |
||
63 | * @return bool |
||
64 | */ |
||
65 | protected function bowOutEarly() |
||
69 | |||
70 | |||
71 | /** |
||
72 | * Process the parameters of a matched function. |
||
73 | * |
||
74 | * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
||
75 | * @param int $stackPtr The position of the current token in the stack. |
||
76 | * @param string $functionName The token content (function name) which was matched. |
||
77 | * @param array $parameters Array with information about the parameters. |
||
78 | * |
||
79 | * @return int|void Integer stack pointer to skip forward or void to continue |
||
80 | * normal file processing. |
||
81 | */ |
||
82 | public function processParameters(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionName, $parameters) |
||
113 | }//end class |
||
114 |