| @@ -66,9 +66,9 @@ | ||
| 66 | 66 | */ |
| 67 | 67 | public function gather_info(): bool { |
| 68 | 68 | $timer = new Timer(); |
| 69 | 69 | $model = $this->scan; |
| 70 | - $need_to_run = empty( $model->task_checkpoint ) ? 'get_core_files' : 'get_content_files'; | |
| 70 | + $need_to_run = '' === $model->task_checkpoint ? 'get_core_files' : 'get_content_files'; | |
| 71 | 71 | if ( 'get_core_files' === $need_to_run ) { |
| 72 | 72 | if ( $this->settings->integrity_check && $this->settings->check_core ) { |
| 73 | 73 | $this->get_core_files(); |
| 74 | 74 | } |
| @@ -131,9 +131,14 @@ | ||
| 131 | 131 | $this->settings->filesize |
| 132 | 132 | ); |
| 133 | 133 | |
| 134 | 134 | $files = array_merge( $core->get_dir_tree(), $outside->get_dir_tree() ); |
| 135 | - $files = array_filter( $files ); | |
| 135 | + $files = array_filter( | |
| 136 | + $files, | |
| 137 | + function ( $value ) { | |
| 138 | + return is_string( $value ) && '' !== trim( $value ); | |
| 139 | + } | |
| 140 | + ); | |
| 136 | 141 | $this->log( sprintf( 'Core: %s', count( $files ) ), Scan_Controller::SCAN_LOG ); |
| 137 | 142 | update_site_option( self::CACHE_CORE, $files ); |
| 138 | 143 | |
| 139 | 144 | return $files; |
| @@ -148,15 +153,21 @@ | ||
| 148 | 153 | $cache = get_site_option( self::CACHE_CONTENT, false ); |
| 149 | 154 | if ( is_array( $cache ) ) { |
| 150 | 155 | return $cache; |
| 151 | 156 | } |
| 157 | + | |
| 158 | + $arr_extension = array( 'php' ); | |
| 159 | + // Since v5.8.0. | |
| 160 | + $enabled = apply_filters( 'wpdef_scan_js_detection_enabled', true ); | |
| 161 | + $enabled = is_bool( $enabled ) ? $enabled : (bool) $enabled; | |
| 162 | + if ( $enabled ) { | |
| 163 | + $arr_extension[] = 'js'; | |
| 164 | + } | |
| 152 | 165 | $content = new File( |
| 153 | 166 | defender_replace_line( ABSPATH ), |
| 154 | 167 | true, |
| 155 | 168 | false, |
| 156 | - array( | |
| 157 | - 'ext' => array( 'php' ), | |
| 158 | - ), | |
| 169 | + array( 'ext' => $arr_extension ), | |
| 159 | 170 | array(), |
| 160 | 171 | true, |
| 161 | 172 | true, |
| 162 | 173 | $this->settings->filesize |
| @@ -162,9 +173,14 @@ | ||
| 162 | 173 | $this->settings->filesize |
| 163 | 174 | ); |
| 164 | 175 | |
| 165 | 176 | $files = $content->get_dir_tree(); |
| 166 | - $files = array_filter( $files ); | |
| 177 | + $files = array_filter( | |
| 178 | + $files, | |
| 179 | + function ( $value ) { | |
| 180 | + return is_string( $value ) && '' !== trim( $value ); | |
| 181 | + } | |
| 182 | + ); | |
| 167 | 183 | $files[] = defender_wp_config_path(); |
| 168 | 184 | $this->log( sprintf( 'Number of files: %s', count( $files ) ), Scan_Controller::SCAN_LOG ); |
| 169 | 185 | update_site_option( self::CACHE_CONTENT, $files ); |
| 170 | 186 | } |