From 12176d7757d89256bee5b5854842be2ef33d94f0 Mon Sep 17 00:00:00 2001 From: Safeer Ahmed Date: Thu, 6 Mar 2014 20:42:58 +0000 Subject: [PATCH 1/3] Flag uses of WP_User_Query on VIP sites fixes #22 --- vip-scanner/checks/WPUserQueryCheck.php | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 vip-scanner/checks/WPUserQueryCheck.php diff --git a/vip-scanner/checks/WPUserQueryCheck.php b/vip-scanner/checks/WPUserQueryCheck.php new file mode 100644 index 0000000..249c735 --- /dev/null +++ b/vip-scanner/checks/WPUserQueryCheck.php @@ -0,0 +1,42 @@ +filter_files( $files, 'php' ) as $file_path => $file_content ) { + + $this->increment_check_count(); + + if ( preg_match_all( $pattern, $file_content, $matches, PREG_SET_ORDER ) ) { + + $filename = $this->get_filename( $file_path ); + + foreach( $matches as $match ) { + if ( ! in_array( $match[1], $whitelist ) ) { + $lines = $this->grep_content( $match[1], $file_content ); + } + } + + if ( ! empty( $lines ) ) { + $this->add_error( + 'wp-user-query', + 'Use of WP_User_Query', + 'info', + $filename, + $lines + ); + $result = false; + } + + } + } + + return $result; + + } + +} From 5c3c6f4dbf9c6ac47e3cc1e273cbb3baa32472f7 Mon Sep 17 00:00:00 2001 From: Hibernation Date: Thu, 13 Mar 2014 20:32:42 +0000 Subject: [PATCH 2/3] Move WP_User_Query check to VIPRestrictedCommandsCheck --- vip-scanner/checks/VIPRestrictedCommandsCheck.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vip-scanner/checks/VIPRestrictedCommandsCheck.php b/vip-scanner/checks/VIPRestrictedCommandsCheck.php index abc0839..595bc6a 100644 --- a/vip-scanner/checks/VIPRestrictedCommandsCheck.php +++ b/vip-scanner/checks/VIPRestrictedCommandsCheck.php @@ -6,6 +6,9 @@ function check( $files ) { $result = true; $checks = array( + // WordPress Classes + "WP_User_Query" => array( 'level' => "Note", "note" => "Use of WP_User_Query" ), + // wordpress functions "remove_filter" => array( "level" => "Note", "note" => "Removing filters" ), "remove_action" => array( "level" => "Note", "note" => "Removing actions" ), From ef02d19a4b1089f49c910fc606e552dff46b1761 Mon Sep 17 00:00:00 2001 From: Hibernation Date: Thu, 13 Mar 2014 20:40:39 +0000 Subject: [PATCH 3/3] Remove unneeded WPUserQueryCheck file as the pattern has been moved to VIPRestrictedCommandsCheck --- vip-scanner/checks/WPUserQueryCheck.php | 42 ------------------------- 1 file changed, 42 deletions(-) delete mode 100644 vip-scanner/checks/WPUserQueryCheck.php diff --git a/vip-scanner/checks/WPUserQueryCheck.php b/vip-scanner/checks/WPUserQueryCheck.php deleted file mode 100644 index 249c735..0000000 --- a/vip-scanner/checks/WPUserQueryCheck.php +++ /dev/null @@ -1,42 +0,0 @@ -filter_files( $files, 'php' ) as $file_path => $file_content ) { - - $this->increment_check_count(); - - if ( preg_match_all( $pattern, $file_content, $matches, PREG_SET_ORDER ) ) { - - $filename = $this->get_filename( $file_path ); - - foreach( $matches as $match ) { - if ( ! in_array( $match[1], $whitelist ) ) { - $lines = $this->grep_content( $match[1], $file_content ); - } - } - - if ( ! empty( $lines ) ) { - $this->add_error( - 'wp-user-query', - 'Use of WP_User_Query', - 'info', - $filename, - $lines - ); - $result = false; - } - - } - } - - return $result; - - } - -}