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

+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>
);
}