PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/behavior/scan/class-malware-deep-scan.php +8 -5 5.3.1 → 6.3.0 View file →
@@ -19,8 +19,9 @@
19 19 use PHP_CodeSniffer\Tokenizers\Tokenizer;
20 20 use PHP_CodeSniffer\Exceptions\RuntimeException;
21 21 use PHP_CodeSniffer\Exceptions\DeepExitException;
22 22 use PHP_CodeSniffer\Exceptions\TokenizerException;
23 +use WP_Filesystem_Base;
23 24
24 25 /**
25 26 * We need to verify the result to avoid false positive.
26 27 */
@@ -31,17 +32,16 @@
31 32 /**
32 33 * Perform a deep scan on the provided file content to identify specific tokens.
33 34 *
34 35 * @param mixed $file The file content to be scanned.
35 - * @param array $rules The rules to be applied during scanning.
36 36 * @param array $quick_found Array containing quick found items.
37 37 *
38 38 * @return array|bool Returns the array of quick found items after scanning or false if no tokens are found.
39 39 */
40 - public function do_deep_scan( $file, $rules, $quick_found ) {
40 + public function do_deep_scan( $file, $quick_found ) {
41 41 global $wp_filesystem;
42 42 // Initialize the WP filesystem, no more using 'file-put-contents' function.
43 - if ( empty( $wp_filesystem ) ) {
43 + if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) {
44 44 require_once ABSPATH . '/wp-admin/includes/file.php';
45 45 WP_Filesystem();
46 46 }
47 47 $this->load_phpcodesniffer_needed();
@@ -82,10 +82,13 @@
82 82 ) ) {
83 83 unset( $tokens[ $k ] );
84 84 }
85 85 }
86 - $tokens = array_filter( $tokens );
87 - if ( empty( $tokens ) ) {
86 + $tokens = array_filter(
87 + $tokens,
88 + static fn( array $token ): bool => array() !== $token
89 + );
90 + if ( array() === $tokens ) {
88 91 // This mean the catch is comment, do nothing.
89 92 return false;
90 93 }
91 94 unset( $catch['text'] );