PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.0.1
Defender Security – Malware Scanner, Login Security & Firewall v3.0.1
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 / disable-xml-rpc.php

disable-xml-rpc.php in Defender Security – Malware Scanner, Login Security & Firewall 3.0.1, at src/component/security-tweaks/disable-xml-rpc.php

85 lines 1.8 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
7 /**
8 * Class Disable_XML_RPC
9 * @package WP_Defender\Component\Security_Tweaks
10 */
11 class Disable_XML_RPC extends Component {
12 public $slug = 'disable-xml-rpc';
13 public $resolved = false;
14
15 /**
16 * Check whether the issue has been resolved or not.
17 *
18 * @return bool
19 */
20 public function check() {
21 return $this->resolved;
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 *
27 * @return bool
28 */
29 public function process() {
30 return true;
31 }
32
33 /**
34 * This is for un-do stuff that has be done in @process.
35 *
36 * @return bool
37 */
38 public function revert() {
39 return true;
40 }
41
42 /**
43 * Shield up.
44 *
45 * @return void
46 */
47 public function shield_up() {
48 $this->resolved = true;
49
50 add_filter( 'xmlrpc_enabled', '__return_false' );
51 add_filter( 'xmlrpc_methods', [ $this, 'block_xmlrpc_attacks' ] );
52 }
53
54 /**
55 * Block XML-RFC attacks.
56 *
57 * @param array $methods
58 *
59 * @return array
60 */
61 public function block_xmlrpc_attacks( $methods ) {
62 unset( $methods['pingback.ping'] );
63 unset( $methods['pingback.extensions.getPingbacks'] );
64
65 return $methods;
66 }
67
68 /**
69 * Return a summary data of this tweak.
70 *
71 * @return array
72 */
73 public function to_array() {
74 return [
75 'slug' => $this->slug,
76 'title' => __( 'Disable XML-RPC', 'wpdef' ),
77 'errorReason' => __( 'XML-RPC is currently enabled.', 'wpdef' ),
78 'successReason' => __( 'XML-RPC is disabled, great job!', 'wpdef' ),
79 'misc' => [],
80 'bulk_description' => __( 'In the past, there were security concerns with XML-RPC so we recommend making sure this feature is fully disabled if you don’t need it active. We will disable XML-RPC for you.', 'wpdef' ),
81 'bulk_title' => 'XML-RPC'
82 ];
83 }
84 }
85