mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-12 15:53:46 -04:00
feat(server-security): scan host OS packages for vulnerabilities (#12482)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c8497912ba
commit
65dba32385
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ImageScanErrorCode;
|
||||
use App\Services\ImageScan\Finding;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* The last scan of the OS packages of a server, one row per server. A failed scan sets `error_code` and keeps the
|
||||
* findings of the last completed scan (`scanned_at`). `error_context` holds the values of the error message.
|
||||
*
|
||||
* @property ?array{critical: int, high: int, medium: int, low: int, unknown: int, fixable: int, exploited: int, likely: int, other_kernels?: int, total: int, running_kernel?: string} $summary
|
||||
*/
|
||||
class ServerHostScan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/** Relevant findings that are stored; the summary counts all of them. */
|
||||
public const MAX_STORED_FINDINGS = 500;
|
||||
|
||||
protected $fillable = [
|
||||
'server_id',
|
||||
'error_code',
|
||||
'error_context',
|
||||
'eol',
|
||||
'summary',
|
||||
'findings',
|
||||
'findings_truncated',
|
||||
'grype_db_built_at',
|
||||
'scanned_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'error_code' => ImageScanErrorCode::class,
|
||||
'error_context' => 'array',
|
||||
'eol' => 'array',
|
||||
'summary' => 'array',
|
||||
'findings' => 'array',
|
||||
'findings_truncated' => 'boolean',
|
||||
'grype_db_built_at' => 'datetime',
|
||||
'scanned_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function server(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Server::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<Finding>
|
||||
*/
|
||||
public function findingList(): array
|
||||
{
|
||||
return array_map(fn (array $finding) => Finding::fromArray($finding), $this->findings ?? []);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user