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-plugin-integrity.php +29 -9 6.0.1 → 6.3.0 View file →
@@ -28,11 +28,12 @@
28 28
29 29 use IO;
30 30 use Plugin;
31 31
32 - public const URL_PLUGIN_VCS = 'https://downloads.wordpress.org/plugin-checksums/';
33 - public const PLUGIN_SLUGS = 'wd_plugin_slugs_changes';
34 - public const PLUGIN_PREMIUM_SLUGS = 'wd_plugin_premium_slugs';
32 + public const URL_PLUGIN_VCS = 'https://downloads.wordpress.org/plugin-checksums/';
33 + public const PLUGIN_SLUGS = 'wd_plugin_slugs_changes';
34 + public const PLUGIN_SLUGS_CHECKPOINT = 'wd_plugin_slugs_changes_checkpoint';
35 + public const PLUGIN_PREMIUM_SLUGS = 'wd_plugin_premium_slugs';
35 36 /**
36 37 * List of premium plugin slugs.
37 38 *
38 39 * @var array
@@ -211,8 +212,11 @@
211 212 $timer = new Timer();
212 213 $model = $this->owner->scan;
213 214 $pos = (int) $model->task_checkpoint;
214 215 $plugin_files->seek( $pos );
216 + if ( 0 === $pos ) {
217 + delete_site_option( self::PLUGIN_SLUGS_CHECKPOINT );
218 + }
215 219 $slugs_of_edited_plugins = array();
216 220 $integration_smush = wd_di()->get( Smush::class );
217 221 $exist_smush_images = $integration_smush->exist_image_table();
218 222 while ( $plugin_files->valid() ) {
@@ -303,11 +307,9 @@
303 307 // We will check if we have any ignore issue from last scan, so we can bring it here.
304 308 $last = Scan::get_last();
305 309 if ( is_object( $last ) ) {
306 310 $ignored_issues = $last->get_issues( Scan_Item::TYPE_PLUGIN_CHECK, Scan_Item::STATUS_IGNORE );
307 - foreach ( $ignored_issues as $issue ) {
308 - $model->add_item( Scan_Item::TYPE_PLUGIN_CHECK, $issue->raw_data, Scan_Item::STATUS_IGNORE );
309 - }
311 + $model->carry_forward_ignored_issues( Scan_Item::TYPE_PLUGIN_CHECK, $ignored_issues, 'file' );
310 312 }
311 313 // Done, reset this, so we can use later.
312 314 $model->task_checkpoint = '';
313 315 }
@@ -318,11 +320,9 @@
318 320 *
319 321 * @since 2.4.10
320 322 */
321 323 if ( ( new Scan_Settings() )->scan_malware ) {
322 - if ( array() !== $slugs_of_edited_plugins ) {
323 - update_site_option( self::PLUGIN_SLUGS, array_unique( $slugs_of_edited_plugins ) );
324 - }
324 + $this->persist_changed_plugin_slugs( $slugs_of_edited_plugins, ! $plugin_files->valid() );
325 325 if ( array() !== $this->premium_slugs ) {
326 326 update_site_option( self::PLUGIN_PREMIUM_SLUGS, $this->premium_slugs );
327 327 }
328 328 }
@@ -327,8 +327,28 @@
327 327 }
328 328 }
329 329
330 330 return ! $plugin_files->valid();
331 + }
332 +
333 + /**
334 + * Persist changed plugin slugs across checkpoint scan batches.
335 + *
336 + * @param array $batch_slugs Slugs found in the current batch.
337 + * @param bool $is_complete Whether the plugin integrity task has completed.
338 + *
339 + * @return void
340 + */
341 + private function persist_changed_plugin_slugs( array $batch_slugs, bool $is_complete ): void {
342 + $checkpoint_slugs = (array) get_site_option( self::PLUGIN_SLUGS_CHECKPOINT, array() );
343 + $changed_slugs = array_values( array_unique( array_merge( $checkpoint_slugs, $batch_slugs ) ) );
344 +
345 + if ( $is_complete ) {
346 + update_site_option( self::PLUGIN_SLUGS, $changed_slugs );
347 + delete_site_option( self::PLUGIN_SLUGS_CHECKPOINT );
348 + } else {
349 + update_site_option( self::PLUGIN_SLUGS_CHECKPOINT, $changed_slugs );
350 + }
331 351 }
332 352
333 353 /**
334 354 * Checks if given file is a valid image.