Runbooks per alert kind, high-vulnerability threshold, wall display extras
A "What to do" note (text and/or link) can be written once for a whole kind of alert and shows beside every alert of that kind; alerts now carry their kind and source type. New optional setting: warn when a Docker host has N or more high vulnerabilities (off by default). The wall display gains tiles (Hetzner and game servers running, critical vulnerabilities, stuck downloads) and a summary line for each group of integrations, also in share links. Migration 0074; docs and tests included. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d9083adb5b
commit
3d9a2310bb
35 files changed
+9129
-30
No files matched your search
@@ -152,6 +152,22 @@ describe("the fake Dockhand", () => {
|
||||
assert.deepEqual(dv.dockerVulnProblems(id, [{ ...jackie, critical: 0, high: 50 }]), []);
|
||||
});
|
||||
|
||||
test("high findings are raised only when a number is set, from that many, and then beside the critical ones", async () => {
|
||||
const jackie = (await rows()).find((r) => r.environmentName === "Jackie")!;
|
||||
const many = { ...jackie, critical: 0, high: 12 };
|
||||
assert.deepEqual(dv.dockerVulnProblems(id, [many], 0), [], "off by default");
|
||||
assert.deepEqual(dv.dockerVulnProblems(id, [many]), [], "and with no number given");
|
||||
assert.deepEqual(dv.dockerVulnProblems(id, [many], 13), [], "below the number");
|
||||
const p = dv.dockerVulnProblems(id, [many], 10);
|
||||
assert.deepEqual(p.map((x) => [x.key, x.severity]), [[`docker-vuln-high:${id}:1`, "warning"]]);
|
||||
assert.equal(p[0].message, "Jackie: 12 high vulnerabilities in the scanned images (you asked to hear of 10 or more)");
|
||||
assert.equal(dv.dockerVulnProblems(id, [{ ...many, high: 12 }], 12).length, 1, "at the number counts");
|
||||
assert.deepEqual(dv.dockerVulnProblems(id, [{ ...many, high: 1 }], 1).map((x) => x.message), ["Jackie: 1 high vulnerability in the scanned images (you asked to hear of 1 or more)"]);
|
||||
assert.deepEqual(dv.dockerVulnProblems(id, [{ ...many, high: null }], 1), [], "an unknown count says nothing");
|
||||
const both = dv.dockerVulnProblems(id, [{ ...jackie, critical: 2, high: 40 }], 10);
|
||||
assert.deepEqual(both.map((x) => x.key), [`docker-vuln-high:${id}:1`, `docker-vuln:${id}:1`]);
|
||||
});
|
||||
|
||||
describe("the health pass, the Alerts page, the Docker page and /metrics", () => {
|
||||
let app: Server;
|
||||
let base = "";
|
||||
@@ -224,6 +240,30 @@ describe("the fake Dockhand", () => {
|
||||
assert.equal((await getSettings()).healthChecks.vulnerabilityAlerts, true);
|
||||
});
|
||||
|
||||
test("high findings: off by default (an old setting without the number is read as 0); with a number the host's high count is an alert of its own, under maintenance like the other", async () => {
|
||||
const checks = (await getSettings()).healthChecks;
|
||||
assert.equal(checks.vulnerabilityHighThreshold, 0);
|
||||
const { vulnerabilityHighThreshold: _dropped, ...older } = checks;
|
||||
await updateSettings({ healthChecks: older as never });
|
||||
assert.equal((await getSettings()).healthChecks.vulnerabilityHighThreshold, 0);
|
||||
const highIds = async () => {
|
||||
invalidateAlertsCache();
|
||||
return (await getAlerts(true)).alerts.map((x) => x.id).filter((i) => i.includes("docker-vuln-high:"));
|
||||
};
|
||||
assert.deepEqual(await highIds(), []);
|
||||
await updateSettings({ healthChecks: { ...checks, vulnerabilityHighThreshold: 5 } });
|
||||
assert.ok((await highIds()).includes(`services:docker-vuln-high:${id}:1`), "Jackie has 7 high findings");
|
||||
const a = (await getAlerts(true)).alerts.find((x) => x.id === `services:docker-vuln-high:${id}:1`)!;
|
||||
assert.deepEqual([a.severity, a.source, a.link, a.target?.type], ["warning", "Docker", "/docker", "integration"]);
|
||||
assert.match(a.message, /Jackie: 7 high vulnerabilities/);
|
||||
assert.equal(subjectOfConditionKey(`docker-vuln-high:${id}:1`), `integration:${id}`);
|
||||
await updateSettings({ healthChecks: { ...checks, vulnerabilityHighThreshold: 8 } });
|
||||
assert.ok(!(await highIds()).includes(`services:docker-vuln-high:${id}:1`), "7 is under 8");
|
||||
await updateSettings({ healthChecks: { ...checks, vulnerabilityAlerts: false, vulnerabilityHighThreshold: 5 } });
|
||||
assert.deepEqual(await highIds(), [], "the switch for the vulnerability alerts turns this off as well");
|
||||
await updateSettings({ healthChecks: checks });
|
||||
});
|
||||
|
||||
test("anyone signed in sees each host's counts, the critical findings and how many images are scanned", async () => {
|
||||
const body = (await (await fetch(`${base}/vulnerabilities`, { headers: { connection: "close" } })).json()) as { alerts: boolean; fresh: boolean; environments: { environmentName: string; critical: number; high: number; imagesScanned: number; totalImages: number; findings: { cve: string }[] }[] };
|
||||
assert.deepEqual([body.alerts, body.fresh], [true, true]);
|
||||
|
||||
Reference in new issue
Block a user