744 lines
24 KiB
PHP
744 lines
24 KiB
PHP
<?php
|
|
/**
|
|
* WP-CLI commands for WPVulnerability.
|
|
*
|
|
* Provides WP-CLI commands to inspect WordPress core, plugins,
|
|
* and themes for known vulnerabilities.
|
|
*
|
|
* @package WPVulnerability
|
|
* @return void
|
|
*/
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
if ( defined( 'WP_CLI' ) ) {
|
|
/**
|
|
* Basic WPVulnerability commands.
|
|
*
|
|
* @return void
|
|
*/
|
|
class WPVulnerability_CLI extends WP_CLI_Command {
|
|
/**
|
|
* Abort with an error if the current WordPress user lacks admin capabilities.
|
|
*
|
|
* Enforces the same access control as the REST API endpoints (manage_options /
|
|
* manage_network_options). Commands must be run with --user=<admin_login> when
|
|
* no privileged WordPress user is loaded in the current WP-CLI session.
|
|
*
|
|
* @since 5.0.0
|
|
* @return void
|
|
*/
|
|
private function require_admin() {
|
|
$capability = is_multisite() ? 'manage_network_options' : 'manage_options';
|
|
if ( ! current_user_can( $capability ) ) {
|
|
\WP_CLI::error(
|
|
__( 'This command requires a WordPress administrator. Run with --user=<admin_login>.', 'wpvulnerability' )
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Cast a mixed value to string safely.
|
|
*
|
|
* @param mixed $value The value to cast.
|
|
* @return string
|
|
*/
|
|
private function to_string( $value ): string {
|
|
return is_scalar( $value ) ? (string) $value : '';
|
|
}
|
|
|
|
/**
|
|
* Cast a mixed value to int safely.
|
|
*
|
|
* @param mixed $value The value to cast.
|
|
* @return int
|
|
*/
|
|
private function to_int( $value ): int {
|
|
return is_scalar( $value ) ? (int) $value : 0;
|
|
}
|
|
|
|
/**
|
|
* Cast a mixed value to float safely.
|
|
*
|
|
* @param mixed $value The value to cast.
|
|
* @return float
|
|
*/
|
|
private function to_float( $value ): float {
|
|
return is_scalar( $value ) ? (float) $value : 0.0;
|
|
}
|
|
|
|
/**
|
|
* Display core vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability core
|
|
* wp wpvulnerability core --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function core( $args, $assoc_args ) {
|
|
$this->require_admin();
|
|
|
|
$format = isset( $assoc_args['format'] ) ? $assoc_args['format'] : 'table';
|
|
|
|
$core_vulnerabilities = array();
|
|
if ( function_exists( 'wpvulnerability_analyze_filter' ) && wpvulnerability_analyze_filter( 'core' ) ) {
|
|
$core_vulnerabilities = wpvulnerability_core_get_vulnerabilities();
|
|
}
|
|
|
|
$items = array();
|
|
foreach ( $core_vulnerabilities as $vulnerability ) {
|
|
if ( ! is_array( $vulnerability ) ) {
|
|
continue;
|
|
}
|
|
$vuln_impact = isset( $vulnerability['impact'] ) && is_array( $vulnerability['impact'] ) ? $vulnerability['impact'] : array();
|
|
$vuln_cvss = isset( $vuln_impact['cvss'] ) && is_array( $vuln_impact['cvss'] ) ? $vuln_impact['cvss'] : array();
|
|
$vuln_cwe = isset( $vuln_impact['cwe'] ) && is_array( $vuln_impact['cwe'] ) ? $vuln_impact['cwe'] : array();
|
|
$vuln_sources = isset( $vulnerability['source'] ) && is_array( $vulnerability['source'] ) ? $vulnerability['source'] : array();
|
|
|
|
$item = array();
|
|
$item['version'] = trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability['name'] ?? null ), 'strip' ) ) );
|
|
$item['severity'] = null;
|
|
if ( isset( $vuln_cvss['severity'] ) ) {
|
|
$item['severity'] = wpvulnerability_severity( $this->to_string( $vuln_cvss['severity'] ) );
|
|
}
|
|
|
|
$item['cwe'] = array();
|
|
if ( count( $vuln_cwe ) ) {
|
|
foreach ( $vuln_cwe as $vulnerability_cwe ) {
|
|
if ( ! is_array( $vulnerability_cwe ) ) {
|
|
continue;
|
|
}
|
|
$item['cwe'][] = array(
|
|
'name' => trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability_cwe['name'] ?? null ), 'strip' ) ) ),
|
|
'description' => trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability_cwe['description'] ?? null ), 'strip' ) ) ),
|
|
);
|
|
}
|
|
}
|
|
|
|
$item['score'] = null;
|
|
if ( isset( $vuln_cvss['score'] ) ) {
|
|
$item['score'] = number_format( $this->to_float( $vuln_cvss['score'] ), 1, '.', '' );
|
|
}
|
|
|
|
$item['source'] = array();
|
|
if ( count( $vuln_sources ) ) {
|
|
foreach ( $vuln_sources as $vulnerability_source ) {
|
|
if ( ! is_array( $vulnerability_source ) ) {
|
|
continue;
|
|
}
|
|
$item['source'][] = array(
|
|
'name' => trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability_source['name'] ?? null ), 'strip' ) ) ),
|
|
'link' => esc_url_raw( $this->to_string( $vulnerability_source['link'] ?? null ) ),
|
|
);
|
|
}
|
|
}
|
|
|
|
$items[] = $item;
|
|
}
|
|
|
|
if ( 'json' === $format ) {
|
|
echo wp_json_encode( $items );
|
|
return;
|
|
}
|
|
|
|
if ( empty( $items ) ) {
|
|
\WP_CLI::success( __( 'No core vulnerabilities found.', 'wpvulnerability' ) );
|
|
return;
|
|
}
|
|
|
|
$vulnerabilities = array();
|
|
foreach ( $items as $c_vuln ) {
|
|
$v_description_array = array();
|
|
foreach ( $c_vuln['cwe'] as $c_cwe ) {
|
|
$v_description_array[] = $c_cwe['name'];
|
|
}
|
|
$vulnerabilities[] = array(
|
|
'version' => $c_vuln['version'],
|
|
'score' => $c_vuln['score'],
|
|
'severity' => $c_vuln['severity'],
|
|
'description' => trim( implode( ' + ', $v_description_array ) ),
|
|
);
|
|
}
|
|
|
|
\WP_CLI\Utils\format_items( 'table', $vulnerabilities, array( 'version', 'score', 'severity', 'description' ) );
|
|
}
|
|
|
|
/**
|
|
* Display plugin vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability plugins
|
|
* wp wpvulnerability plugins --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function plugins( $args, $assoc_args ) {
|
|
$this->require_admin();
|
|
|
|
$format = isset( $assoc_args['format'] ) ? $assoc_args['format'] : 'table';
|
|
|
|
$plugin_vulnerabilities = array();
|
|
if ( function_exists( 'wpvulnerability_analyze_filter' ) && wpvulnerability_analyze_filter( 'plugins' ) ) {
|
|
$plugin_vulnerabilities = wpvulnerability_plugin_get_vulnerabilities();
|
|
}
|
|
|
|
$items = array();
|
|
foreach ( $plugin_vulnerabilities as $plugin ) {
|
|
if ( ! is_array( $plugin ) ) {
|
|
continue;
|
|
}
|
|
$vulnerable_raw = $plugin['vulnerable'] ?? 0;
|
|
if ( 1 === ( is_scalar( $vulnerable_raw ) ? (int) $vulnerable_raw : 0 ) ) {
|
|
$plugin_temp = array();
|
|
$plugin_temp['name'] = trim( html_entity_decode( wp_kses( $this->to_string( $plugin['Name'] ?? null ), 'strip' ) ) );
|
|
$plugin_temp['slug'] = trim( html_entity_decode( wp_kses( $this->to_string( $plugin['slug'] ?? null ), 'strip' ) ) );
|
|
$plugin_vulns = isset( $plugin['vulnerabilities'] ) && is_array( $plugin['vulnerabilities'] ) ? $plugin['vulnerabilities'] : array();
|
|
foreach ( $plugin_vulns as $vulnerability ) {
|
|
if ( ! is_array( $vulnerability ) ) {
|
|
continue;
|
|
}
|
|
$vuln_impact = isset( $vulnerability['impact'] ) && is_array( $vulnerability['impact'] ) ? $vulnerability['impact'] : array();
|
|
$vuln_cvss = isset( $vuln_impact['cvss'] ) && is_array( $vuln_impact['cvss'] ) ? $vuln_impact['cvss'] : array();
|
|
$vuln_cwe = isset( $vuln_impact['cwe'] ) && is_array( $vuln_impact['cwe'] ) ? $vuln_impact['cwe'] : array();
|
|
$vuln_sources = isset( $vulnerability['source'] ) && is_array( $vulnerability['source'] ) ? $vulnerability['source'] : array();
|
|
|
|
$vul = array();
|
|
$vul['severity'] = null;
|
|
if ( isset( $vuln_cvss['severity'] ) ) {
|
|
$vul['severity'] = wpvulnerability_severity( $this->to_string( $vuln_cvss['severity'] ) );
|
|
}
|
|
$vul['version'] = trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability['versions'] ?? null ), 'strip' ) ) );
|
|
$vul['name'] = trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability['name'] ?? null ), 'strip' ) ) );
|
|
$vul['closed'] = $this->to_int( $vulnerability['closed'] ?? null );
|
|
$vul['unfixed'] = $this->to_int( $vulnerability['unfixed'] ?? null );
|
|
|
|
$vul['cwe'] = array();
|
|
foreach ( $vuln_cwe as $cwe ) {
|
|
if ( ! is_array( $cwe ) ) {
|
|
continue;
|
|
}
|
|
$vul['cwe'][] = array(
|
|
'name' => trim( html_entity_decode( wp_kses( $this->to_string( $cwe['name'] ?? null ), 'strip' ) ) ),
|
|
'description' => trim( html_entity_decode( wp_kses( $this->to_string( $cwe['description'] ?? null ), 'strip' ) ) ),
|
|
);
|
|
}
|
|
|
|
$vul['score'] = null;
|
|
if ( isset( $vuln_cvss['score'] ) ) {
|
|
$vul['score'] = number_format( $this->to_float( $vuln_cvss['score'] ), 1, '.', '' );
|
|
}
|
|
|
|
$vul['source'] = array();
|
|
foreach ( $vuln_sources as $source ) {
|
|
if ( ! is_array( $source ) ) {
|
|
continue;
|
|
}
|
|
$vul['source'][] = array(
|
|
'name' => trim( html_entity_decode( wp_kses( $this->to_string( $source['name'] ?? null ), 'strip' ) ) ),
|
|
'link' => esc_url_raw( $this->to_string( $source['link'] ?? null ) ),
|
|
);
|
|
}
|
|
|
|
$plugin_temp['vulnerabilities'][] = $vul;
|
|
}
|
|
$items[] = $plugin_temp;
|
|
}
|
|
}
|
|
|
|
if ( 'json' === $format ) {
|
|
echo wp_json_encode( $items );
|
|
return;
|
|
}
|
|
|
|
if ( empty( $items ) ) {
|
|
\WP_CLI::success( __( 'No plugin vulnerabilities found.', 'wpvulnerability' ) );
|
|
return;
|
|
}
|
|
|
|
$vulnerabilities = array();
|
|
foreach ( $items as $p_vuln ) {
|
|
$v_name = $p_vuln['slug'];
|
|
foreach ( ( $p_vuln['vulnerabilities'] ?? array() ) as $p_vul ) {
|
|
$v_fixed = $p_vul['unfixed'] ? 'no' : 'yes';
|
|
$v_closed = $p_vul['closed'] ? 'yes' : 'no';
|
|
$v_description_array = array();
|
|
foreach ( $p_vul['cwe'] as $p_cwe ) {
|
|
$v_description_array[] = $p_cwe['name'];
|
|
}
|
|
$vulnerabilities[] = array(
|
|
'name' => $v_name,
|
|
'version' => $p_vul['version'],
|
|
'fixed' => $v_fixed,
|
|
'closed' => $v_closed,
|
|
'score' => $p_vul['score'],
|
|
'severity' => $p_vul['severity'],
|
|
'description' => trim( implode( ' + ', $v_description_array ) ),
|
|
);
|
|
}
|
|
}
|
|
|
|
\WP_CLI\Utils\format_items( 'table', $vulnerabilities, array( 'name', 'version', 'fixed', 'closed', 'score', 'severity', 'description' ) );
|
|
}
|
|
|
|
/**
|
|
* Display theme vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability themes
|
|
* wp wpvulnerability themes --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function themes( $args, $assoc_args ) {
|
|
$this->require_admin();
|
|
|
|
$format = isset( $assoc_args['format'] ) ? $assoc_args['format'] : 'table';
|
|
|
|
$theme_vulnerabilities = array();
|
|
if ( function_exists( 'wpvulnerability_analyze_filter' ) && wpvulnerability_analyze_filter( 'themes' ) ) {
|
|
$theme_vulnerabilities = wpvulnerability_theme_get_vulnerabilities();
|
|
}
|
|
|
|
$items = array();
|
|
foreach ( $theme_vulnerabilities as $theme ) {
|
|
if ( ! is_array( $theme ) ) {
|
|
continue; }
|
|
$theme_wpv = isset( $theme['wpvulnerability'] ) && is_array( $theme['wpvulnerability'] ) ? $theme['wpvulnerability'] : array();
|
|
$theme_vulns = isset( $theme_wpv['vulnerabilities'] ) && is_array( $theme_wpv['vulnerabilities'] ) ? $theme_wpv['vulnerabilities'] : array();
|
|
if ( ! empty( $theme_vulns ) ) {
|
|
$theme_temp = array();
|
|
$theme_temp['name'] = trim( html_entity_decode( wp_kses( $this->to_string( $theme_wpv['name'] ?? null ), 'strip' ) ) );
|
|
$theme_temp['slug'] = trim( html_entity_decode( wp_kses( $this->to_string( $theme_wpv['slug'] ?? null ), 'strip' ) ) );
|
|
|
|
foreach ( $theme_vulns as $vulnerability ) {
|
|
if ( ! is_array( $vulnerability ) ) {
|
|
continue; }
|
|
$vuln_impact = isset( $vulnerability['impact'] ) && is_array( $vulnerability['impact'] ) ? $vulnerability['impact'] : array();
|
|
$vuln_cvss = isset( $vuln_impact['cvss'] ) && is_array( $vuln_impact['cvss'] ) ? $vuln_impact['cvss'] : array();
|
|
$vuln_cwe = isset( $vuln_impact['cwe'] ) && is_array( $vuln_impact['cwe'] ) ? $vuln_impact['cwe'] : array();
|
|
$vuln_sources = isset( $vulnerability['source'] ) && is_array( $vulnerability['source'] ) ? $vulnerability['source'] : array();
|
|
|
|
$vul = array();
|
|
$vul['severity'] = isset( $vuln_cvss['severity'] ) ? wpvulnerability_severity( $this->to_string( $vuln_cvss['severity'] ) ) : null;
|
|
$vul['version'] = trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability['versions'] ?? null ), 'strip' ) ) );
|
|
$vul['name'] = trim( html_entity_decode( wp_kses( $this->to_string( $vulnerability['name'] ?? null ), 'strip' ) ) );
|
|
$vul['closed'] = is_numeric( $vulnerability['closed'] ?? 0 ) ? $this->to_int( $vulnerability['closed'] ?? null ) : 0;
|
|
$vul['unfixed'] = is_numeric( $vulnerability['unfixed'] ?? 0 ) ? $this->to_int( $vulnerability['unfixed'] ?? null ) : 0;
|
|
|
|
$vul['cwe'] = array();
|
|
foreach ( $vuln_cwe as $cwe ) {
|
|
if ( ! is_array( $cwe ) ) {
|
|
continue; }
|
|
$vul['cwe'][] = array(
|
|
'name' => trim( html_entity_decode( wp_kses( $this->to_string( $cwe['name'] ?? null ), 'strip' ) ) ),
|
|
'description' => trim( html_entity_decode( wp_kses( $this->to_string( $cwe['description'] ?? null ), 'strip' ) ) ),
|
|
);
|
|
}
|
|
|
|
$vul['score'] = isset( $vuln_cvss['score'] ) ? number_format( $this->to_float( $vuln_cvss['score'] ), 1, '.', '' ) : null;
|
|
|
|
$vul['source'] = array();
|
|
foreach ( $vuln_sources as $source ) {
|
|
if ( ! is_array( $source ) ) {
|
|
continue; }
|
|
$vul['source'][] = array(
|
|
'name' => trim( html_entity_decode( wp_kses( $this->to_string( $source['name'] ?? null ), 'strip' ) ) ),
|
|
'link' => esc_url_raw( $this->to_string( $source['link'] ?? null ) ),
|
|
);
|
|
}
|
|
|
|
$theme_temp['vulnerabilities'][] = $vul;
|
|
}
|
|
$items[] = $theme_temp;
|
|
}
|
|
}
|
|
|
|
if ( 'json' === $format ) {
|
|
echo wp_json_encode( $items );
|
|
return;
|
|
}
|
|
|
|
if ( empty( $items ) ) {
|
|
\WP_CLI::success( __( 'No theme vulnerabilities found.', 'wpvulnerability' ) );
|
|
return;
|
|
}
|
|
|
|
$vulnerabilities = array();
|
|
foreach ( $items as $t_vuln ) {
|
|
$v_name = $t_vuln['slug'];
|
|
foreach ( ( $t_vuln['vulnerabilities'] ?? array() ) as $t_vul ) {
|
|
$v_fixed = $t_vul['unfixed'] ? 'no' : 'yes';
|
|
$v_closed = $t_vul['closed'] ? 'yes' : 'no';
|
|
$v_description_array = array();
|
|
foreach ( $t_vul['cwe'] as $t_cwe ) {
|
|
$v_description_array[] = $t_cwe['name'];
|
|
}
|
|
$vulnerabilities[] = array(
|
|
'name' => $v_name,
|
|
'version' => $t_vul['version'],
|
|
'fixed' => $v_fixed,
|
|
'closed' => $v_closed,
|
|
'score' => $t_vul['score'],
|
|
'severity' => $t_vul['severity'],
|
|
'description' => trim( implode( ' + ', $v_description_array ) ),
|
|
);
|
|
}
|
|
}
|
|
|
|
\WP_CLI\Utils\format_items( 'table', $vulnerabilities, array( 'name', 'version', 'fixed', 'closed', 'score', 'severity', 'description' ) );
|
|
}
|
|
|
|
/**
|
|
* Display vulnerabilities for a piece of server software.
|
|
*
|
|
* @param string $software Software slug.
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
private function software( $software, $args, $assoc_args ) {
|
|
$this->require_admin();
|
|
|
|
$format = isset( $assoc_args['format'] ) ? $assoc_args['format'] : 'table';
|
|
|
|
$software_vulnerabilities = array();
|
|
switch ( $software ) {
|
|
case 'php':
|
|
case 'apache':
|
|
case 'nginx':
|
|
case 'mariadb':
|
|
case 'mysql':
|
|
case 'imagemagick':
|
|
case 'curl':
|
|
case 'memcached':
|
|
case 'redis':
|
|
case 'sqlite':
|
|
$software_data = wpvulnerability_software_get_vulnerabilities( $software );
|
|
if ( is_array( $software_data ) && isset( $software_data['vulnerabilities'] ) && is_array( $software_data['vulnerabilities'] ) ) {
|
|
$software_vulnerabilities = $software_data['vulnerabilities'];
|
|
}
|
|
break;
|
|
default:
|
|
$software_vulnerabilities = array();
|
|
}
|
|
|
|
$items = array();
|
|
foreach ( $software_vulnerabilities as $item ) {
|
|
if ( ! is_array( $item ) ) {
|
|
continue;
|
|
}
|
|
$item_sources = isset( $item['source'] ) && is_array( $item['source'] ) ? $item['source'] : array();
|
|
|
|
$complete_temp = array();
|
|
$complete_temp['version'] = trim( html_entity_decode( wp_kses( $this->to_string( $item['version'] ?? null ), 'strip' ) ) );
|
|
$complete_temp['affected'] = trim( html_entity_decode( wp_kses( $this->to_string( $item['versions'] ?? null ), 'strip' ) ) );
|
|
$complete_temp['unfixed'] = $this->to_int( $item['unfixed'] ?? null );
|
|
$complete_temp['source'] = array();
|
|
if ( count( $item_sources ) ) {
|
|
foreach ( $item_sources as $source ) {
|
|
if ( ! is_array( $source ) ) {
|
|
continue;
|
|
}
|
|
$complete_temp['source'][] = array(
|
|
'name' => trim( html_entity_decode( wp_kses( $this->to_string( $source['id'] ?? null ), 'strip' ) ) ),
|
|
'description' => trim( html_entity_decode( wp_kses( $this->to_string( $source['description'] ?? null ), 'strip' ) ) ),
|
|
'link' => esc_url_raw( $this->to_string( $source['link'] ?? null ) ),
|
|
);
|
|
}
|
|
}
|
|
$items[] = $complete_temp;
|
|
}
|
|
|
|
if ( 'json' === $format ) {
|
|
echo wp_json_encode( $items );
|
|
return;
|
|
}
|
|
|
|
if ( empty( $items ) ) {
|
|
/* translators: %s is the software name (php, apache, nginx, etc.) */
|
|
\WP_CLI::success( sprintf( __( 'No %s vulnerabilities found.', 'wpvulnerability' ), $software ) );
|
|
return;
|
|
}
|
|
|
|
$vulnerabilities = array();
|
|
foreach ( $items as $vuln ) {
|
|
$v_fixed = $vuln['unfixed'] ? 'no' : 'yes';
|
|
$v_description = array();
|
|
foreach ( $vuln['source'] as $source ) {
|
|
$v_description[] = $source['name'] . ': ' . $source['description'];
|
|
}
|
|
$vulnerabilities[] = array(
|
|
'version' => $vuln['version'],
|
|
'affected' => $vuln['affected'],
|
|
'fixed' => $v_fixed,
|
|
'description' => trim( implode( ' + ', $v_description ) ),
|
|
);
|
|
}
|
|
|
|
\WP_CLI\Utils\format_items( 'table', $vulnerabilities, array( 'version', 'affected', 'fixed', 'description' ) );
|
|
}
|
|
|
|
/**
|
|
* Display PHP vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability php
|
|
* wp wpvulnerability php --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function php( $args, $assoc_args ) {
|
|
$this->software( 'php', $args, $assoc_args );
|
|
}
|
|
|
|
/**
|
|
* Display Apache vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability apache
|
|
* wp wpvulnerability apache --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function apache( $args, $assoc_args ) {
|
|
$this->software( 'apache', $args, $assoc_args );
|
|
}
|
|
|
|
/**
|
|
* Display Nginx vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability nginx
|
|
* wp wpvulnerability nginx --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function nginx( $args, $assoc_args ) {
|
|
$this->software( 'nginx', $args, $assoc_args );
|
|
}
|
|
|
|
/**
|
|
* Display MariaDB vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability mariadb
|
|
* wp wpvulnerability mariadb --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function mariadb( $args, $assoc_args ) {
|
|
$this->software( 'mariadb', $args, $assoc_args );
|
|
}
|
|
|
|
/**
|
|
* Display MySQL vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability mysql
|
|
* wp wpvulnerability mysql --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function mysql( $args, $assoc_args ) {
|
|
$this->software( 'mysql', $args, $assoc_args );
|
|
}
|
|
|
|
/**
|
|
* Display ImageMagick vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability imagemagick
|
|
* wp wpvulnerability imagemagick --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function imagemagick( $args, $assoc_args ) {
|
|
$this->software( 'imagemagick', $args, $assoc_args );
|
|
}
|
|
|
|
/**
|
|
* Display cURL vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability curl
|
|
* wp wpvulnerability curl --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function curl( $args, $assoc_args ) {
|
|
$this->software( 'curl', $args, $assoc_args );
|
|
}
|
|
|
|
/**
|
|
* Display Memcached vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability memcached
|
|
* wp wpvulnerability memcached --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function memcached( $args, $assoc_args ) {
|
|
$this->software( 'memcached', $args, $assoc_args );
|
|
}
|
|
|
|
/**
|
|
* Display Redis vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability redis
|
|
* wp wpvulnerability redis --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function redis( $args, $assoc_args ) {
|
|
$this->software( 'redis', $args, $assoc_args );
|
|
}
|
|
|
|
/**
|
|
* Display SQLite vulnerabilities.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* [--format=<format>]
|
|
* : Render output in a specific format. Accepted values: table, json. Default: table.
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp wpvulnerability sqlite
|
|
* wp wpvulnerability sqlite --format=json
|
|
*
|
|
* @when after_wp_load
|
|
*
|
|
* @param array<int, string> $args Positional arguments.
|
|
* @param array<string, mixed> $assoc_args Associative arguments.
|
|
* @return void
|
|
*/
|
|
public function sqlite( $args, $assoc_args ) {
|
|
$this->software( 'sqlite', $args, $assoc_args );
|
|
}
|
|
}
|
|
|
|
WP_CLI::add_command( 'wpvulnerability', 'WPVulnerability_CLI' );
|
|
}
|