feat(firewall): complete operational reliability phase
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace KTXC\Console\Firewall;
|
||||
|
||||
use KTXC\Service\FirewallService;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
#[AsCommand(name: 'firewall:maintenance', description: 'Remove expired firewall data and record the outcome')]
|
||||
final class FirewallMaintenanceCommand extends Command
|
||||
{
|
||||
public function __construct(private readonly FirewallService $firewall)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
try {
|
||||
$result = $this->firewall->cleanup();
|
||||
} catch (\Throwable $error) {
|
||||
$io->error('Firewall maintenance failed: '.$error->getMessage());
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$io->success(sprintf(
|
||||
'Firewall maintenance complete: %d expired rules, %d old logs, and %d expired claims removed.',
|
||||
$result['expiredRules'],
|
||||
$result['oldLogs'],
|
||||
$result['expiredBruteForceClaims']
|
||||
));
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user