Skip to content

Commit

Permalink
CLI endpoints: some CLI endpoints were failing. (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercasares authored Oct 4, 2024
2 parents 7ea4970 + 78c17d2 commit 717f936
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**Fixed**

* API endpoints: some API endpoints were failing.
* CLI endpoints: some CLI endpoints were failing.

**Compatibility**

Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ First of all, peace of mind. Investigate what the vulnerability is and, above al
**Fixed**

* API endpoints: some API endpoints were failing.
* CLI endpoints: some CLI endpoints were failing.

**Compatibility**

Expand Down
27 changes: 20 additions & 7 deletions wpvulnerability-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,17 +501,30 @@ function wpvulnerability_cli_software( $software, $format ) {
break;
}

$vulnerabilities = array();
$get_vulnerabilities_function = 'wpvulnerability_' . $software . '_get_vulnerabilities';
$software_vulnerabilities = ( function_exists( $get_vulnerabilities_function ) && wpvulnerability_analyze_filter( $software ) )
? $get_vulnerabilities_function()
: array();
$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_vulnerabilities = wpvulnerability_get_vulnerabilities( $software, wpvulnerability_get_software_version( $software ) );
break;
default:
$software_vulnerabilities = null;
}

$software_complete = array();

if ( isset( $software_vulnerabilities['vulnerabilities'] ) ) {
if ( isset( $software_vulnerabilities ) && is_array( $software_vulnerabilities ) ) {
// Loop through each vulnerability.
foreach ( $software_vulnerabilities['vulnerabilities'] as $item ) {
foreach ( $software_vulnerabilities as $item ) {
$complete_temp = array();

$complete_temp['version'] = trim( html_entity_decode( wp_kses( (string) $item['version'], 'strip' ) ) );
Expand Down

0 comments on commit 717f936

Please sign in to comment.