$label, 'url' => $url ); } /** * What to do once the malware is gone, every time. */ public static function after_cleanup() { return array( __( 'Rotate the security keys (Tools): every login cookie, stolen or not, stops working.', 'ai-guardwall' ), __( 'Change the password of every administrator, of the database and of your hosting/FTP account.', 'ai-guardwall' ), __( 'Update WordPress, every plugin and theme, and delete the ones you do not use.', 'ai-guardwall' ), __( 'Run a new scan: a clean site shows 0 critical and 0 confirmed findings.', 'ai-guardwall' ), __( 'Switch on the Recommended preset and two-factor authentication under Security Wall so it does not happen again.', 'ai-guardwall' ), ); } /* ------------------------------ guide ------------------------------ */ /** * The guide for one finding. * * @since 1.1.0 * @param array $f Hydrated finding. * @return array title, steps[], primary (action id or ''), links[] {label,url}, after (bool), done (bool) */ public static function guide( array $f ) { $meta = isset( $f['meta_arr'] ) ? $f['meta_arr'] : array(); $actions = Softvolt_Ai_Bodyguard_Remediation::actions_for( $f ); $sig = (string) $f['signature']; $cat = (string) $f['category']; $rel = isset( $meta['rel'] ) ? (string) $meta['rel'] : ''; $line = (int) $f['line']; $status = (string) $f['status']; $is_file = in_array( $cat, self::FILE_CATEGORIES, true ) || ( 'config' === $cat && '' !== $rel ); $bad = 'confirmed' === $f['verdict'] || 'confirmed_malware' === $f['ai_verdict']; $g = array( 'title' => '', 'steps' => array(), 'primary' => '', 'links' => array(), 'after' => false, 'done' => false ); if ( ! in_array( $status, array( 'open' ), true ) ) { $g['done'] = true; $g['title'] = __( 'Nothing left to do here', 'ai-guardwall' ); $labels = Softvolt_Ai_Bodyguard_Findings::statuses(); $g['steps'] = array( sprintf( /* translators: %s: status */ __( 'This finding is marked "%s". Reopen it if it was a mistake; run a new scan to confirm the site is clean.', 'ai-guardwall' ), isset( $labels[ $status ] ) ? $labels[ $status ] : $status ) ); if ( in_array( $status, array( 'quarantined', 'deleted' ), true ) ) { $g['steps'][] = __( 'If something on the site broke after this was removed, re-install the plugin or theme it belonged to, or WordPress itself from Dashboard › Updates.', 'ai-guardwall' ); } return $g; } switch ( true ) { /* ---------- files ---------- */ case $is_file && ! empty( $meta['official_url'] ) && ! $bad: $g['title'] = __( 'Get the official file back', 'ai-guardwall' ); $g['primary'] = ''; $g['steps'] = array( __( 'Re-install the official copy: Dashboard › Updates › "Re-install version" for WordPress files; for a plugin or theme, delete it and install it again from WordPress.org (its settings stay in the database).', 'ai-guardwall' ), 'core' === $cat ? __( 'Many core files modified? Dashboard › Updates › "Re-install" replaces all of wp-admin and wp-includes at once; your content and settings are untouched.', 'ai-guardwall' ) : __( 'Many files of the same plugin or theme modified? Delete it and install it again from WordPress.org; its settings stay in the database.', 'ai-guardwall' ), __( 'If you changed this file on purpose (a customised plugin, a development copy), press "Mark as false positive" instead.', 'ai-guardwall' ), __( 'Run a new scan. A file that comes back modified is being rewritten by something else on the site: clean the other findings first.', 'ai-guardwall' ), ); $g['links'][] = self::link( 'core' === $cat ? __( 'Dashboard › Updates', 'ai-guardwall' ) : __( 'Plugins screen', 'ai-guardwall' ), admin_url( 'core' === $cat ? 'update-core.php' : 'plugins.php' ) ); break; case $is_file && $bad && isset( $actions['quarantine'] ): $g['title'] = __( 'Remove the file now', 'ai-guardwall' ); $g['primary'] = 'quarantine'; $g['after'] = true; $g['steps'] = array( __( 'Press "Quarantine". The file is moved out of the site at once and can no longer run; it is kept for 30 days and can be restored with one click if anything breaks (with malware that almost never happens).', 'ai-guardwall' ), __( 'Look in the same folder (by FTP or with the file manager in your hosting panel) for other files changed on the same day; malicious files rarely come alone.', 'ai-guardwall' ), __( 'Clean every other confirmed finding, then work through the checklist below: the keys and passwords must change because whoever placed this file may know them.', 'ai-guardwall' ), ); break; case $is_file && in_array( $sig, array( 'file_modified', 'file_new' ), true ): $g['title'] = __( 'Confirm the change was yours', 'ai-guardwall' ); $g['primary'] = 'ignore'; $g['steps'] = array( __( 'The file changed since the previous scan and no update explains it. If you, your developer or a plugin you updated by hand changed it, press "Ignore".', 'ai-guardwall' ), __( 'Not sure? Press "AI analyse": the analyst reads the code and says whether it is harmless.', 'ai-guardwall' ), __( 'If you do not recognise it, press "Quarantine"; restore it if something stops working.', 'ai-guardwall' ), ); break; case $is_file && 'upload' === $cat: $g['title'] = __( 'Remove it and stop PHP from running in uploads', 'ai-guardwall' ); $g['primary'] = 'quarantine'; $g['after'] = true; $g['steps'] = array( __( 'Press "Quarantine". Nothing legitimate runs PHP from the uploads folder, so nothing can break.', 'ai-guardwall' ), __( 'Switch on "Block PHP execution in uploads" under Security Wall › Hardening so no file in this folder can ever run again.', 'ai-guardwall' ), __( 'Update every plugin and theme (an outdated one with a file-upload flaw is the usual way in) and change the administrator passwords.', 'ai-guardwall' ), ); $g['links'][] = self::link( __( 'Hardening rule: block PHP in uploads', 'ai-guardwall' ), self::rule_url( 'block_php_uploads' ) ); break; case 'exposed_backup' === $sig: $g['title'] = __( 'Move the backup out of the public folder', 'ai-guardwall' ); $g['primary'] = 'delete'; $g['steps'] = array( __( 'Download it by FTP or with the file manager in your hosting panel if you still need it, then press "Delete" (a copy stays in quarantine for 30 days).', 'ai-guardwall' ), __( 'If it contained wp-config.php or a database dump, change the database password in your hosting panel and in wp-config.php.', 'ai-guardwall' ), __( 'Keep future backups outside the web root, in your host\'s backup tool or in cloud storage.', 'ai-guardwall' ), ); break; case $is_file && in_array( $sig, array( 'mu_plugin_present', 'dropin_present', 'core_unknown', 'plugin_unknown_file', 'root_unknown_php' ), true ): $g['title'] = __( 'Find out where this file came from', 'ai-guardwall' ); $g['primary'] = 'ai'; $g['steps'] = array( __( 'Read the "Code" box below: a header comment usually names the host, plugin or tool that created it. Press "AI analyse" when it does not.', 'ai-guardwall' ), __( 'Created by your host, a caching plugin or an installer you used: press "Ignore" so it is not reported again.', 'ai-guardwall' ), __( 'Unknown or clearly out of place: press "Quarantine" (a drop-in made by a caching plugin comes back while that plugin is active; deactivate the plugin first).', 'ai-guardwall' ), ); break; case $is_file && ( 0 === strpos( $sig, 'htaccess_' ) || 'ini_auto_prepend' === $sig || in_array( $sig, array( 'spam_keywords', 'hidden_links', 'hidden_iframe', 'known_bad_host', 'ndsw_injection', 'ua_cloaking_redirect', 'mobile_redirect', 'js_eval_decoded', 'js_document_write_unescape', 'js_fromcharcode_blob', 'js_obfuscator_io', 'js_redirect_external', 'js_script_bad_tld', 'js_cryptominer', 'js_card_skimmer', 'js_hidden_iframe_builder' ), true ) ): $g['title'] = __( 'Cut the injected lines out of the file', 'ai-guardwall' ); $g['primary'] = 'ai'; $g['after'] = true; $g['steps'] = array( sprintf( /* translators: %d: number */ __( 'Open the file by FTP or with the file manager in your hosting panel and go to line %d. The "Matched indicators" list below shows every flagged line; injected code is usually one very long line at the top or bottom.', 'ai-guardwall' ), max( 1, $line ) ), __( 'Keep a copy of the file, then delete the flagged block, leave the rest and save.', 'ai-guardwall' ), __( 'Theme files from a marketplace: download a fresh copy from the vendor and upload it over this one by FTP or with the file manager in your hosting panel.', 'ai-guardwall' ), __( 'Run a new scan; the same injection often sits in several files and in database records (the scan lists each one).', 'ai-guardwall' ), ); if ( 0 === strpos( $sig, 'htaccess_' ) ) { $g['steps'][] = __( 'Lost? Settings › Permalinks › Save regenerates the standard WordPress .htaccess; add your own rules back afterwards.', 'ai-guardwall' ); $g['links'][] = self::link( __( 'Settings › Permalinks', 'ai-guardwall' ), admin_url( 'options-permalink.php' ) ); } break; case $is_file: $g['title'] = __( 'Let the AI analyst decide, then act on its verdict', 'ai-guardwall' ); $g['primary'] = 'ai'; $g['steps'] = array( __( 'Press "AI analyse". The analyst reads the code with the cleanup instructions and answers: confirmed malware, suspicious, likely legitimate or needs manual review.', 'ai-guardwall' ), __( '"Likely legitimate": press "Mark as false positive". Plugins that handle licenses, caching or file uploads often trigger these rules.', 'ai-guardwall' ), __( '"Confirmed malware": press "Quarantine".', 'ai-guardwall' ), sprintf( /* translators: %d: number */ __( '"Needs manual review": open the file by FTP or with the file manager in your hosting panel, read what the flagged lines around line %d do, or send the finding to a security professional (Download report).', 'ai-guardwall' ), max( 1, $line ) ), ); break; /* ---------- database ---------- */ case 'db' === $cat && isset( $actions['clean_db'] ): $g['title'] = __( 'Remove the injected code from the record', 'ai-guardwall' ); $g['primary'] = 'clean_db'; $g['after'] = true; $g['steps'] = array( __( 'Press "Remove injected code". The flagged scripts, iframes and hidden link blocks are stripped and a backup of the original value is kept.', 'ai-guardwall' ), __( 'Or edit the record yourself (in its own editor, or with phpMyAdmin in your hosting panel) and delete the flagged block; the "Code" box shows exactly what was matched.', 'ai-guardwall' ), __( 'Widgets and "custom code" boxes of themes are the usual places: check Appearance › Widgets and your theme settings for the same text.', 'ai-guardwall' ), __( 'Then find what put it there in the other findings (a file, a cron job, an unknown administrator), or it comes back.', 'ai-guardwall' ), ); if ( ! empty( $meta['edit_link'] ) ) { $g['links'][] = self::link( __( 'Edit in WordPress', 'ai-guardwall' ), $meta['edit_link'] ); } break; case 'db' === $cat && false !== strpos( $sig, 'active_plugin' ): $g['title'] = __( 'Remove the plugin entry, then its file', 'ai-guardwall' ); $g['primary'] = 'delete_record'; $g['after'] = true; $g['steps'] = array( __( 'Press "Deactivate this plugin entry": the file stops loading on the next request.', 'ai-guardwall' ), __( 'Delete the file it pointed to by FTP or with the file manager in your hosting panel (and its folder when the whole plugin is unknown to you).', 'ai-guardwall' ), ); break; case 'db' === $cat && ( false !== strpos( $sig, 'siteurl' ) || false !== strpos( $sig, 'home' ) ): $g['title'] = __( 'Set the site addresses back to your domain', 'ai-guardwall' ); $g['steps'] = array( __( 'Settings › General: set "WordPress Address" and "Site Address" to your real domain (with https:// when you have SSL).', 'ai-guardwall' ), __( 'If wp-admin is unreachable, edit the "siteurl" and "home" rows of the options table with phpMyAdmin in your hosting panel.', 'ai-guardwall' ), __( 'If they change back by themselves, something on the site rewrites them: clean the other findings first.', 'ai-guardwall' ), ); $g['links'][] = self::link( __( 'Settings › General', 'ai-guardwall' ), admin_url( 'options-general.php' ) ); break; case 'db' === $cat && ( false !== strpos( $sig, 'default_role' ) || false !== strpos( $sig, 'registration' ) ): $g['title'] = __( 'Close the registration door', 'ai-guardwall' ); $g['steps'] = array( __( 'Settings › General: set "New User Default Role" to Subscriber, and untick "Anyone can register" unless your site needs it (shops and memberships: keep it, with the Subscriber or Customer role).', 'ai-guardwall' ), __( 'Users › All Users: remove every account you do not recognise, administrators first.', 'ai-guardwall' ), ); $g['links'][] = self::link( __( 'Settings › General', 'ai-guardwall' ), admin_url( 'options-general.php' ) ); $g['links'][] = self::link( __( 'Administrators', 'ai-guardwall' ), admin_url( 'users.php?role=administrator' ) ); break; case 'db' === $cat && false !== strpos( $sig, 'table' ): $g['title'] = __( 'Check the unknown table', 'ai-guardwall' ); $g['steps'] = array( __( 'Find it on Database › Tables: tables left by a removed plugin are harmless but useless.', 'ai-guardwall' ), __( 'Unknown and unused: remove it on Database › Tables (a backup is taken first). A plugin you still use recreates its table when needed.', 'ai-guardwall' ), __( 'A table belonging to a plugin you use: press "Ignore".', 'ai-guardwall' ), ); $g['links'][] = self::link( __( 'Database › Tables', 'ai-guardwall' ), Softvolt_Ai_Bodyguard_Admin::url( 'database', 'tables' ) ); $g['primary'] = 'ignore'; break; case 'db' === $cat: $g['title'] = isset( $actions['delete_record'] ) ? __( 'Remove the record', 'ai-guardwall' ) : __( 'Review the record', 'ai-guardwall' ); $g['primary'] = isset( $actions['delete_record'] ) ? 'delete_record' : 'ai'; $g['steps'] = array( isset( $actions['delete_record'] ) ? __( 'Press the remove action (trash for posts and comments, delete for options and meta; a backup is kept where possible).', 'ai-guardwall' ) : __( 'Read the flagged value in the "Code" box below.', 'ai-guardwall' ), __( 'Part of a plugin or theme you use and it looks like configuration: press "Ignore".', 'ai-guardwall' ), __( 'Unknown: remove the flagged part where the value is set (the plugin or theme settings, or phpMyAdmin in your hosting panel).', 'ai-guardwall' ), ); if ( ! empty( $meta['edit_link'] ) ) { $g['links'][] = self::link( __( 'Edit in WordPress', 'ai-guardwall' ), $meta['edit_link'] ); } break; /* ---------- users and cron ---------- */ case 'user' === $cat && false !== strpos( $sig, 'admin_username' ): $g['title'] = __( 'Rename the "admin" account', 'ai-guardwall' ); $g['steps'] = array( __( 'Tools › Rename a user: pick "admin", type a new name, press Rename. Log in with the new name from now on; nothing else changes.', 'ai-guardwall' ), __( 'Keep "admin" on the attack-usernames list (Login security) so bots that try it are locked out at once.', 'ai-guardwall' ), ); $g['links'][] = self::link( __( 'Security Wall › User security › Rename a user', 'ai-guardwall' ), self::security_url( 'usersec' ) ); break; case 'user' === $cat: $g['title'] = __( 'Remove the account unless someone on your team created it', 'ai-guardwall' ); $g['primary'] = isset( $actions['delete_user'] ) ? 'delete_user' : ''; $g['after'] = true; $g['steps'] = array( __( 'Ask your team first: an administrator nobody created, or an account whose role grew without reason, belongs to an attacker.', 'ai-guardwall' ), isset( $actions['delete_user'] ) ? __( 'Press "Delete this user": the account is removed and its content is reassigned to you.', 'ai-guardwall' ) : __( 'Users › All Users: delete the account, or set its role back to what it should be.', 'ai-guardwall' ), __( 'If the account was yours or a colleague\'s, press "Ignore" and reset its password anyway.', 'ai-guardwall' ), __( 'Accounts that do not show under Users at all can be seen and removed with phpMyAdmin in your hosting panel (users table).', 'ai-guardwall' ), ); $g['links'][] = self::link( __( 'Users', 'ai-guardwall' ), admin_url( 'users.php' ) ); break; case 'cron' === $cat: $g['title'] = __( 'Remove the scheduled task and what created it', 'ai-guardwall' ); $g['primary'] = isset( $actions['remove_cron'] ) ? 'remove_cron' : ''; $g['steps'] = array( __( 'A task you cannot match to a plugin you use: press "Remove the scheduled task".', 'ai-guardwall' ), __( 'Search the site files for the hook name (the file manager in your hosting panel, or grep over SSH) to find the code that schedules it; quarantine that file or it schedules the task again.', 'ai-guardwall' ), __( 'A task of a plugin you use: press "Ignore".', 'ai-guardwall' ), ); break; /* ---------- configuration ---------- */ case 'config' === $cat && isset( $actions['apply_rule'] ): $rules = Softvolt_Ai_Bodyguard_Hardening::rules(); $rule = isset( $rules[ $meta['rule'] ] ) ? $rules[ $meta['rule'] ] : null; $g['title'] = $rule ? sprintf( /* translators: %s: title */ __( 'Switch on "%s"', 'ai-guardwall' ), $rule['title'] ) : __( 'Switch the hardening rule on', 'ai-guardwall' ); $g['primary'] = 'apply_rule'; $g['steps'] = array( __( 'Press "Switch the hardening rule on". It is applied immediately and the finding is closed.', 'ai-guardwall' ), $rule && ! empty( $rule['impact'] ) ? sprintf( /* translators: %s: impact */ __( 'What could change: %s', 'ai-guardwall' ), $rule['impact'] ) : __( 'Server rules are rolled back automatically if they break the site.', 'ai-guardwall' ), __( 'Prefer to read about it first? Open the rule under Security Wall › Hardening; the wizard explains every rule and what it may affect.', 'ai-guardwall' ), ); $g['links'][] = self::link( __( 'Open the rule in the Hardening wizard', 'ai-guardwall' ), self::rule_url( $meta['rule'] ) ); break; case 'config' === $cat && 'update' === $f['remediation']: $g['title'] = __( 'Install the update', 'ai-guardwall' ); $g['steps'] = array( __( 'Dashboard › Updates: update WordPress, the plugins and the themes listed there. Back up first if you have not done so today.', 'ai-guardwall' ), __( 'Delete plugins and themes you no longer use instead of updating them.', 'ai-guardwall' ), __( 'Switch on automatic updates for plugins and themes on the Plugins and Themes screens (WordPress\'s own setting) so this stops being a finding.', 'ai-guardwall' ), ); $g['links'][] = self::link( __( 'Dashboard › Updates', 'ai-guardwall' ), admin_url( 'update-core.php' ) ); break; case 'cfg_salts' === $sig: $g['title'] = __( 'Rotate the security keys', 'ai-guardwall' ); $g['steps'] = array( __( 'Tools › "Rotate keys now": fresh keys are written into wp-config.php (a backup is kept). Everyone, including you, has to log in again.', 'ai-guardwall' ), ); $g['links'][] = self::link( __( 'Security Wall › User security › Salt', 'ai-guardwall' ), self::security_url( 'usersec' ) ); break; case 'cfg_wp_debug' === $sig: $g['title'] = __( 'Turn debug output off', 'ai-guardwall' ); $g['steps'] = array( __( 'Open wp-config.php by FTP or with the file manager in your hosting panel and set WP_DEBUG_DISPLAY to false (and WP_DEBUG to false on a live site); save.', 'ai-guardwall' ), ); break; case 'cfg_wp_config_include' === $sig: $g['title'] = __( 'Check what wp-config.php loads', 'ai-guardwall' ); $g['primary'] = 'ai'; $g['steps'] = array( __( 'Open wp-config.php by FTP or with the file manager in your hosting panel and find the include/require line that is not wp-settings.php.', 'ai-guardwall' ), __( 'A file your host documents (environment settings, a local config): press "Ignore".', 'ai-guardwall' ), __( 'Anything else: open the included file, press "AI analyse" on it if it has a finding, delete the include line and quarantine the file.', 'ai-guardwall' ), ); break; case 'cfg_php_version' === $sig: $g['title'] = __( 'Switch to a supported PHP version', 'ai-guardwall' ); $g['steps'] = array( __( 'In your hosting panel (cPanel › MultiPHP, Plesk › PHP settings, or your host\'s site tools) choose PHP 8.3 or newer (on PHP 8.2, at least 8.2.35), then open the site and wp-admin to check that everything still works.', 'ai-guardwall' ), __( 'If a plugin breaks, update it first; a plugin that cannot run on PHP 8 is abandoned and should be replaced.', 'ai-guardwall' ), ); break; case 0 === strpos( $sig, 'cfg_inactive' ): $g['title'] = __( 'Delete what you do not use', 'ai-guardwall' ); $g['steps'] = array( __( 'Plugins › Inactive: delete each plugin you no longer need. Appearance › Themes: keep the active theme, its parent and one default theme.', 'ai-guardwall' ), __( 'Keep the ones you really use seasonally, and press "Ignore".', 'ai-guardwall' ), ); $g['primary'] = 'ignore'; $g['links'][] = self::link( __( 'Inactive plugins', 'ai-guardwall' ), admin_url( 'plugins.php?plugin_status=inactive' ) ); $g['links'][] = self::link( __( 'Themes', 'ai-guardwall' ), admin_url( 'themes.php' ) ); break; case 'cfg_table_prefix' === $sig: $g['title'] = __( 'Optional: change the table prefix', 'ai-guardwall' ); $g['primary'] = 'ignore'; $g['steps'] = array( __( 'This is a small hurdle, not a hole. Change it only with a full backup and a tool made for it (your host\'s site tools or a prefix-change plugin), or press "Ignore".', 'ai-guardwall' ), ); break; case 0 === strpos( $sig, 'cfg_missing' ) || false !== strpos( $sig, 'missing_core' ): $g['title'] = __( 'Re-install WordPress core', 'ai-guardwall' ); $g['steps'] = array( __( 'Dashboard › Updates › "Re-install version …": the missing core files are restored; your content and plugins stay.', 'ai-guardwall' ), ); $g['links'][] = self::link( __( 'Dashboard › Updates', 'ai-guardwall' ), admin_url( 'update-core.php' ) ); break; case 'config' === $cat: $g['title'] = __( 'Follow the description', 'ai-guardwall' ); $g['steps'] = array( __( 'The description above says exactly what to change and where. When it is done, run a new scan and the finding closes by itself; if it does not apply to your site, press "Ignore".', 'ai-guardwall' ), ); $g['primary'] = 'ignore'; break; default: $g['title'] = __( 'Review, then ignore or fix', 'ai-guardwall' ); $g['steps'] = array( __( 'Read the description and the matched indicators, fix what applies, then run a new scan; press "Ignore" when it does not apply to your site.', 'ai-guardwall' ) ); break; } if ( '' !== $g['primary'] && 'ai' !== $g['primary'] && ! isset( $actions[ $g['primary'] ] ) ) { $g['primary'] = ''; } return $g; } /** * One line for the findings table and the report. */ public static function short( array $f ) { $g = self::guide( $f ); return $g['title']; } /* ------------------------------ plan ------------------------------ */ /** * The open findings, grouped into the order a cleanup is done in. * * @since 1.1.0 * @param int $scan_id Scan (0 = every open finding). * @return array phases[] { id, title, text, count, ids[], action, action_label, link }, after[] */ public static function plan( $scan_id = 0 ) { $rows = Softvolt_Ai_Bodyguard_Findings::query( array( 'status' => 'open', 'scan_id' => (int) $scan_id, 'per_page' => 1000, 'orderby' => 'severity' ) ); $phases = array( 'remove' => array( 'ids' => array(), 'action' => 'quarantine', 'action_label' => __( 'Quarantine all of them', 'ai-guardwall' ), 'title' => __( 'Remove confirmed malware', 'ai-guardwall' ), 'text' => __( 'Files the scanner or the AI analyst confirmed. Removing them first closes the attacker\'s access; each file is kept in quarantine and can be restored.', 'ai-guardwall' ) ), 'repair' => array( 'ids' => array(), 'action' => '', 'action_label' => '', 'title' => __( 'Restore modified core and plugin files', 'ai-guardwall' ), 'text' => __( 'Files that differ from WordPress.org. Re-install WordPress from Dashboard › Updates, and each plugin or theme from WordPress.org, to get the originals back.', 'ai-guardwall' ) ), 'db' => array( 'ids' => array(), 'action' => 'clean_db', 'action_label' => __( 'Clean all records', 'ai-guardwall' ), 'title' => __( 'Clean the database', 'ai-guardwall' ), 'text' => __( 'Injected scripts, iframes and spam links in posts, options and meta. The original values are backed up before they are cleaned.', 'ai-guardwall' ) ), 'access' => array( 'ids' => array(), 'action' => '', 'action_label' => '', 'title' => __( 'Rogue users and scheduled tasks', 'ai-guardwall' ), 'text' => __( 'Accounts and cron jobs the attacker uses to come back. Each needs a look (is it yours?) before it is removed, so these are done one by one.', 'ai-guardwall' ) ), 'review' => array( 'ids' => array(), 'action' => 'ai', 'action_label' => __( 'AI analyse all of them', 'ai-guardwall' ), 'title' => __( 'Review the suspicious files', 'ai-guardwall' ), 'text' => __( 'Code that looks dangerous but is not certain. The AI analyst gives a verdict for each; then quarantine the confirmed ones and mark the rest as false positives.', 'ai-guardwall' ) ), 'doors' => array( 'ids' => array(), 'action' => 'apply_rule', 'action_label' => __( 'Switch all these rules on', 'ai-guardwall' ), 'title' => __( 'Close the doors', 'ai-guardwall' ), 'text' => __( 'Updates, exposed files and missing protections. Hardening rules can be switched on in one go; updates are installed from Dashboard › Updates.', 'ai-guardwall' ) ), ); $updates = 0; foreach ( $rows['rows'] as $f ) { $actions = Softvolt_Ai_Bodyguard_Remediation::actions_for( $f ); $is_file = in_array( $f['category'], self::FILE_CATEGORIES, true ); $bad = 'confirmed' === $f['verdict'] || 'confirmed_malware' === $f['ai_verdict']; if ( $is_file && $bad && isset( $actions['quarantine'] ) ) { $phases['remove']['ids'][] = (int) $f['id']; } elseif ( $is_file && ! empty( $f['meta_arr']['official_url'] ) ) { $phases['repair']['ids'][] = (int) $f['id']; } elseif ( 'db' === $f['category'] && isset( $actions['clean_db'] ) ) { $phases['db']['ids'][] = (int) $f['id']; } elseif ( in_array( $f['category'], array( 'user', 'cron' ), true ) ) { $phases['access']['ids'][] = (int) $f['id']; } elseif ( $is_file && 'info' !== $f['severity'] && '' === $f['ai_verdict'] && ! in_array( $f['signature'], array( 'file_modified', 'file_new' ), true ) ) { $phases['review']['ids'][] = (int) $f['id']; } elseif ( 'config' === $f['category'] && isset( $actions['apply_rule'] ) ) { $phases['doors']['ids'][] = (int) $f['id']; } elseif ( 'config' === $f['category'] && 'update' === $f['remediation'] ) { $updates++; } } $out = array(); foreach ( $phases as $id => $p ) { $p['id'] = $id; $p['count'] = count( $p['ids'] ); $p['link'] = Softvolt_Ai_Bodyguard_Admin::url( 'cleanup', 'findings', array( 'plan' => $id ) ); if ( 'doors' === $id ) { $p['updates'] = $updates; } $out[] = $p; } return array( 'phases' => $out, 'open' => (int) $rows['total'], 'after' => self::after_cleanup(), ); } /** * Finding ids for one plan phase (for the Findings page filter). */ public static function phase_ids( $phase, $scan_id = 0 ) { foreach ( self::plan( $scan_id )['phases'] as $p ) { if ( $p['id'] === $phase ) { return $p['ids']; } } return array(); } }