PluginProbe
WPVulnerability / 5.1.2
WPVulnerability v5.1.2
5.1.6 5.1.2 5.1.1 5.0.1 5.0.0 trunk 0.1 0.2 1.0 1.0.1 1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 All 57 releases
wpvulnerability / class-wpvulnerability-cli.php

class-wpvulnerability-cli.php in WPVulnerability 5.1.2, at class-wpvulnerability-cli.php

745 lines 24.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WP-CLI commands for WPVulnerability.
4 *
5 * Provides WP-CLI commands to inspect WordPress core, plugins,
6 * and themes for known vulnerabilities.
7 *
8 * @package WPVulnerability
9 * @return void
10 */
11
12 defined( 'ABSPATH' ) || exit;
13
14 if ( defined( 'WP_CLI' ) ) {
15 /**
16 * Basic WPVulnerability commands.
17 *
18 * @return void
19 */
20 class WPVulnerability_CLI extends WP_CLI_Command {
21 /**
22 * Abort with an error if the current WordPress user lacks admin capabilities.
23 *
24 * Enforces the same access control as the REST API endpoints (manage_options /
25 * manage_network_options). Commands must be run with --user=<admin_login> when
26 * no privileged WordPress user is loaded in the current WP-CLI session.
27 *
28 * @since 5.0.0
29 * @return void
30 */
31 private function require_admin() {
32 $capability = is_multisite() ? 'manage_network_options' : 'manage_options';
33 if ( ! current_user_can( $capability ) ) {
34 \WP_CLI::error(
35 __( 'This command requires a WordPress administrator. Run with --user=<admin_login>.', 'wpvulnerability' )
36 );
37 }
38 }
39
40 /**
41 * Cast a mixed value to string safely.
42 *
43 * @param mixed $value The value to cast.
44 * @return string
45 */
46 private function to_string( $value ): string {
47 return is_scalar( $value ) ? (string) $value : '';
48 }
49
50 /**
51 * Cast a mixed value to int safely.
52 *
53 * @param mixed $value The value to cast.
54 * @return int
55 */
56 private function to_int( $value ): int {
57 return is_scalar( $value ) ? (int) $value : 0;
58 }
59
60 /**
61 * Cast a mixed value to float safely.
62 *
63 * @param mixed $value The value to cast.
64 * @return float
65 */
66 private function to_float( $value ): float {
67 return is_scalar( $value ) ? (float) $value : 0.0;
68 }
69
70 /**
71 * Display core vulnerabilities.
72 *
73 * ## OPTIONS
74 *
75 * [--format=<format>]
76 * : Render output in a specific format. Accepted values: table, json. Default: table.
77 *
78 * ## EXAMPLES
79 *
80 * wp wpvulnerability core
81 * wp wpvulnerability core --format=json
82 *
83 * @when after_wp_load
84 *
85 * @param array<int, string> $args Positional arguments.
86 * @param array<string, mixed> $assoc_args Associative arguments.
87 * @return void
88 */
89 public function core( $args, $assoc_args ) {
90 $this->require_admin();
91
92 $format = isset( $assoc_args['format'] ) ? $assoc_args['format'] : 'table';
93
94 $core_vulnerabilities = array();
95 if ( function_exists( 'wpvulnerability_analyze_filter' ) && wpvulnerability_analyze_filter( 'core' ) ) {
96 $core_vulnerabilities = wpvulnerability_core_get_vulnerabilities();
97 }
98
99 $items = array();
100 foreach ( $core_vulnerabilities as $vulnerability ) {
101 if ( ! is_array( $vulnerability ) ) {
102 continue;
103 }
104 $vuln_impact = isset( $vulnerability['impact'] ) && is_array( $vulnerability['impact'] ) ? $vulnerability['impact'] : array();
105 $vuln_cvss = isset( $vuln_impact['cvss'] ) && is_array( $vuln_impact['cvss'] ) ? $vuln_impact['cvss'] : array();
106 $vuln_cwe = isset( $vuln_impact['cwe'] ) && is_array( $vuln_impact['cwe'] ) ? $vuln_impact['cwe'] : array();
107 $vuln_sources = isset( $vulnerability['source'] ) && is_array( $vulnerability['source'] ) ? $vulnerability['source'] : array();
108
109 $item = array();
110 $item['version'] = trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability['name'] ?? null ), 'strip' ) ) );
111 $item['severity'] = null;
112 if ( isset( $vuln_cvss['severity'] ) ) {
113 $item['severity'] = wpvulnerability_severity( $this->to_string( $vuln_cvss['severity'] ) );
114 }
115
116 $item['cwe'] = array();
117 if ( count( $vuln_cwe ) ) {
118 foreach ( $vuln_cwe as $vulnerability_cwe ) {
119 if ( ! is_array( $vulnerability_cwe ) ) {
120 continue;
121 }
122 $item['cwe'][] = array(
123 'name' => trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability_cwe['name'] ?? null ), 'strip' ) ) ),
124 'description' => trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability_cwe['description'] ?? null ), 'strip' ) ) ),
125 );
126 }
127 }
128
129 $item['score'] = null;
130 if ( isset( $vuln_cvss['score'] ) ) {
131 $item['score'] = number_format( $this->to_float( $vuln_cvss['score'] ), 1, '.', '' );
132 }
133
134 $item['source'] = array();
135 if ( count( $vuln_sources ) ) {
136 foreach ( $vuln_sources as $vulnerability_source ) {
137 if ( ! is_array( $vulnerability_source ) ) {
138 continue;
139 }
140 $item['source'][] = array(
141 'name' => trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability_source['name'] ?? null ), 'strip' ) ) ),
142 'link' => esc_url_raw( $this->to_string( $vulnerability_source['link'] ?? null ) ),
143 );
144 }
145 }
146
147 $items[] = $item;
148 }
149
150 if ( 'json' === $format ) {
151 echo wp_json_encode( $items );
152 return;
153 }
154
155 if ( empty( $items ) ) {
156 \WP_CLI::success( __( 'No core vulnerabilities found.', 'wpvulnerability' ) );
157 return;
158 }
159
160 $vulnerabilities = array();
161 foreach ( $items as $c_vuln ) {
162 $v_description_array = array();
163 foreach ( $c_vuln['cwe'] as $c_cwe ) {
164 $v_description_array[] = $c_cwe['name'];
165 }
166 $vulnerabilities[] = array(
167 'version' => $c_vuln['version'],
168 'score' => $c_vuln['score'],
169 'severity' => $c_vuln['severity'],
170 'description' => trim( implode( ' + ', $v_description_array ) ),
171 );
172 }
173
174 \WP_CLI\Utils\format_items( 'table', $vulnerabilities, array( 'version', 'score', 'severity', 'description' ) );
175 }
176
177 /**
178 * Display plugin vulnerabilities.
179 *
180 * ## OPTIONS
181 *
182 * [--format=<format>]
183 * : Render output in a specific format. Accepted values: table, json. Default: table.
184 *
185 * ## EXAMPLES
186 *
187 * wp wpvulnerability plugins
188 * wp wpvulnerability plugins --format=json
189 *
190 * @when after_wp_load
191 *
192 * @param array<int, string> $args Positional arguments.
193 * @param array<string, mixed> $assoc_args Associative arguments.
194 * @return void
195 */
196 public function plugins( $args, $assoc_args ) {
197 $this->require_admin();
198
199 $format = isset( $assoc_args['format'] ) ? $assoc_args['format'] : 'table';
200
201 $plugin_vulnerabilities = array();
202 if ( function_exists( 'wpvulnerability_analyze_filter' ) && wpvulnerability_analyze_filter( 'plugins' ) ) {
203 $plugin_vulnerabilities = wpvulnerability_plugin_get_vulnerabilities();
204 }
205
206 $items = array();
207 foreach ( $plugin_vulnerabilities as $plugin ) {
208 if ( ! is_array( $plugin ) ) {
209 continue;
210 }
211 $vulnerable_raw = $plugin['vulnerable'] ?? 0;
212 if ( 1 === ( is_scalar( $vulnerable_raw ) ? (int) $vulnerable_raw : 0 ) ) {
213 $plugin_temp = array();
214 $plugin_temp['name'] = trim( html_entity_decode( wp_kses( $this->to_string( $plugin['Name'] ?? null ), 'strip' ) ) );
215 $plugin_temp['slug'] = trim( html_entity_decode( wp_kses( $this->to_string( $plugin['slug'] ?? null ), 'strip' ) ) );
216 $plugin_vulns = isset( $plugin['vulnerabilities'] ) && is_array( $plugin['vulnerabilities'] ) ? $plugin['vulnerabilities'] : array();
217 foreach ( $plugin_vulns as $vulnerability ) {
218 if ( ! is_array( $vulnerability ) ) {
219 continue;
220 }
221 $vuln_impact = isset( $vulnerability['impact'] ) && is_array( $vulnerability['impact'] ) ? $vulnerability['impact'] : array();
222 $vuln_cvss = isset( $vuln_impact['cvss'] ) && is_array( $vuln_impact['cvss'] ) ? $vuln_impact['cvss'] : array();
223 $vuln_cwe = isset( $vuln_impact['cwe'] ) && is_array( $vuln_impact['cwe'] ) ? $vuln_impact['cwe'] : array();
224 $vuln_sources = isset( $vulnerability['source'] ) && is_array( $vulnerability['source'] ) ? $vulnerability['source'] : array();
225
226 $vul = array();
227 $vul['severity'] = null;
228 if ( isset( $vuln_cvss['severity'] ) ) {
229 $vul['severity'] = wpvulnerability_severity( $this->to_string( $vuln_cvss['severity'] ) );
230 }
231 $vul['version'] = trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability['versions'] ?? null ), 'strip' ) ) );
232 $vul['name'] = trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability['name'] ?? null ), 'strip' ) ) );
233 $vul['closed'] = $this->to_int( $vulnerability['closed'] ?? null );
234 $vul['unfixed'] = $this->to_int( $vulnerability['unfixed'] ?? null );
235
236 $vul['cwe'] = array();
237 foreach ( $vuln_cwe as $cwe ) {
238 if ( ! is_array( $cwe ) ) {
239 continue;
240 }
241 $vul['cwe'][] = array(
242 'name' => trim( html_entity_decode( wp_kses( $this->to_string( $cwe['name'] ?? null ), 'strip' ) ) ),
243 'description' => trim( html_entity_decode( wp_kses( $this->to_string( $cwe['description'] ?? null ), 'strip' ) ) ),
244 );
245 }
246
247 $vul['score'] = null;
248 if ( isset( $vuln_cvss['score'] ) ) {
249 $vul['score'] = number_format( $this->to_float( $vuln_cvss['score'] ), 1, '.', '' );
250 }
251
252 $vul['source'] = array();
253 foreach ( $vuln_sources as $source ) {
254 if ( ! is_array( $source ) ) {
255 continue;
256 }
257 $vul['source'][] = array(
258 'name' => trim( html_entity_decode( wp_kses( $this->to_string( $source['name'] ?? null ), 'strip' ) ) ),
259 'link' => esc_url_raw( $this->to_string( $source['link'] ?? null ) ),
260 );
261 }
262
263 $plugin_temp['vulnerabilities'][] = $vul;
264 }
265 $items[] = $plugin_temp;
266 }
267 }
268
269 if ( 'json' === $format ) {
270 echo wp_json_encode( $items );
271 return;
272 }
273
274 if ( empty( $items ) ) {
275 \WP_CLI::success( __( 'No plugin vulnerabilities found.', 'wpvulnerability' ) );
276 return;
277 }
278
279 $vulnerabilities = array();
280 foreach ( $items as $p_vuln ) {
281 $v_name = $p_vuln['slug'];
282 foreach ( ( $p_vuln['vulnerabilities'] ?? array() ) as $p_vul ) {
283 $v_fixed = $p_vul['unfixed'] ? 'no' : 'yes';
284 $v_closed = $p_vul['closed'] ? 'yes' : 'no';
285 $v_description_array = array();
286 foreach ( $p_vul['cwe'] as $p_cwe ) {
287 $v_description_array[] = $p_cwe['name'];
288 }
289 $vulnerabilities[] = array(
290 'name' => $v_name,
291 'version' => $p_vul['version'],
292 'fixed' => $v_fixed,
293 'closed' => $v_closed,
294 'score' => $p_vul['score'],
295 'severity' => $p_vul['severity'],
296 'description' => trim( implode( ' + ', $v_description_array ) ),
297 );
298 }
299 }
300
301 \WP_CLI\Utils\format_items( 'table', $vulnerabilities, array( 'name', 'version', 'fixed', 'closed', 'score', 'severity', 'description' ) );
302 }
303
304 /**
305 * Display theme vulnerabilities.
306 *
307 * ## OPTIONS
308 *
309 * [--format=<format>]
310 * : Render output in a specific format. Accepted values: table, json. Default: table.
311 *
312 * ## EXAMPLES
313 *
314 * wp wpvulnerability themes
315 * wp wpvulnerability themes --format=json
316 *
317 * @when after_wp_load
318 *
319 * @param array<int, string> $args Positional arguments.
320 * @param array<string, mixed> $assoc_args Associative arguments.
321 * @return void
322 */
323 public function themes( $args, $assoc_args ) {
324 $this->require_admin();
325
326 $format = isset( $assoc_args['format'] ) ? $assoc_args['format'] : 'table';
327
328 $theme_vulnerabilities = array();
329 if ( function_exists( 'wpvulnerability_analyze_filter' ) && wpvulnerability_analyze_filter( 'themes' ) ) {
330 $theme_vulnerabilities = wpvulnerability_theme_get_vulnerabilities();
331 }
332
333 $items = array();
334 foreach ( $theme_vulnerabilities as $theme ) {
335 if ( ! is_array( $theme ) ) {
336 continue; }
337 $theme_wpv = isset( $theme['wpvulnerability'] ) && is_array( $theme['wpvulnerability'] ) ? $theme['wpvulnerability'] : array();
338 $theme_vulns = isset( $theme_wpv['vulnerabilities'] ) && is_array( $theme_wpv['vulnerabilities'] ) ? $theme_wpv['vulnerabilities'] : array();
339 if ( ! empty( $theme_vulns ) ) {
340 $theme_temp = array();
341 $theme_temp['name'] = trim( html_entity_decode( wp_kses( $this->to_string( $theme_wpv['name'] ?? null ), 'strip' ) ) );
342 $theme_temp['slug'] = trim( html_entity_decode( wp_kses( $this->to_string( $theme_wpv['slug'] ?? null ), 'strip' ) ) );
343
344 foreach ( $theme_vulns as $vulnerability ) {
345 if ( ! is_array( $vulnerability ) ) {
346 continue; }
347 $vuln_impact = isset( $vulnerability['impact'] ) && is_array( $vulnerability['impact'] ) ? $vulnerability['impact'] : array();
348 $vuln_cvss = isset( $vuln_impact['cvss'] ) && is_array( $vuln_impact['cvss'] ) ? $vuln_impact['cvss'] : array();
349 $vuln_cwe = isset( $vuln_impact['cwe'] ) && is_array( $vuln_impact['cwe'] ) ? $vuln_impact['cwe'] : array();
350 $vuln_sources = isset( $vulnerability['source'] ) && is_array( $vulnerability['source'] ) ? $vulnerability['source'] : array();
351
352 $vul = array();
353 $vul['severity'] = isset( $vuln_cvss['severity'] ) ? wpvulnerability_severity( $this->to_string( $vuln_cvss['severity'] ) ) : null;
354 $vul['version'] = trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability['versions'] ?? null ), 'strip' ) ) );
355 $vul['name'] = trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability['name'] ?? null ), 'strip' ) ) );
356 $vul['closed'] = is_numeric( $vulnerability['closed'] ?? 0 ) ? $this->to_int( $vulnerability['closed'] ?? null ) : 0;
357 $vul['unfixed'] = is_numeric( $vulnerability['unfixed'] ?? 0 ) ? $this->to_int( $vulnerability['unfixed'] ?? null ) : 0;
358
359 $vul['cwe'] = array();
360 foreach ( $vuln_cwe as $cwe ) {
361 if ( ! is_array( $cwe ) ) {
362 continue; }
363 $vul['cwe'][] = array(
364 'name' => trim( html_entity_decode( wp_kses( $this->to_string( $cwe['name'] ?? null ), 'strip' ) ) ),
365 'description' => trim( html_entity_decode( wp_kses( $this->to_string( $cwe['description'] ?? null ), 'strip' ) ) ),
366 );
367 }
368
369 $vul['score'] = isset( $vuln_cvss['score'] ) ? number_format( $this->to_float( $vuln_cvss['score'] ), 1, '.', '' ) : null;
370
371 $vul['source'] = array();
372 foreach ( $vuln_sources as $source ) {
373 if ( ! is_array( $source ) ) {
374 continue; }
375 $vul['source'][] = array(
376 'name' => trim( html_entity_decode( wp_kses( $this->to_string( $source['name'] ?? null ), 'strip' ) ) ),
377 'link' => esc_url_raw( $this->to_string( $source['link'] ?? null ) ),
378 );
379 }
380
381 $theme_temp['vulnerabilities'][] = $vul;
382 }
383 $items[] = $theme_temp;
384 }
385 }
386
387 if ( 'json' === $format ) {
388 echo wp_json_encode( $items );
389 return;
390 }
391
392 if ( empty( $items ) ) {
393 \WP_CLI::success( __( 'No theme vulnerabilities found.', 'wpvulnerability' ) );
394 return;
395 }
396
397 $vulnerabilities = array();
398 foreach ( $items as $t_vuln ) {
399 $v_name = $t_vuln['slug'];
400 foreach ( ( $t_vuln['vulnerabilities'] ?? array() ) as $t_vul ) {
401 $v_fixed = $t_vul['unfixed'] ? 'no' : 'yes';
402 $v_closed = $t_vul['closed'] ? 'yes' : 'no';
403 $v_description_array = array();
404 foreach ( $t_vul['cwe'] as $t_cwe ) {
405 $v_description_array[] = $t_cwe['name'];
406 }
407 $vulnerabilities[] = array(
408 'name' => $v_name,
409 'version' => $t_vul['version'],
410 'fixed' => $v_fixed,
411 'closed' => $v_closed,
412 'score' => $t_vul['score'],
413 'severity' => $t_vul['severity'],
414 'description' => trim( implode( ' + ', $v_description_array ) ),
415 );
416 }
417 }
418
419 \WP_CLI\Utils\format_items( 'table', $vulnerabilities, array( 'name', 'version', 'fixed', 'closed', 'score', 'severity', 'description' ) );
420 }
421
422 /**
423 * Display vulnerabilities for a piece of server software.
424 *
425 * @param string $software Software slug.
426 * @param array<int, string> $args Positional arguments.
427 * @param array<string, mixed> $assoc_args Associative arguments.
428 * @return void
429 */
430 private function software( $software, $args, $assoc_args ) {
431 $this->require_admin();
432
433 $format = isset( $assoc_args['format'] ) ? $assoc_args['format'] : 'table';
434
435 $software_vulnerabilities = array();
436 switch ( $software ) {
437 case 'php':
438 case 'apache':
439 case 'nginx':
440 case 'mariadb':
441 case 'mysql':
442 case 'imagemagick':
443 case 'curl':
444 case 'memcached':
445 case 'redis':
446 case 'sqlite':
447 $software_data = wpvulnerability_software_get_vulnerabilities( $software );
448 if ( is_array( $software_data ) && isset( $software_data['vulnerabilities'] ) && is_array( $software_data['vulnerabilities'] ) ) {
449 $software_vulnerabilities = $software_data['vulnerabilities'];
450 }
451 break;
452 default:
453 $software_vulnerabilities = array();
454 }
455
456 $items = array();
457 foreach ( $software_vulnerabilities as $item ) {
458 if ( ! is_array( $item ) ) {
459 continue;
460 }
461 $item_sources = isset( $item['source'] ) && is_array( $item['source'] ) ? $item['source'] : array();
462
463 $complete_temp = array();
464 $complete_temp['version'] = trim( html_entity_decode( wp_kses( $this->to_string( $item['version'] ?? null ), 'strip' ) ) );
465 $complete_temp['affected'] = trim( html_entity_decode( wp_kses( $this->to_string( $item['versions'] ?? null ), 'strip' ) ) );
466 $complete_temp['unfixed'] = $this->to_int( $item['unfixed'] ?? null );
467 $complete_temp['source'] = array();
468 if ( count( $item_sources ) ) {
469 foreach ( $item_sources as $source ) {
470 if ( ! is_array( $source ) ) {
471 continue;
472 }
473 $complete_temp['source'][] = array(
474 'name' => trim( html_entity_decode( wp_kses( $this->to_string( $source['id'] ?? null ), 'strip' ) ) ),
475 'description' => trim( html_entity_decode( wp_kses( $this->to_string( $source['description'] ?? null ), 'strip' ) ) ),
476 'link' => esc_url_raw( $this->to_string( $source['link'] ?? null ) ),
477 );
478 }
479 }
480 $items[] = $complete_temp;
481 }
482
483 if ( 'json' === $format ) {
484 echo wp_json_encode( $items );
485 return;
486 }
487
488 if ( empty( $items ) ) {
489 /* translators: %s is the software name (php, apache, nginx, etc.) */
490 \WP_CLI::success( sprintf( __( 'No %s vulnerabilities found.', 'wpvulnerability' ), $software ) );
491 return;
492 }
493
494 $vulnerabilities = array();
495 foreach ( $items as $vuln ) {
496 $v_fixed = $vuln['unfixed'] ? 'no' : 'yes';
497 $v_description = array();
498 foreach ( $vuln['source'] as $source ) {
499 $v_description[] = $source['name'] . ': ' . $source['description'];
500 }
501 $vulnerabilities[] = array(
502 'version' => $vuln['version'],
503 'affected' => $vuln['affected'],
504 'fixed' => $v_fixed,
505 'description' => trim( implode( ' + ', $v_description ) ),
506 );
507 }
508
509 \WP_CLI\Utils\format_items( 'table', $vulnerabilities, array( 'version', 'affected', 'fixed', 'description' ) );
510 }
511
512 /**
513 * Display PHP vulnerabilities.
514 *
515 * ## OPTIONS
516 *
517 * [--format=<format>]
518 * : Render output in a specific format. Accepted values: table, json. Default: table.
519 *
520 * ## EXAMPLES
521 *
522 * wp wpvulnerability php
523 * wp wpvulnerability php --format=json
524 *
525 * @when after_wp_load
526 *
527 * @param array<int, string> $args Positional arguments.
528 * @param array<string, mixed> $assoc_args Associative arguments.
529 * @return void
530 */
531 public function php( $args, $assoc_args ) {
532 $this->software( 'php', $args, $assoc_args );
533 }
534
535 /**
536 * Display Apache vulnerabilities.
537 *
538 * ## OPTIONS
539 *
540 * [--format=<format>]
541 * : Render output in a specific format. Accepted values: table, json. Default: table.
542 *
543 * ## EXAMPLES
544 *
545 * wp wpvulnerability apache
546 * wp wpvulnerability apache --format=json
547 *
548 * @when after_wp_load
549 *
550 * @param array<int, string> $args Positional arguments.
551 * @param array<string, mixed> $assoc_args Associative arguments.
552 * @return void
553 */
554 public function apache( $args, $assoc_args ) {
555 $this->software( 'apache', $args, $assoc_args );
556 }
557
558 /**
559 * Display Nginx vulnerabilities.
560 *
561 * ## OPTIONS
562 *
563 * [--format=<format>]
564 * : Render output in a specific format. Accepted values: table, json. Default: table.
565 *
566 * ## EXAMPLES
567 *
568 * wp wpvulnerability nginx
569 * wp wpvulnerability nginx --format=json
570 *
571 * @when after_wp_load
572 *
573 * @param array<int, string> $args Positional arguments.
574 * @param array<string, mixed> $assoc_args Associative arguments.
575 * @return void
576 */
577 public function nginx( $args, $assoc_args ) {
578 $this->software( 'nginx', $args, $assoc_args );
579 }
580
581 /**
582 * Display MariaDB vulnerabilities.
583 *
584 * ## OPTIONS
585 *
586 * [--format=<format>]
587 * : Render output in a specific format. Accepted values: table, json. Default: table.
588 *
589 * ## EXAMPLES
590 *
591 * wp wpvulnerability mariadb
592 * wp wpvulnerability mariadb --format=json
593 *
594 * @when after_wp_load
595 *
596 * @param array<int, string> $args Positional arguments.
597 * @param array<string, mixed> $assoc_args Associative arguments.
598 * @return void
599 */
600 public function mariadb( $args, $assoc_args ) {
601 $this->software( 'mariadb', $args, $assoc_args );
602 }
603
604 /**
605 * Display MySQL vulnerabilities.
606 *
607 * ## OPTIONS
608 *
609 * [--format=<format>]
610 * : Render output in a specific format. Accepted values: table, json. Default: table.
611 *
612 * ## EXAMPLES
613 *
614 * wp wpvulnerability mysql
615 * wp wpvulnerability mysql --format=json
616 *
617 * @when after_wp_load
618 *
619 * @param array<int, string> $args Positional arguments.
620 * @param array<string, mixed> $assoc_args Associative arguments.
621 * @return void
622 */
623 public function mysql( $args, $assoc_args ) {
624 $this->software( 'mysql', $args, $assoc_args );
625 }
626
627 /**
628 * Display ImageMagick vulnerabilities.
629 *
630 * ## OPTIONS
631 *
632 * [--format=<format>]
633 * : Render output in a specific format. Accepted values: table, json. Default: table.
634 *
635 * ## EXAMPLES
636 *
637 * wp wpvulnerability imagemagick
638 * wp wpvulnerability imagemagick --format=json
639 *
640 * @when after_wp_load
641 *
642 * @param array<int, string> $args Positional arguments.
643 * @param array<string, mixed> $assoc_args Associative arguments.
644 * @return void
645 */
646 public function imagemagick( $args, $assoc_args ) {
647 $this->software( 'imagemagick', $args, $assoc_args );
648 }
649
650 /**
651 * Display cURL vulnerabilities.
652 *
653 * ## OPTIONS
654 *
655 * [--format=<format>]
656 * : Render output in a specific format. Accepted values: table, json. Default: table.
657 *
658 * ## EXAMPLES
659 *
660 * wp wpvulnerability curl
661 * wp wpvulnerability curl --format=json
662 *
663 * @when after_wp_load
664 *
665 * @param array<int, string> $args Positional arguments.
666 * @param array<string, mixed> $assoc_args Associative arguments.
667 * @return void
668 */
669 public function curl( $args, $assoc_args ) {
670 $this->software( 'curl', $args, $assoc_args );
671 }
672
673 /**
674 * Display Memcached vulnerabilities.
675 *
676 * ## OPTIONS
677 *
678 * [--format=<format>]
679 * : Render output in a specific format. Accepted values: table, json. Default: table.
680 *
681 * ## EXAMPLES
682 *
683 * wp wpvulnerability memcached
684 * wp wpvulnerability memcached --format=json
685 *
686 * @when after_wp_load
687 *
688 * @param array<int, string> $args Positional arguments.
689 * @param array<string, mixed> $assoc_args Associative arguments.
690 * @return void
691 */
692 public function memcached( $args, $assoc_args ) {
693 $this->software( 'memcached', $args, $assoc_args );
694 }
695
696 /**
697 * Display Redis vulnerabilities.
698 *
699 * ## OPTIONS
700 *
701 * [--format=<format>]
702 * : Render output in a specific format. Accepted values: table, json. Default: table.
703 *
704 * ## EXAMPLES
705 *
706 * wp wpvulnerability redis
707 * wp wpvulnerability redis --format=json
708 *
709 * @when after_wp_load
710 *
711 * @param array<int, string> $args Positional arguments.
712 * @param array<string, mixed> $assoc_args Associative arguments.
713 * @return void
714 */
715 public function redis( $args, $assoc_args ) {
716 $this->software( 'redis', $args, $assoc_args );
717 }
718
719 /**
720 * Display SQLite vulnerabilities.
721 *
722 * ## OPTIONS
723 *
724 * [--format=<format>]
725 * : Render output in a specific format. Accepted values: table, json. Default: table.
726 *
727 * ## EXAMPLES
728 *
729 * wp wpvulnerability sqlite
730 * wp wpvulnerability sqlite --format=json
731 *
732 * @when after_wp_load
733 *
734 * @param array<int, string> $args Positional arguments.
735 * @param array<string, mixed> $assoc_args Associative arguments.
736 * @return void
737 */
738 public function sqlite( $args, $assoc_args ) {
739 $this->software( 'sqlite', $args, $assoc_args );
740 }
741 }
742
743 WP_CLI::add_command( 'wpvulnerability', 'WPVulnerability_CLI' );
744 }
745