31 lines
1.1 KiB
PHP
31 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\Malware\MalwareScanner;
|
|
use Illuminate\Console\Command;
|
|
|
|
class CheckMalwareScanner extends Command
|
|
{
|
|
protected $signature = 'malware:health';
|
|
|
|
protected $description = 'Check ClamAV availability and signature freshness';
|
|
|
|
public function handle(MalwareScanner $scanner): int
|
|
{
|
|
$health = $scanner->health();
|
|
$this->line('Scanner: '.($health['engine'] ?? 'ClamAV'));
|
|
$this->line('Available: '.($health['available'] ? 'yes' : 'no'));
|
|
$this->line('Engine version: '.($health['engine_version'] ?? 'unavailable'));
|
|
$this->line('Signatures UTC: '.($health['signatures_at']?->format(DATE_ATOM) ?? 'unavailable'));
|
|
$this->line('Signature age hours: '.($health['signature_age_hours'] === null ? 'unavailable' : number_format($health['signature_age_hours'], 2)));
|
|
if (! $health['available']) {
|
|
$this->error('Reason: '.($health['reason_code'] ?? 'scanner_unavailable'));
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|