PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.1.0
Defender Security – Malware Scanner, Login Security & Firewall v3.1.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / component / security-tweaks / protect-information.php

protect-information.php in Defender Security – Malware Scanner, Login Security & Firewall 3.1.0, at src/component/security-tweaks/protect-information.php

83 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WP_Defender\Component\Security_Tweaks;
4
5 use Calotes\Base\Component;
6 use WP_Defender\Component\Security_Tweaks\Servers\Server;
7
8 /**
9 * Class Protect_Information
10 * @package WP_Defender\Component\Security_Tweaks
11 */
12 class Protect_Information extends Component {
13 public $slug = 'protect-information';
14
15 /**
16 * Check whether the issue has been resolved or not.
17 *
18 * @return bool
19 */
20 public function check() {
21 return Server::create( Server::get_current_server() )->from( $this->slug )->check();
22 }
23
24 /**
25 * Here is the code for processing, if the return is true, we add it to resolve list, WP_Error if any error.
26 * @param string $current_server
27 *
28 * @return bool|\WP_Error
29 */
30 public function process( $current_server) {
31 if ( 'apache' === $current_server || 'litespeed' === $current_server ) {
32 // because the Prevent_PHP tweak uses the 'process' method too
33 return Server::create( $current_server )->from( $this->slug )->process( false );
34 } else {
35
36 return Server::create( $current_server )->from( $this->slug )->process();
37 }
38 }
39
40 /**
41 * This is for un-do stuff that has be done in @process.
42 * @param string|null $current_server
43 *
44 * @return bool|\WP_Error
45 */
46 public function revert( $current_server = null ) {
47 if ( is_null( $current_server ) ) {
48 $current_server = Server::get_current_server();
49 }
50 return Server::create( $current_server )->from( $this->slug )->revert();
51 }
52
53 /**
54 * Shield up.
55 *
56 * @return bool
57 */
58 public function shield_up() {
59 return true;
60 }
61
62 /**
63 * Return a summary data of this tweak.
64 *
65 * @return array
66 */
67 public function to_array() {
68 return [
69 'slug' => $this->slug,
70 'title' => __( 'Prevent Information Disclosure', 'wpdef' ),
71 'errorReason' => __( 'You don\'t have information disclosure protection active.', 'wpdef' ),
72 'successReason' => __( 'You\'ve automatically enabled information disclosure protection.', 'wpdef' ),
73 'misc' => [
74 'active_server' => Server::get_current_server(),
75 'apache_rules' => Server::create( 'apache' )->from( $this->slug )->get_rules_for_instruction(),
76 'nginx_rules' => Server::create( 'nginx' )->from( $this->slug )->get_rules(),
77 ],
78 'blk_description' => __( 'Often servers are incorrectly configured, and can allow an attacker to get access to sensitive files like your config, .htaccess and backup files. We will automatically add an .htaccess file to your root folder to action this fix.', 'wpdef' ),
79 'bulk_title' => __( 'Information Disclosure', 'wpdef' )
80 ];
81 }
82 }
83