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