PluginProbe ʕ •ᴥ•ʔ
CloudSecure WP Security / 1.4.13
CloudSecure WP Security v1.4.13
1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 trunk 0.9.0 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.19 1.3.2 1.3.20 1.3.21 1.3.22 1.3.23 1.3.24 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8
cloudsecure-wp-security / modules / cloudsecure-wp.php
cloudsecure-wp-security / modules Last commit date
admin 2 weeks ago cli 2 weeks ago lib 1 month ago captcha.php 2 weeks ago cloudsecure-wp.php 2 weeks ago common.php 4 months ago config.php 2 years ago disable-access-system-file.php 1 month ago disable-author-query.php 2 weeks ago disable-login.php 1 month ago disable-restapi.php 2 weeks ago disable-xmlrpc.php 1 year ago htaccess.php 4 months ago login-log.php 1 month ago login-notification.php 3 months ago protect-rest-batch.php 1 month ago rename-login-page.php 4 months ago restrict-admin-page.php 3 months ago server-error-notification.php 3 months ago two-factor-authentication.php 3 months ago unify-messages.php 2 years ago update-notice.php 9 months ago waf-engine.php 1 month ago waf.php 1 month ago
cloudsecure-wp.php
741 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 require_once __DIR__ . '/common.php';
8 require_once __DIR__ . '/config.php';
9 require_once __DIR__ . '/htaccess.php';
10 require_once __DIR__ . '/login-notification.php';
11 require_once __DIR__ . '/disable-login.php';
12 require_once __DIR__ . '/rename-login-page.php';
13 require_once __DIR__ . '/unify-messages.php';
14 require_once __DIR__ . '/restrict-admin-page.php';
15 require_once __DIR__ . '/disable-xmlrpc.php';
16 require_once __DIR__ . '/disable-author-query.php';
17 require_once __DIR__ . '/disable-restapi.php';
18 require_once __DIR__ . '/protect-rest-batch.php';
19 require_once __DIR__ . '/update-notice.php';
20 require_once __DIR__ . '/captcha.php';
21 require_once __DIR__ . '/../really-simple-captcha/really-simple-captcha.php';
22 require_once __DIR__ . '/lib/class-time-based-one-time-password.php';
23 require_once __DIR__ . '/lib/class-recovery-codes.php';
24 require_once __DIR__ . '/login-log.php';
25 require_once __DIR__ . '/two-factor-authentication.php';
26 require_once __DIR__ . '/server-error-notification.php';
27 require_once __DIR__ . '/lib/class-waf-rules.php';
28 require_once __DIR__ . '/waf-engine.php';
29 require_once __DIR__ . '/waf.php';
30 require_once __DIR__ . '/disable-access-system-file.php';
31 require_once __DIR__ . '/lib/class-disable-access-system-file-rules.php';
32
33 class CloudSecureWP extends CloudSecureWP_Common {
34 private $config;
35 private $htaccess;
36 private $login_notification;
37 private $disable_login;
38 private $rename_login_page;
39 private $unify_messages;
40 private $restrict_admin_page;
41 private $disable_xmlrpc;
42 private $disable_author_query;
43 private $disable_restapi;
44 private $protect_rest_batch;
45 private $update_notice;
46 private $captcha;
47 private $login_log;
48 private $two_factor_authentication;
49 private $server_error_notification;
50 private $waf;
51 private $disable_access_system_file;
52
53 function __construct( array $info ) {
54 parent::__construct( $info );
55 $this->config = new CloudSecureWP_Config( $info );
56 $this->htaccess = new CloudSecureWP_Htaccess( $info );
57 $this->login_notification = new CloudSecureWP_Login_Notification( $info, $this->config );
58 $this->disable_login = new CloudSecureWP_Disable_Login( $info, $this->config );
59 $this->rename_login_page = new CloudSecureWP_Rename_Login_Page( $info, $this->config, $this->htaccess );
60 $this->unify_messages = new CloudSecureWP_Unify_Messages( $info, $this->config, $this->disable_login );
61 $this->restrict_admin_page = new CloudSecureWP_Restrict_Admin_Page( $info, $this->config, $this->htaccess, $this->disable_login );
62 $this->disable_xmlrpc = new CloudSecureWP_Disable_XMLRPC( $info, $this->config, $this->htaccess );
63 $this->disable_author_query = new CloudSecureWP_Disable_Author_Query( $info, $this->config );
64 $this->disable_restapi = new CloudSecureWP_Disable_RESTAPI( $info, $this->config );
65 $this->protect_rest_batch = new CloudSecureWP_Protect_REST_Batch( $info );
66 $this->update_notice = new CloudSecureWP_Update_Notice( $info, $this->config );
67 $this->captcha = new CloudSecureWP_CAPTCHA( $info, $this->config );
68 $this->login_log = new CloudSecureWP_Login_Log( $info, $this->config, $this->disable_login );
69 $this->two_factor_authentication = new CloudSecureWP_Two_Factor_Authentication( $info, $this->config, $this->disable_login, $this->login_log, $this->disable_xmlrpc );
70 $this->server_error_notification = new CloudSecureWP_Server_Error_Notification( $info, $this->config );
71 $this->waf = new CloudSecureWP_Waf( $info, $this->config );
72 $this->disable_access_system_file = new CloudSecureWP_Disable_Access_System_File( $info, $this->config );
73 }
74
75 /**
76 * プラグイン実行
77 *
78 * @return void
79 */
80 public function run() {
81 if ( ! $this->check_environment() ) {
82 if ( $this->login_notification->is_enabled() ) {
83 $this->login_notification->deactivate();
84 }
85
86 if ( $this->disable_login->is_enabled() ) {
87 $this->disable_login->deactivate();
88 }
89
90 if ( $this->rename_login_page->is_enabled() ) {
91 $this->rename_login_page->deactivate();
92 }
93
94 if ( $this->unify_messages->is_enabled() ) {
95 $this->unify_messages->deactivate();
96 }
97
98 if ( $this->restrict_admin_page->is_enabled() ) {
99 $this->restrict_admin_page->deactivate();
100 }
101
102 if ( $this->disable_xmlrpc->is_enabled() ) {
103 $this->disable_xmlrpc->deactivate();
104 }
105
106 if ( $this->disable_author_query->is_enabled() ) {
107 $this->disable_author_query->deactivate();
108 }
109
110 if ( $this->disable_restapi->is_enabled() ) {
111 $this->disable_restapi->deactivate();
112 }
113
114 if ( $this->update_notice->is_enabled() ) {
115 $this->update_notice->deactivate();
116 }
117
118 if ( $this->captcha->is_enabled() ) {
119 $this->captcha->deactivate();
120 }
121
122 if ( $this->two_factor_authentication->is_enabled() ) {
123 $this->two_factor_authentication->deactivate();
124 }
125
126 if ( $this->server_error_notification->is_enabled() ) {
127 $this->server_error_notification->deactivate();
128 }
129
130 if ( $this->waf->is_enabled() ) {
131 $this->waf->deactivate();
132 }
133
134 if ( $this->disable_access_system_file->is_enabled() ) {
135 $this->disable_access_system_file->deactivate();
136 }
137 } else {
138 if ( $this->waf->is_enabled() ) {
139 add_action( 'plugins_loaded', array( $this->waf, 'waf' ), 10 );
140 }
141
142 if ( $this->server_error_notification->is_enabled() ) {
143 add_filter( 'wp_php_error_args', array( $this->server_error_notification, 'notification' ), 10, 2 );
144 }
145
146 if ( $this->disable_access_system_file->is_enabled() ) {
147 add_action( 'plugins_loaded', array( $this->disable_access_system_file, 'init' ), 11 );
148 }
149
150 add_action( 'wp_login', array( $this->login_log, 'wp_login' ), 1, 1 );
151 add_action( 'wp_login', array( $this->two_factor_authentication, 'cleanup_expired_sessions' ), 2, 0 );
152 add_action( 'xmlrpc_call', array( $this->login_log, 'xmlrpc_call' ), 10 );
153 add_action( 'wp_login_failed', array( $this->login_log, 'wp_login_failed' ), 20, 2 );
154
155 if ( $this->login_notification->is_enabled() ) {
156 add_action( 'wp_login', array( $this->login_notification, 'notification' ), 10, 2 );
157 }
158
159 if ( $this->disable_login->is_enabled() ) {
160 add_filter( 'shake_error_codes', array( $this->disable_login, 'shake_error_codes' ) );
161 add_filter( 'authenticate', array( $this->disable_login, 'authenticate' ), 99, 3 );
162 add_action( 'wp_login_failed', array( $this->disable_login, 'wp_login_failed' ), 10, 2 );
163 }
164
165 if ( $this->rename_login_page->is_enabled() ) {
166 if ( $this->htaccess->setting_tag_exists( $this->rename_login_page->get_feature_key() ) ) {
167 remove_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
168 add_action( 'plugins_loaded', array( $this->rename_login_page, 'wp_register_404' ), 10 );
169 add_filter( 'login_init', array( $this->rename_login_page, 'login_init' ), 10, 2 );
170 add_filter( 'site_url', array( $this->rename_login_page, 'site_url' ), 10, 4 );
171 add_filter( 'network_site_url', array( $this->rename_login_page, 'network_site_url' ), 10, 3 );
172 add_filter( 'register', array( $this->rename_login_page, 'register' ), 10, 1 );
173 add_filter( 'wp_redirect', array( $this->rename_login_page, 'wp_redirect' ), 10, 2 );
174 add_filter( 'auth_redirect_scheme', array( $this->rename_login_page, 'auth_redirect_scheme' ), 99, 1 );
175
176 } else {
177 add_action( 'admin_notices', array( $this->rename_login_page, 'admin_notices' ), 10, 0 );
178 $this->rename_login_page->deactivate();
179 }
180 } else {
181 if ( $this->htaccess->setting_tag_exists( $this->rename_login_page->get_feature_key() ) ) {
182 $this->rename_login_page->deactivate();
183 }
184 }
185
186 if ( $this->unify_messages->is_enabled() ) {
187 add_filter( 'login_errors', array( $this->unify_messages, 'login_errors' ), 10, 1 );
188 }
189
190 if ( $this->restrict_admin_page->is_enabled() ) {
191 if ( $this->htaccess->setting_tag_exists( $this->restrict_admin_page->get_feature_key() ) ) {
192 add_action( 'wp_login', array( $this->restrict_admin_page, 'update' ), 1, 2 );
193
194 } else {
195 add_action( 'admin_notices', array( $this->restrict_admin_page, 'admin_notices' ), 10, 0 );
196 $this->restrict_admin_page->deactivate();
197 }
198 } else {
199 if ( $this->htaccess->setting_tag_exists( $this->restrict_admin_page->get_feature_key() ) ) {
200 $this->restrict_admin_page->deactivate();
201 }
202 }
203
204 if ( $this->disable_xmlrpc->is_enabled() ) {
205 if ( $this->disable_xmlrpc->is_pingback_disabled() ) {
206 if ( $this->htaccess->setting_tag_exists( $this->disable_xmlrpc->get_feature_key() ) ) {
207 add_action( 'admin_notices', array( $this->disable_xmlrpc, 'admin_notices' ), 10, 0 );
208 $this->disable_xmlrpc->deactivate();
209 } else {
210 add_filter( 'xmlrpc_methods', array( $this->disable_xmlrpc, 'xmlrpc_methods' ) );
211 }
212 }
213
214 if ( $this->disable_xmlrpc->is_xmlrpc_disabled() ) {
215 if ( ! $this->htaccess->setting_tag_exists( $this->disable_xmlrpc->get_feature_key() ) ) {
216 add_action( 'admin_notices', array( $this->disable_xmlrpc, 'admin_notices' ), 10, 0 );
217 $this->disable_xmlrpc->deactivate();
218 }
219 }
220 } else {
221 if ( $this->htaccess->setting_tag_exists( $this->disable_xmlrpc->get_feature_key() ) ) {
222 $this->disable_xmlrpc->deactivate();
223 }
224 }
225
226 if ( $this->disable_author_query->is_enabled() ) {
227 add_action( 'pre_get_posts', array( $this->disable_author_query, 'pre_get_posts' ) );
228 }
229
230 // wp2shell(CVE-2026-63030)緩和パッチ: 未認証の /batch/v1 アクセスを常時拒否(設定なし・優�
231 �度1で類似機能より�
232 �に評価)
233 add_filter( 'rest_pre_dispatch', array( $this->protect_rest_batch, 'rest_pre_dispatch' ), 1, 3 );
234
235 if ( $this->disable_restapi->is_enabled() ) {
236 add_filter( 'rest_pre_dispatch', array( $this->disable_restapi, 'rest_pre_dispatch' ), 10, 3 );
237 }
238
239 if ( $this->update_notice->is_enabled() ) {
240 $this->update_notice->set_cron();
241 add_action( $this->update_notice->get_cron_key(), array( $this->update_notice, 'update_notice' ) );
242 }
243
244 if ( $this->captcha->is_enabled() && 'xmlrpc.php' !== basename( sanitize_text_field( $_SERVER['SCRIPT_NAME'] ) ) && ! is_admin() ) {
245 add_filter( 'shake_error_codes', array( $this->captcha, 'shake_error_codes' ) );
246
247 if ( $this->captcha->is_login_form_enabled() ) {
248 add_filter( 'login_form', array( $this->captcha, 'login_form' ) );
249 add_action( 'wp_authenticate_user', array( $this->captcha, 'wp_authenticate_user' ), 10, 2 );
250 }
251
252 if ( $this->captcha->is_comment_form_enabled() ) {
253 add_action( 'comment_form_logged_in_after', array( $this->captcha, 'comment_form_default_fields' ), 1 );
254 add_action( 'comment_form_after_fields', array( $this->captcha, 'comment_form_default_fields' ) );
255 add_filter( 'preprocess_comment', array( $this->captcha, 'preprocess_comment' ) );
256 add_action( 'wp_footer', array( $this->captcha, 'comment_captcha_reload_script' ) );
257 }
258
259 if ( $this->captcha->is_lost_password_form_enabled() ) {
260 add_filter( 'lostpassword_form', array( $this->captcha, 'lostpassword_form' ) );
261 add_filter( 'allow_password_reset', array( $this->captcha, 'allow_password_reset' ), 10, 2 );
262 }
263
264 if ( $this->captcha->is_register_form_enabled() ) {
265 add_action( 'register_form', array( $this->captcha, 'register_form' ) );
266 add_action( 'register_post', array( $this->captcha, 'register_post' ), 10, 3 );
267 }
268 }
269
270 if ( $this->two_factor_authentication->is_enabled() ) {
271 // 2段階認証のAJAXハンドラー
272 add_action( 'wp_ajax_cloudsecurewp_generate_key', array( $this->two_factor_authentication, 'ajax_generate_key' ) );
273 add_action( 'wp_ajax_cloudsecurewp_generate_key_and_send_email', array( $this->two_factor_authentication, 'ajax_generate_key_and_send_email' ) );
274 add_action( 'wp_ajax_cloudsecurewp_verify_auth_code', array( $this->two_factor_authentication, 'ajax_verify_auth_code' ) );
275 add_action( 'wp_ajax_cloudsecurewp_generate_recovery_codes', array( $this->two_factor_authentication, 'ajax_generate_recovery_codes' ) );
276 }
277
278 if ( $this->two_factor_authentication->is_enabled() && 'xmlrpc.php' !== basename( sanitize_text_field( $_SERVER['SCRIPT_NAME'] ) ) && ! is_admin() ) {
279 // エラーメッセージ表示
280 add_filter( 'wp_login_errors', array( $this->two_factor_authentication, 'filter_login_errors' ), 10, 2 );
281 // id・passの認証
282 add_filter( 'authenticate', array( $this->two_factor_authentication, 'two_factor_disable_login_check' ), 100, 3 );
283 add_filter( 'authenticate', array( $this->two_factor_authentication, 'block_auth_cookies_for_2fa_user' ), PHP_INT_MAX, 3 );
284 add_action( 'set_auth_cookie', array( $this->two_factor_authentication, 'collect_auth_cookie_tokens' ), 10, 1 );
285 add_action( 'set_logged_in_cookie', array( $this->two_factor_authentication, 'collect_auth_cookie_tokens' ), 10, 1 );
286 add_action( 'wp_login', array( $this->two_factor_authentication, 'maybe_show_two_factor_login' ), 0, 2 );
287 // 2FAコードの認証
288 add_action( 'login_form_cloudsecurewp_validate_2fa', array( $this->two_factor_authentication, 'validate_two_factor_login' ) );
289 add_action( 'wp_login', array( $this->two_factor_authentication, 'redirect_if_not_two_factor_authentication_registered' ), 10, 2 );
290 }
291
292 if ( $this->two_factor_authentication->is_enabled() && $this->two_factor_authentication->is_xmlrpc_login_denied() && 'xmlrpc.php' === basename( sanitize_text_field( $_SERVER['SCRIPT_NAME'] ) ) ) {
293 add_filter( 'authenticate', array( $this->two_factor_authentication, 'deny_xmlrpc_authentication' ), 50, 3 );
294 }
295
296 if ( $this->two_factor_authentication->is_enabled() && is_admin() && current_user_can( 'administrator' ) ) {
297 add_filter( 'manage_users_columns', array( $this->two_factor_authentication, 'add_2factor_state_2user_list' ) );
298 add_action( 'manage_users_custom_column', array( $this->two_factor_authentication, 'show_2factor_state_2user_list' ), 10, 3 );
299 }
300 }
301
302 if ( is_admin() ) {
303 if ( 'cloudsecurewp_rename_login_page' === sanitize_text_field( $_GET['page'] ?? '' ) ) {
304 ob_start();
305 }
306
307 $this->update();
308
309 add_action( 'admin_notices', array( $this->two_factor_authentication, 'admin_notice_148_xmlrpc' ), 1, 0 );
310 add_action( 'wp_ajax_cloudsecurewp_dismiss_notice_148', array( $this->two_factor_authentication, 'ajax_dismiss_notice_148' ) );
311
312 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
313 }
314 }
315
316 /**
317 * プラグイン有効化
318 */
319 public function activate(): void {
320 $this->config->rm();
321 $this->config->set( 'version', $this->info['version'] );
322 $this->config->save();
323
324 $this->login_notification->activate();
325 $this->disable_login->activate();
326 $this->rename_login_page->activate();
327 $this->unify_messages->activate();
328 $this->restrict_admin_page->activate();
329 $this->disable_xmlrpc->activate();
330 $this->disable_author_query->activate();
331 $this->disable_restapi->activate();
332 $this->update_notice->activate();
333 $this->captcha->activate();
334 $this->login_log->activate();
335 $this->two_factor_authentication->activate();
336 $this->server_error_notification->activate();
337 $this->waf->activate();
338 $this->disable_access_system_file->activate();
339 }
340
341 /**
342 * プラグイン無効化
343 */
344 public function deactivate(): void {
345 $this->config->load_option();
346 $this->login_notification->deactivate();
347 $this->disable_login->deactivate();
348 $this->rename_login_page->deactivate();
349 $this->unify_messages->deactivate();
350 $this->restrict_admin_page->deactivate();
351 $this->disable_xmlrpc->deactivate();
352 $this->disable_author_query->deactivate();
353 $this->disable_restapi->deactivate();
354 $this->update_notice->deactivate();
355 $this->captcha->deactivate();
356 $this->two_factor_authentication->deactivate();
357 $this->server_error_notification->deactivate();
358 $this->waf->deactivate();
359 $this->disable_access_system_file->deactivate();
360 }
361
362 /**
363 * admin menuを追加
364 */
365 public function admin_menu(): void {
366 require_once __DIR__ . '/admin/common.php';
367
368 wp_enqueue_style( 'cloudsecurewp', $this->info['plugin_url'] . 'assets/css/style.css', array(), $this->info['version'] );
369
370 $slug = 'cloudsecurewp';
371 add_menu_page( $this->info['plugin_name'], $this->info['plugin_name'], 'manage_options', $slug, array( $this, 'dashboard' ), $this->info['plugin_url'] . 'assets/images/plugin-icon.png?v=2' );
372 add_submenu_page( $slug, 'ダッシュボード', 'ダッシュボード', 'manage_options', $slug, array( $this, 'dashboard' ) );
373 add_submenu_page( $slug, 'ログイン無効化', 'ログイン無効化', 'manage_options', $slug . '_disable_login', array( $this, 'm_disable_login' ) );
374 add_submenu_page( $slug, 'ログインURL変更', 'ログインURL変更', 'manage_options', $slug . '_rename_login_page', array( $this, 'm_rename_login_page' ) );
375 add_submenu_page( $slug, 'ログインエラーメッセージ統一', 'ログインエラーメッセージ統一', 'manage_options', $slug . '_unify_messages', array( $this, 'm_unify_messages' ) );
376 add_submenu_page( $slug, '2段階認証', '2段階認証', 'manage_options', $slug . '_two_factor_authentication', array( $this, 'm_two_factor_authentication' ) );
377 add_submenu_page( $slug, '画像認証追加', '画像認証追加', 'manage_options', $slug . '_captcha', array( $this, 'm_captcha' ) );
378 add_submenu_page( $slug, 'ユーザー名漏えい防止', 'ユーザー名漏えい防止', 'manage_options', $slug . '_disable_author_query', array( $this, 'm_disable_author_query' ) );
379 add_submenu_page( $slug, 'XML-RPC無効化', 'XML-RPC無効化', 'manage_options', $slug . '_disable_xmlrpc', array( $this, 'm_disable_xmlrpc' ) );
380 add_submenu_page( $slug, 'REST API無効化', 'REST API無効化', 'manage_options', $slug . '_disable_restapi', array( $this, 'm_disable_restapi' ) );
381 add_submenu_page( $slug, '管理画面アクセス制限', '管理画面アクセス制限', 'manage_options', $slug . '_restrict_admin_page', array( $this, 'm_restrict_admin_page' ) );
382 add_submenu_page( $slug, '設定ファイルアクセス防止', '設定ファイルアクセス防止', 'manage_options', $slug . '_disable_access_system_file', array( $this, 'm_disable_access_system_file' ) );
383 add_submenu_page( $slug, 'シンプルWAF', 'シンプルWAF', 'manage_options', $slug . '_waf', array( $this, 'm_waf' ) );
384 add_submenu_page( $slug, 'ログイン通知', 'ログイン通知', 'manage_options', $slug . '_login_notification', array( $this, 'm_login_notification' ) );
385 add_submenu_page( $slug, 'アップデート通知', 'アップデート通知', 'manage_options', $slug . '_update_notification', array( $this, 'm_update_notice' ) );
386 add_submenu_page( $slug, 'サーバーエラー通知', 'サーバーエラー通知', 'manage_options', $slug . '_server_error_notification', array( $this, 'm_server_error_notification' ) );
387 add_submenu_page( $slug, 'ログイン履歴', 'ログイン履歴', 'manage_options', $slug . '_login_log', array( $this, 'm_login_log' ) );
388
389 if ( $this->two_factor_authentication->is_enabled_on_screen() ) {
390 add_menu_page( '2段階認証の設定', '2段階認証の設定', 'read', $slug . '_two_factor_authentication_registration', array( $this, 'm_two_factor_authentication_registration' ), 'dashicons-lock', 72 );
391 }
392 }
393
394 /**
395 * ダッシュボードページ
396 *
397 * @return void
398 */
399 public function dashboard(): void {
400 require_once 'admin/dashboard.php';
401
402 $datas = array(
403 $this->login_notification->get_feature_key() => $this->config->get( $this->login_notification->get_feature_key() ),
404 $this->disable_login->get_feature_key() => $this->config->get( $this->disable_login->get_feature_key() ),
405 $this->rename_login_page->get_feature_key() => $this->config->get( $this->rename_login_page->get_feature_key() ),
406 $this->unify_messages->get_feature_key() => $this->config->get( $this->unify_messages->get_feature_key() ),
407 $this->restrict_admin_page->get_feature_key() => $this->config->get( $this->restrict_admin_page->get_feature_key() ),
408 $this->disable_xmlrpc->get_feature_key() => $this->config->get( $this->disable_xmlrpc->get_feature_key() ),
409 $this->disable_author_query->get_feature_key() => $this->config->get( $this->disable_author_query->get_feature_key() ),
410 $this->disable_restapi->get_feature_key() => $this->config->get( $this->disable_restapi->get_feature_key() ),
411 $this->update_notice->get_feature_key() => $this->config->get( $this->update_notice->get_feature_key() ),
412 $this->server_error_notification->get_feature_key() => $this->config->get( $this->server_error_notification->get_feature_key() ),
413 $this->captcha->get_feature_key() => $this->config->get( $this->captcha->get_feature_key() ),
414 $this->two_factor_authentication->get_feature_key() => $this->config->get( $this->two_factor_authentication->get_feature_key() ),
415 $this->waf->get_feature_key() => $this->config->get( $this->waf->get_feature_key() ),
416 $this->disable_access_system_file->get_feature_key() => $this->config->get( $this->disable_access_system_file->get_feature_key() ),
417 );
418
419 new CloudSecureWP_Admin_Dashboard( $this->info, $datas );
420 }
421
422 /**
423 * ログイン通知ページ
424 *
425 * @return void
426 */
427 public function m_login_notification(): void {
428 require_once 'admin/login-notification.php';
429 new CloudSecureWP_Admin_Login_Notification( $this->info, $this->login_notification );
430 }
431
432 /**
433 * ログイン無効化ページ
434 *
435 * @return void
436 */
437 public function m_disable_login(): void {
438 require_once 'admin/disable-login.php';
439 new CloudSecureWP_Admin_Disable_Login( $this->info, $this->disable_login );
440 }
441
442 /**
443 * ログインURL変更
444 *
445 * @return void
446 */
447 public function m_rename_login_page(): void {
448 require_once 'admin/rename-login-page.php';
449 new CloudSecureWP_Admin_Rename_Login_Page( $this->info, $this->rename_login_page );
450 }
451
452 /**
453 * エラーメッセージ単一化機能
454 *
455 * @return void
456 */
457 public function m_unify_messages(): void {
458 require_once 'admin/unify-messages.php';
459 new CloudSecureWP_Admin_Unify_Messages( $this->info, $this->unify_messages );
460 }
461
462 /**
463 * 管理画面アクセス制限
464 *
465 * @return void
466 */
467 public function m_restrict_admin_page(): void {
468 require_once 'admin/restrict-admin-page.php';
469 new CloudSecureWP_Admin_Restrict_Admin_Page( $this->info, $this->restrict_admin_page );
470 }
471
472 /**
473 * XMLRPC無効化
474 *
475 * @return void
476 */
477 public function m_disable_xmlrpc(): void {
478 require_once 'admin/disable-xmlrpc.php';
479 new CloudSecureWP_Admin_Disable_XMLRPC( $this->info, $this->disable_xmlrpc );
480 }
481
482 /**
483 * ユーザー名漏えい防止
484 *
485 * @return void
486 */
487 public function m_disable_author_query(): void {
488 require_once 'admin/disable-author-query.php';
489 new CloudSecureWP_Admin_Disable_Author_Query( $this->info, $this->disable_author_query );
490 }
491
492 /**
493 * REST API無効化
494 *
495 * @return void
496 */
497 public function m_disable_restapi(): void {
498 require_once 'admin/disable-restapi.php';
499 new CloudSecureWP_Admin_Disable_RESTAPI( $this->info, $this->disable_restapi );
500 }
501
502 /**
503 * アップデート通知
504 *
505 * @return void
506 */
507 public function m_update_notice(): void {
508 require_once 'admin/update-notice.php';
509 new CloudSecureWP_Admin_Update_Notice( $this->info, $this->update_notice );
510 }
511
512 /**
513 * 画像認証追加
514 *
515 * @return void
516 */
517 public function m_captcha(): void {
518 require_once 'admin/captcha.php';
519 new CloudSecureWP_Admin_CAPTCHA( $this->info, $this->captcha );
520 }
521
522 /**
523 * ログイン履歴
524 *
525 * @return void
526 */
527 public function m_login_log(): void {
528 require_once 'admin/login-log.php';
529 require_once 'admin/login-log-table.php';
530 new CloudSecureWP_Admin_Login_Log( $this->info, $this->login_log );
531 }
532
533 /**
534 * 2段階認証
535 *
536 * @return void
537 */
538 public function m_two_factor_authentication(): void {
539 require_once 'admin/two-factor-authentication.php';
540 new CloudSecureWP_Admin_Two_Factor_Authentication( $this->info, $this->two_factor_authentication );
541 }
542
543 /**
544 * 2段階認証のデバイス登録
545 *
546 * @return void
547 */
548 public function m_two_factor_authentication_registration(): void {
549 require_once 'admin/two-factor-authentication-registration.php';
550 new CloudSecureWP_Admin_Two_Factor_Authentication_Registration( $this->info, $this->two_factor_authentication );
551 }
552
553 /**
554 * サーバーエラー通知
555 *
556 * @return void
557 */
558 public function m_server_error_notification(): void {
559 require_once 'admin/server-error-notification.php';
560 require_once 'admin/server-error-table.php';
561 new CloudSecureWP_Admin_Server_Error_Notification( $this->info, $this->server_error_notification );
562 }
563
564 /**
565 * シンプルWAF
566 *
567 * @return void
568 */
569 public function m_waf(): void {
570 require_once 'admin/waf.php';
571 require_once 'admin/waf-table.php';
572 new CloudSecureWP_Admin_Waf( $this->info, $this->waf );
573 }
574
575 /**
576 * 設定ファイルアクセス防止
577 *
578 * @return void
579 */
580 public function m_disable_access_system_file(): void {
581 require_once 'admin/disable-access-system-file.php';
582 new CloudSecureWP_Admin_Disable_Access_System_File( $this->info, $this->disable_access_system_file );
583 }
584
585 /**
586 * CLI用のgetterメソッド群
587 * 注意: これらのメソッドはWP-CLI環境でのみ使用されることを想定しています
588 */
589 private function validate_cli_access() {
590 // WP-CLI環境チェック
591 if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) {
592 wp_die( 'Unauthorized access: CLI only' );
593 }
594 }
595
596 public function get_config() {
597 $this->validate_cli_access();
598 return $this->config;
599 }
600
601 public function get_htaccess() {
602 $this->validate_cli_access();
603 return $this->htaccess;
604 }
605
606 public function get_login_notification() {
607 $this->validate_cli_access();
608 return $this->login_notification;
609 }
610
611 public function get_disable_login() {
612 $this->validate_cli_access();
613 return $this->disable_login;
614 }
615
616 public function get_rename_login_page() {
617 $this->validate_cli_access();
618 return $this->rename_login_page;
619 }
620
621 public function get_unify_messages() {
622 $this->validate_cli_access();
623 return $this->unify_messages;
624 }
625
626 public function get_restrict_admin_page() {
627 $this->validate_cli_access();
628 return $this->restrict_admin_page;
629 }
630
631 public function get_disable_xmlrpc() {
632 $this->validate_cli_access();
633 return $this->disable_xmlrpc;
634 }
635
636 public function get_disable_author_query() {
637 $this->validate_cli_access();
638 return $this->disable_author_query;
639 }
640
641 public function get_disable_restapi() {
642 $this->validate_cli_access();
643 return $this->disable_restapi;
644 }
645
646 public function get_update_notice() {
647 $this->validate_cli_access();
648 return $this->update_notice;
649 }
650
651 public function get_captcha() {
652 $this->validate_cli_access();
653 return $this->captcha;
654 }
655
656 public function get_login_log() {
657 $this->validate_cli_access();
658 return $this->login_log;
659 }
660
661 public function get_two_factor_authentication() {
662 $this->validate_cli_access();
663 return $this->two_factor_authentication;
664 }
665
666 public function get_server_error_notification() {
667 $this->validate_cli_access();
668 return $this->server_error_notification;
669 }
670
671 public function get_waf() {
672 $this->validate_cli_access();
673 return $this->waf;
674 }
675
676 public function get_disable_access_system_file() {
677 $this->validate_cli_access();
678 return $this->disable_access_system_file;
679 }
680
681 /**
682 * プラグイン更新時の処理
683 */
684 private function update(): void {
685 $old_version = $this->config->get( 'version' );
686 $now_version = $this->info['version'];
687
688 if ( empty( $old_version ) ) {
689 $old_version = '1.0.0';
690 }
691
692 if ( 0 <= version_compare( $old_version, $now_version ) ) {
693 return;
694 }
695
696 if ( version_compare( $old_version, '1.1.0' ) < 0 ) {
697 $this->two_factor_authentication->activate();
698 $this->server_error_notification->activate();
699 }
700
701 if ( version_compare( $old_version, '1.3.0' ) < 0 ) {
702 $this->waf->activate();
703 $this->disable_access_system_file->activate();
704 }
705
706 if ( version_compare( $old_version, '1.3.7' ) < 0 ) {
707 $this->waf->activate();
708 $this->server_error_notification->activate();
709 }
710
711 if ( version_compare( $old_version, '1.3.24' ) < 0 ) {
712 $this->htaccess->reorganize_plugin_settings_blocks();
713 }
714
715 if ( version_compare( $old_version, '1.4.0' ) < 0 ) {
716 $this->two_factor_authentication->setup_2fa_tables();
717 }
718
719 if ( version_compare( $old_version, '1.4.6' ) < 0 ) {
720 $this->two_factor_authentication->migrate_recovery_codes_to_json();
721 }
722
723 if ( version_compare( $old_version, '1.4.8' ) < 0 ) {
724 $this->two_factor_authentication->migrate_xmlrpc_login_default();
725 $this->two_factor_authentication->send_update_notice();
726 }
727
728 if ( version_compare( $old_version, '1.4.10' ) < 0 ) {
729 $this->two_factor_authentication->migrate_2fa_setup_secret_transient_keys();
730 $this->two_factor_authentication->migrate_2fa_user_data();
731 }
732
733 if ( version_compare( $old_version, '1.4.12' ) < 0 ) {
734 $this->waf->migrate_waf_backtrack_error_default();
735 }
736
737 $this->config->set( 'version', $now_version );
738 $this->config->save();
739 }
740 }
741