@astrofoundry/pi-astro 0.40.76 → 0.40.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/astro-discord/arcane-watch.test.ts +3 -3
- package/extensions/astro-discord/arcane-watch.ts +3 -3
- package/extensions/astro-discord/daily-report.test.ts +14 -14
- package/extensions/astro-discord/daily-report.ts +20 -20
- package/extensions/astro-discord/daily-run.test.ts +7 -7
- package/extensions/astro-discord/daily-run.ts +9 -9
- package/extensions/astro-discord/index.ts +7 -7
- package/extensions/astro-discord/security-monitor.test.ts +8 -8
- package/extensions/astro-discord/security-monitor.ts +15 -15
- package/extensions/astro-discord/security.test.ts +40 -40
- package/extensions/astro-discord/security.ts +39 -39
- package/extensions/astro-discord/supervise.test.ts +1 -1
- package/extensions/astro-discord/supervise.ts +2 -2
- package/extensions/astro-discord/tools-report.test.ts +6 -6
- package/extensions/astro-discord/tools-report.ts +12 -12
- package/package.json +1 -1
|
@@ -75,7 +75,7 @@ function texts(components: readonly MessageComponent[]): string[] {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
function posted(over: Partial<PostedAlert> = {}): PostedAlert {
|
|
78
|
-
return { messageId: "m1", channelId: "c1", key: alertKey(deploy), event: deploy, count: 1, repeat: "first
|
|
78
|
+
return { messageId: "m1", channelId: "c1", key: alertKey(deploy), event: deploy, count: 1, repeat: "first this week", postedAt: "2026-10-20T12:51:00Z", investigation: "none", ...over };
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
describe("security classification", () => {
|
|
@@ -123,7 +123,7 @@ describe("urgent alert message", () => {
|
|
|
123
123
|
[
|
|
124
124
|
"🚨 **Security alert** · level 10 · arcane · rule 100020",
|
|
125
125
|
"Deployment file changed: /opt/docker/grimoire/compose.yaml. Check against the approved GitOps change.",
|
|
126
|
-
"Seen 20 Oct 14:50 CEST · first
|
|
126
|
+
"Seen 20 Oct 14:50 CEST · first this week",
|
|
127
127
|
"-# file modified · origin unknown: no GitOps commit has this content",
|
|
128
128
|
`<@${OWNER}>`,
|
|
129
129
|
].join("\n"),
|
|
@@ -136,7 +136,7 @@ describe("urgent alert message", () => {
|
|
|
136
136
|
|
|
137
137
|
it("shows acknowledgement and investigation state on the buttons", () => {
|
|
138
138
|
const acked = alertComponents(posted({ ack: { by: OWNER, until: "2026-10-27T12:51:00Z" }, investigation: "running" }), [OWNER], TZ);
|
|
139
|
-
expect(acked[0].content).toContain(`-# ✅ Acknowledged by <@${OWNER}>; repeats
|
|
139
|
+
expect(acked[0].content).toContain(`-# ✅ Acknowledged by <@${OWNER}>; repeats muted until 27 Oct`);
|
|
140
140
|
expect(acked[1].components?.map((c) => [c.label, c.disabled ?? false])).toEqual([
|
|
141
141
|
["Investigating…", true],
|
|
142
142
|
["Acknowledged", true],
|
|
@@ -154,14 +154,14 @@ describe("urgent alert message", () => {
|
|
|
154
154
|
|
|
155
155
|
it("counts earlier pages of the same key this week", () => {
|
|
156
156
|
const now = Date.parse("2026-10-20T12:50:00Z");
|
|
157
|
-
expect(repeatText([], "k", now, 1, TZ)).toBe("first
|
|
158
|
-
expect(repeatText([], "k", now, 3, TZ)).toBe("first
|
|
157
|
+
expect(repeatText([], "k", now, 1, TZ)).toBe("first this week");
|
|
158
|
+
expect(repeatText([], "k", now, 3, TZ)).toBe("first this week · × 3 this check");
|
|
159
159
|
const earlier = [
|
|
160
160
|
{ key: "k", at: "2026-10-12T10:00:00Z" },
|
|
161
161
|
{ key: "k", at: "2026-10-19T10:00:00Z" },
|
|
162
162
|
{ key: "other", at: "2026-10-20T10:00:00Z" },
|
|
163
163
|
];
|
|
164
|
-
expect(repeatText(earlier, "k", now, 1, TZ)).toBe("
|
|
164
|
+
expect(repeatText(earlier, "k", now, 1, TZ)).toBe("2 times this week, last 19 Oct 12:00 CEST");
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
it("accepts only its own button ids", () => {
|
|
@@ -227,7 +227,7 @@ describe("health", () => {
|
|
|
227
227
|
expect(parseAttention({ bouncer: {} })).toBeNull();
|
|
228
228
|
expect(healthLine(parseAttention({ ...attention, health_issues: [] }))).toBe("Health · 7/8 Wazuh agents active · bouncer pulled 4 s ago");
|
|
229
229
|
expect(healthLine(parseAttention(attention))).toBe("Health · 1 issue · Wazuh agent dmz is Disconnected");
|
|
230
|
-
expect(healthLine(null)).toBe("Health ·
|
|
230
|
+
expect(healthLine(null)).toBe("Health · check failed");
|
|
231
231
|
});
|
|
232
232
|
|
|
233
233
|
it("tags only a new problem and reports recovery without a tag", () => {
|
|
@@ -238,7 +238,7 @@ describe("health", () => {
|
|
|
238
238
|
expect(healthChange(["wazuh-agent:dmz"], [dmz])).toBeNull();
|
|
239
239
|
expect(healthChange(["wazuh-agent:dmz"], [dmz, bouncer])?.mention).toBe(true);
|
|
240
240
|
expect(healthChange(["bouncer-stale:fd", "wazuh-agent:dmz"], [dmz])).toEqual({ text: "⚠️ **Security health changed:**\n- Wazuh agent dmz is Disconnected.", mention: false });
|
|
241
|
-
expect(healthChange(["wazuh-agent:dmz"], [])).toEqual({ text: "✅ **Security health recovered:**
|
|
241
|
+
expect(healthChange(["wazuh-agent:dmz"], [])).toEqual({ text: "✅ **Security health recovered:** all checks clear.", mention: false });
|
|
242
242
|
});
|
|
243
243
|
});
|
|
244
244
|
|
|
@@ -275,10 +275,10 @@ function summary(over: Partial<AlertSummary> = {}): AlertSummary {
|
|
|
275
275
|
describe("CrowdSec lines", () => {
|
|
276
276
|
it("summarises a day: bans, scenario, escalations, sources", () => {
|
|
277
277
|
expect(crowdsecDailyLine(summary())).toBe(
|
|
278
|
-
"CrowdSec · 19 bans, all front door SNI scanning · 2 repeat offenders
|
|
278
|
+
"CrowdSec · 19 bans, all front door SNI scanning · 2 repeat offenders banned longer: 1 × 7 days, 1 × 24 h · top sources: US 12, BE 3, BG 2; AS396982 GOOGLE-CLOUD-PLATFORM 8",
|
|
279
279
|
);
|
|
280
280
|
expect(crowdsecDailyLine(summary({ count: 0 }))).toBe("CrowdSec · no bans");
|
|
281
|
-
expect(crowdsecDailyLine(null)).toBe("CrowdSec ·
|
|
281
|
+
expect(crowdsecDailyLine(null)).toBe("CrowdSec · check failed");
|
|
282
282
|
expect(crowdsecDailyLine(summary({ scenarios: [{ scenario: "37pla/frontdoor-sni-scanning", count: 15 }, { scenario: "crowdsecurity/ssh-bf", count: 4 }], escalated: [], countries: [], networks: [] }))).toBe("CrowdSec · 19 bans, front door SNI scanning 15, ssh-bf 4");
|
|
283
283
|
});
|
|
284
284
|
|
|
@@ -286,7 +286,7 @@ describe("CrowdSec lines", () => {
|
|
|
286
286
|
expect(weekChange(121, 132)).toBe("−8 % vs last week");
|
|
287
287
|
expect(weekChange(132, 121)).toBe("+9 % vs last week");
|
|
288
288
|
expect(weekChange(10, 10)).toBe("±0 % vs last week");
|
|
289
|
-
expect(weekChange(5, null)).toBe("no earlier week
|
|
289
|
+
expect(weekChange(5, null)).toBe("no earlier week");
|
|
290
290
|
expect(weekChange(5, 0)).toBe("none last week");
|
|
291
291
|
expect(crowdsecWeeklyLine(summary({ count: 121, uniqueIps: 118, scenarios: [{ scenario: "37pla/frontdoor-sni-scanning", count: 121 }] }), 132)).toBe(
|
|
292
292
|
"CrowdSec · 121 bans (−8 % vs last week) · 118 IPs · longest: 1 × 7 days · scenarios: front door SNI scanning 100 % · top sources: US 12, BE 3, BG 2; AS396982 GOOGLE-CLOUD-PLATFORM 8",
|
|
@@ -311,7 +311,7 @@ describe("Wazuh digest", () => {
|
|
|
311
311
|
expect(digest.unacknowledged.map((e) => e.id)).toEqual(["d3"]);
|
|
312
312
|
expect(wazuhDigest([deploy, { ...deploy, id: "d2" }], origins, () => false).line).toBe("Wazuh · 2 alerts at level 10+, none urgent · deployment file changed on arcane × 2, both matched GitOps");
|
|
313
313
|
expect(wazuhDigest([], {}, () => false).line).toBe("Wazuh · no alerts at level 10+");
|
|
314
|
-
expect(wazuhDigest(null, {}, () => false)).toMatchObject({ line: "Wazuh ·
|
|
314
|
+
expect(wazuhDigest(null, {}, () => false)).toMatchObject({ line: "Wazuh · check failed", failed: true });
|
|
315
315
|
});
|
|
316
316
|
});
|
|
317
317
|
|
|
@@ -359,11 +359,11 @@ describe("vulnerabilities", () => {
|
|
|
359
359
|
vuln({ cve: "CVE-2025-68745", package: "linux-image-cloud-amd64", agent: "dmz", severity: "-", score: -1, condition: "Package default status" }),
|
|
360
360
|
vuln({ cve: "CVE-2025-68745", package: "linux-image-cloud-amd64", agent: "identity", severity: "-", score: -1, condition: "Package default status" }),
|
|
361
361
|
];
|
|
362
|
-
expect(vulnLine(found)).toBe("Host packages · 1 new CVE on 2 hosts, no
|
|
362
|
+
expect(vulnLine(found)).toBe("Host packages · 1 new CVE on 2 hosts, no fix yet · CVE-2025-68745 (linux-image-cloud-amd64) on dmz, identity");
|
|
363
363
|
expect(vulnLine([])).toBe("Host packages · no new CVEs");
|
|
364
|
-
expect(vulnLine(null)).toBe("Host packages ·
|
|
364
|
+
expect(vulnLine(null)).toBe("Host packages · check failed");
|
|
365
365
|
const many = ["A", "B", "C", "D"].map((c, i) => vuln({ cve: `CVE-${c}`, score: 5 + i }));
|
|
366
|
-
expect(vulnLine(many)).toBe("Host packages · 4 new CVEs on 1 host,
|
|
366
|
+
expect(vulnLine(many)).toBe("Host packages · 4 new CVEs on 1 host, all fixable · CVE-D (libfoo, High 8.0) on arcane · CVE-C (libfoo, High 7.0) on arcane · CVE-B (libfoo, High 6.0) on arcane · +1 more CVEs");
|
|
367
367
|
const closed = [
|
|
368
368
|
vuln({ agent: "frontdoor-1337", cve: "CVE-2026-50252", package: "libunbound8", version: "1.26.0-1", status: "Solved", severity: "Critical", score: 9.8 }),
|
|
369
369
|
vuln({ agent: "dmz", cve: "CVE-X", package: "openssl", version: "3.5.1", status: "Solved", score: 5 }),
|
|
@@ -430,15 +430,15 @@ describe("Arcane image scans", () => {
|
|
|
430
430
|
],
|
|
431
431
|
};
|
|
432
432
|
expect(imageVulnLine(facts, offers, "1549873938140499999")).toBe(
|
|
433
|
-
"Arcane images · 5 critical CVEs
|
|
433
|
+
"Arcane images · 5 fixable critical CVEs in 3 images · update offered in <#1549873938140499999>: mealie 3 (mealie) · held: postgres:15.8.1.085 1 (supabase: coordinated release: review first) · waiting on publisher: nginx 1",
|
|
434
434
|
);
|
|
435
435
|
expect(offeredImages(facts, offers)).toEqual(["mealie"]);
|
|
436
436
|
expect(offeredImages(null, offers)).toEqual([]);
|
|
437
|
-
expect(imageVulnLine(null, offers)).toBe("Arcane images ·
|
|
437
|
+
expect(imageVulnLine(null, offers)).toBe("Arcane images · check failed");
|
|
438
438
|
expect(imageVulnLine({ scanned: 0, total: 57, critical: [] }, offers)).toBe("Arcane images · no Trivy scan yet (57 images)");
|
|
439
|
-
expect(imageVulnLine({ ...facts, critical: facts.critical.slice(4) }, new Map(), undefined, 1)).toBe("Arcane images · 1 critical CVE
|
|
439
|
+
expect(imageVulnLine({ ...facts, critical: facts.critical.slice(4) }, new Map(), undefined, 1)).toBe("Arcane images · 1 fixable critical CVE in 1 image · waiting on publisher: nginx 1");
|
|
440
440
|
expect(imageVulnLine(facts, offers, undefined, 0)).toBe(
|
|
441
|
-
"Arcane images · 5 critical CVEs
|
|
441
|
+
"Arcane images · 5 fixable critical CVEs in 3 images · update offered in the Arcane Daily Report: mealie 3 (mealie) · held: postgres:15.8.1.085 1 (supabase: coordinated release: review first)",
|
|
442
442
|
);
|
|
443
443
|
});
|
|
444
444
|
|
|
@@ -466,7 +466,7 @@ describe("Arcane image scans", () => {
|
|
|
466
466
|
builds,
|
|
467
467
|
};
|
|
468
468
|
expect(imageVulnLine(facts, new Map(), undefined, 1)).toBe(
|
|
469
|
-
"Arcane images · 6 critical CVEs
|
|
469
|
+
"Arcane images · 6 fixable critical CVEs in 5 images · ours to rebuild: arcane-graphile-worker 2 (built 7 Sept, newer build in registry), bigcapital-redis:astrofoundry 1 (build date unknown), grimoire-server:v0.27.57 1 (built 21 Sept) · waiting on publisher: lidarr:pr-plugins 1, +1 more",
|
|
470
470
|
);
|
|
471
471
|
expect(shortImageName("postgres:18.6")).toBe("postgres:18.6");
|
|
472
472
|
});
|
|
@@ -496,11 +496,11 @@ describe("daily report", () => {
|
|
|
496
496
|
components: [
|
|
497
497
|
{ type: 10, content: "## 🛡️ Security Daily Report\n🟢 quiet day · 24 h to 06:00 CEST" },
|
|
498
498
|
{ type: 14, divider: true, spacing: 1 },
|
|
499
|
-
{ type: 10, content: "🚫 **CrowdSec** · 19 bans, all front door SNI scanning\n- 2 repeat offenders
|
|
499
|
+
{ type: 10, content: "🚫 **CrowdSec** · 19 bans, all front door SNI scanning\n- 2 repeat offenders banned longer: 1 × 7 days, 1 × 24 h\n- top sources: US 12, BE 3, BG 2; AS396982 GOOGLE-CLOUD-PLATFORM 8" },
|
|
500
500
|
{ type: 10, content: "👁️ **Wazuh** · no alerts at level 10+" },
|
|
501
501
|
{ type: 10, content: "📦 **Host packages** · no new CVEs" },
|
|
502
502
|
{ type: 10, content: "🩹 **Patches** · none" },
|
|
503
|
-
{ type: 10, content: "🐳 **Arcane images** · no critical CVE
|
|
503
|
+
{ type: 10, content: "🐳 **Arcane images** · no fixable critical CVE (57 of 57 images scanned)" },
|
|
504
504
|
{ type: 10, content: "🩺 **Health** · 8/8 Wazuh agents active\n- bouncer pulled 6 s ago" },
|
|
505
505
|
],
|
|
506
506
|
},
|
|
@@ -514,12 +514,12 @@ describe("daily report", () => {
|
|
|
514
514
|
const data = { until: "06:00 CEST", timeZone: TZ, crowdsec: null, wazuh, found: [], closed: [], attention, images: { scanned: 57, total: 57, critical: [] }, offers: new Map(), alerts: [{ key: alertKey(event({ rule: "5712" })), channelId: "c9" }] };
|
|
515
515
|
const report = dailyCard(data, [OWNER]);
|
|
516
516
|
expect(report.headline).toBe("1 urgent alert, 1 check failed (24 h to 06:00 CEST)");
|
|
517
|
-
expect(report.needs).toEqual(["urgent alert
|
|
517
|
+
expect(report.needs).toEqual(["unacknowledged urgent alert: brute force on arcane, 20 Oct 14:50 CEST; Acknowledge in <#c9>", "1 check failed; reason in the bridge log on Cortex"]);
|
|
518
518
|
expect(report.mention).toBe(true);
|
|
519
519
|
expect(report.components[0].accent_color).toBe(0xe67e22);
|
|
520
520
|
expect(texts(report.components).slice(0, 2)).toEqual([
|
|
521
521
|
"## 🛡️ Security Daily Report\n🟠 1 urgent alert, 1 check failed · 24 h to 06:00 CEST",
|
|
522
|
-
"### Needs you\n1. urgent alert
|
|
522
|
+
"### Needs you\n1. unacknowledged urgent alert: brute force on arcane, 20 Oct 14:50 CEST; Acknowledge in <#c9>\n2. 1 check failed; reason in the bridge log on Cortex",
|
|
523
523
|
]);
|
|
524
524
|
expect(report.components[1]).toEqual({ type: 10, content: `<@${OWNER}>` });
|
|
525
525
|
});
|
|
@@ -539,10 +539,10 @@ describe("daily report", () => {
|
|
|
539
539
|
{ id: "CVE-4", pkg: "d", image: "docker.io/library/redis:7", os: true },
|
|
540
540
|
];
|
|
541
541
|
const data = { until: "06:00 CEST", timeZone: TZ, crowdsec: summary(), wazuh, found: [], closed: [], attention, images: { scanned: 57, total: 57, critical, builds }, offers: new Map(), alerts: [{ key: alertKey(oom), channelId: "c9" }] };
|
|
542
|
-
expect(dailyNeeds(data)).toEqual(["urgent alert
|
|
542
|
+
expect(dailyNeeds(data)).toEqual(["unacknowledged urgent alert: System running out of memory. Availability of the system is in risk on space-x, 20 Oct 08:24 CEST; Acknowledge in <#c9>"]);
|
|
543
543
|
const linked = { ...data, guildId: "g1", alerts: [{ key: alertKey(oom), channelId: "c9", messageId: "m1" }, { key: alertKey(oom), channelId: "c9", messageId: "m2" }] };
|
|
544
|
-
expect(dailyNeeds(linked)).toEqual(["urgent alert
|
|
545
|
-
expect(rebuildItems(data.images)).toEqual(["rebuild app:1 (2):
|
|
544
|
+
expect(dailyNeeds(linked)).toEqual(["unacknowledged urgent alert: System running out of memory. Availability of the system is in risk on space-x, 20 Oct 08:24 CEST; Acknowledge on [the alert](https://discord.com/channels/g1/c9/m2)"]);
|
|
545
|
+
expect(rebuildItems(data.images)).toEqual(["rebuild app:1 (2): fixable critical CVEs in base image packages"]);
|
|
546
546
|
expect(dailyCard(data, [OWNER]).components[0].accent_color).toBe(0xe67e22);
|
|
547
547
|
});
|
|
548
548
|
});
|
|
@@ -579,10 +579,10 @@ describe("weekly report", () => {
|
|
|
579
579
|
"## 🛡️ Security Weekly Report · 13–19 Oct 2026\n🟢 no incident · nothing needs you",
|
|
580
580
|
"🚫 **CrowdSec** · 121 bans (−8 % vs last week)\n- 118 IPs\n- longest: 1 × 7 days\n- scenarios: front door SNI scanning 16 %\n- top sources: US 12, BE 3, BG 2; AS396982 GOOGLE-CLOUD-PLATFORM 8",
|
|
581
581
|
"👁️ **Wazuh** · no alerts at level 10+",
|
|
582
|
-
"📦 **Host packages** · 0 new CVEs\n- 0 closed by patches\n- 0 open with a
|
|
582
|
+
"📦 **Host packages** · 0 new CVEs\n- 0 closed by patches\n- 0 open with a fix",
|
|
583
583
|
"🩹 **Patching** · 14 package installs on 2 hosts\n- 0 CVEs closed\n- agent restarts: frontdoor-1337 19 Oct\n- reboot pending: none",
|
|
584
|
-
"🐳 **Arcane images** · no critical CVE
|
|
585
|
-
"🩺 **Health** · 8/8 Wazuh agents active\n- bouncer pulled 4 s ago\n- RADIUS CRL: no renewal warning (
|
|
584
|
+
"🐳 **Arcane images** · no fixable critical CVE (57 of 57 images scanned)",
|
|
585
|
+
"🩺 **Health** · 8/8 Wazuh agents active\n- bouncer pulled 4 s ago\n- RADIUS CRL: no renewal warning (warns 30 days ahead)",
|
|
586
586
|
"💾 **Backups** · Proxmox: the only guest backed up within 48 h, last 20 Oct 02:30 CEST\n- restic check: success 18 Oct 04:00",
|
|
587
587
|
"-# Last 24 h · 16 bans · 0 Wazuh alerts at level 10+ · 0 new CVEs · 2 CVEs closed · health ok",
|
|
588
588
|
]);
|
|
@@ -599,15 +599,15 @@ describe("weekly report", () => {
|
|
|
599
599
|
const shown = texts(out.components);
|
|
600
600
|
expect(shown[0]).toBe("## 🛡️ Security Weekly Report · 13–19 Oct 2026\n🟠 1 urgent alert · 6 items need you");
|
|
601
601
|
expect(shown[1]).toBe(
|
|
602
|
-
"### Needs you\n1. 1 unexplained deployment change this week; Investigate on the alert\n2. reboot dmz
|
|
602
|
+
"### Needs you\n1. 1 unexplained deployment change this week; Investigate on the alert\n2. reboot dmz for installed updates\n3. 1 fixable CVE open over 3 days (dmz); unattended-upgrades may be stuck\n4. renew the RADIUS CRL (`wifi-device.sh renew-crl`), 23 days left\n5. no Proxmox backup within 48 h for observability\n6. restic check ended with exit-code",
|
|
603
603
|
);
|
|
604
604
|
expect(out.components[0].components?.map((c) => c.type).slice(0, 5)).toEqual([10, 14, 10, 14, 10]);
|
|
605
605
|
expect(shown.join("\n")).toContain("- RADIUS CRL: renew within 23 days (warned 19 Oct)");
|
|
606
606
|
expect(out.components.at(-1)).toEqual({ type: 10, content: `<@${OWNER}>` });
|
|
607
607
|
const offers = imageOffers([{ stack: "mealie", lines: [{ ref: "ghcr.io/mealie-recipes/mealie:latest" }], actionable: true, state: "offered" }]);
|
|
608
608
|
const withImages = weeklyCard({ ...base, offers, images: { scanned: 57, total: 57, critical: [{ id: "CVE-9", pkg: "openssl", image: "ghcr.io/mealie-recipes/mealie:1", os: true }] } }, [OWNER]);
|
|
609
|
-
expect(texts(withImages.components)[1]).toBe("### Needs you\n1. update mealie in the Arcane Daily Report:
|
|
610
|
-
expect(needsYou({ ...base, images: null })).toEqual(["1 check
|
|
609
|
+
expect(texts(withImages.components)[1]).toBe("### Needs you\n1. update mealie in the Arcane Daily Report: replaces an image with a critical CVE");
|
|
610
|
+
expect(needsYou({ ...base, images: null })).toEqual(["1 check failed; reason in the bridge log on Cortex"]);
|
|
611
611
|
});
|
|
612
612
|
|
|
613
613
|
it("tells base-image rebuilds from dependency updates, and Mac CVEs from stuck unattended-upgrades", () => {
|
|
@@ -625,9 +625,9 @@ describe("weekly report", () => {
|
|
|
625
625
|
];
|
|
626
626
|
const mac: ReportedVuln = { agent: "CORTEX", cve: "CVE-10", package: "macOS", version: "26.7.2", severity: "High", score: 7, fix: true, since: "2026-10-10T00:00:00Z" };
|
|
627
627
|
expect(needsYou({ ...base, images: { scanned: 57, total: 57, critical }, openWithFix: [mac, { ...mac, agent: "NEXUS", cve: "CVE-11" }] })).toEqual([
|
|
628
|
-
"2 macOS CVEs open
|
|
629
|
-
"rebuild webapp:1 (1):
|
|
630
|
-
"update dependencies of server:1 (6: form-data, handlebars, proxy-addr, tar +1), grimoire-server:v1 (1: certifi) in their repositories:
|
|
628
|
+
"2 macOS CVEs open over 3 days on CORTEX, NEXUS: install the waiting macOS update",
|
|
629
|
+
"rebuild webapp:1 (1): fixable critical CVEs in base image packages",
|
|
630
|
+
"update dependencies of server:1 (6: form-data, handlebars, proxy-addr, tar +1), grimoire-server:v1 (1: certifi) in their repositories: fixable critical CVEs in language packages",
|
|
631
631
|
]);
|
|
632
632
|
expect(rebuildItems(null)).toEqual([]);
|
|
633
633
|
});
|
|
@@ -639,10 +639,10 @@ describe("weekly report", () => {
|
|
|
639
639
|
const brute = event({ id: "b1", rule: "5712", level: 12, description: "sshd: brute force trying to get access to the system." });
|
|
640
640
|
const wazuh = wazuhDigest([setup, test1, test2, brute], {}, (e) => e.id === "b1");
|
|
641
641
|
expect(needsYou({ ...base, wazuh, alerts: [{ key: alertKey(test1), channelId: "c9" }] })).toEqual([
|
|
642
|
-
"urgent alert never posted
|
|
643
|
-
"urgent alert
|
|
642
|
+
"urgent alert never posted (no Acknowledge button): `/etc/sudoers.d/spc-arcane` added on arcane, 19 Oct 23:31 CEST; check it was expected",
|
|
643
|
+
"unacknowledged urgent alert: `/etc/sudoers.d/zz-alert-test` deleted on arcane × 2, last 21 Oct 23:48 CEST; Acknowledge in <#c9>",
|
|
644
644
|
]);
|
|
645
|
-
expect(needsYou({ ...base, wazuh: wazuhDigest([brute], {}, () => false) })).toEqual(["urgent alert never posted
|
|
645
|
+
expect(needsYou({ ...base, wazuh: wazuhDigest([brute], {}, () => false) })).toEqual(["urgent alert never posted (no Acknowledge button): sshd: brute force trying to get access to the system on arcane, 20 Oct 14:50 CEST; check it was expected"]);
|
|
646
646
|
});
|
|
647
647
|
|
|
648
648
|
it("names the week before the Monday it is posted on", () => {
|
|
@@ -664,7 +664,7 @@ describe("weekly report", () => {
|
|
|
664
664
|
expect(resticStatus(`Result=success\nExecMainStartTimestamp=\nExecMainExitTimestamp=\n${timer}`)).toEqual({ result: "success", at: "8 Nov 02:25" });
|
|
665
665
|
expect(resticStatus("Result=success\nExecMainStartTimestamp=\n- - - - restic-check.timer restic-check.service\n")).toEqual({ result: "success", at: "never ran" });
|
|
666
666
|
expect(resticStatus("Result=success\nExecMainStartTimestamp=\nSun 2026-11-15 02:25:00 CET 5 days - - restic-check.timer restic-check.service\n")).toEqual({ result: "success", at: "never ran" });
|
|
667
|
-
expect(backupLine(null, 0, TZ)).toBe("Backups ·
|
|
667
|
+
expect(backupLine(null, 0, TZ)).toBe("Backups · check failed");
|
|
668
668
|
const crl = event({ rule: "100011", level: 10, timestamp: "2026-10-12T04:00:00.000+0000", log: "radius-crl-alert: days_remaining=30 threshold=30" });
|
|
669
669
|
expect(crlFromEvents([crl], Date.parse("2026-10-20T04:00:00Z"))).toEqual({ days: 22, warned: crl.timestamp });
|
|
670
670
|
expect(crlFromEvents([], 0)).toBeNull();
|
|
@@ -225,9 +225,9 @@ export function dayText(iso: string, timeZone: string): string {
|
|
|
225
225
|
/** How often this key paged in the last 7 days, before this check. */
|
|
226
226
|
export function repeatText(occurrences: SecurityState["occurrences"], key: string, now: number, count: number, timeZone: string): string {
|
|
227
227
|
const earlier = occurrences.filter((o) => o.key === key && Date.parse(o.at) >= now - 7 * DAY).map((o) => o.at).sort();
|
|
228
|
-
const here = count > 1 ? ` · × ${count}
|
|
229
|
-
if (earlier.length === 0) return `first
|
|
230
|
-
return
|
|
228
|
+
const here = count > 1 ? ` · × ${count} this check` : "";
|
|
229
|
+
if (earlier.length === 0) return `first this week${here}`;
|
|
230
|
+
return `${earlier.length + 1} times this week, last ${clockText(earlier[earlier.length - 1], timeZone)}${here}`;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
function mentionLine(owners: readonly string[]): string {
|
|
@@ -244,7 +244,7 @@ export function alertText(alert: PostedAlert, owners: readonly string[], timeZon
|
|
|
244
244
|
if (e.path) lines.push(`-# file ${escapeDiscord(e.event ?? "changed")}${alert.origin ? ` · origin ${alert.origin.verdict}: ${escapeDiscord(alert.origin.reason)}` : ""}`);
|
|
245
245
|
else if (e.log) lines.push(`-# ${escapeDiscord(firstLine(e.log).slice(0, 200))}`);
|
|
246
246
|
lines.push(mentionLine(owners));
|
|
247
|
-
if (alert.ack) lines.push(`-# ✅ Acknowledged by <@${alert.ack.by}>; repeats
|
|
247
|
+
if (alert.ack) lines.push(`-# ✅ Acknowledged by <@${alert.ack.by}>; repeats muted until ${dayText(alert.ack.until, timeZone)}`);
|
|
248
248
|
return lines.join("\n");
|
|
249
249
|
}
|
|
250
250
|
|
|
@@ -334,24 +334,24 @@ export function healthChange(previous: string[] | null, issues: readonly HealthI
|
|
|
334
334
|
const codes = issues.map((i) => i.code).sort();
|
|
335
335
|
if (previous === null && codes.length === 0) return null;
|
|
336
336
|
if (previous !== null && previous.length === codes.length && previous.every((c, i) => c === codes[i])) return null;
|
|
337
|
-
if (codes.length === 0) return { text: "✅ **Security health recovered:**
|
|
337
|
+
if (codes.length === 0) return { text: "✅ **Security health recovered:** all checks clear.", mention: false };
|
|
338
338
|
const list = issues.map((i) => `- ${escapeDiscord(i.message)}`).join("\n");
|
|
339
339
|
const added = previous === null || codes.some((c) => !previous.includes(c));
|
|
340
340
|
return { text: `⚠️ **Security health${previous === null ? "" : " changed"}:**\n${list}`, mention: added };
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
export function checksFailingText(what: string, minutes: number, reason: string): string {
|
|
344
|
-
return `⚠️ **Security checks failing:**
|
|
344
|
+
return `⚠️ **Security checks failing:** ${what} unreadable for ${minutes} min (${escapeDiscord(reason.slice(0, 200))}). Urgent alerts unchecked meanwhile; details in the specialist log on Cortex.`;
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
export function checksRecoveredText(what: string): string {
|
|
348
|
-
return `✅ **Security checks** read ${what} again;
|
|
348
|
+
return `✅ **Security checks** read ${what} again; the gap is checked now.`;
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
export function healthLine(a: Attention | null): string {
|
|
352
|
-
if (!a) return "Health ·
|
|
352
|
+
if (!a) return "Health · check failed";
|
|
353
353
|
if (a.issues.length > 0) return `Health · ${a.issues.length} issue${a.issues.length === 1 ? "" : "s"} · ${a.issues.map((i) => escapeDiscord(i.message.replace(/\.$/, ""))).join(" · ")}`;
|
|
354
|
-
const pull = a.oldestPullSeconds === null ? "no bouncer pull
|
|
354
|
+
const pull = a.oldestPullSeconds === null ? "no bouncer pull" : `bouncer pulled ${a.oldestPullSeconds} s ago`;
|
|
355
355
|
return `Health · ${a.agentsActive ?? "?"}/${a.agentsTotal ?? "?"} Wazuh agents active · ${pull}`;
|
|
356
356
|
}
|
|
357
357
|
|
|
@@ -374,27 +374,27 @@ function sources(s: AlertSummary): string {
|
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
export function crowdsecDailyLine(s: AlertSummary | null): string {
|
|
377
|
-
if (!s) return "CrowdSec ·
|
|
377
|
+
if (!s) return "CrowdSec · check failed";
|
|
378
378
|
if (s.count === 0) return "CrowdSec · no bans";
|
|
379
379
|
const scenarios = s.scenarios.length === 1 ? `all ${scenarioLabel(s.scenarios[0].scenario)}` : s.scenarios.slice(0, 3).map((x) => `${scenarioLabel(x.scenario)} ${x.count}`).join(", ");
|
|
380
380
|
const lengths = new Map<string, number>();
|
|
381
381
|
for (const e of s.escalated) lengths.set(e.ban, (lengths.get(e.ban) ?? 0) + 1);
|
|
382
382
|
const order = (len: string) => s.bans.find((b) => b.length === len)?.hours ?? 0;
|
|
383
383
|
const escalated = [...lengths.entries()].sort((x, y) => order(y[0]) - order(x[0])).map(([len, n]) => `${n} × ${len}`);
|
|
384
|
-
const repeat = s.escalated.length === 0 ? "" : ` · ${s.escalated.length} repeat offender${s.escalated.length === 1 ? "" : "s"}
|
|
384
|
+
const repeat = s.escalated.length === 0 ? "" : ` · ${s.escalated.length} repeat offender${s.escalated.length === 1 ? "" : "s"} banned longer: ${escalated.join(", ")}`;
|
|
385
385
|
return `CrowdSec · ${s.count} ban${s.count === 1 ? "" : "s"}, ${escapeDiscord(scenarios)}${repeat}${sources(s)}`;
|
|
386
386
|
}
|
|
387
387
|
|
|
388
388
|
/** `−8 %` against the previous week, or why there is no comparison. */
|
|
389
389
|
export function weekChange(count: number, previous: number | null): string {
|
|
390
|
-
if (previous === null) return "no earlier week
|
|
390
|
+
if (previous === null) return "no earlier week";
|
|
391
391
|
if (previous === 0) return count === 0 ? "none last week either" : "none last week";
|
|
392
392
|
const pct = Math.round(((count - previous) / previous) * 100);
|
|
393
393
|
return `${pct > 0 ? "+" : pct < 0 ? "−" : "±"}${Math.abs(pct)} % vs last week`;
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
export function crowdsecWeeklyLine(s: AlertSummary | null, previous: number | null): string {
|
|
397
|
-
if (!s) return "CrowdSec ·
|
|
397
|
+
if (!s) return "CrowdSec · check failed";
|
|
398
398
|
if (s.count === 0) return `CrowdSec · no bans (${weekChange(0, previous)})`;
|
|
399
399
|
const longest = s.bans[s.bans.length - 1];
|
|
400
400
|
const scenarios = s.scenarios.map((x) => `${scenarioLabel(x.scenario)} ${Math.round((x.count / s.count) * 100)} %`).join(", ");
|
|
@@ -418,12 +418,12 @@ export interface WazuhDigest {
|
|
|
418
418
|
|
|
419
419
|
function originCount(n: number, of: number): string {
|
|
420
420
|
if (n === of) return of === 1 ? "matched GitOps" : of === 2 ? "both matched GitOps" : "all matched GitOps";
|
|
421
|
-
return n === 0 ?
|
|
421
|
+
return n === 0 ? (of === 1 ? "unexplained" : "all unexplained") : `${n} matched GitOps, ${of - n} unexplained`;
|
|
422
422
|
}
|
|
423
423
|
|
|
424
424
|
/** The Wazuh line of a report: alerts at level 10 or higher, grouped by issue and agent, urgent ones first. */
|
|
425
425
|
export function wazuhDigest(events: readonly WazuhEvent[] | null, origins: SecurityState["origins"], acked: (e: WazuhEvent) => boolean, maxGroups = 4): WazuhDigest {
|
|
426
|
-
if (!events) return { line: "Wazuh ·
|
|
426
|
+
if (!events) return { line: "Wazuh · check failed", failed: true, count: 0, urgent: 0, unacknowledged: [], open: [], unexplained: [] };
|
|
427
427
|
if (events.length === 0) return { line: "Wazuh · no alerts at level 10+", failed: false, count: 0, urgent: 0, unacknowledged: [], open: [], unexplained: [] };
|
|
428
428
|
const groups = new Map<string, { label: string; agent: string; events: WazuhEvent[]; urgent: number; known: number }>();
|
|
429
429
|
let urgent = 0;
|
|
@@ -526,7 +526,7 @@ function severityText(e: { severity: string; score: number | null }): string {
|
|
|
526
526
|
}
|
|
527
527
|
|
|
528
528
|
export function vulnLine(found: readonly VulnEvent[] | null, maxShown = 3): string {
|
|
529
|
-
if (!found) return "Host packages ·
|
|
529
|
+
if (!found) return "Host packages · check failed";
|
|
530
530
|
if (found.length === 0) return "Host packages · no new CVEs";
|
|
531
531
|
const byCve = new Map<string, { e: VulnEvent; hosts: string[]; fix: boolean }>();
|
|
532
532
|
for (const e of found) {
|
|
@@ -544,13 +544,13 @@ export function vulnLine(found: readonly VulnEvent[] | null, maxShown = 3): stri
|
|
|
544
544
|
});
|
|
545
545
|
const more = groups.length > maxShown ? ` · +${groups.length - maxShown} more CVEs` : "";
|
|
546
546
|
const fixes = groups.filter((g) => g.fix).length;
|
|
547
|
-
const fixText = fixes === 0 ? "no
|
|
547
|
+
const fixText = fixes === 0 ? "no fix yet" : fixes === groups.length ? "all fixable" : `${fixes} fixable`;
|
|
548
548
|
const hosts = new Set(found.map((e) => e.agent)).size;
|
|
549
549
|
return `Host packages · ${groups.length} new CVE${groups.length === 1 ? "" : "s"} on ${hosts} host${hosts === 1 ? "" : "s"}, ${fixText} · ${shown.join(" · ")}${more}`;
|
|
550
550
|
}
|
|
551
551
|
|
|
552
552
|
export function patchLine(closed: readonly VulnEvent[] | null, label = "Patches", maxShown = 3): string {
|
|
553
|
-
if (!closed) return `${label} ·
|
|
553
|
+
if (!closed) return `${label} · check failed`;
|
|
554
554
|
if (closed.length === 0) return `${label} · none`;
|
|
555
555
|
const byPackage = new Map<string, { agent: string; pkg: string; version: string; cves: VulnEvent[] }>();
|
|
556
556
|
for (const e of closed) {
|
|
@@ -686,7 +686,7 @@ export function shortImageName(image: string): string {
|
|
|
686
686
|
|
|
687
687
|
function buildText(build: ImageBuild | undefined): string {
|
|
688
688
|
const built = build?.created ? `built ${new Intl.DateTimeFormat("en-GB", { timeZone: "UTC", day: "numeric", month: "short" }).format(new Date(build.created * 1000))}` : "build date unknown";
|
|
689
|
-
return build?.newer ? `${built},
|
|
689
|
+
return build?.newer ? `${built}, newer build in registry` : built;
|
|
690
690
|
}
|
|
691
691
|
|
|
692
692
|
/**
|
|
@@ -696,9 +696,9 @@ function buildText(build: ImageBuild | undefined): string {
|
|
|
696
696
|
* A `maxWaiting` of 0 leaves the publisher group out: nobody here can act on it.
|
|
697
697
|
*/
|
|
698
698
|
export function imageVulnLine(facts: ImageVulnFacts | null, offers: ReadonlyMap<string, ImageOffer>, arcaneChannelId?: string, maxWaiting = 5): string {
|
|
699
|
-
if (!facts) return "Arcane images ·
|
|
699
|
+
if (!facts) return "Arcane images · check failed";
|
|
700
700
|
if (facts.scanned === 0) return `Arcane images · no Trivy scan yet (${facts.total} images)`;
|
|
701
|
-
if (facts.critical.length === 0) return `Arcane images · no critical CVE
|
|
701
|
+
if (facts.critical.length === 0) return `Arcane images · no fixable critical CVE (${facts.scanned} of ${facts.total} images scanned)`;
|
|
702
702
|
const counts = new Map<string, number>();
|
|
703
703
|
for (const v of facts.critical) counts.set(v.image, (counts.get(v.image) ?? 0) + 1);
|
|
704
704
|
const images = [...counts.entries()].sort((x, y) => y[1] - x[1] || x[0].localeCompare(y[0]));
|
|
@@ -715,12 +715,12 @@ export function imageVulnLine(facts: ImageVulnFacts | null, offers: ReadonlyMap<
|
|
|
715
715
|
else waiting.push(name);
|
|
716
716
|
}
|
|
717
717
|
const n = facts.critical.length;
|
|
718
|
-
const parts = [`Arcane images · ${n} critical CVE${n === 1 ? "" : "s"}
|
|
718
|
+
const parts = [`Arcane images · ${n} fixable critical CVE${n === 1 ? "" : "s"} in ${images.length} image${images.length === 1 ? "" : "s"}`];
|
|
719
719
|
if (own.length > 0) parts.push(`ours to rebuild: ${own.join(", ")}`);
|
|
720
720
|
if (offered.length > 0) parts.push(`update offered${arcaneChannelId ? ` in <#${arcaneChannelId}>` : " in the Arcane Daily Report"}: ${offered.join(", ")}`);
|
|
721
721
|
if (held.length > 0) parts.push(`held: ${held.join(", ")}`);
|
|
722
722
|
const rest = waiting.length - Math.min(waiting.length, maxWaiting);
|
|
723
|
-
if (waiting.length > 0 && maxWaiting > 0) parts.push(`waiting on
|
|
723
|
+
if (waiting.length > 0 && maxWaiting > 0) parts.push(`waiting on publisher: ${[...waiting.slice(0, maxWaiting), ...(rest > 0 ? [`+${rest} more`] : [])].join(", ")}`);
|
|
724
724
|
return parts.join(" · ");
|
|
725
725
|
}
|
|
726
726
|
|
|
@@ -750,14 +750,14 @@ export function rebuildItems(facts: ImageVulnFacts | null): string[] {
|
|
|
750
750
|
}
|
|
751
751
|
const byCount = <T>(m: Map<string, T>, count: (t: T) => number) => [...m.entries()].sort((x, y) => count(y[1]) - count(x[1]) || x[0].localeCompare(y[0]));
|
|
752
752
|
const items: string[] = [];
|
|
753
|
-
if (os.size > 0) items.push(`rebuild ${byCount(os, (n) => n).map(([image, n]) => `${escapeDiscord(shortImageName(image))} (${n})`).join(", ")}:
|
|
753
|
+
if (os.size > 0) items.push(`rebuild ${byCount(os, (n) => n).map(([image, n]) => `${escapeDiscord(shortImageName(image))} (${n})`).join(", ")}: fixable critical CVEs in base image packages`);
|
|
754
754
|
if (lang.size > 0) {
|
|
755
755
|
const images = byCount(lang, (e) => e.n).map(([image, e]) => {
|
|
756
756
|
const pkgs = [...e.pkgs].sort();
|
|
757
757
|
const shown = pkgs.slice(0, MAX_PACKAGES).map(escapeDiscord).join(", ");
|
|
758
758
|
return `${escapeDiscord(shortImageName(image))} (${e.n}: ${shown}${pkgs.length > MAX_PACKAGES ? ` +${pkgs.length - MAX_PACKAGES}` : ""})`;
|
|
759
759
|
});
|
|
760
|
-
items.push(`update dependencies of ${images.join(", ")} in their repositories:
|
|
760
|
+
items.push(`update dependencies of ${images.join(", ")} in their repositories: fixable critical CVEs in language packages`);
|
|
761
761
|
}
|
|
762
762
|
return items;
|
|
763
763
|
}
|
|
@@ -843,7 +843,7 @@ export function dailyNeeds(d: DailyData): string[] {
|
|
|
843
843
|
if (d.wazuh.unexplained.length > 0) items.push(`${d.wazuh.unexplained.length} unexplained deployment change${d.wazuh.unexplained.length === 1 ? "" : "s"}; Investigate on the alert`);
|
|
844
844
|
items.push(...unacknowledgedItems(d.wazuh, d.alerts, d.timeZone, d.guildId));
|
|
845
845
|
const failed = failures(d);
|
|
846
|
-
if (failed > 0) items.push(`${failed} check${failed === 1 ? "" : "s"}
|
|
846
|
+
if (failed > 0) items.push(`${failed} check${failed === 1 ? "" : "s"} failed; reason in the bridge log on Cortex`);
|
|
847
847
|
return items;
|
|
848
848
|
}
|
|
849
849
|
|
|
@@ -952,7 +952,7 @@ export function resticStatus(text: string): BackupFacts["restic"] {
|
|
|
952
952
|
const STALE_BACKUP_S = 48 * 3600;
|
|
953
953
|
|
|
954
954
|
export function backupLine(b: BackupFacts | null, now: number, timeZone: string): string {
|
|
955
|
-
if (!b) return "Backups ·
|
|
955
|
+
if (!b) return "Backups · check failed";
|
|
956
956
|
const stale = b.guests.filter((g) => now / 1000 - g.last > STALE_BACKUP_S);
|
|
957
957
|
const newest = Math.max(...b.guests.map((g) => g.last));
|
|
958
958
|
const proxmox =
|
|
@@ -966,7 +966,7 @@ export function backupLine(b: BackupFacts | null, now: number, timeZone: string)
|
|
|
966
966
|
}
|
|
967
967
|
|
|
968
968
|
export function patchingLine(p: PatchingFacts | null, closed: readonly VulnEvent[] | null, timeZone: string): string {
|
|
969
|
-
if (!p) return "Patching ·
|
|
969
|
+
if (!p) return "Patching · check failed";
|
|
970
970
|
const installs = p.installs.reduce((n, i) => n + i.count, 0);
|
|
971
971
|
const cves = closed === null ? "" : ` · ${new Set(closed.map((c) => `${c.agent}|${c.cve}`)).size} CVEs closed`;
|
|
972
972
|
const restarts = p.restarts.length === 0 ? "none" : p.restarts.map((r) => `${escapeDiscord(r.agent)} ${dayText(r.last, timeZone)}`).join(", ");
|
|
@@ -985,7 +985,7 @@ export function crlFromEvents(events: readonly WazuhEvent[], now: number): { day
|
|
|
985
985
|
|
|
986
986
|
function crlText(crl: WeeklyData["crl"], timeZone: string): string {
|
|
987
987
|
if (crl === "unknown") return "RADIUS CRL: unknown";
|
|
988
|
-
if (crl === null) return "RADIUS CRL: no renewal warning (
|
|
988
|
+
if (crl === null) return "RADIUS CRL: no renewal warning (warns 30 days ahead)";
|
|
989
989
|
return `RADIUS CRL: renew within ${crl.days} days (warned ${dayText(crl.warned, timeZone)})`;
|
|
990
990
|
}
|
|
991
991
|
|
|
@@ -999,9 +999,9 @@ function unacknowledgedItems(wazuh: WazuhDigest, alerts: readonly PostedAlertRef
|
|
|
999
999
|
const when = events.length > 1 ? ` × ${events.length}, last ${clockText(last.timestamp, timeZone)}` : `, ${clockText(last.timestamp, timeZone)}`;
|
|
1000
1000
|
const posted = alerts.filter((a) => a.key === key).at(-1);
|
|
1001
1001
|
const fact = `${what} on ${escapeDiscord(last.agent)}${when}`;
|
|
1002
|
-
if (!posted) return `urgent alert never posted
|
|
1002
|
+
if (!posted) return `urgent alert never posted (no Acknowledge button): ${fact}; check it was expected`;
|
|
1003
1003
|
const where = guildId && posted.messageId ? `on [the alert](https://discord.com/channels/${guildId}/${posted.channelId}/${posted.messageId})` : `in <#${posted.channelId}>`;
|
|
1004
|
-
return `urgent alert
|
|
1004
|
+
return `unacknowledged urgent alert: ${fact}; Acknowledge ${where}`;
|
|
1005
1005
|
});
|
|
1006
1006
|
}
|
|
1007
1007
|
|
|
@@ -1013,25 +1013,25 @@ export function needsYou(d: WeeklyData): string[] {
|
|
|
1013
1013
|
for (const i of d.attention?.issues ?? []) items.push(escapeDiscord(i.message.replace(/\.$/, "")));
|
|
1014
1014
|
if (d.wazuh.unexplained.length > 0) items.push(`${d.wazuh.unexplained.length} unexplained deployment change${d.wazuh.unexplained.length === 1 ? "" : "s"} this week; Investigate on the alert`);
|
|
1015
1015
|
items.push(...unacknowledgedItems(d.wazuh, d.alerts, d.timeZone, d.guildId));
|
|
1016
|
-
if (d.patching && d.patching.rebootPending.length > 0) items.push(`reboot ${d.patching.rebootPending.map(escapeDiscord).join(", ")}
|
|
1016
|
+
if (d.patching && d.patching.rebootPending.length > 0) items.push(`reboot ${d.patching.rebootPending.map(escapeDiscord).join(", ")} for installed updates`);
|
|
1017
1017
|
const stuck = d.openWithFix.filter((v) => d.now - Date.parse(v.since) > 3 * DAY);
|
|
1018
1018
|
const agents = (list: readonly ReportedVuln[]) => [...new Set(list.map((v) => v.agent))].map(escapeDiscord).join(", ");
|
|
1019
1019
|
// Wazuh reports a Mac's own CVEs under the package `macOS`; only a macOS update closes them, never unattended-upgrades.
|
|
1020
1020
|
const mac = stuck.filter((v) => v.package === MACOS_PACKAGE);
|
|
1021
1021
|
const linux = stuck.filter((v) => v.package !== MACOS_PACKAGE);
|
|
1022
|
-
if (linux.length > 0) items.push(`${linux.length} CVE${linux.length === 1 ? "" : "s"}
|
|
1023
|
-
if (mac.length > 0) items.push(`${mac.length} macOS CVE${mac.length === 1 ? "" : "s"} open
|
|
1022
|
+
if (linux.length > 0) items.push(`${linux.length} fixable CVE${linux.length === 1 ? "" : "s"} open over 3 days (${agents(linux)}); unattended-upgrades may be stuck`);
|
|
1023
|
+
if (mac.length > 0) items.push(`${mac.length} macOS CVE${mac.length === 1 ? "" : "s"} open over 3 days on ${agents(mac)}: install the waiting macOS update`);
|
|
1024
1024
|
const offered = offeredImages(d.images, d.offers);
|
|
1025
|
-
if (offered.length > 0) items.push(`update ${offered.map(escapeDiscord).join(", ")} in the Arcane Daily Report:
|
|
1025
|
+
if (offered.length > 0) items.push(`update ${offered.map(escapeDiscord).join(", ")} in the Arcane Daily Report: replaces an image with a critical CVE`);
|
|
1026
1026
|
items.push(...rebuildItems(d.images));
|
|
1027
|
-
if (d.crl !== null && d.crl !== "unknown") items.push(`renew the RADIUS CRL (wifi-device.sh renew-crl), ${d.crl.days} days left`);
|
|
1027
|
+
if (d.crl !== null && d.crl !== "unknown") items.push(`renew the RADIUS CRL (\`wifi-device.sh renew-crl\`), ${d.crl.days} days left`);
|
|
1028
1028
|
if (d.backups) {
|
|
1029
1029
|
const stale = d.backups.guests.filter((g) => d.now / 1000 - g.last > STALE_BACKUP_S);
|
|
1030
1030
|
if (stale.length > 0) items.push(`no Proxmox backup within 48 h for ${stale.map((g) => escapeDiscord(g.name)).join(", ")}`);
|
|
1031
|
-
if (d.backups.restic && d.backups.restic.result !== "success") items.push(`
|
|
1031
|
+
if (d.backups.restic && d.backups.restic.result !== "success") items.push(`restic check ended with ${escapeDiscord(d.backups.restic.result)}`);
|
|
1032
1032
|
}
|
|
1033
1033
|
const failed = [d.crowdsec === null, d.wazuh.failed, d.found === null, d.patching === null, d.attention === null, d.backups === null, d.images === null].filter(Boolean).length;
|
|
1034
|
-
if (failed > 0) items.push(`${failed} check${failed === 1 ? "" : "s"}
|
|
1034
|
+
if (failed > 0) items.push(`${failed} check${failed === 1 ? "" : "s"} failed; reason in the bridge log on Cortex`);
|
|
1035
1035
|
return items;
|
|
1036
1036
|
}
|
|
1037
1037
|
|
|
@@ -1054,7 +1054,7 @@ export function weeklyCard(d: WeeklyData, owners: readonly string[]): ReportCard
|
|
|
1054
1054
|
const sections = [
|
|
1055
1055
|
section("🚫", crowdsecWeeklyLine(d.crowdsec, d.previousBans)),
|
|
1056
1056
|
section("👁️", d.wazuh.line),
|
|
1057
|
-
section("📦", `Host packages · ${found} · ${closed} · ${fixable} open with a
|
|
1057
|
+
section("📦", `Host packages · ${found} · ${closed} · ${fixable} open with a fix${tracking}`),
|
|
1058
1058
|
section("🩹", patchingLine(d.patching, d.closed, d.timeZone)),
|
|
1059
1059
|
section("🐳", imageVulnLine(d.images, d.offers, d.arcaneChannelId)),
|
|
1060
1060
|
section("🩺", `${healthLine(d.attention)} · ${crlText(d.crl, d.timeZone)}`),
|
|
@@ -26,7 +26,7 @@ describe("supervision", () => {
|
|
|
26
26
|
it("tags the owners and hands the foreman a read-only task with the evidence to collect", () => {
|
|
27
27
|
const applied = { stack: "media", finishedAt: Date.parse("2026-10-24T03:05:00Z"), detail: "updated: sonarr 4.0.21", commit: "abc1234" };
|
|
28
28
|
expect(autoFailureText(applied, ["sonarr unhealthy"], "Rolled back to the previous Compose file.", ["178096425509453824"])).toBe(
|
|
29
|
-
"⚠️ **Automatic update failed its check** · media · updated: sonarr 4.0.21\
|
|
29
|
+
"⚠️ **Automatic update failed its check** · media · updated: sonarr 4.0.21\nRecheck found: sonarr unhealthy.\nRolled back to the previous Compose file.\nThe foreman investigates read-only in the thread.\n<@178096425509453824>",
|
|
30
30
|
);
|
|
31
31
|
const task = foremanTask(applied, ["sonarr unhealthy"], "rolled back", Date.parse("2026-10-24T03:10:00Z"));
|
|
32
32
|
expect(task).toContain("host container-logs <name> 2026-10-24T02:35:00.000Z 2026-10-24T03:10:00.000Z");
|
|
@@ -41,9 +41,9 @@ export function stackProblems(snapshot: readonly WatchedContainer[], stack: stri
|
|
|
41
41
|
export function autoFailureText(applied: Applied, problems: readonly string[], rollback: string, owners: readonly string[]): string {
|
|
42
42
|
return [
|
|
43
43
|
`⚠️ **Automatic update failed its check** · ${escapeDiscord(applied.stack)} · ${escapeDiscord(applied.detail)}`,
|
|
44
|
-
`
|
|
44
|
+
`Recheck found: ${problems.map(escapeDiscord).join(", ")}.`,
|
|
45
45
|
rollback,
|
|
46
|
-
"The foreman investigates in the thread
|
|
46
|
+
"The foreman investigates read-only in the thread.",
|
|
47
47
|
owners.map((id) => `<@${id}>`).join(" "),
|
|
48
48
|
].join("\n");
|
|
49
49
|
}
|
|
@@ -129,7 +129,7 @@ describe("casks whose installer needs a password", () => {
|
|
|
129
129
|
const chrome = lines.find((l) => l.key === "cask:google-chrome");
|
|
130
130
|
expect(temurin?.manual).toContain("brew upgrade --cask temurin@17");
|
|
131
131
|
expect(chrome?.manual).toBeUndefined();
|
|
132
|
-
expect(lineText(temurin as ToolLine)).toContain("
|
|
132
|
+
expect(lineText(temurin as ToolLine)).toContain("needs your password");
|
|
133
133
|
expect(brewHasOutdated(outdated)).toBe(false);
|
|
134
134
|
});
|
|
135
135
|
});
|
|
@@ -292,13 +292,13 @@ describe("report layout", () => {
|
|
|
292
292
|
const report = sampleReport([], false);
|
|
293
293
|
const pages = layoutMessages(report);
|
|
294
294
|
expect(pages).toEqual([{ keys: [], head: true, all: false }]);
|
|
295
|
-
expect(messageComponents(report, pages[0])).toEqual([{ type: 10, content: "**Cortex Tools Report:**
|
|
295
|
+
expect(messageComponents(report, pages[0])).toEqual([{ type: 10, content: "**Cortex Tools Report:** all up to date (checked 06:00 CEST)." }]);
|
|
296
296
|
});
|
|
297
297
|
|
|
298
298
|
it("shows the review, a major change, and each button state", () => {
|
|
299
299
|
const [pi] = buildLines(COLLECTED);
|
|
300
300
|
pi.review = { verdict: "breaking", reason: "Removes the `--tools` flag in favor of `--allow`" };
|
|
301
|
-
expect(lineText(pi)).toBe("**Pi** 0.87.1 → 1.3.0 · major
|
|
301
|
+
expect(lineText(pi)).toBe("**Pi** 0.87.1 → 1.3.0 · major\n-# 🔴 breaking: Removes the \\`--tools\\` flag in favor of \\`--allow\\`");
|
|
302
302
|
const report = sampleReport([pi]);
|
|
303
303
|
const page = layoutMessages(report)[0];
|
|
304
304
|
const button = () => messageComponents(report, page)[1].accessory;
|
|
@@ -322,7 +322,7 @@ describe("report layout", () => {
|
|
|
322
322
|
const components = messageComponents(report, page);
|
|
323
323
|
expect(components[2].accessory).toMatchObject({ label: "Automatic", disabled: true });
|
|
324
324
|
expect(components[0].content).toContain("\n-# 1 update applies automatically; Pi waits for its button.");
|
|
325
|
-
expect(components[0].content).toContain("\n<@178096425509453824> 1 update needs you: Pi (major
|
|
325
|
+
expect(components[0].content).toContain("\n<@178096425509453824> 1 update needs you: Pi (major)");
|
|
326
326
|
pi.plan = "button";
|
|
327
327
|
expect(messageComponents(report, page)[0].content).not.toContain("<@");
|
|
328
328
|
jq.state = "running";
|
|
@@ -382,13 +382,13 @@ describe("release-notes review", () => {
|
|
|
382
382
|
|
|
383
383
|
it("says why there is nothing to review", async () => {
|
|
384
384
|
const gcloud = buildLines(COLLECTED).find((l) => l.key === "spc:gcloud") as ToolLine;
|
|
385
|
-
expect(await notesFor(gcloud, fetch)).toEqual({ notes: null, reason: "no release notes
|
|
385
|
+
expect(await notesFor(gcloud, fetch)).toEqual({ notes: null, reason: "no release notes here; see https://cloud.google.com/sdk/docs/release-notes" });
|
|
386
386
|
const trendarr: ToolLine = { key: "spc:trendarr", label: "trendarr", installed: "0.6.0", latest: "0.7.0", major: false, action: { kind: "installer", component: "trendarr" }, state: "offered" };
|
|
387
387
|
const notFound = vi.fn(async () => new Response("{}", { status: 404 })) as unknown as typeof fetch;
|
|
388
388
|
expect(await notesFor(trendarr, notFound)).toMatchObject({ notes: null, reason: expect.stringMatching(/release notes unavailable: GitHub answered 404/) });
|
|
389
389
|
const empty = vi.fn(async () => new Response("[]")) as unknown as typeof fetch;
|
|
390
390
|
const herdr = buildLines(COLLECTED).find((l) => l.key === "brew:herdr") as ToolLine;
|
|
391
|
-
expect(await notesFor(herdr, empty)).toEqual({ notes: null, reason: "GitHub
|
|
391
|
+
expect(await notesFor(herdr, empty)).toEqual({ notes: null, reason: "no GitHub release between the versions" });
|
|
392
392
|
expect(await notesFor(buildLines(COLLECTED).find((l) => l.key === "brew:gh") as ToolLine, empty)).toEqual({ notes: null, reason: "not reviewed" });
|
|
393
393
|
});
|
|
394
394
|
|