@astrofoundry/pi-astro 0.37.0 → 0.37.2

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.
@@ -68,6 +68,8 @@ export interface ServiceLine {
68
68
  latest: string | null;
69
69
  /** The tag the Compose file names (`latest`, `18`, `2.9.13`); what "new build of" refers to. */
70
70
  tag: string;
71
+ /** The image reference in the Compose file; the Security Daily Report matches scanned images to stacks by it. */
72
+ ref?: string;
71
73
  major: boolean;
72
74
  note: string;
73
75
  review?: Review;
@@ -146,7 +148,7 @@ export function buildStacks(report: unknown): ReportStacks | null {
146
148
  .map((r): ServiceLine => {
147
149
  const running = releaseTag(r.running);
148
150
  const latest = releaseTag(r.latest);
149
- return { service: r.service, status: r.status, action: r.action ?? "", running, latest, tag: tagOf(r.ref ?? ""), major: PENDING.has(r.status) && crossesMajor(running, latest), note: r.note ?? "" };
151
+ return { service: r.service, status: r.status, action: r.action ?? "", running, latest, tag: tagOf(r.ref ?? ""), ...(r.ref ? { ref: r.ref } : {}), major: PENDING.has(r.status) && crossesMajor(running, latest), note: r.note ?? "" };
150
152
  });
151
153
  const pending = lines.some((l) => PENDING.has(l.status));
152
154
  const held = holds[stack];
@@ -84,7 +84,7 @@ function harness(): Harness {
84
84
  rest,
85
85
  runEntry: async (service, _caller, args) => {
86
86
  calls.push([service, ...args]);
87
- const answer = answers.get(`${service} ${args[0]}`);
87
+ const answer = answers.get(`${service} ${args.slice(0, 3).join(" ")}`) ?? answers.get(`${service} ${args[0]}`);
88
88
  if (!answer) throw new Error(`no answer for ${service} ${args.join(" ")}`);
89
89
  return answer();
90
90
  },
@@ -295,8 +295,12 @@ describe("security monitor", () => {
295
295
  h.answers.set("security wazuh-vuln-events", () =>
296
296
  JSON.stringify({ days: 2, count: 1, events: [{ timestamp: "2026-10-20T20:00:00.000+0000", agent: "dmz", cve: "CVE-1", status: "Active", package: "openssl", version: "3.5.1", severity: "High", score: 7.5, condition: "Package less than 3.5.2" }] }),
297
297
  );
298
+ h.answers.set("arcane images vulnerabilities summary", () => JSON.stringify({ totalImages: 57, scannedImages: 57, summary: { critical: 1 } }));
299
+ h.answers.set("arcane images vulnerabilities list", () => JSON.stringify({ data: [{ vulnerabilityId: "CVE-7", pkgName: "zlib", fixedVersion: "1.3.1", ignored: false, imageName: "nginx:latest" }] }));
298
300
  await h.monitor.dailyReport(SCHEDULE, "2026-10-21");
299
301
  const text = h.rest.messages[0].message.content;
302
+ expect(text).toContain("Arcane images · 1 critical CVE with a fix in 1 image: nginx:latest: CVE-7 (zlib); no newer image offered yet");
303
+ expect(h.calls).toContainEqual(["arcane", "images", "vulnerabilities", "list", "--severity", "critical", "--all"]);
300
304
  expect(text.split("\n")[0]).toBe("**Security Daily Report:** quiet day (24 h to 06:05 CEST)");
301
305
  expect(text).toContain("CrowdSec · 2 bans, all front door SNI scanning");
302
306
  expect(text).toContain("Vulnerabilities · 1 new CVE on 1 host: CVE-1 (openssl, High 7.5) on dmz · fixed versions exist");
@@ -1,4 +1,5 @@
1
1
  import { chunkMessage } from "./chunk.ts";
2
+ import { readPostedArcane } from "./daily-report.ts";
2
3
  import { type DiscordConfig, isOwner, type ReportSchedule, reportSchedule } from "./config.ts";
3
4
  import { KeyedQueue } from "./media.ts";
4
5
  import { MONDAY, writeReportState, zonedWeekday } from "./reports.ts";
@@ -19,6 +20,9 @@ import {
19
20
  dailyNeedsOwner,
20
21
  dailyText,
21
22
  healthChange,
23
+ type ImageOffer,
24
+ imageOffers,
25
+ type ImageVulnFacts,
22
26
  investigationTask,
23
27
  isAcked,
24
28
  MAX_POSTS_PER_CHECK,
@@ -28,6 +32,7 @@ import {
28
32
  type OriginVerdict,
29
33
  originArgs,
30
34
  parseAttention,
35
+ parseImageVulns,
31
36
  parseOrigin,
32
37
  parseSecurityButton,
33
38
  type PatchingFacts,
@@ -429,6 +434,16 @@ export class SecurityMonitor {
429
434
  });
430
435
  }
431
436
 
437
+ /** Arcane's Trivy results (critical, with a fix) and the stacks of the newest Arcane Daily Report that would replace those images. */
438
+ private async imageFacts(): Promise<{ images: ImageVulnFacts | null; offers: Map<string, ImageOffer>; arcaneChannelId?: string }> {
439
+ const summary = await this.read("images vulnerabilities summary", "arcane", ["images", "vulnerabilities", "summary"], (v) => (v && typeof v === "object" ? v : null));
440
+ const list = summary ? await this.read("images vulnerabilities list", "arcane", ["images", "vulnerabilities", "list", "--severity", "critical", "--all"], (v) => (v && typeof v === "object" ? v : null), 5 * MINUTE) : null;
441
+ const images = summary && list ? parseImageVulns(summary, list) : null;
442
+ if (summary && list && !images) this.deps.log("security report: images vulnerabilities returned an unexpected answer");
443
+ const arcaneChannelId = reportSchedule(this.deps.config(), "arcane")?.channelId;
444
+ return { images, offers: imageOffers(readPostedArcane()?.stacks ?? []), ...(arcaneChannelId ? { arcaneChannelId } : {}) };
445
+ }
446
+
432
447
  private async postReport(channelId: string, text: string, mention: boolean): Promise<string> {
433
448
  const owners = this.owners();
434
449
  let first = "";
@@ -451,11 +466,12 @@ export class SecurityMonitor {
451
466
  const events = await this.read("wazuh-events", "security", ["wazuh-events", "1440", String(WATCH_LEVEL)], parseEvents);
452
467
  const attention = await this.read("attention", "security", ["attention"], parseAttention, 2 * MINUTE);
453
468
  const vulns = await this.vulnerabilities(now);
469
+ const images = await this.imageFacts();
454
470
  await this.fillOrigins(events);
455
471
  const state = readSecurityState();
456
472
  const wazuh = wazuhDigest(events, state.origins, (e) => acked(state, e));
457
473
  if (this.deps.stopping()) return;
458
- const data = { until: clockText(new Date(now).toISOString(), s.timeZone).replace(/^\d+ \w+ /, ""), crowdsec, wazuh, found: vulns?.found ?? null, closed: vulns?.closed ?? null, attention };
474
+ const data = { until: clockText(new Date(now).toISOString(), s.timeZone).replace(/^\d+ \w+ /, ""), crowdsec, wazuh, found: vulns?.found ?? null, closed: vulns?.closed ?? null, attention, ...images };
459
475
  writeReportState("security", { date, status: "sending" });
460
476
  const id = await this.postReport(s.channelId, dailyText(data, this.owners()), dailyNeedsOwner(data));
461
477
  writeReportState("security", { date, status: "sent", messageId: id });
@@ -475,6 +491,7 @@ export class SecurityMonitor {
475
491
  const resticText = await this.readText("restic-check-status", "backup", ["restic-check-status"]);
476
492
  // Monday has no daily report, so the weekly one moves the vulnerability record forward.
477
493
  const day = await this.vulnerabilities(now);
494
+ const images = await this.imageFacts();
478
495
  await this.fillOrigins(events);
479
496
  const { state, previousBans } = await this.update((st) => {
480
497
  const last = st.weeks[st.weeks.length - 1];
@@ -500,6 +517,7 @@ export class SecurityMonitor {
500
517
  attention,
501
518
  crl: events ? crlFromEvents(events, now) : ("unknown" as const),
502
519
  backups: archives ? { guests: archives, restic: resticText === null ? null : resticStatus(resticText) } : null,
520
+ ...images,
503
521
  last24h: {
504
522
  bans: lastDay?.count ?? null,
505
523
  wazuh: lastDayEvents?.length ?? null,
@@ -33,6 +33,12 @@ import {
33
33
  type PostedAlert,
34
34
  pruneState,
35
35
  type ReportedVuln,
36
+ type ImageOffer,
37
+ imageOffers,
38
+ imageVulnLine,
39
+ type ImageVulnFacts,
40
+ offeredImages,
41
+ parseImageVulns,
36
42
  repeatText,
37
43
  resticStatus,
38
44
  type VulnEvent,
@@ -59,10 +65,11 @@ function posted(over: Partial<PostedAlert> = {}): PostedAlert {
59
65
  }
60
66
 
61
67
  describe("security classification", () => {
62
- it("pages level 12 and up and our own rules, and keeps the rest for the digest", () => {
68
+ it("pages level 11 and up and our own rules, and keeps the rest for the digest", () => {
63
69
  expect(classify(event({ level: 12, rule: "5712" }), undefined)).toBe("urgent");
64
70
  expect(classify(event({ level: 15, rule: "40112" }), undefined)).toBe("urgent");
65
- expect(classify(event({ level: 11, rule: "521" }), undefined)).toBe("digest");
71
+ expect(classify(event({ level: 11, rule: "521" }), undefined)).toBe("urgent");
72
+ expect(classify(event({ level: 10, rule: "5503" }), undefined)).toBe("digest");
66
73
  expect(classify(event({ level: 10, rule: "100021" }), undefined)).toBe("urgent");
67
74
  expect(classify(event({ level: 10, rule: "100011" }), undefined)).toBe("urgent");
68
75
  expect(classify(event({ level: 10, rule: "100012" }), undefined)).toBe("urgent");
@@ -356,11 +363,58 @@ describe("vulnerabilities", () => {
356
363
  });
357
364
  });
358
365
 
366
+ describe("Arcane image scans", () => {
367
+ const item = (over: Record<string, unknown> = {}) => ({ vulnerabilityId: "CVE-2026-1", pkgName: "openssl", installedVersion: "3.0.1", fixedVersion: "3.0.2", severity: "CRITICAL", ignored: false, imageName: "ghcr.io/mealie-recipes/mealie:latest", ...over });
368
+ const stacks = [
369
+ { stack: "mealie", lines: [{ ref: "ghcr.io/mealie-recipes/mealie:latest" }], actionable: true, state: "offered" },
370
+ { stack: "supabase", lines: [{ ref: "supabase/postgres:15.8.1.085" }], actionable: false, state: "offered", held: "coordinated release: review first" },
371
+ { stack: "vault", lines: [{ ref: "vaultwarden/server:latest" }], actionable: true, state: "updated" },
372
+ ];
373
+
374
+ it("keeps critical findings that have a fix and are not ignored", () => {
375
+ const facts = parseImageVulns({ totalImages: 57, scannedImages: 3 }, { data: [item(), item({ vulnerabilityId: "CVE-2", ignored: true }), item({ vulnerabilityId: "CVE-3", fixedVersion: "" }), { nonsense: true }] });
376
+ expect(facts).toEqual({ scanned: 3, total: 57, critical: [{ id: "CVE-2026-1", pkg: "openssl", image: "ghcr.io/mealie-recipes/mealie:latest" }] });
377
+ expect(parseImageVulns({ totalImages: 57 }, { data: [] })).toBeNull();
378
+ expect(parseImageVulns({ totalImages: 1, scannedImages: 1 }, {})).toBeNull();
379
+ });
380
+
381
+ it("matches images to stacks by repository, whatever the tag or registry spelling", () => {
382
+ const offers = imageOffers(stacks);
383
+ expect(offers.get("ghcr.io/mealie-recipes/mealie")).toEqual({ stack: "mealie", offered: true });
384
+ expect(offers.get("docker.io/supabase/postgres")).toEqual({ stack: "supabase", offered: false, held: "coordinated release: review first" });
385
+ expect(offers.get("docker.io/vaultwarden/server")).toEqual({ stack: "vault", offered: false });
386
+ expect(imageOffers([{ stack: "x", lines: [{}], actionable: true, state: "offered" }]).size).toBe(0);
387
+ });
388
+
389
+ it("points each image at its stack's Update button, a hold, or nothing yet", () => {
390
+ const offers = imageOffers(stacks);
391
+ const facts: ImageVulnFacts = {
392
+ scanned: 57,
393
+ total: 57,
394
+ critical: [
395
+ { id: "CVE-1", pkg: "openssl", image: "ghcr.io/mealie-recipes/mealie:latest" },
396
+ { id: "CVE-2", pkg: "zlib", image: "ghcr.io/mealie-recipes/mealie:latest" },
397
+ { id: "CVE-3", pkg: "glibc", image: "ghcr.io/mealie-recipes/mealie:latest" },
398
+ { id: "CVE-4", pkg: "libpq", image: "supabase/postgres:15.8.1.085" },
399
+ { id: "CVE-5", pkg: "curl", image: "nginx:latest" },
400
+ ],
401
+ };
402
+ expect(imageVulnLine(facts, offers, "1549873938140499999")).toBe(
403
+ "Arcane images · 5 critical CVEs with a fix in 3 images: ghcr.io/mealie-recipes/mealie:latest: CVE-1 (openssl), CVE-2 (zlib), +1 more; update offered: Update on mealie in the Arcane Daily Report (<#1549873938140499999>) · nginx:latest: CVE-5 (curl); no newer image offered yet · supabase/postgres:15.8.1.085: CVE-4 (libpq); supabase is held: coordinated release: review first",
404
+ );
405
+ expect(offeredImages(facts, offers)).toEqual(["mealie"]);
406
+ expect(offeredImages(null, offers)).toEqual([]);
407
+ expect(imageVulnLine(null, offers)).toBe("Arcane images · the check failed");
408
+ expect(imageVulnLine({ scanned: 0, total: 57, critical: [] }, offers)).toBe("Arcane images · no Trivy scan yet (57 images)");
409
+ expect(imageVulnLine({ ...facts, critical: facts.critical.slice(4) }, new Map(), undefined, 0)).toBe("Arcane images · 1 critical CVE with a fix in 1 image: · +1 more images");
410
+ });
411
+ });
412
+
359
413
  describe("daily report", () => {
360
414
  const attention = parseAttention({ checked_at: "x", bouncer: { count: 1, oldest_pull_seconds: 6 }, wazuh_agents: { total: 8, active: 8 }, health_issues: [] });
361
415
 
362
416
  it("reads quiet day and tags nobody when nothing is open", () => {
363
- const data = { until: "06:00 CEST", crowdsec: summary(), wazuh: wazuhDigest([], {}, () => false), found: [], closed: [], attention };
417
+ const data = { until: "06:00 CEST", crowdsec: summary(), wazuh: wazuhDigest([], {}, () => false), found: [], closed: [], attention, images: { scanned: 57, total: 57, critical: [] }, offers: new Map() };
364
418
  expect(dailyText(data, [OWNER])).toBe(
365
419
  [
366
420
  "**Security Daily Report:** quiet day (24 h to 06:00 CEST)",
@@ -368,15 +422,17 @@ describe("daily report", () => {
368
422
  "Wazuh · no alerts at level 10+",
369
423
  "Vulnerabilities · nothing new",
370
424
  "Patches · none",
425
+ "Arcane images · no critical CVE with a fix (57 of 57 images scanned)",
371
426
  "Health · 8/8 Wazuh agents active · bouncer pulled 6 s ago",
372
427
  ].join("\n"),
373
428
  );
374
429
  expect(dailyNeedsOwner(data)).toBe(false);
430
+ expect(dailyNeedsOwner({ ...data, images: null })).toBe(true);
375
431
  });
376
432
 
377
433
  it("names urgent alerts and failed checks in the headline and tags the owner while something is open", () => {
378
434
  const wazuh = wazuhDigest([event({ rule: "5712", level: 12, description: "brute force" })], {}, () => false);
379
- const data = { until: "06:00 CEST", crowdsec: null, wazuh, found: [], closed: [], attention };
435
+ const data = { until: "06:00 CEST", crowdsec: null, wazuh, found: [], closed: [], attention, images: { scanned: 57, total: 57, critical: [] }, offers: new Map() };
380
436
  const text = dailyText(data, [OWNER]);
381
437
  expect(text.split("\n")[0]).toBe("**Security Daily Report:** 1 urgent alert, 1 check failed (24 h to 06:00 CEST)");
382
438
  expect(text.endsWith(`<@${OWNER}>`)).toBe(true);
@@ -400,6 +456,8 @@ describe("weekly report", () => {
400
456
  crl: null,
401
457
  backups: { guests: [{ vmid: "100", name: "arcane", last: Date.parse("2026-10-20T00:30:00Z") / 1000 }], restic: { result: "success", at: "18 Oct 04:00" } },
402
458
  last24h: { bans: 16, wazuh: 0, urgent: 0, found: 0, closed: 2, health: 0 },
459
+ images: { scanned: 57, total: 57, critical: [] } as ImageVulnFacts | null,
460
+ offers: new Map<string, ImageOffer>(),
403
461
  };
404
462
 
405
463
  it("follows the approved layout and says when nothing needs the owner", () => {
@@ -412,6 +470,7 @@ describe("weekly report", () => {
412
470
  "Wazuh · no alerts at level 10+",
413
471
  "Vulnerabilities · 0 new · 0 closed by patches · 0 open with a fixed version",
414
472
  "Patching · 14 package installs on 2 hosts · 0 CVEs closed · agent restarts: frontdoor-1337 19 Oct · reboot pending: none",
473
+ "Arcane images · no critical CVE with a fix (57 of 57 images scanned)",
415
474
  "Health · 8/8 Wazuh agents active · bouncer pulled 4 s ago · RADIUS CRL: no renewal warning (it warns 30 days ahead)",
416
475
  "Backups · Proxmox: the only guest backed up within 48 h, last 20 Oct 02:30 CEST · restic check: success 18 Oct 04:00",
417
476
  "Needs you · nothing",
@@ -430,6 +489,10 @@ describe("weekly report", () => {
430
489
  "Needs you · 1) 1 unexplained deployment change this week; Investigate on the alert 2) reboot dmz to load installed updates 3) 1 CVE with a fixed version still open after 3 days (dmz); unattended-upgrades may be stuck 4) renew the RADIUS CRL (wifi-device.sh renew-crl), 23 days left 5) no Proxmox backup within 48 h for observability 6) the restic check ended with exit-code",
431
490
  );
432
491
  expect(out.text).toContain("RADIUS CRL: renew within 23 days (warned 19 Oct)");
492
+ const offers = imageOffers([{ stack: "mealie", lines: [{ ref: "ghcr.io/mealie-recipes/mealie:latest" }], actionable: true, state: "offered" }]);
493
+ const withImages = weeklyText({ ...base, offers, images: { scanned: 57, total: 57, critical: [{ id: "CVE-9", pkg: "openssl", image: "ghcr.io/mealie-recipes/mealie:1" }] } }, [OWNER]);
494
+ expect(withImages.text).toContain("Needs you · 1) update mealie in the Arcane Daily Report: the newer image replaces one with a critical CVE");
495
+ expect(weeklyText({ ...base, images: null }, [OWNER]).text).toContain("1) 1 check of this report failed");
433
496
  expect(out.text.endsWith(`<@${OWNER}>`)).toBe(true);
434
497
  });
435
498
 
@@ -2,6 +2,7 @@ import { readFileSync, renameSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import type { ChangeOrigin } from "../../specialists/lib/change-origin.ts";
4
4
  import type { AlertSummary, VulnEvent, WazuhEvent } from "../../specialists/security/run.ts";
5
+ import { parseImageRef } from "../../specialists/lib/registry.ts";
5
6
  import { configDir } from "./config.ts";
6
7
  import { escapeDiscord } from "./media.ts";
7
8
  import type { MessageComponent } from "./rest.ts";
@@ -11,7 +12,7 @@ export type { AlertSummary, VulnEvent, WazuhEvent };
11
12
  export const DAILY_PREFIX = "Security Daily Report:";
12
13
  export const WEEKLY_PREFIX = "Security Weekly Report:";
13
14
  /** Wazuh levels from here on page at once; our own rules page at level 10 by rule id. */
14
- export const URGENT_LEVEL = 12;
15
+ export const URGENT_LEVEL = 11;
15
16
  /** The poller and the reports read Wazuh from this level: every rule of ours is level 10. */
16
17
  export const WATCH_LEVEL = 10;
17
18
  export const ACK_DAYS = 7;
@@ -44,7 +45,7 @@ export interface OriginVerdict {
44
45
  reason: string;
45
46
  }
46
47
 
47
- /** Urgent: level 12 or higher, or a paging rule of ours; a deployment-file change explained by GitOps or our own operation is known. */
48
+ /** Urgent: level 11 or higher, or a paging rule of ours; a deployment-file change explained by GitOps or our own operation is known. */
48
49
  export function classify(e: WazuhEvent, origin: OriginVerdict | undefined): EventClass {
49
50
  if (e.rule === DEPLOYMENT_RULE) return origin?.verdict === "known" ? "known" : "urgent";
50
51
  const own = OWN_RULES[e.rule];
@@ -545,6 +546,98 @@ export function patchLine(closed: readonly VulnEvent[] | null, label = "Patches"
545
546
  return `${label} · ${shown.join(" · ")}${more}`;
546
547
  }
547
548
 
549
+ // ---------------------------------------------------------------- Arcane image scans
550
+
551
+ /** One critical finding of Arcane's Trivy scan that has a fixed version (`images vulnerabilities list`). */
552
+ export interface ImageVuln {
553
+ id: string;
554
+ pkg: string;
555
+ image: string;
556
+ }
557
+
558
+ export interface ImageVulnFacts {
559
+ scanned: number;
560
+ total: number;
561
+ critical: ImageVuln[];
562
+ }
563
+
564
+ /** What the newest Arcane Daily Report offers for the stack that runs an image. */
565
+ export interface ImageOffer {
566
+ stack: string;
567
+ /** The stack has an Update button that still applies. */
568
+ offered: boolean;
569
+ held?: string;
570
+ }
571
+
572
+ /** `images vulnerabilities summary` plus `list --severity critical --all`; ignored findings and findings without a fix are left out. */
573
+ export function parseImageVulns(summary: unknown, list: unknown): ImageVulnFacts | null {
574
+ const s = summary as { totalImages?: unknown; scannedImages?: unknown } | null;
575
+ const data = (list as { data?: unknown } | null)?.data;
576
+ if (!s || typeof s.totalImages !== "number" || typeof s.scannedImages !== "number" || !Array.isArray(data)) return null;
577
+ const critical: ImageVuln[] = [];
578
+ for (const v of data as Record<string, unknown>[]) {
579
+ if (typeof v.vulnerabilityId !== "string" || typeof v.imageName !== "string" || v.ignored === true) continue;
580
+ if (typeof v.fixedVersion !== "string" || v.fixedVersion.length === 0) continue;
581
+ critical.push({ id: v.vulnerabilityId, pkg: typeof v.pkgName === "string" ? v.pkgName : "?", image: v.imageName });
582
+ }
583
+ return { scanned: s.scannedImages, total: s.totalImages, critical };
584
+ }
585
+
586
+ function repositoryOf(ref: string): string | null {
587
+ try {
588
+ const r = parseImageRef(ref);
589
+ return `${r.registry}/${r.repository}`;
590
+ } catch {
591
+ return null;
592
+ }
593
+ }
594
+
595
+ /** Image repository to the stack that runs it, from the stacks the newest Arcane Daily Report shows. */
596
+ export function imageOffers(stacks: readonly { stack: string; lines: { ref?: string }[]; actionable: boolean; state: string; held?: string }[]): Map<string, ImageOffer> {
597
+ const out = new Map<string, ImageOffer>();
598
+ for (const s of stacks) {
599
+ for (const l of s.lines) {
600
+ const repo = l.ref ? repositoryOf(l.ref) : null;
601
+ if (repo) out.set(repo, { stack: s.stack, offered: s.actionable && s.state === "offered", ...(s.held ? { held: s.held } : {}) });
602
+ }
603
+ }
604
+ return out;
605
+ }
606
+
607
+ function offerText(offer: ImageOffer | undefined, arcaneChannelId: string | undefined): string {
608
+ if (offer?.offered) return `update offered: Update on ${escapeDiscord(offer.stack)} in the Arcane Daily Report${arcaneChannelId ? ` (<#${arcaneChannelId}>)` : ""}`;
609
+ if (offer?.held) return `${escapeDiscord(offer.stack)} is held: ${escapeDiscord(offer.held)}`;
610
+ return "no newer image offered yet";
611
+ }
612
+
613
+ /** Images with critical CVEs that an update in the newest Arcane Daily Report would replace. */
614
+ export function offeredImages(facts: ImageVulnFacts | null, offers: ReadonlyMap<string, ImageOffer>): string[] {
615
+ if (!facts) return [];
616
+ const stacks = new Set<string>();
617
+ for (const v of facts.critical) {
618
+ const offer = offers.get(repositoryOf(v.image) ?? "");
619
+ if (offer?.offered) stacks.add(offer.stack);
620
+ }
621
+ return [...stacks].sort();
622
+ }
623
+
624
+ export function imageVulnLine(facts: ImageVulnFacts | null, offers: ReadonlyMap<string, ImageOffer>, arcaneChannelId?: string, maxShown = 3): string {
625
+ if (!facts) return "Arcane images · the check failed";
626
+ if (facts.scanned === 0) return `Arcane images · no Trivy scan yet (${facts.total} images)`;
627
+ if (facts.critical.length === 0) return `Arcane images · no critical CVE with a fix (${facts.scanned} of ${facts.total} images scanned)`;
628
+ const byImage = new Map<string, ImageVuln[]>();
629
+ for (const v of facts.critical) byImage.set(v.image, [...(byImage.get(v.image) ?? []), v]);
630
+ const groups = [...byImage.entries()].sort((x, y) => y[1].length - x[1].length || x[0].localeCompare(y[0]));
631
+ const shown = groups.slice(0, maxShown).map(([image, vulns]) => {
632
+ const named = vulns.slice(0, 2).map((v) => `${escapeDiscord(v.id)} (${escapeDiscord(v.pkg)})`);
633
+ const rest = vulns.length > 2 ? `, +${vulns.length - 2} more` : "";
634
+ return `${escapeDiscord(image)}: ${named.join(", ")}${rest}; ${offerText(offers.get(repositoryOf(image) ?? ""), arcaneChannelId)}`;
635
+ });
636
+ const more = groups.length > maxShown ? ` · +${groups.length - maxShown} more images` : "";
637
+ const n = facts.critical.length;
638
+ return `Arcane images · ${n} critical CVE${n === 1 ? "" : "s"} with a fix in ${groups.length} image${groups.length === 1 ? "" : "s"}: ${shown.join(" · ")}${more}`;
639
+ }
640
+
548
641
  // ---------------------------------------------------------------- reports
549
642
 
550
643
  export interface DailyData {
@@ -555,6 +648,10 @@ export interface DailyData {
555
648
  found: VulnEvent[] | null;
556
649
  closed: VulnEvent[] | null;
557
650
  attention: Attention | null;
651
+ images: ImageVulnFacts | null;
652
+ offers: ReadonlyMap<string, ImageOffer>;
653
+ /** The Arcane Daily Report's channel, linked from offered updates. */
654
+ arcaneChannelId?: string;
558
655
  }
559
656
 
560
657
  function headline(urgent: number, unexplained: number, health: number, failed: number): string {
@@ -568,7 +665,7 @@ function headline(urgent: number, unexplained: number, health: number, failed: n
568
665
  }
569
666
 
570
667
  function failures(d: DailyData): number {
571
- return [d.crowdsec === null, d.wazuh.failed, d.found === null, d.attention === null].filter(Boolean).length;
668
+ return [d.crowdsec === null, d.wazuh.failed, d.found === null, d.attention === null, d.images === null].filter(Boolean).length;
572
669
  }
573
670
 
574
671
  /** Owners are tagged only while something is open: a health issue or a check that failed. */
@@ -578,7 +675,7 @@ export function dailyNeedsOwner(d: DailyData): boolean {
578
675
 
579
676
  export function dailyText(d: DailyData, owners: readonly string[]): string {
580
677
  const head = `**${DAILY_PREFIX}** ${headline(d.wazuh.urgent, d.wazuh.unexplained.length, d.attention?.issues.length ?? 0, failures(d))} (24 h to ${d.until})`;
581
- const lines = [head, crowdsecDailyLine(d.crowdsec), d.wazuh.line, vulnLine(d.found), patchLine(d.closed), healthLine(d.attention)];
678
+ const lines = [head, crowdsecDailyLine(d.crowdsec), d.wazuh.line, vulnLine(d.found), patchLine(d.closed), imageVulnLine(d.images, d.offers, d.arcaneChannelId), healthLine(d.attention)];
582
679
  if (dailyNeedsOwner(d)) lines.push(mentionLine(owners));
583
680
  return lines.join("\n");
584
681
  }
@@ -613,6 +710,9 @@ export interface WeeklyData {
613
710
  attention: Attention | null;
614
711
  crl: { days: number; warned: string } | null | "unknown";
615
712
  backups: BackupFacts | null;
713
+ images: ImageVulnFacts | null;
714
+ offers: ReadonlyMap<string, ImageOffer>;
715
+ arcaneChannelId?: string;
616
716
  last24h: { bans: number | null; wazuh: number | null; urgent: number; found: number | null; closed: number | null; health: number | null };
617
717
  }
618
718
 
@@ -688,13 +788,15 @@ export function needsYou(d: WeeklyData): string[] {
688
788
  if (d.patching && d.patching.rebootPending.length > 0) items.push(`reboot ${d.patching.rebootPending.map(escapeDiscord).join(", ")} to load installed updates`);
689
789
  const stuck = d.openWithFix.filter((v) => d.now - Date.parse(v.since) > 3 * DAY);
690
790
  if (stuck.length > 0) items.push(`${stuck.length} CVE${stuck.length === 1 ? "" : "s"} with a fixed version still open after 3 days (${[...new Set(stuck.map((v) => v.agent))].map(escapeDiscord).join(", ")}); unattended-upgrades may be stuck`);
791
+ const offered = offeredImages(d.images, d.offers);
792
+ if (offered.length > 0) items.push(`update ${offered.map(escapeDiscord).join(", ")} in the Arcane Daily Report: the newer image replaces one with a critical CVE`);
691
793
  if (d.crl !== null && d.crl !== "unknown") items.push(`renew the RADIUS CRL (wifi-device.sh renew-crl), ${d.crl.days} days left`);
692
794
  if (d.backups) {
693
795
  const stale = d.backups.guests.filter((g) => d.now / 1000 - g.last > STALE_BACKUP_S);
694
796
  if (stale.length > 0) items.push(`no Proxmox backup within 48 h for ${stale.map((g) => escapeDiscord(g.name)).join(", ")}`);
695
797
  if (d.backups.restic && d.backups.restic.result !== "success") items.push(`the restic check ended with ${escapeDiscord(d.backups.restic.result)}`);
696
798
  }
697
- const failed = [d.crowdsec === null, d.wazuh.failed, d.found === null, d.patching === null, d.attention === null, d.backups === null].filter(Boolean).length;
799
+ 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;
698
800
  if (failed > 0) items.push(`${failed} check${failed === 1 ? "" : "s"} of this report failed; the bridge log on Cortex has the reason`);
699
801
  return items;
700
802
  }
@@ -719,6 +821,7 @@ export function weeklyText(d: WeeklyData, owners: readonly string[]): { text: st
719
821
  d.wazuh.line,
720
822
  `Vulnerabilities · ${found} · ${closed} · ${fixable} open with a fixed version${tracking}`,
721
823
  patchingLine(d.patching, d.closed, d.timeZone),
824
+ imageVulnLine(d.images, d.offers, d.arcaneChannelId),
722
825
  `${healthLine(d.attention)} · ${crlText(d.crl, d.timeZone)}`,
723
826
  backupLine(d.backups, d.now, d.timeZone),
724
827
  `Needs you · ${items.length === 0 ? "nothing" : items.map((t, i) => `${i + 1}) ${t}`).join(" ")}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrofoundry/pi-astro",
3
- "version": "0.37.0",
3
+ "version": "0.37.2",
4
4
  "description": "Personal pi customizations (extensions, subagents, skills, prompts, themes) for the pi coding agent.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -5,7 +5,7 @@ description: How the security specialist reads Wazuh, CrowdSec, and the remote l
5
5
 
6
6
  # Security specialist
7
7
 
8
- VM 106 (`10.0.90.10`, VLAN 90) runs the Wazuh manager (container `observability-wazuh-manager-1`, agents `identity`, `arcane`, `dmz`, `CORTEX`, `NEXUS`, `hermes`, `frontdoor-1337`, `tailscale`), CrowdSec with its local API for the front-door bouncer, and rsyslog, which archives remote logs under `/var/log/remote/<host>/<program>.log` (14 days). The Discord bridge on Cortex reads Wazuh through this tool every two minutes and posts urgent alerts at once (level 12 or higher, and rules 100011, 100012, 100020, 100021; a deployment-file change that a GitOps commit or our own operation explains is not urgent), with Investigate and Acknowledge buttons for the owners; everything else goes into the Security Daily Report (06:00) and, on Mondays, the Security Weekly Report. The VM itself no longer posts to Discord. Two local CrowdSec scenarios matter: `37pla/pomerium-http-probing` (repeated Pomerium denials) and `37pla/frontdoor-sni-scanning` (rejected SNI at the VPS; bans escalate 4h, 24h, 7d, 30d, 90d). The home WAN address is whitelisted every five minutes; a scan test in August 2026 once banned it.
8
+ VM 106 (`10.0.90.10`, VLAN 90) runs the Wazuh manager (container `observability-wazuh-manager-1`, agents `identity`, `arcane`, `dmz`, `CORTEX`, `NEXUS`, `hermes`, `frontdoor-1337`, `tailscale`), CrowdSec with its local API for the front-door bouncer, and rsyslog, which archives remote logs under `/var/log/remote/<host>/<program>.log` (14 days). The Discord bridge on Cortex reads Wazuh through this tool every two minutes and posts urgent alerts at once (level 11 or higher, and rules 100011, 100012, 100020, 100021; a deployment-file change that a GitOps commit or our own operation explains is not urgent), with Investigate and Acknowledge buttons for the owners; everything else goes into the Security Daily Report (06:00) and, on Mondays, the Security Weekly Report. The VM itself no longer posts to Discord. Two local CrowdSec scenarios matter: `37pla/pomerium-http-probing` (repeated Pomerium denials) and `37pla/frontdoor-sni-scanning` (rejected SNI at the VPS; bans escalate 4h, 24h, 7d, 30d, 90d). The home WAN address is whitelisted every five minutes; a scan test in August 2026 once banned it.
9
9
 
10
10
  The `security` tool is read-only. Every call is a fixed command on the guest; `["--help"]` lists them.
11
11
 
@@ -25,7 +25,7 @@ The `security` tool is read-only. Every call is a fixed command on the guest; `[
25
25
  | `wazuh-log <lines>` | manager container log |
26
26
  | `remote-hosts` | `host/program.log` names in the archive |
27
27
  | `remote-log <host> <program> <lines>` | tail of one archived log, e.g. `remote-log frontdoor-1337 nginx-stream 200` |
28
- | `journal <unit> <since>` | `crowdsec`, `rsyslog`, `nftables`, `docker`, `security-attention`, `update-home-whitelist`, `ssh` |
28
+ | `journal <unit> <since>` | `crowdsec`, `rsyslog`, `nftables`, `docker`, `update-home-whitelist`, `ssh` |
29
29
 
30
30
  ```json
31
31
  { "args": ["attention"] }
@@ -47,7 +47,7 @@ case "$name" in
47
47
  sudo -n tail -n "$3" "/var/log/remote/$1/$2.log" ;;
48
48
  journal)
49
49
  unit="${rest%% *}"; since="${rest#* }"
50
- case "$unit" in crowdsec|rsyslog|nftables|docker|security-attention|update-home-whitelist|ssh) ;; *) echo "bad unit" >&2; exit 2 ;; esac
50
+ case "$unit" in crowdsec|rsyslog|nftables|docker|update-home-whitelist|ssh) ;; *) echo "bad unit" >&2; exit 2 ;; esac
51
51
  since_ok "$since" || { echo "bad since" >&2; exit 2; }
52
52
  sudo -n journalctl -u "$unit" --since "$since" --no-pager -n 200 ;;
53
53
  *) echo "refused: $cmd" >&2; exit 2 ;;
@@ -32,7 +32,7 @@ export const OBS_COMMANDS: Readonly<Record<string, { args: [number, number]; hel
32
32
  journal: { args: [2, 2], help: "journal <unit> <since> e.g. journal crowdsec '1 hour ago'" },
33
33
  };
34
34
 
35
- export const OBS_UNITS = ["crowdsec", "rsyslog", "nftables", "docker", "security-attention", "update-home-whitelist", "ssh"];
35
+ export const OBS_UNITS = ["crowdsec", "rsyslog", "nftables", "docker", "update-home-whitelist", "ssh"];
36
36
  const SINCE = /^[A-Za-z0-9 :\-+]{1,40}$/;
37
37
  const HOSTNAME = /^[A-Za-z0-9][A-Za-z0-9.-]{0,62}$/;
38
38
  const PROGRAM = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,62}$/;