Skip to content

Commit

Permalink
Perf. on /vulnerabilities endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
csavelief committed Sep 12, 2024
1 parent effc09d commit 09d07a3
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ public function getVulnerabilitiesWithAssetInfo(?int $attackerId = null): array
->join('scans', 'scans.id', '=', 'ports.scan_id')
->join('assets', 'assets.cur_scan_id', '=', 'scans.ports_scan_id')
->get()
->filter(fn(Alert $alert) => !$attackerId || $alert->events($attackerId)->exists())
->filter(fn(Alert $alert) => !$attackerId || !$alert->cve_id || $alert->events($attackerId)->exists())
->map(function (Alert $alert) use ($attackerId) {
return [
'alert' => $alert,
'asset' => $alert->asset(),
'port' => $alert->port(),
'events' => $alert->events($attackerId)->get()->toArray(),
'events' => $alert->cve_id ? $alert->events($attackerId)->get()->toArray() : [],
];
})
->toArray();
Expand Down

0 comments on commit 09d07a3

Please sign in to comment.