45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Jobs;
|
||
|
|
|
||
|
|
use App\Models\Finding;
|
||
|
|
use App\Osint\RunnerRegistry;
|
||
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||
|
|
use Illuminate\Foundation\Queue\Queueable;
|
||
|
|
|
||
|
|
class RunFinding implements ShouldQueue
|
||
|
|
{
|
||
|
|
use Queueable;
|
||
|
|
|
||
|
|
public int $tries = 1;
|
||
|
|
|
||
|
|
public function __construct(
|
||
|
|
public readonly int $findingId,
|
||
|
|
) {
|
||
|
|
}
|
||
|
|
|
||
|
|
public function handle(RunnerRegistry $registry): void
|
||
|
|
{
|
||
|
|
$finding = Finding::with(['target', 'source'])->findOrFail($this->findingId);
|
||
|
|
|
||
|
|
$finding->update(['status' => 'running']);
|
||
|
|
|
||
|
|
try {
|
||
|
|
$result = $registry->resolve($finding->source->key)->run($finding->target);
|
||
|
|
|
||
|
|
$finding->update([
|
||
|
|
'status' => 'completed',
|
||
|
|
'raw_payload' => $result->raw,
|
||
|
|
'summary' => $result->summary,
|
||
|
|
'ran_at' => now(),
|
||
|
|
]);
|
||
|
|
} catch (\Throwable $e) {
|
||
|
|
$finding->update([
|
||
|
|
'status' => 'failed',
|
||
|
|
'error' => $e->getMessage(),
|
||
|
|
'ran_at' => now(),
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|