mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
v4.7 (#12478)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Co-authored-by: Aditya Tripathi <aditya@climactic.co>
This commit is contained in:
co-authored by
Claude Opus 5.5
peaklabs-dev
Aditya Tripathi
parent
b7dc2e435b
commit
033f0c84da
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\ImageScan;
|
||||
use App\Services\ImageScan\ScanNotifications;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
/**
|
||||
* Looks again at the alert of a scan whose exploited problems waited for the version check (spec 15.8). It runs when
|
||||
* the wait ends, so the alert is sent even when the check never stores a result. Unique per scan and scan time, so a
|
||||
* rescan of the same row during a wait gets its own run.
|
||||
*/
|
||||
class ImageScanAlertCheckJob implements ShouldBeUnique, ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable;
|
||||
|
||||
public $tries = 3;
|
||||
|
||||
public $uniqueFor = 7200;
|
||||
|
||||
/**
|
||||
* @param ?string $scannedAt The scan time of the row when the wait started.
|
||||
*/
|
||||
public function __construct(public int $scanId, public ?string $scannedAt = null)
|
||||
{
|
||||
$this->onQueue('high');
|
||||
}
|
||||
|
||||
public function uniqueId(): string
|
||||
{
|
||||
return $this->scanId.':'.$this->scannedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
public function backoff(): array
|
||||
{
|
||||
return [60, 300];
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$scan = ImageScan::query()->find($this->scanId);
|
||||
if ($scan instanceof ImageScan) {
|
||||
// Errors fail the run, so it is tried again.
|
||||
ScanNotifications::afterScan($scan, candidateCheck: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user