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/component/class-scan.php +55 -9 6.0.1 → 6.3.0 View file →
@@ -102,9 +102,9 @@
102 102 $this->attach_behavior( WPMUDEV::class, WPMUDEV::class );
103 103 $this->attach_behavior( Core_Integrity::class, Core_Integrity::class );
104 104 $this->attach_behavior( Plugin_Integrity::class, Plugin_Integrity::class );
105 105
106 - $this->is_apikey = false !== wd_di()->get( WPMUDEV::class )->get_apikey();
106 + $this->is_apikey = wd_di()->get( WPMUDEV::class )->is_apikey_available();
107 107 $this->settings = wd_di()->get( Scan_Settings::class );
108 108 }
109 109
110 110 /**
@@ -139,11 +139,13 @@
139 139 if ( Scan_Model::STATUS_INIT === $scan->status ) {
140 140 // Get the first.
141 141 $this->log( 'Prepare facts for a scan', Scan_Controller::SCAN_LOG );
142 142 $task = Scan_Model::STEP_GATHER_INFO;
143 + $this->scan->status = $task;
143 144 $this->scan->percent = 0;
144 145 $this->scan->total_tasks = $runner->count();
145 146 $this->scan->save();
147 + $this->scan->enqueue_status_message( $this->scan->get_status_text() );
146 148 }
147 149 if (
148 150 in_array(
149 151 $this->scan->status,
@@ -179,8 +181,9 @@
179 181 $this->scan->status = $runner->key();
180 182 $this->scan->task_checkpoint = '';
181 183 $this->scan->date_end = gmdate( 'Y-m-d H:i:s' );
182 184 $this->scan->save();
185 + $this->scan->enqueue_status_message( $this->scan->get_status_text() );
183 186 // Queue for next run.
184 187 return false;
185 188 }
186 189 $this->log( 'All done!', Scan_Controller::SCAN_LOG );
@@ -293,10 +296,14 @@
293 296 );
294 297 }
295 298
296 299 return $this->abandoned_plugin_check( $this->abandoned_plugin );
300 + case 'core_integrity_check':
301 + return $this->core_integrity_check();
302 + case 'plugin_integrity_check':
303 + return $this->plugin_integrity_check();
297 304 default:
298 - return is_callable( array( $this, $task ) ) ? $this->$task() : false;
305 + return false;
299 306 }
300 307 }
301 308
302 309 /**
@@ -455,8 +462,30 @@
455 462 return $count;
456 463 }
457 464
458 465 /**
466 + * Checks if any scan type is active.
467 + *
468 + * @return bool True if any scan type is active, false otherwise.
469 + */
470 + public function is_any_scan_type_active(): bool {
471 + $settings = $this->settings;
472 + $file_change_check = $settings->is_checked_any_file_change_types();
473 + // Check#1 the 'File change detection' type because only it's available with nested types.
474 + // Check#2 the Abandoned plugin type.
475 + $check_free_settings = $file_change_check || $settings->check_abandoned_plugin;
476 + // Indicates if the API key is available for HC features.
477 + if ( $this->is_apikey ) {
478 + // HC version. Check all parent types.
479 + return $check_free_settings || $settings->check_known_vuln || $settings->scan_malware;
480 + } else {
481 + // Without HC access.
482 + return $check_free_settings;
483 + }
484 + }
485 +
486 +
487 + /**
459 488 * Checks if any scan type is active based on the scan settings and the user's membership status.
460 489 *
461 490 * @param array $scan_settings The scan settings.
462 491 *
@@ -461,9 +490,9 @@
461 490 * @param array $scan_settings The scan settings.
462 491 *
463 492 * @return bool Returns true if any scan type is active, false otherwise.
464 493 */
465 - public function is_any_scan_active( $scan_settings ): bool {
494 + public function check_scan_active_by( $scan_settings ): bool {
466 495 if ( ! isset( $scan_settings['integrity_check'] ) || ! $scan_settings['integrity_check'] ) {
467 496 // Check the parent type.
468 497 $file_change_check = false;
469 498 } elseif (
@@ -476,16 +505,18 @@
476 505 } else {
477 506 $file_change_check = true;
478 507 }
479 508
509 + $check_free_settings = $file_change_check
510 + || ( isset( $scan_settings['check_abandoned_plugin'] ) && $scan_settings['check_abandoned_plugin'] );
480 511 // For HC features.
481 512 if ( $this->is_apikey ) {
482 - // Similar to is_any_active(...) method from the controller.Check all parent types including HC features.
483 - return $file_change_check || ( isset( $scan_settings['check_known_vuln'] ) && $scan_settings['check_known_vuln'] )
513 + // Similar to is_any_scan_type_active() method.Check all parent types including HC features.
514 + return $check_free_settings || ( isset( $scan_settings['check_known_vuln'] ) && $scan_settings['check_known_vuln'] )
484 515 || ( isset( $scan_settings['scan_malware'] ) && $scan_settings['scan_malware'] );
485 516 }
486 517
487 - return $file_change_check || ( isset( $scan_settings['check_abandoned_plugin'] ) && $scan_settings['check_abandoned_plugin'] );
518 + return $check_free_settings;
488 519 }
489 520
490 521 /**
491 522 * Update the idle scan status due the time limit.
@@ -555,8 +586,9 @@
555 586 delete_site_option( Gather_Fact::CACHE_CONTENT );
556 587 delete_site_option( Malware_Scan::YARA_RULES );
557 588 delete_site_option( Core_Integrity::CACHE_CHECKSUMS );
558 589 delete_site_option( Plugin_Integrity::PLUGIN_SLUGS );
590 + delete_site_option( Plugin_Integrity::PLUGIN_SLUGS_CHECKPOINT );
559 591 delete_site_option( Plugin_Integrity::PLUGIN_PREMIUM_SLUGS );
560 592 delete_site_option( self::PLUGINS_ACTIONED );
561 593 $this->maybe_track_failed_checksum();
562 594 }
@@ -636,9 +668,9 @@
636 668 'notice-error'
637 669 );
638 670
639 671 $notice = sprintf(
640 - /* translators: %s - Plugin name. */
672 + /* translators: %s: Plugin name. */
641 673 esc_html__(
642 674 '%s has detected a vulnerability in this plugin that may cause harm to your site.',
643 675 'defender-security'
644 676 ),
@@ -653,9 +685,9 @@
653 685 $notice .= implode( '<br/>', $lines );
654 686 $notice .= '<hr/><span class="vulnerability-indent"></span>';
655 687 if ( '0' !== $last_fixed_in ) {
656 688 $notice .= sprintf(
657 - /* translators: %s - Version number. */
689 + /* translators: %s: Version number. */
658 690 esc_html__(
659 691 'The vulnerability has been fixed in version %s. We recommend that you update this plugin accordingly.',
660 692 'defender-security'
661 693 ),
@@ -674,9 +706,9 @@
674 706 'We recommend that you deactivate this plugin until the vulnerability has been fixed.',
675 707 'defender-security'
676 708 )
677 709 : sprintf(
678 - /* translators: 1: Version number. */
710 + /* translators: %s: Version number. */
679 711 esc_html__(
680 712 'The vulnerability has been fixed in version %s. We recommend that you update this plugin accordingly.',
681 713 'defender-security'
682 714 ),
@@ -915,6 +947,20 @@
915 947 * @return string
916 948 */
917 949 public function get_lock_filename(): string {
918 950 return $this->lock_filename;
951 + }
952 +
953 + /**
954 + * Get the text for the emergency scan stop case.
955 + *
956 + * @return string
957 + */
958 + public static function get_emergency_scan_stop_text(): string {
959 + $text = __( 'Scan aborted. No scan types are enabled. Enable at least one scan type under Defender > Settings > Tools before running a scan.', 'defender-security' );
960 + if ( defender_is_wp_cli() ) {
961 + return $text;
962 + }
963 +
964 + return esc_html( $text );
919 965 }
920 966 }