ARGUS WordPress Defence 1.0.0 — first production release
Automatic WordPress security: local firewall, malware and file-integrity scanning, vulnerability protection, quarantine, scheduled backups, an optional page cache, and automatic global threat intelligence. See README.md for installation, update, and uninstall instructions.
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Argus_Plugin {
|
||||
|
||||
protected static $instance = null;
|
||||
|
||||
public static function instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function boot() {
|
||||
Argus_DB::maybe_upgrade();
|
||||
Argus_MU_Installer::ensure_current();
|
||||
|
||||
add_filter( 'cron_schedules', array( __CLASS__, 'register_cron_schedules' ) ); // phpcs:ignore WordPress.WP.CronInterval
|
||||
|
||||
Argus_Login_Guard::init();
|
||||
Argus_API_Guard::init();
|
||||
Argus_GeoIP_RIR::init();
|
||||
Argus_Static_Cache::init();
|
||||
Argus_Auto_Update::init();
|
||||
Argus_Upload_Guard::init();
|
||||
Argus_ANIS_Client::init();
|
||||
Argus_Vuln_Intel::init();
|
||||
|
||||
add_action( 'init', array( 'Argus_WAF', 'inspect_and_enforce' ), 0 );
|
||||
|
||||
add_action( 'argus_wpd_hourly', array( __CLASS__, 'run_hourly' ) );
|
||||
add_action( 'argus_wpd_daily', array( __CLASS__, 'run_daily' ) );
|
||||
add_action( 'argus_wpd_five_minutes', array( 'Argus_ANIS_Client', 'maybe_retry_sync' ) );
|
||||
add_action( 'argus_wpd_five_minutes', array( 'Argus_Vuln_Intel', 'maybe_retry' ) );
|
||||
|
||||
add_action( 'argus_wpd_five_minutes', array( 'Argus_Update_Client', 'maybe_check' ) );
|
||||
|
||||
if ( class_exists( 'Argus_Integrity' ) ) {
|
||||
add_action( 'upgrader_process_complete', array( 'Argus_Integrity', 'on_upgrader_complete' ), 10, 2 );
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
require_once ARGUS_WPD_DIR . 'admin/class-argus-admin.php';
|
||||
Argus_Admin::init();
|
||||
}
|
||||
}
|
||||
|
||||
public static function run_hourly() {
|
||||
Argus_Ban_Engine::sweep_expired();
|
||||
Argus_Events::prune();
|
||||
Argus_Policy_Engine::prune();
|
||||
Argus_Login_Guard::prune_attempts();
|
||||
|
||||
$scan_started = time();
|
||||
$integrity_ran = class_exists( 'Argus_Integrity' ) && Argus_Settings::get( 'integrity_scan_enabled', true );
|
||||
$malware_ran = class_exists( 'Argus_Malware_Scanner' ) && Argus_Settings::get( 'malware_scan_enabled', true );
|
||||
if ( $integrity_ran ) {
|
||||
Argus_Integrity::incremental_scan();
|
||||
}
|
||||
if ( $malware_ran ) {
|
||||
Argus_Malware_Scanner::incremental_scan();
|
||||
}
|
||||
if ( ( $integrity_ran || $malware_ran ) && class_exists( 'Argus_Scan_History' ) ) {
|
||||
Argus_Scan_History::record( Argus_Scan_History::TYPE_SCHEDULED_INCREMENTAL, $scan_started );
|
||||
}
|
||||
if ( class_exists( 'Argus_Correlation' ) ) {
|
||||
Argus_Correlation::run();
|
||||
}
|
||||
if ( class_exists( 'Argus_REST_Inventory' ) ) {
|
||||
Argus_REST_Inventory::snapshot();
|
||||
}
|
||||
if ( class_exists( 'Argus_AJAX_Inventory' ) ) {
|
||||
Argus_AJAX_Inventory::snapshot();
|
||||
}
|
||||
if ( class_exists( 'Argus_Cache_Log' ) ) {
|
||||
Argus_Cache_Log::rollup_and_prune();
|
||||
}
|
||||
if ( class_exists( 'Argus_Cache_Warmer' ) && Argus_Settings::get( 'cache_warming_enabled', false ) ) {
|
||||
Argus_Cache_Warmer::process_queue();
|
||||
}
|
||||
if ( class_exists( 'Argus_ANIS_Client' ) && Argus_ANIS_Client::is_connected() ) {
|
||||
|
||||
Argus_ANIS_Client::scheduled_sync();
|
||||
}
|
||||
if ( class_exists( 'Argus_Vuln_Intel' ) && Argus_Settings::get( 'vuln_intel_enabled', true ) ) {
|
||||
|
||||
Argus_Vuln_Intel::scheduled_check();
|
||||
}
|
||||
if ( class_exists( 'Argus_Backup' ) ) {
|
||||
|
||||
Argus_Backup::maybe_run_scheduled();
|
||||
}
|
||||
}
|
||||
|
||||
public static function register_cron_schedules( $schedules ) {
|
||||
$schedules['argus_wpd_five_minutes'] = array(
|
||||
'interval' => 5 * MINUTE_IN_SECONDS,
|
||||
'display' => __( 'Every 5 Minutes (ARGUS Defence)', 'argus-wordpress-defence' ),
|
||||
);
|
||||
return $schedules;
|
||||
}
|
||||
|
||||
public static function run_daily() {
|
||||
if ( class_exists( 'Argus_Integrity' ) ) {
|
||||
$scan_started = time();
|
||||
Argus_Integrity::full_scan();
|
||||
if ( class_exists( 'Argus_Scan_History' ) ) {
|
||||
Argus_Scan_History::record( Argus_Scan_History::TYPE_SCHEDULED_FULL, $scan_started, Argus_Integrity::scan_status()['files_scanned'] );
|
||||
}
|
||||
}
|
||||
if ( class_exists( 'Argus_GeoIP_RIR' ) && Argus_Settings::get( 'geoip_rir_enabled', true ) ) {
|
||||
Argus_GeoIP_RIR::run_daily_refresh();
|
||||
}
|
||||
if ( class_exists( 'Argus_Cache_Discovery' ) && Argus_Settings::get( 'cache_discovery_enabled', true ) && Argus_Settings::get( 'static_cache_enabled', false ) ) {
|
||||
Argus_Cache_Discovery::run_discovery();
|
||||
}
|
||||
if ( class_exists( 'Argus_ANIS_Client' ) && Argus_ANIS_Client::is_enabled() ) {
|
||||
|
||||
Argus_ANIS_Client::register();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user