@@ -79,6 +79,8 @@ class SecureCommand extends WP_CLI_Command {
79
79
* $ wp secure disable_directory_browsing
80
80
* Success: Directory Browsing security rule is now active.
81
81
*
82
+ * @subcommand disable-directory-browsing
83
+ *
82
84
* @when before_wp_load
83
85
*/
84
86
public function disable_directory_browsing ($ args , $ assoc_args ) : void {
@@ -121,15 +123,15 @@ public function disable_directory_browsing($args, $assoc_args) : void {
121
123
*
122
124
* @when before_wp_load
123
125
*
124
- * @subcommand block-php
126
+ * @subcommand block-php-execution
125
127
*/
126
128
public function block_php ($ args , $ assoc_args ) : void {
127
129
128
130
$ block_part = $ args [0 ];
129
131
130
132
// Failure first.
131
133
if ( ! in_array ( $ block_part ,
132
- array ( 'plugins ' , 'uploads ' , 'includes ' , 'themes ' , 'all ' ),
134
+ array ( 'plugins ' , 'uploads ' , 'wp- includes ' , 'themes ' , 'all ' ),
133
135
true )
134
136
) {
135
137
WP_CLI ::error ( sprintf ( 'Invalid block part "%s" was provided. Allowed values are "plugins", "uploads", "includes", "themes" or "all" ' ,
@@ -142,11 +144,11 @@ public function block_php($args, $assoc_args) : void {
142
144
}
143
145
if ( 'all ' === $ block_part || 'uploads ' === $ block_part ) {
144
146
WP_CLI ::debug ( 'Securing the uploads folder. ' , 'secure ' );
145
- ( new BlockPhpExecutionInWpIncludes ( $ assoc_args ) )->output ();
147
+ ( new BlockPhpExecutionInUploads ( $ assoc_args ) )->output ();
146
148
}
147
- if ( 'all ' === $ block_part || 'includes ' === $ block_part ) {
149
+ if ( 'all ' === $ block_part || 'wp- includes ' === $ block_part ) {
148
150
WP_CLI ::debug ( 'Securing the includes folder. ' , 'secure ' );
149
- ( new BlockPhpExecutionInUploads ( $ assoc_args ) )->output ();
151
+ ( new BlockPhpExecutionInWpIncludes ( $ assoc_args ) )->output ();
150
152
}
151
153
if ( 'all ' === $ block_part || 'themes ' === $ block_part ) {
152
154
WP_CLI ::debug ( 'Securing the themes folder. ' , 'secure ' );
@@ -155,14 +157,14 @@ public function block_php($args, $assoc_args) : void {
155
157
}
156
158
157
159
/**
158
- * Blocks direct access to sensitive files.
160
+ * Blocks direct access to various sensitive files and directories
159
161
*
160
162
* Blocks direct access to readme.html, readme.txt, wp-config.php and wp-admin/install.php files.
161
163
*
162
164
* ## OPTIONS
163
165
*
164
166
* <block-part>
165
- * : Required. accepts: files, directories, htaccess, xmlrpc or all.
167
+ * : This option is required. Accepts one of the following values: sensitive- files, sensitive- directories, htaccess, xmlrpc or all.
166
168
*
167
169
* [--remove]
168
170
* : Removes the rule from .htaccess or nginx.conf.
@@ -195,15 +197,15 @@ public function block_access($args, $assoc_args): void {
195
197
$ block_part = $ args [0 ];
196
198
197
199
// Failure first.
198
- if ( ! in_array ( $ block_part , array ( 'files ' , 'directories ' , 'htaccess ' , 'xmlrpc ' , 'all ' ), true ) ) {
200
+ if ( ! in_array ( $ block_part , array ( 'sensitive- files ' , 'sensitive- directories ' , 'htaccess ' , 'xmlrpc ' , 'all ' ), true ) ) {
199
201
WP_CLI ::error ( sprintf ( 'Invalid block part "%s" was provided. Allowed values are "files", "directories", "htaccess", "xmlrpc" or "all" ' , $ block_part ) );
200
202
}
201
203
202
- if ( 'all ' === $ block_part || 'files ' === $ block_part ) {
204
+ if ( 'all ' === $ block_part || 'sensitive- files ' === $ block_part ) {
203
205
WP_CLI ::debug ( 'Blocking access to the sensitive files. ' , 'secure ' );
204
206
(new BlockAccessToSensitiveFiles ($ assoc_args ))->output ();
205
207
}
206
- if ( 'all ' === $ block_part || 'directories ' === $ block_part ) {
208
+ if ( 'all ' === $ block_part || 'sensitive- directories ' === $ block_part ) {
207
209
WP_CLI ::debug ( 'Blocking access to the directories. ' , 'secure ' );
208
210
( new BlockAccessToSensitiveDirectories ( $ assoc_args ) )->output ();
209
211
}
@@ -217,15 +219,6 @@ public function block_access($args, $assoc_args): void {
217
219
}
218
220
}
219
221
220
- /**
221
- * Blocks direct access to sensitive directories.
222
- *
223
- * Blocks direct access to files in .git, svn and vendor directories
224
- */
225
- public function block_access_to_sensitive_directories ($ args , $ assoc_args ) : void {
226
-
227
- }
228
-
229
222
/**
230
223
* Blocks author scanning
231
224
*
@@ -252,6 +245,8 @@ public function block_access_to_sensitive_directories($args, $assoc_args) : void
252
245
* $ wp secure block_author_scanning
253
246
* Success: Block Author Scanning rule has been deployed.
254
247
*
248
+ * @subcommand block-author-scanning
249
+ *
255
250
* @when before_wp_load
256
251
*/
257
252
public function block_author_scanning ($ args , $ assoc_args ) : void {
@@ -297,30 +292,28 @@ public function flush($args, $assoc_args) : void {
297
292
*
298
293
* @return void
299
294
*
295
+ * @subcommand integrity-scan
300
296
* @when before_wp_load
301
297
*/
302
298
public function integrityscan ($ args , $ assoc_args ) : void {
303
299
WP_CLI ::runcommand ('core verify-checksums ' );
304
300
}
305
301
306
302
/**
307
- * Disable the file editor in Wordpress.
303
+ * Disable the file editor in WordPress
308
304
*
309
- * @return void
310
- */
311
- public function disable_file_editor () : void {
312
- WP_CLI ::runcommand ('config set DISALLOW_FILE_EDIT true ' );
313
- }
314
-
315
- /**
316
- * Enable the file editor in Wordpress.
305
+ * @subcommand disable-directory-browsing
317
306
*
307
+ * @param $args
308
+ * @param $assoc_args
309
+ *
310
+ * @when before_wp_load
318
311
* @return void
319
312
*/
320
- public function allow_file_editor ( ) : void {
321
- WP_CLI ::runcommand ('config set DISALLOW_FILE_EDIT false ' );
313
+ public function disable_file_editor ( $ args , $ assoc_args ) : void {
314
+ WP_CLI ::runcommand ('config set DISALLOW_FILE_EDIT ' . ! isset ( $ assoc_args [ ' remove ' ]) );
322
315
}
323
- }
316
+
324
317
/**
325
318
* Fix all directory and file permissions of the wordpress installation
326
319
*
@@ -332,10 +325,12 @@ public function allow_file_editor() : void {
332
325
* $ wp secure fix_permissions
333
326
* Success: All permission are reset to wordpress default.
334
327
*
328
+ * @subcommand fix-permissions
335
329
* @when before_wp_load
336
330
*/
337
331
public function fix_permissions ($ args , $ assoc_args ) : void {
338
332
(new FixFileAndDirPermissions ($ assoc_args ))->fixPermissions ();
333
+
339
334
WP_CLI ::success ("Permission successfully updated. " );
340
335
}
341
336
}
0 commit comments