| @@ -3,14 +3,14 @@ | ||
| 3 | 3 | * Plugin Name: Patchstack Security |
| 4 | 4 | * Plugin URI: https://patchstack.com/?utm_medium=wp&utm_source=dashboard&utm_campaign=patchstack%20plugin |
| 5 | 5 | * Author URI: https://patchstack.com/?utm_medium=wp&utm_source=dashboard&utm_campaign=patchstack%20plugin |
| 6 | 6 | * Description: Patchstack identifies security vulnerabilities in WordPress plugins, themes, and core. |
| 7 | - * Version: 2.3.7 | |
| 7 | + * Version: 2.2.0 | |
| 8 | 8 | * Author: Patchstack |
| 9 | 9 | * License: GPLv3 |
| 10 | 10 | * Text Domain: patchstack |
| 11 | 11 | * Domain Path: /languages |
| 12 | - * Requires at least: 5.2 | |
| 12 | + * Requires at least: 4.4 | |
| 13 | 13 | * Requires PHP: 5.6 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | // Do not allow the file to be called directly. |
| @@ -58,9 +58,9 @@ | ||
| 58 | 58 | * The plugin version. |
| 59 | 59 | * |
| 60 | 60 | * @var string |
| 61 | 61 | */ |
| 62 | - const VERSION = '2.3.7'; | |
| 62 | + const VERSION = '2.2.0'; | |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * API URL of Patchstack to communicate with. |
| 66 | 66 | * |
| @@ -143,8 +143,9 @@ | ||
| 143 | 143 | protected $hide_login; |
| 144 | 144 | protected $listener; |
| 145 | 145 | protected $event_log; |
| 146 | 146 | protected $multisite; |
| 147 | + protected $notice; | |
| 147 | 148 | protected $admin_ajax; |
| 148 | 149 | protected $admin_general; |
| 149 | 150 | protected $admin_menu; |
| 150 | 151 | protected $admin_options; |
| @@ -173,10 +174,8 @@ | ||
| 173 | 174 | |
| 174 | 175 | // Define WP_CLI command. |
| 175 | 176 | if ( defined( 'WP_CLI' ) && WP_CLI && method_exists('\WP_CLI', 'add_command')) { |
| 176 | 177 | \WP_CLI::add_command( 'patchstack activate', [ $this, 'cli_activate' ] ); |
| 177 | - \WP_CLI::add_command( 'patchstack deactivate', [ $this, 'cli_deactivate' ] ); | |
| 178 | - \WP_CLI::add_command( 'patchstack status', [ $this, 'cli_status' ] ); | |
| 179 | 178 | } |
| 180 | 179 | } |
| 181 | 180 | |
| 182 | 181 | /** |
| @@ -197,12 +196,13 @@ | ||
| 197 | 196 | 'hacker_log' => 'P_Hacker_Log', |
| 198 | 197 | 'upload' => 'P_Upload', |
| 199 | 198 | 'rules' => 'P_Rules', |
| 200 | 199 | 'hide_login' => 'P_Hide_Login', |
| 200 | + 'listener' => 'P_Listener', | |
| 201 | 201 | 'event_log' => 'P_Event_Log', |
| 202 | 202 | 'activation' => 'P_Activation', |
| 203 | - 'listener' => 'P_Listener', | |
| 204 | 203 | 'multisite' => 'P_Multisite', |
| 204 | + 'notice' => 'P_Cookie_Notice', | |
| 205 | 205 | 'admin_ajax' => 'P_Admin_Ajax', |
| 206 | 206 | 'admin_general' => 'P_Admin_General', |
| 207 | 207 | 'admin_menu' => 'P_Admin_Menu', |
| 208 | 208 | ] as $var => $class ) { |
| @@ -229,39 +229,26 @@ | ||
| 229 | 229 | * Returns an error if the connection was not successful. |
| 230 | 230 | * |
| 231 | 231 | * ## OPTIONS |
| 232 | 232 | * |
| 233 | - * [<id>] | |
| 233 | + * <id> | |
| 234 | 234 | * : The API client id. |
| 235 | - * | |
| 236 | - * [<secret>] | |
| 235 | + * | |
| 236 | + * <secret> | |
| 237 | 237 | * : The API secret key. |
| 238 | 238 | * |
| 239 | - * <secret-id> | |
| 240 | - * : The API client id and secret key merged together, found in the App. E.g. 2b072e8b60402e30d481df351fc08183906254e0-123456 | |
| 241 | - * | |
| 242 | 239 | * ## EXAMPLES |
| 243 | 240 | * |
| 244 | 241 | * $ wp patchstack activate 123456 2b072e8b60402e30d481df351fc08183906254e0 |
| 245 | 242 | * Success: The Patchstack plugin has been successfully connected. |
| 246 | - * | |
| 247 | - * or | |
| 248 | - * | |
| 249 | - * $ wp patchstack activate 2b072e8b60402e30d481df351fc08183906254e0-123456 | |
| 250 | - * Success: The Patchstack plugin has been successfully connected. | |
| 251 | 243 | */ |
| 252 | 244 | public function cli_activate( $args ) { |
| 253 | - // Handle both ways to activate the plugin. | |
| 254 | - if ( count( $args ) === 1 && strpos( $args[0], '-' ) !== false ) { | |
| 255 | - list( $secret, $id ) = explode( '-', $args[0] ); | |
| 256 | - } else { | |
| 257 | - $id = isset( $args[0] ) ? trim( $args[0] ) : ''; | |
| 258 | - $secret = isset( $args[1] ) ? trim( $args[1] ) : ''; | |
| 259 | - } | |
| 245 | + $id = isset( $args[0] ) ? trim( $args[0] ) : ''; | |
| 246 | + $secret = isset( $args[1] ) ? trim( $args[1] ) : ''; | |
| 260 | 247 | |
| 261 | 248 | $result = $this->activation->alter_license( $id, $secret, 'activate' ); |
| 262 | 249 | if ( $result['result'] == 'error' ) { |
| 263 | - \WP_CLI::error( "The Patchstack plugin could not be connected. Make sure the id and secret key are valid and that api.patchstack.com is not blocked. Additional information:\n" . $result['body'] ); | |
| 250 | + \WP_CLI::error( 'The Patchstack plugin could not be connected. Make sure the id and secret key are valid and that api.patchstack.com is not blocked.' ); | |
| 264 | 251 | return; |
| 265 | 252 | } |
| 266 | 253 | |
| 267 | 254 | \WP_CLI::success( 'The Patchstack plugin has been successfully connected.' ); |
| @@ -267,42 +254,8 @@ | ||
| 267 | 254 | \WP_CLI::success( 'The Patchstack plugin has been successfully connected.' ); |
| 268 | 255 | } |
| 269 | 256 | |
| 270 | 257 | /** |
| 271 | - * Disconnects the Patchstack plugin from the API and removes the API key. | |
| 272 | - * | |
| 273 | - * ## EXAMPLES | |
| 274 | - * | |
| 275 | - * $ wp patchstack deactivate | |
| 276 | - * Success: The Patchstack plugin has been successfully disconnected. | |
| 277 | - */ | |
| 278 | - public function cli_deactivate() { | |
| 279 | - $this->activation->deactivate(); | |
| 280 | - $this->activation->alter_license( '', '', 'deactivate' ); | |
| 281 | - | |
| 282 | - \WP_CLI::success( 'The Patchstack plugin has been successfully disconnected.' ); | |
| 283 | - } | |
| 284 | - | |
| 285 | - /** | |
| 286 | - * Gets the current API connection status from the Patchstack plugin. | |
| 287 | - * | |
| 288 | - * ## EXAMPLES | |
| 289 | - * | |
| 290 | - * $ wp patchstack status | |
| 291 | - * Success: The Patchstack plugin is currently connected to the API. | |
| 292 | - * | |
| 293 | - * $ wp patchstack status | |
| 294 | - * Warning: The Patchstack plugin is not connected to the API. | |
| 295 | - */ | |
| 296 | - public function cli_status() { | |
| 297 | - if ( $this->api->is_connected() ) { | |
| 298 | - \WP_CLI::success( __( 'The Patchstack plugin is currently connected to the API.', 'patchstack' ) ); | |
| 299 | - } else { | |
| 300 | - \WP_CLI::warning( __( 'The Patchstack plugin is not connected to the API.', 'patchstack' ) ); | |
| 301 | - } | |
| 302 | - } | |
| 303 | - | |
| 304 | - /** | |
| 305 | 258 | * Deactivate the plugin. |
| 306 | 259 | * |
| 307 | 260 | * @return void |
| 308 | 261 | */ |
| @@ -311,23 +264,15 @@ | ||
| 311 | 264 | $this->activation->deactivate(); |
| 312 | 265 | } |
| 313 | 266 | |
| 314 | 267 | /** |
| 315 | - * Load translated strings for the plugin. | |
| 316 | - * | |
| 317 | - * @return void | |
| 318 | - */ | |
| 319 | - public function load_textdomain () { | |
| 320 | - load_plugin_textdomain( 'patchstack', false, dirname( $this->basename ) . '/languages/' ); | |
| 321 | - } | |
| 322 | - | |
| 323 | - /** | |
| 324 | 268 | * Boot Patchstack. |
| 325 | 269 | * |
| 326 | 270 | * @return void |
| 327 | 271 | */ |
| 328 | 272 | public function init() { |
| 329 | - add_action( 'init', [ $this, 'load_textdomain' ] ); | |
| 273 | + // Load translated strings for plugin. | |
| 274 | + load_plugin_textdomain( 'patchstack', false, dirname( $this->basename ) . '/languages/' ); | |
| 330 | 275 | |
| 331 | 276 | // Initialize plugin classes. |
| 332 | 277 | $this->plugin_classes(); |
| 333 | 278 | |
| @@ -395,35 +340,22 @@ | ||
| 395 | 340 | * @return void |
| 396 | 341 | */ |
| 397 | 342 | function patchstack_uninstall() { |
| 398 | 343 | // Delete most of the Patchstack options. |
| 399 | - global $wpdb; | |
| 400 | - $options = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE 'patchstack_%'" ); | |
| 344 | + $options = [ 'patchstack_eventlog_lastid', 'patchstack_api_token', 'patchstack_dashboardlock', 'patchstack_pluginedit', 'patchstack_move_logs', 'patchstack_userenum', 'patchstack_basicscanblock', 'patchstack_hidewpcontent', 'patchstack_hidewpversionk', 'patchstack_prevent_default_file_access', 'patchstack_basic_firewall', 'patchstack_known_blacklist', 'patchstack_block_debug_log_access', 'patchstack_block_fake_bots', 'patchstack_index_views', 'patchstack_proxy_comment_posting', 'patchstack_bad_query_strings', 'patchstack_advanced_character_string_filter', 'patchstack_advanced_blacklist_firewall', 'patchstack_forbid_rfi', 'patchstack_image_hotlinking', 'patchstack_add_security_headers', 'patchstack_firewall_log_lastid', 'patchstack_user_log_lastid', 'patchstack_captcha_public_key', 'patchstack_captcha_private_key', 'patchstack_scan_interval', 'patchstack_scan_day', 'patchstack_scan_time', 'patchstack_hackers_log', 'patchstack_users_log', 'patchstack_visitors_log', 'external_updates-webarx', 'patchstack_wp_stats', 'patchstack_captcha_login_form', 'patchstack_license_activated', 'patchstack_license_expiry', 'patchstack_software_data_hash', 'patchstack_mv_wp_login', 'patchstack_rename_wp_login', 'patchstack_googledrive_backup_is_running', 'patchstack_googledrive_upload_state', 'patchstack_googledrive_access_token', 'patchstack_googledrive_refresh_token', 'patchstack_cron_offset', 'patchstack_htaccess_rules_hash' ]; | |
| 345 | + foreach ( $options as $option ) { | |
| 346 | + delete_option( $option ); | |
| 401 | 347 | |
| 402 | - // Few options we want to keep. | |
| 403 | - $keep = ['patchstack_hits_last_30', 'patchstack_hits_all_time', 'patchstack_clientid', 'patchstack_secretkey', 'patchstack_secretkey_nonce', 'patchstack_api_token']; | |
| 404 | - | |
| 405 | - // Delete everything else. | |
| 406 | - foreach( $options as $option ) { | |
| 407 | - if ( in_array( $option->option_name, $keep ) || stripos( $option->option_name, 'patchstack_captcha_' ) !== false ) { | |
| 408 | - continue; | |
| 409 | - } | |
| 410 | - | |
| 411 | - delete_option( $option->option_name ); | |
| 412 | - | |
| 413 | 348 | if ( is_multisite() ) { |
| 414 | - delete_site_option( $option->option_name ); | |
| 349 | + delete_site_option( $option ); | |
| 415 | 350 | } |
| 416 | 351 | } |
| 417 | 352 | |
| 418 | - // Drop all tables. | |
| 353 | + // Drop all Patchstack tables. | |
| 419 | 354 | global $wpdb; |
| 420 | - $prefixes = ['patchstack_', 'webarx_']; | |
| 421 | - foreach ( $prefixes as $prefix ) { | |
| 422 | - $tables = [ 'user_log', 'visitor_log', 'firewall_log', 'file_hashes', 'logic', 'ip', 'event_log' ]; | |
| 423 | - foreach ( $tables as $table ) { | |
| 424 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . $prefix . $table ); | |
| 425 | - } | |
| 355 | + $tables = [ 'patchstack_user_log', 'patchstack_visitor_log', 'patchstack_firewall_log', 'patchstack_file_hashes', 'patchstack_logic', 'patchstack_ip', 'patchstack_event_log' ]; | |
| 356 | + foreach ( $tables as $table ) { | |
| 357 | + $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . $table ); | |
| 426 | 358 | } |
| 427 | 359 | } |
| 428 | 360 | } |
| 429 | 361 | |
| @@ -437,13 +369,11 @@ | ||
| 437 | 369 | return patchstack::get_instance(); |
| 438 | 370 | } |
| 439 | 371 | } |
| 440 | 372 | |
| 441 | -if ( ! has_action( 'plugins_loaded', [ patchstack(), 'init' ] ) ) { | |
| 442 | - // Kick it off. | |
| 443 | - add_action( 'plugins_loaded', [ patchstack(), 'init' ] ); | |
| 373 | +// Kick it off. | |
| 374 | +add_action( 'plugins_loaded', [ patchstack(), 'init' ] ); | |
| 444 | 375 | |
| 445 | - // Activation and deactivation hooks. | |
| 446 | - register_activation_hook( __FILE__, [ patchstack(), 'activate' ] ); | |
| 447 | - register_deactivation_hook( __FILE__, [ patchstack(), 'deactivate' ] ); | |
| 448 | - register_uninstall_hook( __FILE__, 'patchstack_uninstall' ); | |
| 449 | -} | |
| 376 | +// Activation and deactivation hooks. | |
| 377 | +register_activation_hook( __FILE__, [ patchstack(), 'activate' ] ); | |
| 378 | +register_deactivation_hook( __FILE__, [ patchstack(), 'deactivate' ] ); | |
| 379 | +register_uninstall_hook( __FILE__, 'patchstack_uninstall' ); | |