Skip to content

Commit

Permalink
merge dev to master
Browse files Browse the repository at this point in the history
  • Loading branch information
svfcode committed Aug 1, 2023
1 parent 88a2c48 commit 9cc6561
Show file tree
Hide file tree
Showing 14 changed files with 265 additions and 110 deletions.
2 changes: 1 addition & 1 deletion inc/spbc-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function spbc_plugin_links_meta($meta, $plugin_file)
function changedPluginName(){
jQuery('.plugin-title strong').each(function(i, item){
if(jQuery(item).html() == '{$plugin_name}')
jQuery(item).html('{$spbc->data["wl_brandname"]}');
jQuery(item).html('{$spbc->data["wl_brandname"]}' + '  Security');
});
}
changedPluginName();
Expand Down
79 changes: 63 additions & 16 deletions inc/spbc-scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function spbc_scanner_count_files($direct_call = false, $path = ABSPATH)
$root_path = realpath(ABSPATH);
$init_params = array(
'count' => true,
'extensions' => 'php, html, htm',
'extensions' => 'php, html, htm, php2, php3, php4, php5, php6, php7, phtml, shtml, phar',
'files_mandatory' => array(),
'dir_exceptions' => array(SPBC_PLUGIN_DIR . 'quarantine')
);
Expand Down Expand Up @@ -438,8 +438,8 @@ function spbc_scanner_file_delete($direct_call = false, $file_id = null)
$remembered_file_content = file_get_contents($file_path);
$result = unlink($file_path);
if ($result) {
$response_content = HTTP::getContentFromURL(get_option('home'), false);
$response_content_admin = HTTP::getContentFromURL(get_option('home') . '/wp-admin/', false);
$response_content = HTTP::getContentFromURL(get_option('home'));
$response_content_admin = HTTP::getContentFromURL(get_option('home') . '/wp-admin/');
if (
isset(
$response_content['error'],
Expand Down Expand Up @@ -1035,29 +1035,76 @@ function ($data) {
return $out;
}

function spbc_scanner_get_files_by_category($status)
/**
* Get SQL *WHERE* suffix for SELECT query depends on files category.
* @param string $category Category of files category which needs to be searched for
* @return string SQL *WHERE* suffix.
*/
function spbc_get_sql_where_addiction_for_table_of_category($category)
{
global $wpdb;

$ids = array();

switch ($status) {
global $spbc;
switch ($category) {
case 'critical':
$res = $wpdb->get_results('SELECT fast_hash from ' . SPBC_TBL_SCAN_FILES . ' WHERE severity = "CRITICAL" AND status <> "QUARANTINED"');
$res = ' WHERE severity IN("CRITICAL") AND
(status <> "QUARANTINED" AND
status <> "APROVED" AND
status <> "APPROVED_BY_CT")
AND
(last_sent IS NULL OR
pscan_status = "DANGEROUS" OR
analysis_status = "DANGEROUS")';
break;
case 'suspicious':
$res = $wpdb->get_results('SELECT fast_hash from ' . SPBC_TBL_SCAN_FILES . ' WHERE status = "MODIFIED" AND severity <> "CRITICAL"');
break;
case 'unknown':
$res = $wpdb->get_results('SELECT fast_hash from ' . SPBC_TBL_SCAN_FILES . ' WHERE status <> "APROVED" AND source IS NULL AND path NOT LIKE "%wp-content%themes%" AND path NOT LIKE "%wp-content%plugins%" AND (severity <> "CRITICAL" OR severity IS NULL)');
$res = ' WHERE severity <> "CRITICAL" AND
last_sent IS NULL AND
(status = "MODIFIED" AND severity IS NOT NULL)
OR (status = "INFECTED" AND severity IN ("SUSPICIOUS","DANGER") )';
break;
case 'approved':
$res = $wpdb->get_results('SELECT fast_hash from ' . SPBC_TBL_SCAN_FILES . ' WHERE status = "APROVED"');
$res = ' WHERE status = "APROVED"';
break;
case 'analysis_log':
$res = $wpdb->get_results('SELECT fast_hash from ' . SPBC_TBL_SCAN_FILES . ' WHERE last_sent IS NOT NULL');
$res = ' WHERE last_sent IS NOT NULL';
break;
case 'unknown':
$res = ' WHERE status NOT IN ("APROVED","APPROVED_BY_CT","APPROVED_BY_CLOUD") AND
detected_at >= ' . (time() - $spbc->settings['scanner__list_unknown__older_than'] * 86400) . ' AND
source IS NULL AND
path NOT LIKE "%wp-content%themes%" AND
path NOT LIKE "%wp-content%plugins%" AND
path NOT LIKE "%wp-content%cache%" AND
path NOT LIKE "%wp-config.php" AND
(severity IS NULL OR severity NOT IN ("CRITICAL", "DANGER", "SUSPICIOUS"))';
break;
case 'quarantined':
$res = ' WHERE status = "QUARANTINED"';
break;
case 'frontend_malware':
$res = ' WHERE approved IS NULL OR approved <> 1';
break;
case 'frontend_scan_results_approved':
$res = ' WHERE approved = 1';
break;
default:
$res = '';
}
return $res;
}

/**
* Get all files IDs of the category.
* @param string $category Category of files category which needs to be searched for
* @return array Array of IDs
*/
function spbc_scanner_get_files_by_category($category)
{
global $wpdb;

$ids = array();

$query = 'SELECT fast_hash from ' . SPBC_TBL_SCAN_FILES . spbc_get_sql_where_addiction_for_table_of_category($category);

$res = $wpdb->get_results($query);

foreach ($res as $tmp) {
$ids[] = $tmp->fast_hash;
Expand Down
Loading

0 comments on commit 9cc6561

Please sign in to comment.