Dockhand vulnerability scans: warn about critical findings, with a setting to turn it off

Reads what Dockhand's scans have already stored (never starts one) every
15 minutes and raises a warning per Docker host with critical findings.
Unknown counts and stale readings are held, not treated as clean.
Settings -> Notifications has a switch (on by default); the Docker page
shows counts, scan coverage and the critical findings; /metrics and docs
updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-25 22:34:06 +01:00
1 parent 65214f6f0f
commit 5a2b320175
25 files changed
+8527 -12

No files matched your search

+2
View File
@@ -21,6 +21,7 @@ import { useTableSearch } from "../hooks/useTableSearch";
import DetailDrawer, { ObjectDetails } from "../components/DetailDrawer";
import { useRowDetail } from "../hooks/useRowDetail";
import { EmptyRow } from "../components/EmptyState";
import DockerVulnerabilities from "./DockerVulnerabilities";
function updateBadge(c: DockhandContainer) {
if (c.updateAvailable === null) return <span className="text-secondary">—</span>;
@@ -354,6 +355,7 @@ export default function Docker({ user }: { user: CurrentUser }) {
<Pagination page={page} pageCount={pageCount} totalCount={totalCount} onPageChange={setPage} />
</div>
)}
{selected?.enabled && <DockerVulnerabilities integrationId={selected.id} />}
</>
)}
{detail.selected && (
+131
View File
@@ -0,0 +1,131 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type DockhandVulnerabilitiesResponse, type DockhandVulnerabilityEnvironment } from "../api/client";
import TimeAgo from "../components/TimeAgo";
import { readableError } from "../utils/errors";
const count = (v: number | null) => (v === null ? "—" : v.toLocaleString());
function Host({ env }: { env: DockhandVulnerabilityEnvironment }) {
const [open, setOpen] = useState(false);
const unscanned = env.totalImages !== null && env.imagesScanned !== null ? env.totalImages - env.imagesScanned : null;
return (
<div className="mb-3">
<div className="d-flex flex-wrap align-items-center gap-2">
<strong>{env.environmentName}</strong>
{env.critical === null ? (
<span className="badge bg-secondary-lt text-secondary">Not read</span>
) : env.critical > 0 ? (
<span className="badge bg-red-lt text-red">{env.critical} critical</span>
) : (
<span className="badge bg-green-lt text-green">No critical</span>
)}
<span className="text-secondary small">
{count(env.high)} high · {count(env.medium)} medium · {count(env.low)} low
</span>
<span className="text-secondary small ms-auto">
{env.imagesScanned === null ? "" : `${env.imagesScanned} of ${env.totalImages ?? "?"} images scanned`}
{unscanned !== null && unscanned > 0 ? ` — ${unscanned} not scanned yet` : ""}
</span>
</div>
{env.findings.length > 0 && (
<>
<button className="btn btn-link btn-sm p-0 mt-1" onClick={() => setOpen((o) => !o)}>
{open ? "Hide the critical findings" : `Show the critical findings${env.critical !== null && env.critical > env.findings.length ? ` (first ${env.findings.length} of ${env.critical})` : ""}`}
</button>
{open && (
<div className="table-responsive mt-2">
<table className="table table-sm table-vcenter">
<thead>
<tr>
<th>CVE</th>
<th>Package</th>
<th>Installed</th>
<th>Fixed in</th>
<th>Image</th>
<th>Used by</th>
</tr>
</thead>
<tbody>
{env.findings.map((f, i) => (
<tr key={`${f.cve}:${f.package}:${f.imageName}:${i}`}>
<td className="text-nowrap">{f.cve}</td>
<td className="text-break">{f.package}</td>
<td className="text-secondary text-break">{f.installedVersion || "—"}</td>
<td className="text-break">{f.fixedVersion ? <span className="text-green">{f.fixedVersion}</span> : <span className="text-secondary">no fix yet</span>}</td>
<td className="text-secondary text-break">{f.imageName}</td>
<td className="text-secondary text-break">{f.containers.length > 0 ? f.containers.join(", ") : "—"}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</>
)}
</div>
);
}
/** What Dockhand's own vulnerability scans found, per Docker host. Read from what was stored; nothing is asked of Dockhand here, and nothing is scanned. */
export default function DockerVulnerabilities({ integrationId }: { integrationId: number }) {
const [data, setData] = useState<DockhandVulnerabilitiesResponse | null>(null);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
setData(null);
const load = () =>
api.integrations.dockhand
.vulnerabilities(integrationId)
.then((r) => {
setData(r);
setError(null);
})
.catch((err) => setError(readableError(err)));
void load();
const t = setInterval(load, 120_000);
return () => clearInterval(t);
}, [integrationId]);
const critical = (data?.environments ?? []).reduce((sum, e) => sum + (e.critical ?? 0), 0);
return (
<div className="card mt-3">
<div className="card-header">
<h3 className="card-title">
Vulnerabilities
{data && data.environments.length > 0 && (critical > 0 ? <span className="text-red fw-normal ms-2">{critical} critical</span> : <span className="text-secondary fw-normal ms-2">none critical</span>)}
</h3>
{data?.status && (
<div className="card-actions text-secondary small">
read <TimeAgo value={data.status.at} />
</div>
)}
</div>
<div className="card-body">
{error && <div className="text-yellow">{error}</div>}
{!data && !error && <div className="text-secondary">Reading…</div>}
{data && (
<>
<p className="text-secondary small">
From the scans Dockhand has already run on its images (it scans when it is told to — nothing is scanned from here). An image that was never scanned is not known to be clean.{" "}
{data.alerts ? (
<>
<strong>Critical</strong> findings are an alert — see <Link to="/alerts">Alerts</Link>; high, medium and low are only shown here.
</>
) : (
<>
The alert for critical findings is switched off (<Link to="/settings/notifications">Settings → Notifications</Link>).
</>
)}
</p>
{data.status && !data.status.ok && <div className="text-yellow mb-2">The last attempt to read them failed: {data.status.error ?? "no answer"}.</div>}
{data.environments.length === 0 && !data.status && <div className="text-secondary">Not read yet — it is read a few minutes after Dockhand is added, then every quarter of an hour.</div>}
{data.environments.length === 0 && data.status?.ok && <div className="text-secondary">Dockhand lists no Docker hosts.</div>}
{data.environments.map((e) => (
<Host key={e.environmentId} env={e} />
))}
</>
)}
</div>
</div>
);
}
@@ -84,7 +84,7 @@ const DIGEST_DAYS: { value: number; label: string }[] = [
{ value: 6, label: "Saturday" },
{ value: 0, label: "Sunday" },
];
const DEFAULT_HEALTH_CHECKS: HealthCheckSettings = { serverOfflineMinutes: 60, diskUsagePercent: 90, domainWarnDays: 30, diskForecastDays: 14, backupStaleHours: 48, restoreTestDays: 0, newPortAlerts: true, flapRaises: 3, deviceOfflineMinutes: 10, osSupportWarnDays: 90, baselineAlerts: true, containerAlerts: true, containerIgnore: [] };
const DEFAULT_HEALTH_CHECKS: HealthCheckSettings = { serverOfflineMinutes: 60, diskUsagePercent: 90, domainWarnDays: 30, diskForecastDays: 14, backupStaleHours: 48, restoreTestDays: 0, newPortAlerts: true, flapRaises: 3, deviceOfflineMinutes: 10, osSupportWarnDays: 90, baselineAlerts: true, containerAlerts: true, vulnerabilityAlerts: true, containerIgnore: [] };
const DEFAULT_MONTHLY: MonthlyReportSettings = { enabled: false, quarterly: false, annual: false, day: 1, time: "08:00" };
type TestResult = { ok: boolean; message: string } | null;
@@ -865,6 +865,16 @@ export default function NotificationSettings() {
onChange={(e) => setHealthChecks((h) => ({ ...h, containerIgnore: e.target.value.split("\n").map((l) => l.trim()).filter(Boolean) }))}
/>
<div className="form-hint">The scanner containers Dockhand starts (dockhand-grype-*, dockhand-trivy-*) are always left alone. There is also a <em>Leave alone</em> button on the Docker page.</div>
<label className="form-check mt-3 mb-0">
<input type="checkbox" className="form-check-input" checked={healthChecks.vulnerabilityAlerts} onChange={(e) => setHealthChecks((h) => ({ ...h, vulnerabilityAlerts: e.target.checked }))} />
<span className="form-check-label">
Warn about critical vulnerabilities in Docker images
<span className="form-hint d-block">
From the scans Dockhand has already run (nothing is scanned from here): a warning for each Docker host whose scanned images have one or more critical findings. High, medium and low findings are shown on the Docker
page but never alerted. Dockhand can send its own vulnerability notifications too; with both switched on you hear twice.
</span>
</span>
</label>
</div>
</div>
</div>