OpenNIT

Quelltext des aktuellen Standes

Fassung 1.1.1

_bsi_table.php

3 KB
<?php
// Erwartet: $bsiRows (array von Advisories mit 'cves'-Array)
$bsiRows = $bsiRows ?? [];
?>
<div class="table-wrapper">
    <table class="data-table">
        <thead>
            <tr>
                <th scope="col" style="white-space:nowrap;width:90px;"><?= $this->te('Datum') ?></th>
                <th scope="col"><?= $this->te('Warnung') ?></th>
                <th scope="col" style="width:110px;"><?= $this->te('Schweregrad') ?></th>
                <th scope="col"><?= $this->te('Referenzierte CVEs') ?></th>
            </tr>
        </thead>
        <tbody>
        <?php foreach ($bsiRows as $adv): ?>
            <tr>
                <td style="white-space:nowrap;color:var(--gray-500);font-size:.82rem;">
                    <?= !empty($adv['published']) ? $this->e(date('d.m.Y', strtotime($adv['published']))) : '–' ?>
                </td>
                <td>
                    <?php if (!empty($adv['url'])): ?>
                        <a href="<?= $this->e($adv['url']) ?>" target="_blank" rel="noopener" class="table-link"><?= $this->e($adv['title']) ?></a>
                    <?php else: ?>
                        <?= $this->e($adv['title']) ?>
                    <?php endif; ?>
                </td>
                <td>
                    <?php if (!empty($adv['severity'])): ?>
                        <?php $bs = strtolower((string)$adv['severity']);
                        $bsCls = match($bs) {
                            'kritisch' => 'status-pill--danger', 'hoch' => 'status-pill--orange',
                            'mittel' => 'status-pill--warning', 'niedrig' => 'status-pill--info',
                            default => 'status-pill--neutral' }; ?>
                        <span class="status-pill <?= $bsCls ?>"><?= $this->e(ucfirst($bs)) ?></span>
                    <?php else: ?>
                        <span style="color:var(--gray-400);font-size:.8rem;">–</span>
                    <?php endif; ?>
                </td>
                <td>
                    <?php if (!empty($adv['cves'])): ?>
                        <?php foreach (array_slice($adv['cves'], 0, 8) as $cveId): ?>
                            <a href="/cve?q=<?= urlencode($cveId) ?>" class="status-pill" style="margin:0 .2rem .2rem 0;display:inline-block;"><?= $this->e($cveId) ?></a>
                        <?php endforeach; ?>
                        <?php if (count($adv['cves']) > 8): ?><span style="color:var(--gray-400);font-size:.78rem;">+<?= count($adv['cves']) - 8 ?></span><?php endif; ?>
                    <?php else: ?>
                        <span style="color:var(--gray-400);font-size:.8rem;">–</span>
                    <?php endif; ?>
                </td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>