Skip to content

Commit

Permalink
Fix. Vulnerability alarm. Checking installed plugins fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glomberg committed Feb 22, 2024
1 parent 1aeb68c commit 0f5806d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
10 changes: 10 additions & 0 deletions lib/CleantalkSP/SpbctWP/VulnerabilityAlarm/Dto/ItemReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,18 @@ class ItemReport
*/
public $rs_app_version_max;

/**
* @var string
*/
public $slug;

/**
* @var string
*/
public $app_name;

/**
* @var string
*/
public $app_description;
}
2 changes: 1 addition & 1 deletion lib/CleantalkSP/SpbctWP/VulnerabilityAlarm/ResearchApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static function method__research_list($modules_names) // phpcs:ignore PSR
$request = array(
'method_name' => '', // Dummy placeholder to prevent php notices
'app_names' => $modules_names,
'list_params' => 'id,CVE,date,app_name,app_status,app_type,rs_app_version_min,rs_app_version_max'
'list_params' => 'id,CVE,date,slug,app_name,app_description,app_status,app_type,rs_app_version_min,rs_app_version_max'
);

return static::sendRequest($request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public static function checkVulnerabilities()
VulnerabilityAlarmService::updateVulnerabilitiesLibrary();
}

public static function checkPluginVulnerability($plugin_file, $plugin_version)
public static function checkPluginVulnerability($plugin_slug, $plugin_version)
{
/** @var ApiResults|null $list */
$list = get_option(self::VULNERABILITY_LIST);
if ( $list === false ) {
return false;
}
static::$plugins = $list->plugins;
return VulnerabilityAlarmService::checkPlugin($plugin_file, $plugin_version);
return VulnerabilityAlarmService::checkPlugin($plugin_slug, $plugin_version);
}

public static function showAlarm($plugin_file, $plugin_data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function checkPlugin($plugin_slug, $plugin_version, $safety_check
}

foreach ( VulnerabilityAlarm::$plugins as $plugin ) {
if ( $plugin->app_name === $plugin_slug ) {
if ( $plugin->slug === $plugin_slug ) {
if ( $safety_check ) {
if ( static::isPluginVersionIsSafe($plugin, $plugin_version) ) {
return $plugin;
Expand Down Expand Up @@ -206,7 +206,7 @@ private static function mapApiResults($api_res)
break;
}

$report->app_name = $res['app_name'];
$report->slug = $res['slug'];
$report->app_status = $res['app_status'];
if ( isset($res['id']) ) {
$report->id = $res['id'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class VulnerabilityAlarmView
public static function showPluginAlarm($plugin_file, $plugin_report)
{
$active = is_plugin_active($plugin_file) ? 'active' : 'inactive';
$slug = $plugin_report->app_name;
$slug = $plugin_report->slug;
$alarm_text = esc_html__('Security by CleanTalk', 'security-malware-firewall');
$alarm_text .= ': ';
$alarm_text .= esc_html__('The plugin contains known vulnerability', 'security-malware-firewall');
Expand Down

0 comments on commit 0f5806d

Please sign in to comment.