Run-all buttons (per target and per investigation) queue every applicable, not-already-in-flight source via a new FindingDispatcher, re-attempting prior failures automatically. RunFinding now applies a per-source RateLimited queue middleware so a bulk run can't hammer the free public APIs (ip-api, crt.sh, whois, sherlock, theharvester) it depends on; $tries raised to 30 to survive rate-limiter releases, with a failed() handler so exhausted retries still resolve the Finding instead of leaving it stuck pending. Also fixes CrtShRunner treating crt.sh's intermittent 404/502 (a known flaky free service) as fatal on the first try — added a bounded retry. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
91 lines
2.8 KiB
PHP
91 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Investigation;
|
|
use App\Models\Source;
|
|
use App\Osint\FindingDispatcher;
|
|
use App\Osint\RunnerRegistry;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class InvestigationController extends Controller
|
|
{
|
|
public function index(Request $request): View
|
|
{
|
|
$investigations = Investigation::query()
|
|
->accessibleBy($request->user())
|
|
->withCount('targets')
|
|
->latest()
|
|
->get();
|
|
|
|
return view('investigations.index', compact('investigations'));
|
|
}
|
|
|
|
public function create(): View
|
|
{
|
|
$this->authorize('create', Investigation::class);
|
|
|
|
return view('investigations.create');
|
|
}
|
|
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
$this->authorize('create', Investigation::class);
|
|
|
|
$data = $request->validate([
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'description' => ['nullable', 'string', 'max:5000'],
|
|
]);
|
|
|
|
$investigation = Investigation::create([
|
|
...$data,
|
|
'owner_id' => $request->user()->id,
|
|
'status' => 'open',
|
|
]);
|
|
|
|
return redirect()->route('investigations.show', $investigation);
|
|
}
|
|
|
|
public function show(Request $request, Investigation $investigation, RunnerRegistry $registry): View
|
|
{
|
|
$this->authorize('view', $investigation);
|
|
|
|
$investigation->load(['owner', 'targets.creator', 'targets.findings.source']);
|
|
|
|
$sources = Source::where('enabled', true)->orderBy('name')->get();
|
|
|
|
return view('investigations.show', [
|
|
'investigation' => $investigation,
|
|
'canEdit' => $investigation->isEditableBy($request->user()),
|
|
'canManageAccess' => $request->user()->can('manageAccess', $investigation),
|
|
'sources' => $sources,
|
|
'runnableSourceKeys' => $sources->filter(fn (Source $s) => $registry->has($s->key))->pluck('key'),
|
|
]);
|
|
}
|
|
|
|
public function destroy(Investigation $investigation): RedirectResponse
|
|
{
|
|
$this->authorize('delete', $investigation);
|
|
|
|
$investigation->delete();
|
|
|
|
return redirect()->route('investigations.index');
|
|
}
|
|
|
|
public function runAll(Request $request, Investigation $investigation, FindingDispatcher $dispatcher): RedirectResponse
|
|
{
|
|
$this->authorize('update', $investigation);
|
|
|
|
$queued = $investigation->targets->sum(
|
|
fn ($target) => $dispatcher->dispatchAllApplicable($target, $request->user())
|
|
);
|
|
|
|
return redirect()->route('investigations.show', $investigation)
|
|
->with('status', $queued > 0
|
|
? "Queued {$queued} lookup(s) across all targets..."
|
|
: 'Nothing to queue — already up to date.');
|
|
}
|
|
}
|