Quelltext des aktuellen Standes
<?php
/**
* Partial: Body des CVE-Widgets (Lazy-Load).
* Wird von /dashboard/widget/cve gerendert und per fetch in #cveBody gesetzt.
*
* Erwartete Variablen: $cve_stats, $cve_latest, $cve_widget_filter, $icon_style
*/
$_cveSev = fn($s) => match (strtoupper($s)) {
'CRITICAL' => ['#dc2626', '#fee2e2'],
'HIGH' => ['#ea580c', '#ffedd5'],
'MEDIUM' => ['#d97706', '#fef3c7'],
'LOW' => ['#2563eb', '#dbeafe'],
default => ['#6b7280', '#f3f4f6'],
};
$_cveStats = $cve_stats ?? ['CRITICAL' => 0, 'HIGH' => 0, 'total' => 0];
$_cveLatest = $cve_latest ?? [];
$_cveFilter = $cve_widget_filter ?? 'all';
$_cveIsFiltered = $_cveFilter === 'filtered';
?>
<div data-cve-filter="<?= $this->e($_cveFilter) ?>">
<!-- Severity-Kacheln -->
<div style="display:grid;grid-template-columns:repeat(4,1fr);gap:0.4rem;margin-bottom:0.75rem;">
<?php foreach (['CRITICAL'=>'Kritisch','HIGH'=>'Hoch','MEDIUM'=>'Mittel','LOW'=>'Niedrig'] as $_s => $_l):
[$_sc,$_sbg] = $_cveSev($_s); ?>
<a href="/cve?severity=<?= strtolower($_s) ?>&tab=all" style="text-decoration:none;">
<div style="background:<?= $_sbg ?>;color:<?= $_sc ?>;border-radius:6px;padding:0.4rem 0.5rem;text-align:center;">
<div style="font-size:1.1rem;font-weight:700;line-height:1;"><?= (int)($_cveStats[$_s] ?? 0) ?></div>
<div style="font-size:0.65rem;font-weight:600;text-transform:uppercase;opacity:.8;"><?= $_l ?></div>
</div>
</a>
<?php endforeach; ?>
</div>
<!-- CVE-Liste -->
<?php if (!empty($_cveLatest)): ?>
<div style="display:flex;flex-direction:column;gap:0.35rem;">
<?php foreach ($_cveLatest as $_c):
[$_cc,$_cbg] = $_cveSev($_c['severity'] ?? '');
$_score = $_c['cvss_score'] !== null ? number_format((float)$_c['cvss_score'],1) : '–';
?>
<a href="/cve" style="display:flex;align-items:center;gap:0.5rem;text-decoration:none;
padding:0.35rem 0.5rem;border-radius:6px;background:#f9fafb;
border:1px solid #f3f4f6;">
<span style="background:<?= $_cbg ?>;color:<?= $_cc ?>;border-radius:4px;
font-size:0.65rem;font-weight:700;padding:0.15rem 0.4rem;white-space:nowrap;">
<?= $this->e($_c['severity'] ?? '') ?>
</span>
<span style="font-size:0.75rem;font-weight:600;color:<?= $_cc ?>;white-space:nowrap;"><?= $this->e($_score) ?></span>
<span style="font-size:0.75rem;font-weight:600;color:var(--gray-700);white-space:nowrap;"><?= $this->e($_c['cve_id']) ?></span>
<span style="font-size:0.72rem;color:var(--gray-500);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;">
<?= $this->e(mb_strimwidth($_c['description'] ?? '', 0, 60, '…')) ?>
</span>
</a>
<?php endforeach; ?>
</div>
<?php else: ?>
<p style="font-size:0.82rem;color:var(--gray-400);text-align:center;padding:0.5rem 0;">
<?= $_cveIsFiltered ? 'Keine CVEs zu deinen Keywords.' : 'Keine kritischen CVEs im Cache.' ?>
</p>
<?php endif; ?>
</div>