Skip to content

Commit

Permalink
Fix. Controller. Detect several same signatures in the file - get a f…
Browse files Browse the repository at this point in the history
…ile line number for each signature found.
  • Loading branch information
alexandergull committed Dec 24, 2024
1 parent c4626e9 commit aa21902
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ private function scanFileForSignatures(FileInfo $file_info, $root_path, &$signat

// Check if md5 is persisting and collectable
if ( (empty($file_info->full_hash) || $file_info->full_hash === 'full_hash') &&
function_exists('md5') &&
!empty($file_content)
function_exists('md5') &&
!empty($file_content)
) {
$file_info->full_hash = md5($file_content);
}
Expand All @@ -92,15 +92,20 @@ function_exists('md5') &&
if (
( $is_regexp && preg_match($signature['body'], $file_content) ) ||
( ! $is_regexp &&
( strripos($file_content, stripslashes($signature['body'])) !== false ||
strripos($file_content, $signature['body']) !== false) )
(
strripos($file_content, stripslashes($signature['body'])) !== false ||
strripos($file_content, $signature['body']) !== false
)
)
) {
$line_number = Helper::getNeedleStringNumberFromFile(
$line_numbers = Helper::getNeedleStringsNumberFromFile(
$root_path . $file_info->path,
$signature['body'],
$is_regexp
);
$verdict['SIGNATURES'][$line_number][] = $signature['id'];
foreach ($line_numbers as $line_number) {
$verdict['SIGNATURES'][$line_number][] = $signature['id'];
}
}
}
}
Expand All @@ -109,6 +114,7 @@ function_exists('md5') &&
$file_info->weak_spots,
true
) : array();

if ( isset($file_info->weak_spots['SIGNATURES']) ) {
unset($file_info->weak_spots['SIGNATURES']);
}
Expand Down

0 comments on commit aa21902

Please sign in to comment.