diff --git a/WordPress-VIP-Go/ruleset-test.inc b/WordPress-VIP-Go/ruleset-test.inc index f9f64919..d151ad67 100644 --- a/WordPress-VIP-Go/ruleset-test.inc +++ b/WordPress-VIP-Go/ruleset-test.inc @@ -56,8 +56,8 @@ $x = sanitize_key( $_COOKIE['bar'] ); // phpcs:ignore WordPress.Security.Validat if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && $_SERVER['HTTP_USER_AGENT'] === 'some_value' ) { // Error. } - - +// Make sure nonce verification is done in global scope to silence notices about use of superglobals without later on in the file. +isset( $_GET['my_nonce'] ) && wp_verify_nonce( sanitize_text_field( $_GET['my_nonce'] ) ); // WordPress.WP.AlternativeFunctions.file_system_read_fopen fopen( 'file.txt', 'r' ); // Warning + Message. @@ -80,7 +80,7 @@ function foo_bar() { } // WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -do_something( $_POST ); // Error. +do_something( $_POST['key'] ); // Error + warning. if ( isset( $_POST['foo2'] ) ) { bar( wp_unslash( $_POST['foo2'] ) ); // Warning. } @@ -279,10 +279,10 @@ $args( [ $query = new WP_Query( ['meta_key' => 'foo' ] ); // Ok. $args = 'foo=bar&meta_key=foo'; // Ok. -// WordPressVIPMinimum.Performance.BatcacheWhitelistedParams -if ( isset( $_GET['migSource'] ) && wp_verify_nonce( sanitize_text_field( $_GET['migSource'] ) ) ) { - $test = sanitize_text_field( $_GET['migSource'] ); // Ok. -} + + + + diff --git a/WordPress-VIP-Go/ruleset-test.php b/WordPress-VIP-Go/ruleset-test.php index 6f37a66a..a77eff98 100644 --- a/WordPress-VIP-Go/ruleset-test.php +++ b/WordPress-VIP-Go/ruleset-test.php @@ -134,6 +134,7 @@ 47 => 1, 63 => 1, 66 => 1, + 83 => 1, 85 => 1, 90 => 1, 94 => 1, diff --git a/WordPress-VIP-Go/ruleset.xml b/WordPress-VIP-Go/ruleset.xml index 93c6bd81..9ea7f34f 100644 --- a/WordPress-VIP-Go/ruleset.xml +++ b/WordPress-VIP-Go/ruleset.xml @@ -243,10 +243,6 @@ 0 - - - 0 - 0 diff --git a/WordPressVIPMinimum/Sniffs/Performance/BatcacheWhitelistedParamsSniff.php b/WordPressVIPMinimum/Sniffs/Performance/BatcacheWhitelistedParamsSniff.php deleted file mode 100644 index af2103b5..00000000 --- a/WordPressVIPMinimum/Sniffs/Performance/BatcacheWhitelistedParamsSniff.php +++ /dev/null @@ -1,113 +0,0 @@ -tokens[ $stackPtr ]['content'] !== '$_GET' ) { - return; - } - - $key = $this->phpcsFile->findNext( array_merge( Tokens::$emptyTokens, [ T_OPEN_SQUARE_BRACKET ] ), $stackPtr + 1, null, true ); - - if ( $this->tokens[ $key ]['code'] !== T_CONSTANT_ENCAPSED_STRING ) { - return; - } - - $variable_name = $this->tokens[ $key ]['content']; - - $variable_name = substr( $variable_name, 1, -1 ); - - if ( in_array( $variable_name, $this->whitelistes_batcache_params, true ) === true ) { - $message = 'Batcache whitelisted GET param, `%s`, found. Batcache whitelisted parameters get stripped and are not available in PHP.'; - $data = [ $variable_name ]; - $this->phpcsFile->addWarning( $message, $stackPtr, 'StrippedGetParam', $data ); - - return; - } - } -} diff --git a/WordPressVIPMinimum/Tests/Performance/BatcacheWhitelistedParamsUnitTest.inc b/WordPressVIPMinimum/Tests/Performance/BatcacheWhitelistedParamsUnitTest.inc deleted file mode 100644 index 5b199444..00000000 --- a/WordPressVIPMinimum/Tests/Performance/BatcacheWhitelistedParamsUnitTest.inc +++ /dev/null @@ -1,9 +0,0 @@ - => - */ - public function getErrorList() { - return []; - } - - /** - * Returns the lines where warnings should occur. - * - * @return array => - */ - public function getWarningList() { - return [ - 3 => 2, - 7 => 1, - ]; - } -} diff --git a/WordPressVIPMinimum/ruleset-test.inc b/WordPressVIPMinimum/ruleset-test.inc index aaef9969..03fd7e06 100644 --- a/WordPressVIPMinimum/ruleset-test.inc +++ b/WordPressVIPMinimum/ruleset-test.inc @@ -442,9 +442,9 @@ add_filter( 'robots_txt', function() { // Warning. return 'test'; } ); -// WordPressVIPMinimum.Performance.BatcacheWhitelistedParams -// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated -$test = sanitize_text_field( $_GET["utm_medium"] ); // Warning. + + + // WordPressVIPMinimum.Performance.CacheValueOverride $bad_wp_users = wp_cache_get( md5( self::CACHE_KEY . '_wp_users'), self::CACHE_GROUP ); diff --git a/WordPressVIPMinimum/ruleset-test.php b/WordPressVIPMinimum/ruleset-test.php index 0972e481..881da76b 100644 --- a/WordPressVIPMinimum/ruleset-test.php +++ b/WordPressVIPMinimum/ruleset-test.php @@ -272,7 +272,6 @@ 439 => 1, 440 => 1, 441 => 1, - 447 => 1, 454 => 1, 457 => 1, 458 => 1,