PluginProbe
Vigilant – 100% Free Security Suite: Firewall, 2FA, Login, Headers, Scanner… / 2.11.8
Vigilant – 100% Free Security Suite: Firewall, 2FA, Login, Headers, Scanner… v2.11.8
3.0.0 2.11.12 2.11.11 2.11.10 2.11.9 2.11.7 2.11.8 2.11.6 2.11.5 2.11.4 2.11.3 2.11.1 2.11.2 2.11.0 2.10.5 2.10.4 2.10.3 2.10.2 2.10.1 2.10.0 2.9.9 2.9.8 2.9.6 2.9.7 2.9.5 All 88 releases
← All changes | admin/class-admin-ajax.php +31 -100 2.11.32.11.8 View file →
@@ -22,95 +22,18 @@
22 22 * AJAX: Apply preset
23 23 */
24 24 // ajax_apply_preset() is defined in class-admin.php directly (not in this trait)
25 25
26 - /**
27 - * AJAX: Clear lockouts
26 + /*
27 + * ajax_clear_lockouts(), ajax_clear_logs(), ajax_run_scan() and
28 + * ajax_test_headers() live in class-admin.php. Until 2.11.8 this trait
29 + * carried older copies of the four, and PHP runs the method of the class,
30 + * so the copies never ran: a fix written into one of them would have looked
31 + * applied and changed nothing. Removed after the audit of the admin surface
32 + * for 2.11.8 found them.
28 33 */
29 - public function ajax_clear_lockouts() {
30 - check_ajax_referer( 'vigilante_admin_nonce', 'nonce' );
31 34
32 - if ( ! current_user_can( 'manage_options' ) ) {
33 - wp_send_json_error( __( 'Permission denied.', 'vigilante' ) );
34 - }
35 -
36 - $ip = isset( $_POST['ip'] ) ? sanitize_text_field( wp_unslash( $_POST['ip'] ) ) : '';
37 -
38 - if ( ! empty( $ip ) ) {
39 - // Clear specific IP
40 - $result = $this->database->clear_lockout( $ip );
41 - } else {
42 - // Clear all
43 - $result = $this->database->clear_all_lockouts();
44 - }
45 -
46 - if ( $result ) {
47 - wp_send_json_success( __( 'Lockouts cleared.', 'vigilante' ) );
48 - } else {
49 - wp_send_json_error( __( 'Failed to clear lockouts.', 'vigilante' ) );
50 - }
51 - }
52 -
53 35 /**
54 - * AJAX: Clear logs
55 - */
56 - public function ajax_clear_logs() {
57 - check_ajax_referer( 'vigilante_admin_nonce', 'nonce' );
58 -
59 - if ( ! current_user_can( 'manage_options' ) ) {
60 - wp_send_json_error( __( 'Permission denied.', 'vigilante' ) );
61 - }
62 -
63 - $result = $this->activity_log->clear_all_logs();
64 -
65 - if ( $result ) {
66 - wp_send_json_success( __( 'Logs cleared.', 'vigilante' ) );
67 - } else {
68 - wp_send_json_error( __( 'Failed to clear logs.', 'vigilante' ) );
69 - }
70 - }
71 -
72 - /**
73 - * AJAX: Run file integrity scan
74 - */
75 - public function ajax_run_scan() {
76 - check_ajax_referer( 'vigilante_admin_nonce', 'nonce' );
77 -
78 - if ( ! current_user_can( 'manage_options' ) ) {
79 - wp_send_json_error( __( 'Permission denied.', 'vigilante' ) );
80 - }
81 -
82 - try {
83 - if ( ! class_exists( 'Vigilante_File_Integrity' ) ) {
84 - require_once VIGILANTE_PLUGIN_DIR . 'includes/class-file-integrity.php';
85 - }
86 -
87 - if ( ! $this->settings ) {
88 - wp_send_json_error( 'Settings not initialized' );
89 - }
90 -
91 - $activity_log = isset( $this->activity_log ) ? $this->activity_log : null;
92 - $database = isset( $this->database ) ? $this->database : null;
93 -
94 - $file_integrity = new Vigilante_File_Integrity( $this->settings, $database, $activity_log );
95 - $results = $file_integrity->run_scan();
96 -
97 - // Save results for display
98 - update_option( 'vigilante_last_integrity_scan', time() );
99 - update_option( 'vigilante_last_integrity_results', $results );
100 -
101 - wp_send_json_success( array(
102 - 'message' => __( 'Scan completed.', 'vigilante' ),
103 - 'results' => $results,
104 - ) );
105 - } catch ( Exception $e ) {
106 - wp_send_json_error( 'Exception: ' . $e->getMessage() );
107 - } catch ( Error $e ) {
108 - wp_send_json_error( 'PHP Error: ' . $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine() );
109 - }
110 - }
111 -
112 - /**
113 36 * AJAX: Approve a critical config file modification
114 37 *
115 38 * Updates the baseline hash for a single critical file (wp-config.php
116 39 * or .htaccess), accepting the current content as legitimate.
@@ -340,8 +263,18 @@
340 263 $removed_from_opposite = true;
341 264 }
342 265 }
343 266
267 + // On the main site of a network the whitelists also build the .htaccess
268 + // rules every site shares, so a user without network rights cannot put
269 + // an entry in them or take one out (2.11.6).
270 + $locked = Vigilante_Settings::get_locked_file_settings();
271 + $locked_firewall = ( isset( $locked['firewall'] ) && is_array( $locked['firewall'] ) ) ? $locked['firewall'] : array();
272 +
273 + if ( in_array( $option_key, $locked_firewall, true ) || ( $removed_from_opposite && in_array( $opposite_key, $locked_firewall, true ) ) ) {
274 + wp_send_json_error( Vigilante_Settings::get_shared_files_notice() );
275 + }
276 +
344 277 wp_cache_delete( Vigilante_Settings::OPTION_NAME, 'options' );
345 278 update_option( Vigilante_Settings::OPTION_NAME, $all_options );
346 279 $this->settings->clear_cache();
347 280
@@ -390,24 +323,8 @@
390 323 wp_send_json_success( $message );
391 324 }
392 325
393 326 /**
394 - * AJAX: Test security headers
395 - */
396 - public function ajax_test_headers() {
397 - check_ajax_referer( 'vigilante_admin_nonce', 'nonce' );
398 -
399 - if ( ! current_user_can( 'manage_options' ) ) {
400 - wp_send_json_error( __( 'Permission denied.', 'vigilante' ) );
401 - }
402 -
403 - $security_headers = new Vigilante_Security_Headers( $this->settings );
404 - $results = $security_headers->test_headers();
405 -
406 - wp_send_json_success( $results );
407 - }
408 -
409 - /**
410 327 * Sanitize activity log data
411 328 *
412 329 * @param array $data Data to sanitize.
413 330 * @return array
@@ -1129,8 +1046,16 @@
1129 1046 if ( ! $user_id ) {
1130 1047 wp_send_json_error( __( 'Invalid user ID.', 'vigilante' ) );
1131 1048 }
1132 1049
1050 + // The pending flag is a user meta, shared by every site of a network, and
1051 + // approving opens the login everywhere. Same rule the other account tools
1052 + // got in 2.10.3: permission over that user, which on a network only a
1053 + // network administrator has (2.11.8).
1054 + if ( ! current_user_can( 'edit_user', $user_id ) ) {
1055 + wp_send_json_error( __( 'Permission denied.', 'vigilante' ) );
1056 + }
1057 +
1133 1058 $user_security = new Vigilante_User_Security( $this->settings, $this->activity_log );
1134 1059 $result = $user_security->approve_user( $user_id, get_current_user_id() );
1135 1060
1136 1061 if ( $result ) {
@@ -1161,8 +1086,14 @@
1161 1086 $reason = isset( $_POST['reason'] ) ? sanitize_text_field( wp_unslash( $_POST['reason'] ) ) : '';
1162 1087
1163 1088 if ( ! $user_id ) {
1164 1089 wp_send_json_error( __( 'Invalid user ID.', 'vigilante' ) );
1090 + }
1091 +
1092 + // See ajax_approve_user(): the account and its pending flag belong to the
1093 + // whole network (2.11.8).
1094 + if ( ! current_user_can( 'edit_user', $user_id ) ) {
1095 + wp_send_json_error( __( 'Permission denied.', 'vigilante' ) );
1165 1096 }
1166 1097
1167 1098 $user = get_userdata( $user_id );
1168 1099 $username = $user ? $user->user_login : $user_id;