feat: scan

This commit is contained in:
hashbro
2026-09-13 01:22:54 +08:00
parent 4fa162c72c
commit 7fc5f43c01
19 changed files with 328 additions and 30 deletions
@@ -17,6 +17,7 @@ class MnemonicFindingController extends Controller
public function index(MnemonicScanService $scan)
{
$this->denyHiddenAgentScan();
$agents = $this->isAgentPortal()
? collect()
: User::query()->orderBy('username')->get(['id', 'username']);
@@ -31,6 +32,7 @@ class MnemonicFindingController extends Controller
public function data(Request $request)
{
$this->denyHiddenAgentScan();
$q = $this->baseQuery($request);
$status = trim((string) $request->query('status', ''));
if (in_array($status, [MnemonicFinding::STATUS_SUSPECTED, MnemonicFinding::STATUS_CONFIRMED, MnemonicFinding::STATUS_DISMISSED], true)) {
@@ -83,6 +85,7 @@ class MnemonicFindingController extends Controller
public function confirm(Request $request, MnemonicFinding $finding, MnemonicScanService $scan)
{
$this->denyHiddenAgentScan();
if (! $this->findingInScope($finding)) {
return response()->json(['code' => 1, 'msg' => '无权操作'], 403);
}
@@ -99,6 +102,7 @@ class MnemonicFindingController extends Controller
public function dismiss(MnemonicFinding $finding, MnemonicScanService $scan)
{
$this->denyHiddenAgentScan();
if (! $this->findingInScope($finding)) {
return response()->json(['code' => 1, 'msg' => '无权操作'], 403);
}
@@ -107,6 +111,13 @@ class MnemonicFindingController extends Controller
return response()->json(['code' => 0, 'msg' => 'ok']);
}
private function denyHiddenAgentScan(): void
{
if ($this->isAgentPortal() && ! config('coruna.scan.agent_visible', true)) {
abort(403, '无权访问');
}
}
private function findingInScope(MnemonicFinding $finding): bool
{
$q = MnemonicFinding::query()