-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
csavelief
committed
Oct 25, 2024
1 parent
ad264f9
commit a6f661b
Showing
6 changed files
with
226 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace App\View\Components; | ||
|
||
use App\Models\YnhOsquery; | ||
use App\Models\YnhServer; | ||
use App\Modules\AdversaryMeter\Models\Asset; | ||
use App\User; | ||
use Carbon\Carbon; | ||
use Closure; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\View\Component; | ||
|
||
class SuspiciousActivity extends Component | ||
{ | ||
public Collection $events; | ||
public Collection $metrics; | ||
public Collection $assetsDiscovered; | ||
|
||
public function __construct() | ||
{ | ||
/** @var User $user */ | ||
$user = Auth::user(); | ||
$servers = YnhServer::forUser($user); | ||
$cutOffTime = Carbon::now()->subDay(); | ||
$this->events = YnhOsquery::suspiciousEvents($servers, $cutOffTime); | ||
$this->metrics = YnhOsquery::suspiciousMetrics($servers, $cutOffTime); | ||
$this->assetsDiscovered = Asset::where('created_at', '>=', $cutOffTime)->orderBy('asset')->get(); | ||
} | ||
|
||
public function render(): View|Closure|string | ||
{ | ||
return view('components.suspicious-activity'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
resources/views/components/suspicious-activity.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-4 pr-0"> | ||
<x-big-number | ||
:number="$assetsDiscovered->count()" | ||
:title="__('Discovered Assets') . ' / 24h'" | ||
icon="world" | ||
color="var(--ds-background-brand-bold)"/> | ||
</div> | ||
<div class="col-4 pl-2 pr-0"> | ||
<x-big-number | ||
:number="$events->count()" | ||
:title="__('Suspicious Events') . ' / 24h'" | ||
icon="event" | ||
color="var(--ds-background-brand-bold)"/> | ||
</div> | ||
<div class="col-4 pl-2"> | ||
<x-big-number | ||
:number="$metrics->count()" | ||
:title="__('Important Metrics') . ' / 24h'" | ||
icon="metric" | ||
color="var(--ds-background-brand-bold)"/> | ||
</div> | ||
</div> | ||
<div class="card mt-2"> | ||
<div class="card-body"> | ||
<h6 class="card-title">{{ __('Assets Discovered During The Last 24 Hours') }}</h6> | ||
@if($assetsDiscovered->isEmpty()) | ||
<div class="row"> | ||
<div class="col"> | ||
{{ __('None.') }} | ||
</div> | ||
</div> | ||
@else | ||
<table class="table table-hover no-bottom-margin"> | ||
<thead> | ||
<tr> | ||
<th style="width:165px">{{ __('Discovery Date') }}</th> | ||
<th style="width:100px">{{ __('Asset Type') }}</th> | ||
<th>{{ __('Asset') }}</th> | ||
<th class="text-end">{{ __('Scan Status') }}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach($assetsDiscovered as $asset) | ||
<tr> | ||
<td> | ||
{{ $asset->created_at->format('Y-m-d H:i') }} | ||
</td> | ||
<td> | ||
<span class="lozenge new"> | ||
{{ $asset->type }} | ||
</span> | ||
</td> | ||
<td> | ||
{{ $asset->asset }} | ||
</td> | ||
<td class="text-end"> | ||
@if($asset->scanInProgress()->isEmpty()) | ||
<span class="lozenge success"> | ||
scan terminé | ||
</span> | ||
@else | ||
<span class="lozenge error"> | ||
scan en cours | ||
</span> | ||
@endif | ||
</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
@endif | ||
</div> | ||
</div> | ||
<div class="card mt-2"> | ||
<div class="card-body"> | ||
<h6 class="card-title">{{ __('Suspicious Activity From The Last 24 Hours') }}</h6> | ||
@if($events->isEmpty()) | ||
<div class="row"> | ||
<div class="col"> | ||
{{ __('None.') }} | ||
</div> | ||
</div> | ||
@else | ||
<table class="table table-hover no-bottom-margin"> | ||
<thead> | ||
<tr> | ||
<th style="width:165px">{{ __('Date') }}</th> | ||
<th>{{ __('Server') }}</th> | ||
<th style="width:75px">{{ __('IP') }}</th> | ||
<th>{{ __('Message') }}</th> | ||
<th class="text-end" style="width:100px">{{ __('Event Id') }}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach($events as $event) | ||
<tr> | ||
<td>{{ $event['timestamp'] }}</td> | ||
<td>{{ $event['server'] }}</td> | ||
<td>{{ $event['ip'] }}</td> | ||
<td class="text-muted">{{ $event['message'] }}</td> | ||
<td class="text-end"> | ||
<span class="lozenge new"> | ||
{{ Illuminate\Support\Number::format($event['id'], locale:'sv') }} | ||
</span> | ||
</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
@endif | ||
</div> | ||
</div> | ||
<div class="card mt-2"> | ||
<div class="card-body"> | ||
<h6 class="card-title">{{ __('Important Metrics From The Last 24 Hours') }}</h6> | ||
@if($metrics->isEmpty()) | ||
<div class="row"> | ||
<div class="col"> | ||
{{ __('None.') }} | ||
</div> | ||
</div> | ||
@else | ||
<table class="table table-hover no-bottom-margin"> | ||
<thead> | ||
<tr> | ||
<th style="width:165px">{{ __('Date') }}</th> | ||
<th>{{ __('Server') }}</th> | ||
<th style="width:75px">{{ __('IP') }}</th> | ||
<th>{{ __('Message') }}</th> | ||
<th class="text-end" style="width:100px">{{ __('Metric Id') }}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach($metrics as $metric) | ||
<tr> | ||
<td>{{ $metric['timestamp'] }}</td> | ||
<td>{{ $metric['server'] }}</td> | ||
<td>{{ $metric['ip'] }}</td> | ||
<td class="text-muted">{{ $metric['message'] }}</td> | ||
<td class="text-end"> | ||
<span class="lozenge new"> | ||
{{ Illuminate\Support\Number::format($metric['id'], locale:'sv') }} | ||
</span> | ||
</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
@endif | ||
</div> | ||
</div> | ||
</div> |