@@ -197,7 +197,7 @@ final class ClamDScanner implements MalwareScanner
|
||||
}
|
||||
$offset += $written;
|
||||
$meta = stream_get_meta_data($socket);
|
||||
if ($meta['timed_out'] ?? false) {
|
||||
if ($meta['timed_out']) {
|
||||
throw new RuntimeException('ClamD scan timed out while sending data.');
|
||||
}
|
||||
}
|
||||
@@ -208,19 +208,21 @@ final class ClamDScanner implements MalwareScanner
|
||||
{
|
||||
$reply = stream_get_line($socket, 65536, "\0");
|
||||
$meta = stream_get_meta_data($socket);
|
||||
if ($reply === false || ($meta['timed_out'] ?? false)) {
|
||||
throw new RuntimeException(($meta['timed_out'] ?? false) ? 'ClamD scan timed out.' : 'ClamD returned no scan result.');
|
||||
if ($reply === false || $meta['timed_out']) {
|
||||
throw new RuntimeException($meta['timed_out'] ? 'ClamD scan timed out.' : 'ClamD returned no scan result.');
|
||||
}
|
||||
|
||||
return trim($reply);
|
||||
}
|
||||
|
||||
/** @return array{available:bool,engine:string,engine_version:?string,signatures_at:?DateTimeImmutable,signature_age_hours:?float,reason_code:?string} */
|
||||
private function unavailable(string $reason): array
|
||||
{
|
||||
return ['available' => false, 'engine' => 'ClamAV', 'engine_version' => null, 'signatures_at' => null,
|
||||
'signature_age_hours' => null, 'reason_code' => $reason];
|
||||
}
|
||||
|
||||
/** @return array{result:string,reason_code:?string,engine:string,engine_version:string,signatures_at:?DateTimeImmutable,duration_ms:int,detail:?string} */
|
||||
private function result(string $result, ?string $reason, int $startedAt, ?string $detail): array
|
||||
{
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user