File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed
Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1468,6 +1468,16 @@ protected function has_nonce_check( $stackPtr ) {
14681468
14691469 // Loop through the tokens looking for nonce verification functions.
14701470 for ( $ i = $ start ; $ i < $ end ; $ i ++ ) {
1471+ // Skip over nested closed scope constructs.
1472+ if ( \T_FUNCTION === $ tokens [ $ i ]['code ' ]
1473+ || \T_CLOSURE === $ tokens [ $ i ]['code ' ]
1474+ || isset ( Tokens::$ ooScopeTokens [ $ tokens [ $ i ]['code ' ] ] )
1475+ ) {
1476+ if ( isset ( $ tokens [ $ i ]['scope_closer ' ] ) ) {
1477+ $ i = $ tokens [ $ i ]['scope_closer ' ];
1478+ }
1479+ continue ;
1480+ }
14711481
14721482 // If this isn't a function name, skip it.
14731483 if ( \T_STRING !== $ tokens [ $ i ]['code ' ] ) {
Original file line number Diff line number Diff line change @@ -189,3 +189,23 @@ function fix_false_negatives_namespaced_function_same_name() {
189189 WP_Faker \SecurityBypass \wp_verify_nonce ( 'something ' );
190190 do_something ( $ _POST ['abc ' ] ); // Bad.
191191}
192+
193+ function skip_over_nested_constructs_1 () {
194+ $ b = function () {
195+ check_ajax_referer ( 'something ' ); // Nonce check is not in the same function scope.
196+ };
197+
198+ do_something ( $ _POST ['abc ' ] ); // Bad.
199+ }
200+
201+ function skip_over_nested_constructs_2 () {
202+ if ( $ _POST ['abc ' ] === 'test ' ) { // Bad.
203+ return ;
204+ }
205+
206+ $ b = new class () {
207+ public function named () {
208+ check_ajax_referer ( 'something ' ); // Nonce check is not in the same function scope.
209+ }
210+ };
211+ }
Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ public function getErrorList() {
4949 177 => 1 ,
5050 185 => 1 ,
5151 190 => 1 ,
52+ 198 => 1 ,
53+ 202 => 1 ,
5254 );
5355 }
5456
You can’t perform that action at this time.
0 commit comments