Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
csavelief committed Sep 10, 2024
1 parent 6524df4 commit 3481529
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/Modules/AdversaryMeter/Listeners/EndVulnsScanListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Modules\AdversaryMeter\Events\EndVulnsScan;
use App\Modules\AdversaryMeter\Helpers\ApiUtilsFacade as ApiUtils;
use App\Modules\AdversaryMeter\Models\Alert;
use App\Modules\AdversaryMeter\Models\Asset;
use App\Modules\AdversaryMeter\Models\Port;
use App\Modules\AdversaryMeter\Models\Scan;
use App\Modules\AdversaryMeter\Models\Screenshot;
Expand Down Expand Up @@ -67,7 +66,7 @@ protected function handle2($event)
$port->closed = 1;
$port->save();

$this->markAssetScanAsCompleted($scan);
$this->markScanAsCompleted($scan);
}
return;
}
Expand All @@ -91,7 +90,7 @@ protected function handle2($event)
$this->setAlertsV1($port, $task);
$this->setAlertsV2($port, $task);
$this->setScreenshot($port, $task);
$this->markAssetScanAsCompleted($scan);
$this->markScanAsCompleted($scan);
}

private function setAlertsV1(Port $port, array $task): void
Expand Down Expand Up @@ -187,7 +186,7 @@ private function setScreenshot(Port $port, array $task)
});
}

private function markAssetScanAsCompleted(Scan $scan): void
private function markScanAsCompleted(Scan $scan): void
{
DB::transaction(function () use ($scan) {

Expand All @@ -201,7 +200,7 @@ private function markAssetScanAsCompleted(Scan $scan): void

if ($remaining === 0) {

$asset = Asset::where('id', $scan->asset_id)->first();
$asset = $scan->asset()->first();

if ($asset) {
if ($asset->cur_scan_id === $scan->ports_scan_id) {
Expand Down

0 comments on commit 3481529

Please sign in to comment.