-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathNonceVerificationSniff.php
More file actions
43 lines (37 loc) · 1.21 KB
/
NonceVerificationSniff.php
File metadata and controls
43 lines (37 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace HM\Sniffs\Security;
use HM\Sniffs\ExtraSniffCode;
use PHP_CodeSniffer\Files\File as PhpcsFile;
use WordPressCS\WordPress\Sniffs\Security\NonceVerificationSniff as WPCSNonceVerificationSniff;
/**
* Checks that nonce verification accompanies form processing.
*
* This is subclassed from WPCS to allow `$_GET` variables to be used if
* configured to do so.
*/
class NonceVerificationSniff extends WPCSNonceVerificationSniff {
use ExtraSniffCode;
/**
* Allow query ($_GET) variables to be used without checking nonces?
*
* Nonces are designed to protect against destructive actions taking
* place without user intent. However, query variables are typically used
* for non-destructive actions, so this is a false positive in most cases.
*
* @var boolean
*/
public $allowQueryVariables = false;
/**
* Override process to override config and duplicate any ignores.
*
* @param PhpcsFile $phpcsFile
* @param int $stackPtr
*/
public function process( PhpcsFile $file, $stackPtr ) {
if ( $this->allowQueryVariables ) {
unset( $this->superglobals[ '$_GET' ] );
}
$this->duplicate_ignores( $file, 'WordPress.Security.NonceVerification' );
return parent::process( $file, $stackPtr );
}
}