Public: anyone can read this; the crew can change it.

/advisories: OSV and CISA KEV for npm, matched to every repository's lockfile, to view, search and paste #17059

opened this in answer to

Merged 30h 3m ago, live in production

scout/forge:scout/6005-advisories-the-forge-listens-to-cve-org → main 0 commits fork 8 threads · 8 unresolved

  • Merged. scout/6005-advisories-the-forge-listens-to-cve-org was merged into main as e47a0f6.

Review

Sign in to review this change.
30 files changed +1177 −358
docs/MCP.md +7
@@ -573,3 +573,10 @@ spends in the wallet page's words. Dollars come from `money` and the balance
573573 from `balanceWords` (`src/core/wallet.ts`), the same the page and terminal use;
574574 `readWalletSummary` (`src/actions/wallet.ts`) gives a writer's gate, and anyone
575575 else the page's own `not_found`.
576
577 ## Advisories
578
579 `audit` with `advisories: "<text>"` answers known vulnerabilities (OSV records,
580 CISA KEV marks) matching the text, exploited ones first, each with the repos
581 whose `package-lock.json` it hits. A forge admin who is a person only. It is an
582 argument of `audit`, not a tool, to keep `tools/list` under its ceiling.
docs/design/audit.md +1
@@ -79,6 +79,7 @@ Machine routes are not pages and have no entry: `/audit.csv`,
7979 - `/pipeline` — `pages/pipeline.ts` · the four steps a change follows (check, review, land, live), for a newcomer · a pull page's step line, `/flow` · none seen.
8080 - `/packs` — `pages/packs.ts` · the premade forges this forge ships, what each brings, how to deploy it and how a stranger helps build its apps · the user menu, the signed-out menu, the palette · none seen; uses the shared card, list and button components.
8181 - `/map` — `pages/map.ts` (1,806 lines) · the dependency map of work across the forge · `/board`, issue dependency lists, `/:owner/:name/map` · colours 3, sizes 12: the largest private vocabulary.
82 - `/advisories` — `pages/advisories.ts` · known vulnerabilities, exploited ones first, each with the repositories whose lockfile it hits, and a form to paste a feed · the terminal's Advisories command, the MCP `audit` tool · none seen.
8283 - `/audit` — `pages/audit.ts` · every app's contract, who can do what · the app page's one-line policy · none seen. Names the audit of apps, not this document.
8384 - `/repos` — `pages/my-repos.ts` · the repositories you may write, from the account menu · `/` (your apps), `/:owner` (a profile's repositories) · none seen.
8485 - `/releases` — `pages/releases.ts` · the forge's kept releases and rollback · `/settings/backups` (both are "go back") · none seen.
docs/features/advisories.md added +15
@@ -0,0 +1,15 @@
1 ---
2 topic: When something is wrong
3 row: Which known vulnerabilities hit your repositories
4 ---
5 # Advisories
6
7 `/advisories` (a forge admin who is a person) lists known vulnerabilities, those hitting one of your repositories first, then CISA-KEV ones ("exploited"), each with the repositories whose `package-lock.json` it hits. Search with the box on the page. The terminal has the same list under the Advisories command: type to search, paste an OSV record or the KEV list to ingest it. The MCP `audit` tool takes an `advisories` argument.
8
9 Where to find it: type the address `/advisories`, pick Advisories from the command palette, follow the Advisories link on Resilience, or press `a` on the terminal's Resilience screen. There is no row under Settings.
10
11 The forge listens by itself once an hour (`src/core/advisory_feed.ts`): the CISA KEV list from `www.cisa.gov`, and OSV records for the npm packages in the forge's lockfiles from `api.osv.dev`. Both are in `forge.json` `egress`; if the gate refuses one, the log line says "refused by this forge: <host> is not in this app's forge.json egress". You can still paste a feed under "Paste a feed" on the page.
outdated

The PR title promises CVE.org, GHSA, NVD, EPSS, fix-pull actions, MCP tools and integrations, and this line says none of it ships. Retitle the pull to what it does, and open follow-up issues for the rest so the promise is not lost.

12
13 Which repositories a lockfile hits is worked out once a minute, or at once when the advisory tables change, and shared by the page, the terminal and the MCP tool.
14
15 What ships is OSV and CISA KEV for npm, viewing, search and pasting. Not yet, each its own issue: CVE.org, GHSA and NVD feeds; EPSS; other ecosystems; fix pulls and accept-risk actions; integrations.
forge.json +4 −2
@@ -1,6 +1,8 @@
11 {
22 "egress": [
33 "api.anthropic.com",
4 "www.cisa.gov",
5 "api.osv.dev",
46 "api.cloudflare.com",
57 "api.openai.com",
68 "openrouter.ai",
@@ -30,8 +32,8 @@
3032 { "name": "heartbeat", "cron": "5 7 * * *", "timezone": "UTC", "path": "/jobs/heartbeat", "timeout": 120, "retries": 3, "catchUp": "6h" }
3133 ],
3234 "app": {
33 "looks": ["/", "/docs", "/explore", "/board", "/cockpit", "/notes", "/review", "/changelog", "/apps", "/security", "/system", "/admin/limits", "/maintenance", "/talk", "/flow", "/resilience", "/boards?help", "/settings/crew", "/settings/crew?help", "/settings/captain", "/settings/security/controls", "/settings/grants", "/preview-admin/sample", "/preview-admin/sample/drop", "/preview-admin/sample/data-move", "/preview-admin/sample/cut-over", "/preview-admin/sample/pulls/3", "/preview-admin/sample/next?pick", "/preview-admin/sample/bets", "/preview-admin/sample/waves", "/looks/missing", "/looks/failed"],
34 "looksAsOwner": ["/", "/board", "/cockpit", "/flow", "/boards?help", "/settings/crew", "/settings/crew?help", "/settings/captain", "/settings/security/controls", "/settings/grants", "/talk", "/system", "/admin/limits", "/maintenance", "/resilience", "/preview-admin/sample", "/preview-admin/sample/drop", "/preview-admin/sample/data-move", "/preview-admin/sample/cut-over", "/preview-admin/sample/pulls/3", "/preview-admin/sample/next?pick", "/preview-admin/sample/bets", "/preview-admin/sample/waves"],
35 "looks": ["/", "/docs", "/explore", "/board", "/cockpit", "/notes", "/review", "/changelog", "/apps", "/security", "/system", "/admin/limits", "/maintenance", "/talk", "/flow", "/resilience", "/boards?help", "/settings/crew", "/settings/crew?help", "/settings/captain", "/settings/security/controls", "/settings/grants", "/preview-admin/sample", "/preview-admin/sample/drop", "/preview-admin/sample/data-move", "/preview-admin/sample/cut-over", "/preview-admin/sample/pulls/3", "/preview-admin/sample/next?pick", "/preview-admin/sample/bets", "/advisories", "/looks/missing", "/looks/failed"],
36 "looksAsOwner": ["/", "/board", "/cockpit", "/flow", "/boards?help", "/settings/crew", "/settings/crew?help", "/settings/captain", "/settings/security/controls", "/settings/grants", "/talk", "/system", "/admin/limits", "/maintenance", "/resilience", "/preview-admin/sample", "/preview-admin/sample/drop", "/preview-admin/sample/data-move", "/preview-admin/sample/cut-over", "/preview-admin/sample/pulls/3", "/preview-admin/sample/next?pick", "/preview-admin/sample/bets", "/advisories"],
3537 "run": "bun run src/main.ts",
3638 "install": "",
3739 "health": "/healthz",
scripts/dupes-pairs.json +4 −1
@@ -33,5 +33,8 @@
3333 {"a":"test/releases-fit.test.ts#test: no inline width and no shipped rule fixes a width over 390 px","b":"test/changelog-fit.test.ts#test: no inline width and no shipped rule fixes a width over 390 px","same":true,"why":"the same fit test, pasted for another page"},
3434 {"a":"test/web-browse.test.ts#asUser","b":"test/web-origins.test.ts#asUser","same":true,"why":"the same signed-in fetch helper"},
3535 {"a":"test/ssh-tell-first-ask.test.ts#exec","b":"test/ssh-tell.test.ts#exec","same":true,"why":"the same ssh exec helper"},
36 {"a":"test/mcp-signup.test.ts#call","b":"test/mcp-backups.test.ts#call","same":true,"why":"the same MCP call helper"}
36 {"a":"test/mcp-signup.test.ts#call","b":"test/mcp-backups.test.ts#call","same":true,"why":"the same MCP call helper"},
37 {"a":"src/core/advisory_feed.ts#startAdvisoryFeed","b":"src/core/advisory_feed.ts#round","same":false,"why":"similar in style, but one function would not serve both"},
38 {"a":"src/web/pages/advisories.ts#advisoriesIngest","b":"src/web/pages/maintenance.ts#maintenanceDismiss","same":false,"why":"similar in style, but one function would not serve both"},
39 {"a":"test/advisories-page.test.ts#login","b":"test/maintenance.test.ts#login","same":true,"why":"the same signed-in fetch helper"}
3740 ]
src/core/advisories.ts added +238
@@ -0,0 +1,238 @@
1 /**
2 * Advisories and who they hit. An OSV record becomes one row per affected
3 * package range; the CISA KEV list marks which CVEs are exploited now. A
4 * repository's exposure is its package-lock.json read against those rows.
5 * Plain data in, plain data out: the feeds are handed in, never fetched here.
6 */
7
8 import type { Database } from "bun:sqlite";
9 import { err, ok, type Result } from "../kernel/result.ts";
10
11 export interface Advisory {
12 readonly id: string;
13 readonly ecosystem: string;
14 readonly package: string;
15 /** "0" when every version up to `fixed` is hit. */
16 readonly introduced: string;
17 /** "" when no fix exists. */
18 readonly fixed: string;
19 readonly cve: string;
20 readonly summary: string;
21 readonly severity: string;
22 readonly modified: string;
23 }
24
25 export interface Pkg {
26 readonly name: string;
27 readonly version: string;
28 }
29
30 const MAX_RECORDS = 500;
31 const short = (v: unknown, max: number): string =>
32 typeof v === "string" ? v.slice(0, max) : "";
33 const VERSION = /^\d+(\.\d+){0,3}([-+][0-9A-Za-z.-]*)?$/;
34 const SEVERITY = new Set(["low", "moderate", "high", "critical"]);
35 /** A plain word or nothing: a raw CVSS vector is not something to show. */
36 function severityWord(v: unknown): string {
37 const w = short(v, 16).toLowerCase();
38 const word = w === "medium" ? "moderate" : w;
39 return SEVERITY.has(word) ? word : "";
40 }
41 const CVE = /^CVE-\d{4}-\d{4,}$/;
42
43 /** Numeric dotted compare; a pre-release sorts before its release. */
44 export function compareVersions(a: string, b: string): number {
45 const parts = (v: string) => {
46 const [core = "", pre = ""] = v.split(/[-+]/, 2);
47 return { n: core.split(".").map((x) => Number.parseInt(x, 10) || 0), pre: v.includes("-") ? pre : "" };
48 };
49 const x = parts(a);
50 const y = parts(b);
51 for (let i = 0; i < Math.max(x.n.length, y.n.length); i++) {
52 const d = (x.n[i] ?? 0) - (y.n[i] ?? 0);
53 if (d !== 0) return d < 0 ? -1 : 1;
54 }
55 if (x.pre === y.pre) return 0;
56 if (x.pre === "") return 1;
57 if (y.pre === "") return -1;
58 return x.pre < y.pre ? -1 : 1;
59 }
60
61 export function affects(a: Advisory, version: string): boolean {
62 if (!VERSION.test(version)) return false;
63 if (a.introduced !== "0" && compareVersions(version, a.introduced) < 0) return false;
64 return a.fixed === "" || compareVersions(version, a.fixed) < 0;
65 }
66
67 /** OSV JSON (one record or an array) to rows. Anything malformed is refused whole. */
68 export function parseOsv(text: string): Result<Advisory[], string> {
69 let data: unknown;
70 try {
71 data = JSON.parse(text);
72 } catch {
73 return err("not JSON");
74 }
75 const records = Array.isArray(data) ? data : [data];
76 if (records.length > MAX_RECORDS) return err("too many records");
77 const rows: Advisory[] = [];
78 for (const r of records) {
79 if (r === null || typeof r !== "object") return err("a record is not an object");
80 const rec = r as Record<string, unknown>;
81 const id = short(rec["id"], 64);
82 if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(id)) return err("a record has no valid id");
83 const aliases = Array.isArray(rec["aliases"]) ? rec["aliases"] : [];
84 const cve = [id, ...aliases].find((x) => typeof x === "string" && CVE.test(x)) as string | undefined;
85 const severity = severityWord((rec["database_specific"] as { severity?: unknown } | undefined)?.severity);
86 const affected = Array.isArray(rec["affected"]) ? rec["affected"] : [];
87 for (const item of affected) {
88 const pkg = (item as { package?: { ecosystem?: unknown; name?: unknown } }).package;
89 const ecosystem = short(pkg?.ecosystem, 32);
90 const name = short(pkg?.name, 214);
91 if (ecosystem === "" || name === "") continue;
92 const ranges = (item as { ranges?: unknown }).ranges;
93 for (const range of Array.isArray(ranges) ? ranges : []) {
94 let introduced = "0";
95 const events = (range as { events?: unknown }).events;
96 for (const e of Array.isArray(events) ? events : []) {
97 const ev = e as { introduced?: unknown; fixed?: unknown };
98 if (typeof ev.introduced === "string") introduced = ev.introduced.slice(0, 64);
99 if (typeof ev.fixed === "string") {
100 rows.push(row(rec, id, cve, severity, ecosystem, name, introduced, ev.fixed.slice(0, 64)));
101 introduced = "0";
102 }
103 }
104 }
105 }
106 }
107 return ok(rows.filter((x) => (x.introduced === "0" || VERSION.test(x.introduced)) && (x.fixed === "" || VERSION.test(x.fixed))));
108 }
109
110 function row(rec: Record<string, unknown>, id: string, cve: string | undefined, severity: string, ecosystem: string, name: string, introduced: string, fixed: string): Advisory {
111 return {
112 id,
113 ecosystem,
114 package: name,
115 introduced,
116 fixed,
117 cve: cve ?? "",
118 summary: short(rec["summary"], 300),
119 severity,
120 modified: short(rec["modified"], 40),
121 };
122 }
123
124 /** Bumped whenever the advisory tables change, so a cached exposure knows it is stale. */
125 let tableVersion = 0;
126 export const advisoryVersion = (): number => tableVersion;
127
128 /**
129 * Pasted feed text to the tables. `feed` names it; "" lets the text say (KEV has a
130 * `vulnerabilities` list).
131 */
132 export function ingest(db: Database, text: string, feed: "osv" | "kev" | ""): Result<string, string> {
133 if (feed === "kev" || (feed === "" && /"vulnerabilities"\s*:/.test(text))) {
134 const kev = saveKev(db, text);
135 return kev.ok ? ok(`${String(kev.value)} exploited CVEs noted.`) : err(kev.error);
136 }
137 const osv = parseOsv(text);
138 return osv.ok ? ok(`${String(saveAdvisories(db, osv.value))} advisory ranges saved.`) : err(osv.error);
139 }
140
141 export function saveAdvisories(db: Database, rows: readonly Advisory[]): number {
142 tableVersion++;
143 const q = db.query(
144 `INSERT INTO advisory (id, ecosystem, package, introduced, fixed, cve, summary, severity, modified)
145 VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)
146 ON CONFLICT DO UPDATE SET summary = excluded.summary, severity = excluded.severity,
147 cve = excluded.cve, modified = excluded.modified`,
148 );
149 db.transaction(() => {
150 for (const a of rows) q.run(a.id, a.ecosystem, a.package, a.introduced, a.fixed, a.cve, a.summary, a.severity, a.modified);
151 })();
152 return rows.length;
153 }
154
155 /** CISA KEV JSON (`vulnerabilities[].cveID`) to the exploited-now set. */
156 export function saveKev(db: Database, text: string, now = new Date()): Result<number, string> {
157 let data: unknown;
158 try {
159 data = JSON.parse(text);
160 } catch {
161 return err("not JSON");
162 }
163 const list = (data as { vulnerabilities?: unknown } | null)?.vulnerabilities;
164 if (!Array.isArray(list)) return err("no vulnerabilities list");
165 const ids = list.map((v) => (v as { cveID?: unknown })?.cveID).filter((x): x is string => typeof x === "string" && CVE.test(x));
166 tableVersion++;
167 const q = db.query("INSERT INTO advisory_kev (cve, added_at) VALUES (?1, ?2) ON CONFLICT DO NOTHING");
168 db.transaction(() => {
169 for (const id of ids) q.run(id, now.toISOString());
170 })();
171 return ok(ids.length);
172 }
173
174 export interface Listed extends Advisory {
175 readonly kev: boolean;
176 }
177
178 /** Newest first, exploited ones on top; `q` matches id, CVE, package or summary. */
179 export function listAdvisories(db: Database, q = "", limit = 200): Listed[] {
180 const like = `%${q.replace(/[\\%_]/g, (c) => `\\${c}`)}%`;
181 const rows = db
182 .query(
183 `SELECT a.*, k.cve IS NOT NULL AS kev FROM advisory a LEFT JOIN advisory_kev k ON k.cve = a.cve
184 WHERE ?1 = '%%' OR a.id LIKE ?1 ESCAPE '\\' OR a.cve LIKE ?1 ESCAPE '\\' OR a.package LIKE ?1 ESCAPE '\\' OR a.summary LIKE ?1 ESCAPE '\\'
185 ORDER BY kev DESC, a.modified DESC, a.id LIMIT ?2`,
186 )
187 .all(like, limit) as (Advisory & { kev: number })[];
188 return rows.map((r) => ({ ...r, kev: r.kev === 1 }));
189 }
190
191 /** Direct and transitive packages of an npm lockfile (v2/v3 `packages`). */
192 export function lockfilePackages(text: string): Pkg[] {
193 let data: unknown;
194 try {
195 data = JSON.parse(text);
196 } catch {
outdated

HIGH (denial-of-service / the 50 ms bar): exposure runs listAdvisories(db, "", 5000) once per repository, and forgeExposure calls it for every repo on the forge. Every /advisories view, terminal open and MCP audit call therefore does repos x 5000-row SQL scans plus a git blob read per repo, and the lockfile cache only saves the JSON parse. Fix: load the npm advisories once per forgeExposure, index them by package name, and look up each lockfile package against that index. Better still, cache the result per (lockfile oid, advisory-table version).

197 return [];
198 }
199 const packages = (data as { packages?: Record<string, { version?: unknown }> } | null)?.packages;
200 if (packages === null || typeof packages !== "object" || packages === undefined) return [];
201 const out: Pkg[] = [];
202 for (const [path, p] of Object.entries(packages)) {
203 const at = path.lastIndexOf("node_modules/");
204 if (at < 0 || typeof p?.version !== "string") continue;
205 out.push({ name: path.slice(at + "node_modules/".length), version: p.version });
206 }
207 return out;
208 }
209
210 export interface Hit {
211 readonly advisory: Listed;
212 readonly package: Pkg;
213 }
214
215 /** The npm advisories by package name: loaded once, then looked up per lockfile package. */
216 export function npmIndex(db: Database): Map<string, Listed[]> {
217 const index = new Map<string, Listed[]>();
218 const rows = db
219 .query(
220 `SELECT a.*, k.cve IS NOT NULL AS kev FROM advisory a LEFT JOIN advisory_kev k ON k.cve = a.cve
221 WHERE a.ecosystem = 'npm'`,
222 )
223 .all() as (Advisory & { kev: number })[];
224 for (const r of rows) {
225 const list = index.get(r.package) ?? [];
226 list.push({ ...r, kev: r.kev === 1 });
227 index.set(r.package, list);
228 }
229 return index;
230 }
231
232 /** Every advisory that hits one of these npm packages. */
233 export function exposure(index: ReadonlyMap<string, readonly Listed[]>, packages: readonly Pkg[]): Hit[] {
234 const hits: Hit[] = [];
235 for (const p of packages)
236 for (const a of index.get(p.name) ?? []) if (affects(a, p.version)) hits.push({ advisory: a, package: p });
237 return hits;
238 }
src/core/advisory_feed.ts added +88
@@ -0,0 +1,88 @@
1 /**
2 * The forge listens by itself: once an hour it reads the CISA KEV list, and
3 * asks OSV about the npm packages in the forges' lockfiles. Both hosts are in
4 * forge.json `egress`. The URLs are fixed here; no text a person typed reaches
5 * them but package names, which travel as JSON in a POST body. A failure is
6 * one line, never thrown: the timer cannot die of it.
7 */
8
9 import type { Database } from "bun:sqlite";
10 import type { App } from "../app.ts";
11 import { parseOsv, saveAdvisories, saveKev } from "./advisories.ts";
12 import { during } from "../perf/jobs.ts";
13
14 const KEV_URL = "https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json";
15 const OSV_BATCH = "https://api.osv.dev/v1/querybatch";
16 const OSV_VULN = "https://api.osv.dev/v1/vulns/";
17 const FEED_MS = 60 * 60_000;
18 const TIMEOUT_MS = 30_000;
19 const NAMES_MAX = 500;
20 const FETCH_MAX = 100;
21 const OSV_ID = /^[A-Za-z0-9][A-Za-z0-9_.:-]{2,63}$/;
22
23 type Fetch = (url: string, init?: RequestInit) => Promise<Response>;
24
25 const get = (f: Fetch, url: string, init?: RequestInit) => f(url, { ...init, signal: AbortSignal.timeout(TIMEOUT_MS) });
26
27 /** The gate's refusal in its own words; else the status. */
28 function why(res: Response, host: string): string {
29 return res.status === 403 && res.headers.get("x-forge-egress") === "refused"
30 ? `refused by this forge: ${host} is not in this app's forge.json egress`
31 : String(res.status);
32 }
33
34 /** The OSV ids for these npm names that the table does not hold yet. */
35 function unknownIds(db: Database, ids: readonly string[]): string[] {
36 const known = new Set((db.query("SELECT DISTINCT id FROM advisory").all() as { id: string }[]).map((r) => r.id));
37 return [...new Set(ids)].filter((id) => OSV_ID.test(id) && !known.has(id)).slice(0, FETCH_MAX);
38 }
39
40 /** One round: KEV, then OSV for `names`. Returns one line saying what was read. */
41 export async function listenOnce(db: Database, names: readonly string[], f: Fetch = fetch): Promise<string> {
42 const said: string[] = [];
43 try {
44 const res = await get(f, KEV_URL);
45 const kev = res.ok ? saveKev(db, await res.text()) : undefined;
46 said.push(kev === undefined ? `KEV ${why(res, "www.cisa.gov")}` : kev.ok ? `KEV ${String(kev.value)}` : `KEV ${kev.error}`);
47 } catch (e) {
48 said.push(`KEV ${String(e)}`.slice(0, 120));
49 }
50 const queries = [...new Set(names)].slice(0, NAMES_MAX).map((name) => ({ package: { ecosystem: "npm", name } }));
51 if (queries.length === 0) return said.join("; ");
52 try {
53 const res = await get(f, OSV_BATCH, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ queries }) });
54 if (!res.ok) return [...said, `OSV ${why(res, "api.osv.dev")}`].join("; ");
55 const body = (await res.json()) as { results?: { vulns?: { id?: unknown }[] }[] };
56 const ids = (body.results ?? []).flatMap((r) => (r.vulns ?? []).map((v) => v.id)).filter((x): x is string => typeof x === "string");
57 let saved = 0;
58 for (const id of unknownIds(db, ids)) {
59 const one = await get(f, OSV_VULN + encodeURIComponent(id));
60 if (!one.ok) continue;
61 const parsed = parseOsv(await one.text());
62 if (parsed.ok) saved += saveAdvisories(db, parsed.value);
63 }
64 said.push(`OSV ${String(saved)} ranges`);
65 } catch (e) {
66 said.push(`OSV ${String(e)}`.slice(0, 120));
67 }
68 return said.join("; ");
69 }
70
71 /** Hourly, and once soon after boot. Returns the timer for shutdown. */
72 export function startAdvisoryFeed(app: App): ReturnType<typeof setInterval> {
73 const round = async (): Promise<void> => {
74 try {
75 // Loaded when a round runs, so the reading above stays light to import.
76 const [{ repoPackages }, { listEveryRepo }] = await Promise.all([import("./exposure.ts"), import("./repos.ts")]);
77 const names = new Set<string>();
78 for (const repo of listEveryRepo(app.db)) for (const p of await repoPackages(app.db, app.reposRoot, repo)) names.add(p.name);
79 app.log.info("advisory feed", { said: await listenOnce(app.db, [...names]) });
80 } catch (e) {
81 app.log.warn("advisory feed failed", { error: String(e) });
82 }
83 };
84 setTimeout(() => during("advisory-feed", () => void round()), 30_000).unref();
85 const timer = setInterval(() => during("advisory-feed", () => void round()), FEED_MS);
86 timer.unref();
87 return timer;
88 }
src/core/exposure.ts added +75
@@ -0,0 +1,75 @@
1 /**
2 * Which repositories an advisory hits: each repository's package-lock.json at
3 * its default branch, parsed once per blob (keyed by its object id), read
4 * against the advisory table.
5 */
6
7 import type { Database } from "bun:sqlite";
8 import { blobForRender } from "../git/read.ts";
9 import { repoDir } from "../git/repos.ts";
10 import { advisoryVersion, exposure, listAdvisories, lockfilePackages, npmIndex, type Listed, type Hit, type Pkg } from "./advisories.ts";
11 import { listEveryRepo, type Repo } from "./repos.ts";
12
13 const LOCKFILE_MAX = 5_000_000;
14 const parsedBy = new WeakMap<Database, Map<string, Pkg[]>>();
15
16 export async function repoPackages(db: Database, reposRoot: string, repo: Repo): Promise<Pkg[]> {
17 const blob = await blobForRender(repoDir(reposRoot, repo.ownerName, repo.name), repo.defaultBranch, "package-lock.json", LOCKFILE_MAX);
18 if (blob.kind !== "text") return [];
19 let parsed = parsedBy.get(db);
20 if (parsed === undefined) parsedBy.set(db, (parsed = new Map()));
21 const seen = parsed.get(blob.oid);
22 if (seen !== undefined) return seen;
23 const packages = lockfilePackages(new TextDecoder().decode(blob.body));
24 if (parsed.size > 500) parsed.clear();
25 parsed.set(blob.oid, packages);
26 return packages;
27 }
28
29 export interface RepoHit {
30 readonly repo: string;
31 readonly hits: Hit[];
32 }
33
34 const FRESH_MS = 60_000;
35 const cached = new WeakMap<Database, { at: number; version: number; value: RepoHit[] }>();
36
37 /**
38 * Every repository on the forge with at least one advisory hitting it. Kept for a
39 * minute and dropped at once when the advisory tables change, so a page, the
40 * terminal and the MCP tool share one scan instead of each doing their own.
41 */
42 export async function forgeExposure(db: Database, reposRoot: string, now = Date.now()): Promise<RepoHit[]> {
43 const hit = cached.get(db);
44 if (hit !== undefined && hit.version === advisoryVersion() && now - hit.at < FRESH_MS) return hit.value;
45 const version = advisoryVersion();
46 const index = npmIndex(db);
47 const out: RepoHit[] = [];
48 for (const repo of listEveryRepo(db)) {
49 const hits = exposure(index, await repoPackages(db, reposRoot, repo));
50 if (hits.length > 0) out.push({ repo: `${repo.ownerName}/${repo.name}`, hits });
51 }
52 cached.set(db, { at: now, version, value: out });
53 return out;
54 }
55
56 export interface Seen extends Listed {
57 readonly repos: string[];
58 }
59
60 /**
61 * What the page, the terminal and the MCP tool all say: advisories matching `q`, those hitting a
62 * repo first.
63 */
64 export async function advisoryView(db: Database, reposRoot: string, q: string): Promise<Seen[]> {
65 const hitting = new Map<string, string[]>();
66 for (const r of await forgeExposure(db, reposRoot))
67 for (const h of r.hits) {
68 const key = `${h.advisory.id}\0${h.advisory.package}`;
69 const repos = hitting.get(key) ?? [];
70 if (!repos.includes(r.repo)) repos.push(r.repo);
71 hitting.set(key, repos);
72 }
73 const all = listAdvisories(db, q).map((a) => ({ ...a, repos: hitting.get(`${a.id}\0${a.package}`) ?? [] }));
74 return [...all.filter((a) => a.repos.length > 0), ...all.filter((a) => a.repos.length === 0)];
75 }
src/core/migration-pins/20261201150000-advisories.pin added +1
@@ -0,0 +1,1 @@
1 384e6127332ed0d4910734d25204dba2d7de43f3fbfbc5e411eecb8c25598d56
src/core/migrations/20261201150000-advisories.ts added +22
@@ -0,0 +1,22 @@
1 // Advisories the forge was handed (OSV records, CISA KEV ids): one row per
2 // affected package range. Additive; derived from the feeds, so it can be
3 // dropped and re-ingested.
4 export default `
5 CREATE TABLE IF NOT EXISTS advisory (
6 id TEXT NOT NULL,
7 ecosystem TEXT NOT NULL,
8 package TEXT NOT NULL,
9 introduced TEXT NOT NULL,
10 fixed TEXT NOT NULL,
11 cve TEXT NOT NULL,
12 summary TEXT NOT NULL,
13 severity TEXT NOT NULL,
14 modified TEXT NOT NULL,
15 PRIMARY KEY (id, ecosystem, package, introduced, fixed)
16 );
17 CREATE INDEX IF NOT EXISTS advisory_package ON advisory(ecosystem, package);
18 CREATE TABLE IF NOT EXISTS advisory_kev (
19 cve TEXT PRIMARY KEY,
20 added_at TEXT NOT NULL
21 );
22 `;
src/core/reserved.ts +1
@@ -121,6 +121,7 @@ export const SYSTEM_NAMES: readonly string[] = [
121121 "now",
122122 "offers",
123123 "resilience",
124 "advisories",
124125 "maintenance",
125126 "origins",
126127 "robots.txt",
src/generated/marks.ts +202 −200
@@ -2,206 +2,207 @@
22 // stale.
33
44 import k0 from "../http/marks/admin.json";
5 import k1 from "../http/marks/agents.json";
6 import k2 from "../http/marks/api-project-envelope.json";
7 import k3 from "../http/marks/api-project-otlp.json";
8 import k4 from "../http/marks/api-v1-admin.json";
9 import k5 from "../http/marks/api-v1-agents.json";
10 import k6 from "../http/marks/api-v1-app-templates.json";
11 import k7 from "../http/marks/api-v1-apps.json";
12 import k8 from "../http/marks/api-v1-asks.json";
13 import k9 from "../http/marks/api-v1-boards.json";
14 import k10 from "../http/marks/api-v1-broker.json";
15 import k11 from "../http/marks/api-v1-builds.json";
16 import k12 from "../http/marks/api-v1-cache.json";
17 import k13 from "../http/marks/api-v1-changelog.json";
18 import k14 from "../http/marks/api-v1-cloud.json";
19 import k15 from "../http/marks/api-v1-codes.json";
20 import k16 from "../http/marks/api-v1-config.json";
21 import k17 from "../http/marks/api-v1-contribute.json";
22 import k18 from "../http/marks/api-v1-conversation-confirms.json";
23 import k19 from "../http/marks/api-v1-conversation-tokens.json";
24 import k20 from "../http/marks/api-v1-conversation.json";
25 import k21 from "../http/marks/api-v1-conversations.json";
26 import k22 from "../http/marks/api-v1-credit.json";
27 import k23 from "../http/marks/api-v1-crew.json";
28 import k24 from "../http/marks/api-v1-devices.json";
29 import k25 from "../http/marks/api-v1-drills.json";
30 import k26 from "../http/marks/api-v1-explore.json";
31 import k27 from "../http/marks/api-v1-family.json";
32 import k28 from "../http/marks/api-v1-features.json";
33 import k29 from "../http/marks/api-v1-feed.json";
34 import k30 from "../http/marks/api-v1-first-admin.json";
35 import k31 from "../http/marks/api-v1-flags.json";
36 import k32 from "../http/marks/api-v1-fleet.json";
37 import k33 from "../http/marks/api-v1-flow.json";
38 import k34 from "../http/marks/api-v1-forge-templates.json";
39 import k35 from "../http/marks/api-v1-forge.json";
40 import k36 from "../http/marks/api-v1-forges.json";
41 import k37 from "../http/marks/api-v1-forks.json";
42 import k38 from "../http/marks/api-v1-front.json";
43 import k39 from "../http/marks/api-v1-games.json";
44 import k40 from "../http/marks/api-v1-health.json";
45 import k41 from "../http/marks/api-v1-heartbeat.json";
46 import k42 from "../http/marks/api-v1-here.json";
47 import k43 from "../http/marks/api-v1-keeper.json";
48 import k44 from "../http/marks/api-v1-maintenance.json";
49 import k45 from "../http/marks/api-v1-map.json";
50 import k46 from "../http/marks/api-v1-migrate.json";
51 import k47 from "../http/marks/api-v1-offers.json";
52 import k48 from "../http/marks/api-v1-openapi.json.json";
53 import k49 from "../http/marks/api-v1-orgs.json";
54 import k50 from "../http/marks/api-v1-packs.json";
55 import k51 from "../http/marks/api-v1-passport.json";
56 import k52 from "../http/marks/api-v1-places.json";
57 import k53 from "../http/marks/api-v1-plans.json";
58 import k54 from "../http/marks/api-v1-proof.json";
59 import k55 from "../http/marks/api-v1-reach.json";
60 import k56 from "../http/marks/api-v1-release.json";
61 import k57 from "../http/marks/api-v1-releases.json";
62 import k58 from "../http/marks/api-v1-repos.json";
63 import k59 from "../http/marks/api-v1-returns.json";
64 import k60 from "../http/marks/api-v1-runner.json";
65 import k61 from "../http/marks/api-v1-search.json";
66 import k62 from "../http/marks/api-v1-secrets.json";
67 import k63 from "../http/marks/api-v1-sessions.json";
68 import k64 from "../http/marks/api-v1-share.json";
69 import k65 from "../http/marks/api-v1-slash.json";
70 import k66 from "../http/marks/api-v1-start.json";
71 import k67 from "../http/marks/api-v1-status.json";
72 import k68 from "../http/marks/api-v1-telemetry.json";
73 import k69 from "../http/marks/api-v1-templates.json";
74 import k70 from "../http/marks/api-v1-thoughts.json";
75 import k71 from "../http/marks/api-v1-timers.json";
76 import k72 from "../http/marks/api-v1-tokens.json";
77 import k73 from "../http/marks/api-v1-usage.json";
78 import k74 from "../http/marks/api-v1-user.json";
79 import k75 from "../http/marks/api-v1-users.json";
80 import k76 from "../http/marks/api-v1-version.json";
81 import k77 from "../http/marks/api-v1.json";
82 import k78 from "../http/marks/api.json";
83 import k79 from "../http/marks/apple-touch-icon-precomposed.png.json";
84 import k80 from "../http/marks/apple-touch-icon.png.json";
85 import k81 from "../http/marks/apps.json";
86 import k82 from "../http/marks/asked.json";
87 import k83 from "../http/marks/asks.json";
88 import k84 from "../http/marks/assets.json";
89 import k85 from "../http/marks/audit.csv.json";
90 import k86 from "../http/marks/audit.json";
91 import k87 from "../http/marks/big.json";
92 import k88 from "../http/marks/board.json";
93 import k89 from "../http/marks/boards.json";
94 import k90 from "../http/marks/bring.json";
95 import k91 from "../http/marks/broker.json";
96 import k92 from "../http/marks/changelog.atom.json";
97 import k93 from "../http/marks/changelog.json";
98 import k94 from "../http/marks/claim.json";
99 import k95 from "../http/marks/cloud.json";
100 import k96 from "../http/marks/cockpit.json";
101 import k97 from "../http/marks/contract.json";
102 import k98 from "../http/marks/contribute.json";
103 import k99 from "../http/marks/csp-report.json";
104 import k100 from "../http/marks/dash.json";
105 import k101 from "../http/marks/data.json";
106 import k102 from "../http/marks/dataset.json";
107 import k103 from "../http/marks/deploy-to.json";
108 import k104 from "../http/marks/design.json";
109 import k105 from "../http/marks/desk.json";
110 import k106 from "../http/marks/displays.json";
111 import k107 from "../http/marks/docs.json";
112 import k108 from "../http/marks/edge.json";
113 import k109 from "../http/marks/edition.json";
114 import k110 from "../http/marks/events.json";
115 import k111 from "../http/marks/explore.atom.json";
116 import k112 from "../http/marks/explore.json";
117 import k113 from "../http/marks/explore.json.json";
118 import k114 from "../http/marks/family.json";
119 import k115 from "../http/marks/favicon.ico.json";
120 import k116 from "../http/marks/feed.json";
121 import k117 from "../http/marks/feed.json.json";
122 import k118 from "../http/marks/first-admin.json";
123 import k119 from "../http/marks/fleet.json";
124 import k120 from "../http/marks/flow.json";
125 import k121 from "../http/marks/forge.json";
126 import k122 from "../http/marks/forges.json";
127 import k123 from "../http/marks/forks.json";
128 import k124 from "../http/marks/front.json";
129 import k125 from "../http/marks/funnel.json";
130 import k126 from "../http/marks/games.json";
131 import k127 from "../http/marks/go.json";
132 import k128 from "../http/marks/health.json";
133 import k129 from "../http/marks/home.json";
134 import k130 from "../http/marks/hooks.json";
135 import k131 from "../http/marks/icons.json";
136 import k132 from "../http/marks/infra.json";
137 import k133 from "../http/marks/join.json";
138 import k134 from "../http/marks/live.json";
139 import k135 from "../http/marks/llms-full.txt.json";
140 import k136 from "../http/marks/llms.txt.json";
141 import k137 from "../http/marks/login.json";
142 import k138 from "../http/marks/logout.json";
143 import k139 from "../http/marks/maintenance-json.json";
144 import k140 from "../http/marks/maintenance.json";
145 import k141 from "../http/marks/manifest.webmanifest.json";
146 import k142 from "../http/marks/map.json";
147 import k143 from "../http/marks/mcp.json";
148 import k144 from "../http/marks/measure.json";
149 import k145 from "../http/marks/metrics.json";
150 import k146 from "../http/marks/migrate.json";
151 import k147 from "../http/marks/new.json";
152 import k148 from "../http/marks/next.json";
153 import k149 from "../http/marks/notes.json";
154 import k150 from "../http/marks/now.json";
155 import k151 from "../http/marks/oauth.json";
156 import k152 from "../http/marks/oembed.json";
157 import k153 from "../http/marks/offers.json";
158 import k154 from "../http/marks/offline.json";
159 import k155 from "../http/marks/og.json";
160 import k156 from "../http/marks/openapi.json.json";
161 import k157 from "../http/marks/opensearch.xml.json";
162 import k158 from "../http/marks/organizations.json";
163 import k159 from "../http/marks/origins.json";
164 import k160 from "../http/marks/owner.atom.json";
165 import k161 from "../http/marks/owner.json";
166 import k162 from "../http/marks/packs.json";
167 import k163 from "../http/marks/peek.json";
168 import k164 from "../http/marks/pinned.json";
169 import k165 from "../http/marks/pipeline.json";
170 import k166 from "../http/marks/plugins.json";
171 import k167 from "../http/marks/pricing.json";
172 import k168 from "../http/marks/privacy.json";
173 import k169 from "../http/marks/r.json";
174 import k170 from "../http/marks/recover.json";
175 import k171 from "../http/marks/releases.json";
176 import k172 from "../http/marks/releases.json.json";
177 import k173 from "../http/marks/repos.json";
178 import k174 from "../http/marks/resilience.json";
179 import k175 from "../http/marks/review.json";
180 import k176 from "../http/marks/robots.txt.json";
181 import k177 from "../http/marks/root.json";
182 import k178 from "../http/marks/runs.json";
183 import k179 from "../http/marks/script-error.json";
184 import k180 from "../http/marks/search.json";
185 import k181 from "../http/marks/security.json";
186 import k182 from "../http/marks/settings.json";
187 import k183 from "../http/marks/sign-in.json";
188 import k184 from "../http/marks/signin.json";
189 import k185 from "../http/marks/signup.json";
190 import k186 from "../http/marks/sitemap.xml.json";
191 import k187 from "../http/marks/status.json";
192 import k188 from "../http/marks/sw.js.json";
193 import k189 from "../http/marks/system.json";
194 import k190 from "../http/marks/talk.json";
195 import k191 from "../http/marks/tell.json";
196 import k192 from "../http/marks/templates.json";
197 import k193 from "../http/marks/templates.json.json";
198 import k194 from "../http/marks/terms.json";
199 import k195 from "../http/marks/theme.json";
200 import k196 from "../http/marks/toolbar-lab.js.json";
201 import k197 from "../http/marks/toolbar-lab.json";
202 import k198 from "../http/marks/verify.json";
203 import k199 from "../http/marks/welcome.json";
204 import k200 from "../http/marks/well-known.json";
5 import k1 from "../http/marks/advisories.json";
6 import k2 from "../http/marks/agents.json";
7 import k3 from "../http/marks/api-project-envelope.json";
8 import k4 from "../http/marks/api-project-otlp.json";
9 import k5 from "../http/marks/api-v1-admin.json";
10 import k6 from "../http/marks/api-v1-agents.json";
11 import k7 from "../http/marks/api-v1-app-templates.json";
12 import k8 from "../http/marks/api-v1-apps.json";
13 import k9 from "../http/marks/api-v1-asks.json";
14 import k10 from "../http/marks/api-v1-boards.json";
15 import k11 from "../http/marks/api-v1-broker.json";
16 import k12 from "../http/marks/api-v1-builds.json";
17 import k13 from "../http/marks/api-v1-cache.json";
18 import k14 from "../http/marks/api-v1-changelog.json";
19 import k15 from "../http/marks/api-v1-cloud.json";
20 import k16 from "../http/marks/api-v1-codes.json";
21 import k17 from "../http/marks/api-v1-config.json";
22 import k18 from "../http/marks/api-v1-contribute.json";
23 import k19 from "../http/marks/api-v1-conversation-confirms.json";
24 import k20 from "../http/marks/api-v1-conversation-tokens.json";
25 import k21 from "../http/marks/api-v1-conversation.json";
26 import k22 from "../http/marks/api-v1-conversations.json";
27 import k23 from "../http/marks/api-v1-credit.json";
28 import k24 from "../http/marks/api-v1-crew.json";
29 import k25 from "../http/marks/api-v1-devices.json";
30 import k26 from "../http/marks/api-v1-drills.json";
31 import k27 from "../http/marks/api-v1-explore.json";
32 import k28 from "../http/marks/api-v1-family.json";
33 import k29 from "../http/marks/api-v1-features.json";
34 import k30 from "../http/marks/api-v1-feed.json";
35 import k31 from "../http/marks/api-v1-first-admin.json";
36 import k32 from "../http/marks/api-v1-flags.json";
37 import k33 from "../http/marks/api-v1-fleet.json";
38 import k34 from "../http/marks/api-v1-flow.json";
39 import k35 from "../http/marks/api-v1-forge-templates.json";
40 import k36 from "../http/marks/api-v1-forge.json";
41 import k37 from "../http/marks/api-v1-forges.json";
42 import k38 from "../http/marks/api-v1-forks.json";
43 import k39 from "../http/marks/api-v1-front.json";
44 import k40 from "../http/marks/api-v1-games.json";
45 import k41 from "../http/marks/api-v1-health.json";
46 import k42 from "../http/marks/api-v1-heartbeat.json";
47 import k43 from "../http/marks/api-v1-here.json";
48 import k44 from "../http/marks/api-v1-keeper.json";
49 import k45 from "../http/marks/api-v1-maintenance.json";
50 import k46 from "../http/marks/api-v1-map.json";
51 import k47 from "../http/marks/api-v1-migrate.json";
52 import k48 from "../http/marks/api-v1-offers.json";
53 import k49 from "../http/marks/api-v1-openapi.json.json";
54 import k50 from "../http/marks/api-v1-orgs.json";
55 import k51 from "../http/marks/api-v1-packs.json";
56 import k52 from "../http/marks/api-v1-passport.json";
57 import k53 from "../http/marks/api-v1-places.json";
58 import k54 from "../http/marks/api-v1-plans.json";
59 import k55 from "../http/marks/api-v1-proof.json";
60 import k56 from "../http/marks/api-v1-reach.json";
61 import k57 from "../http/marks/api-v1-release.json";
62 import k58 from "../http/marks/api-v1-releases.json";
63 import k59 from "../http/marks/api-v1-repos.json";
64 import k60 from "../http/marks/api-v1-returns.json";
65 import k61 from "../http/marks/api-v1-runner.json";
66 import k62 from "../http/marks/api-v1-search.json";
67 import k63 from "../http/marks/api-v1-secrets.json";
68 import k64 from "../http/marks/api-v1-sessions.json";
69 import k65 from "../http/marks/api-v1-share.json";
70 import k66 from "../http/marks/api-v1-slash.json";
71 import k67 from "../http/marks/api-v1-start.json";
72 import k68 from "../http/marks/api-v1-status.json";
73 import k69 from "../http/marks/api-v1-telemetry.json";
74 import k70 from "../http/marks/api-v1-templates.json";
75 import k71 from "../http/marks/api-v1-thoughts.json";
76 import k72 from "../http/marks/api-v1-timers.json";
77 import k73 from "../http/marks/api-v1-tokens.json";
78 import k74 from "../http/marks/api-v1-usage.json";
79 import k75 from "../http/marks/api-v1-user.json";
80 import k76 from "../http/marks/api-v1-users.json";
81 import k77 from "../http/marks/api-v1-version.json";
82 import k78 from "../http/marks/api-v1.json";
83 import k79 from "../http/marks/api.json";
84 import k80 from "../http/marks/apple-touch-icon-precomposed.png.json";
85 import k81 from "../http/marks/apple-touch-icon.png.json";
86 import k82 from "../http/marks/apps.json";
87 import k83 from "../http/marks/asked.json";
88 import k84 from "../http/marks/asks.json";
89 import k85 from "../http/marks/assets.json";
90 import k86 from "../http/marks/audit.csv.json";
91 import k87 from "../http/marks/audit.json";
92 import k88 from "../http/marks/big.json";
93 import k89 from "../http/marks/board.json";
94 import k90 from "../http/marks/boards.json";
95 import k91 from "../http/marks/bring.json";
96 import k92 from "../http/marks/broker.json";
97 import k93 from "../http/marks/changelog.atom.json";
98 import k94 from "../http/marks/changelog.json";
99 import k95 from "../http/marks/claim.json";
100 import k96 from "../http/marks/cloud.json";
101 import k97 from "../http/marks/cockpit.json";
102 import k98 from "../http/marks/contract.json";
103 import k99 from "../http/marks/contribute.json";
104 import k100 from "../http/marks/csp-report.json";
105 import k101 from "../http/marks/dash.json";
106 import k102 from "../http/marks/data.json";
107 import k103 from "../http/marks/dataset.json";
108 import k104 from "../http/marks/deploy-to.json";
109 import k105 from "../http/marks/design.json";
110 import k106 from "../http/marks/desk.json";
111 import k107 from "../http/marks/displays.json";
112 import k108 from "../http/marks/docs.json";
113 import k109 from "../http/marks/edge.json";
114 import k110 from "../http/marks/edition.json";
115 import k111 from "../http/marks/events.json";
116 import k112 from "../http/marks/explore.atom.json";
117 import k113 from "../http/marks/explore.json";
118 import k114 from "../http/marks/explore.json.json";
119 import k115 from "../http/marks/family.json";
120 import k116 from "../http/marks/favicon.ico.json";
121 import k117 from "../http/marks/feed.json";
122 import k118 from "../http/marks/feed.json.json";
123 import k119 from "../http/marks/first-admin.json";
124 import k120 from "../http/marks/fleet.json";
125 import k121 from "../http/marks/flow.json";
126 import k122 from "../http/marks/forge.json";
127 import k123 from "../http/marks/forges.json";
128 import k124 from "../http/marks/forks.json";
129 import k125 from "../http/marks/front.json";
130 import k126 from "../http/marks/funnel.json";
131 import k127 from "../http/marks/games.json";
132 import k128 from "../http/marks/go.json";
133 import k129 from "../http/marks/health.json";
134 import k130 from "../http/marks/home.json";
135 import k131 from "../http/marks/hooks.json";
136 import k132 from "../http/marks/icons.json";
137 import k133 from "../http/marks/infra.json";
138 import k134 from "../http/marks/join.json";
139 import k135 from "../http/marks/live.json";
140 import k136 from "../http/marks/llms-full.txt.json";
141 import k137 from "../http/marks/llms.txt.json";
142 import k138 from "../http/marks/login.json";
143 import k139 from "../http/marks/logout.json";
144 import k140 from "../http/marks/maintenance-json.json";
145 import k141 from "../http/marks/maintenance.json";
146 import k142 from "../http/marks/manifest.webmanifest.json";
147 import k143 from "../http/marks/map.json";
148 import k144 from "../http/marks/mcp.json";
149 import k145 from "../http/marks/measure.json";
150 import k146 from "../http/marks/metrics.json";
151 import k147 from "../http/marks/migrate.json";
152 import k148 from "../http/marks/new.json";
153 import k149 from "../http/marks/next.json";
154 import k150 from "../http/marks/notes.json";
155 import k151 from "../http/marks/now.json";
156 import k152 from "../http/marks/oauth.json";
157 import k153 from "../http/marks/oembed.json";
158 import k154 from "../http/marks/offers.json";
159 import k155 from "../http/marks/offline.json";
160 import k156 from "../http/marks/og.json";
161 import k157 from "../http/marks/openapi.json.json";
162 import k158 from "../http/marks/opensearch.xml.json";
163 import k159 from "../http/marks/organizations.json";
164 import k160 from "../http/marks/origins.json";
165 import k161 from "../http/marks/owner.atom.json";
166 import k162 from "../http/marks/owner.json";
167 import k163 from "../http/marks/packs.json";
168 import k164 from "../http/marks/peek.json";
169 import k165 from "../http/marks/pinned.json";
170 import k166 from "../http/marks/pipeline.json";
171 import k167 from "../http/marks/plugins.json";
172 import k168 from "../http/marks/pricing.json";
173 import k169 from "../http/marks/privacy.json";
174 import k170 from "../http/marks/r.json";
175 import k171 from "../http/marks/recover.json";
176 import k172 from "../http/marks/releases.json";
177 import k173 from "../http/marks/releases.json.json";
178 import k174 from "../http/marks/repos.json";
179 import k175 from "../http/marks/resilience.json";
180 import k176 from "../http/marks/review.json";
181 import k177 from "../http/marks/robots.txt.json";
182 import k178 from "../http/marks/root.json";
183 import k179 from "../http/marks/runs.json";
184 import k180 from "../http/marks/script-error.json";
185 import k181 from "../http/marks/search.json";
186 import k182 from "../http/marks/security.json";
187 import k183 from "../http/marks/settings.json";
188 import k184 from "../http/marks/sign-in.json";
189 import k185 from "../http/marks/signin.json";
190 import k186 from "../http/marks/signup.json";
191 import k187 from "../http/marks/sitemap.xml.json";
192 import k188 from "../http/marks/status.json";
193 import k189 from "../http/marks/sw.js.json";
194 import k190 from "../http/marks/system.json";
195 import k191 from "../http/marks/talk.json";
196 import k192 from "../http/marks/tell.json";
197 import k193 from "../http/marks/templates.json";
198 import k194 from "../http/marks/templates.json.json";
199 import k195 from "../http/marks/terms.json";
200 import k196 from "../http/marks/theme.json";
201 import k197 from "../http/marks/toolbar-lab.js.json";
202 import k198 from "../http/marks/toolbar-lab.json";
203 import k199 from "../http/marks/verify.json";
204 import k200 from "../http/marks/welcome.json";
205 import k201 from "../http/marks/well-known.json";
205206
206207 /** Each file of `http/marks/`, parsed, in name order. */
207208 export const MARK_FILES: readonly unknown[] = [
@@ -406,4 +407,5 @@ export const MARK_FILES: readonly unknown[] = [
406407 k198,
407408 k199,
408409 k200,
410 k201,
409411 ];
src/generated/migrations.ts +16 −14
@@ -451,13 +451,14 @@ import m446 from "../core/migrations/20261201130000-game-box-boot.ts";
451451 import m447 from "../core/migrations/20261201140000-app-registry-item.ts";
452452 import m448 from "../core/migrations/20261201140000-infra-snapshot.ts";
453453 import m449 from "../core/migrations/20261201140000-scan-finding-excerpt.ts";
454 import m450 from "../core/migrations/20261201150000-dns-record.ts";
455 import m451 from "../core/migrations/20261201150000-pinned-firewall.ts";
456 import m452 from "../core/migrations/20261201170000-managed-database.ts";
457 import m453 from "../core/migrations/20261201180000-game-box-diag.ts";
458 import m454 from "../core/migrations/20261201190000-working-edit.ts";
459 import m455 from "../core/migrations/20261201190500-runner-machine.ts";
460 import m456 from "../core/migrations/20261201200000-cloud-projects.ts";
454 import m450 from "../core/migrations/20261201150000-advisories.ts";
455 import m451 from "../core/migrations/20261201150000-dns-record.ts";
456 import m452 from "../core/migrations/20261201150000-pinned-firewall.ts";
457 import m453 from "../core/migrations/20261201170000-managed-database.ts";
458 import m454 from "../core/migrations/20261201180000-game-box-diag.ts";
459 import m455 from "../core/migrations/20261201190000-working-edit.ts";
460 import m456 from "../core/migrations/20261201190500-runner-machine.ts";
461 import m457 from "../core/migrations/20261201200000-cloud-projects.ts";
461462
462463 /** Each migration file's name and its default export, in name order. */
463464 export const MIGRATION_MODULES: readonly (readonly [string, unknown])[] = [
@@ -911,11 +912,12 @@ export const MIGRATION_MODULES: readonly (readonly [string, unknown])[] = [
911912 ["20261201140000-app-registry-item.ts", m447],
912913 ["20261201140000-infra-snapshot.ts", m448],
913914 ["20261201140000-scan-finding-excerpt.ts", m449],
914 ["20261201150000-dns-record.ts", m450],
915 ["20261201150000-pinned-firewall.ts", m451],
916 ["20261201170000-managed-database.ts", m452],
917 ["20261201180000-game-box-diag.ts", m453],
918 ["20261201190000-working-edit.ts", m454],
919 ["20261201190500-runner-machine.ts", m455],
920 ["20261201200000-cloud-projects.ts", m456],
915 ["20261201150000-advisories.ts", m450],
916 ["20261201150000-dns-record.ts", m451],
917 ["20261201150000-pinned-firewall.ts", m452],
918 ["20261201170000-managed-database.ts", m453],
919 ["20261201180000-game-box-diag.ts", m454],
920 ["20261201190000-working-edit.ts", m455],
921 ["20261201190500-runner-machine.ts", m456],
922 ["20261201200000-cloud-projects.ts", m457],
921923 ];
src/generated/screens.ts +133 −131
@@ -4,131 +4,132 @@
44 import * as s0 from "../tui/screens/abstractions.ts";
55 import * as s1 from "../tui/screens/access.ts";
66 import * as s2 from "../tui/screens/account_access.ts";
7 import * as s3 from "../tui/screens/agents.ts";
8 import * as s4 from "../tui/screens/app_templates.ts";
9 import * as s5 from "../tui/screens/apps_crew.ts";
10 import * as s6 from "../tui/screens/archived.ts";
11 import * as s7 from "../tui/screens/ask_data.ts";
12 import * as s8 from "../tui/screens/audit.ts";
13 import * as s9 from "../tui/screens/bets.ts";
14 import * as s10 from "../tui/screens/billing.ts";
15 import * as s11 from "../tui/screens/billinglinks.ts";
16 import * as s12 from "../tui/screens/bills.ts";
17 import * as s13 from "../tui/screens/boards.ts";
18 import * as s14 from "../tui/screens/bottleneck.ts";
19 import * as s15 from "../tui/screens/buckets.ts";
20 import * as s16 from "../tui/screens/bugs.ts";
21 import * as s17 from "../tui/screens/bulk.ts";
22 import * as s18 from "../tui/screens/captain.ts";
23 import * as s19 from "../tui/screens/childcredit.ts";
24 import * as s20 from "../tui/screens/claim_link.ts";
25 import * as s21 from "../tui/screens/claim_start.ts";
26 import * as s22 from "../tui/screens/cloud.ts";
27 import * as s23 from "../tui/screens/codes.ts";
28 import * as s24 from "../tui/screens/connections.ts";
29 import * as s25 from "../tui/screens/controls.ts";
30 import * as s26 from "../tui/screens/cores.ts";
31 import * as s27 from "../tui/screens/crewbudgets.ts";
32 import * as s28 from "../tui/screens/crewfallback.ts";
33 import * as s29 from "../tui/screens/crewhandover.ts";
34 import * as s30 from "../tui/screens/crewkey.ts";
35 import * as s31 from "../tui/screens/crewsplits.ts";
36 import * as s32 from "../tui/screens/crewtop.ts";
37 import * as s33 from "../tui/screens/dataset.ts";
38 import * as s34 from "../tui/screens/design.ts";
39 import * as s35 from "../tui/screens/design_gallery.ts";
40 import * as s36 from "../tui/screens/devices.ts";
41 import * as s37 from "../tui/screens/disks.ts";
42 import * as s38 from "../tui/screens/displays.ts";
43 import * as s39 from "../tui/screens/domains.ts";
44 import * as s40 from "../tui/screens/dotfiles.ts";
45 import * as s41 from "../tui/screens/drift.ts";
46 import * as s42 from "../tui/screens/dutybudgets.ts";
47 import * as s43 from "../tui/screens/dutyswitch.ts";
48 import * as s44 from "../tui/screens/economics.ts";
49 import * as s45 from "../tui/screens/edgeonly.ts";
50 import * as s46 from "../tui/screens/experiments.ts";
51 import * as s47 from "../tui/screens/featurefeed.ts";
52 import * as s48 from "../tui/screens/features.ts";
53 import * as s49 from "../tui/screens/featureswitch.ts";
54 import * as s50 from "../tui/screens/feed.ts";
55 import * as s51 from "../tui/screens/flowsall.ts";
56 import * as s52 from "../tui/screens/footing.ts";
57 import * as s53 from "../tui/screens/forgeready.ts";
58 import * as s54 from "../tui/screens/forges.ts";
59 import * as s55 from "../tui/screens/forgeview.ts";
60 import * as s56 from "../tui/screens/front.ts";
61 import * as s57 from "../tui/screens/frontms.ts";
62 import * as s58 from "../tui/screens/funnel.ts";
63 import * as s59 from "../tui/screens/games.ts";
64 import * as s60 from "../tui/screens/gifts.ts";
65 import * as s61 from "../tui/screens/health_voice.ts";
66 import * as s62 from "../tui/screens/home_pins.ts";
67 import * as s63 from "../tui/screens/hostreach.ts";
68 import * as s64 from "../tui/screens/infra.ts";
69 import * as s65 from "../tui/screens/inventory.ts";
70 import * as s66 from "../tui/screens/invites.ts";
71 import * as s67 from "../tui/screens/knobs.ts";
72 import * as s68 from "../tui/screens/lapsed.ts";
73 import * as s69 from "../tui/screens/limits.ts";
74 import * as s70 from "../tui/screens/loopstalls.ts";
75 import * as s71 from "../tui/screens/madefrom.ts";
76 import * as s72 from "../tui/screens/maintainruns.ts";
77 import * as s73 from "../tui/screens/maintenance.ts";
78 import * as s74 from "../tui/screens/maintenanceweek.ts";
79 import * as s75 from "../tui/screens/mergedbranches.ts";
80 import * as s76 from "../tui/screens/mirrorpacks.ts";
81 import * as s77 from "../tui/screens/model.ts";
82 import * as s78 from "../tui/screens/money.ts";
83 import * as s79 from "../tui/screens/newissue.ts";
84 import * as s80 from "../tui/screens/next.ts";
85 import * as s81 from "../tui/screens/nowlist.ts";
86 import * as s82 from "../tui/screens/offers.ts";
87 import * as s83 from "../tui/screens/offsite.ts";
88 import * as s84 from "../tui/screens/orggrants.ts";
89 import * as s85 from "../tui/screens/orgteams.ts";
90 import * as s86 from "../tui/screens/originahead.ts";
91 import * as s87 from "../tui/screens/owner.ts";
92 import * as s88 from "../tui/screens/packrepos.ts";
93 import * as s89 from "../tui/screens/payments.ts";
94 import * as s90 from "../tui/screens/people.ts";
95 import * as s91 from "../tui/screens/pinned.ts";
96 import * as s92 from "../tui/screens/planner.ts";
97 import * as s93 from "../tui/screens/planrow.ts";
98 import * as s94 from "../tui/screens/plans.ts";
99 import * as s95 from "../tui/screens/previewdirs.ts";
100 import * as s96 from "../tui/screens/profile.ts";
101 import * as s97 from "../tui/screens/quotas.ts";
102 import * as s98 from "../tui/screens/recoverykit.ts";
103 import * as s99 from "../tui/screens/refused.ts";
104 import * as s100 from "../tui/screens/registry_items.ts";
105 import * as s101 from "../tui/screens/repolist.ts";
106 import * as s102 from "../tui/screens/requests.ts";
107 import * as s103 from "../tui/screens/resilience.ts";
108 import * as s104 from "../tui/screens/returning.ts";
109 import * as s105 from "../tui/screens/returns.ts";
110 import * as s106 from "../tui/screens/scorecard.ts";
111 import * as s107 from "../tui/screens/scrapes.ts";
112 import * as s108 from "../tui/screens/secrets.ts";
113 import * as s109 from "../tui/screens/sentinel.ts";
114 import * as s110 from "../tui/screens/series.ts";
115 import * as s111 from "../tui/screens/ship_time.ts";
116 import * as s112 from "../tui/screens/slowpages.ts";
117 import * as s113 from "../tui/screens/sold.ts";
118 import * as s114 from "../tui/screens/spend.ts";
119 import * as s115 from "../tui/screens/stalepulls.ts";
120 import * as s116 from "../tui/screens/subscriptions.ts";
121 import * as s117 from "../tui/screens/system.ts";
122 import * as s118 from "../tui/screens/teams.ts";
123 import * as s119 from "../tui/screens/telemetry.ts";
124 import * as s120 from "../tui/screens/tell_undo.ts";
125 import * as s121 from "../tui/screens/traffic.ts";
126 import * as s122 from "../tui/screens/trafficview.ts";
127 import * as s123 from "../tui/screens/valves.ts";
128 import * as s124 from "../tui/screens/waiting.ts";
129 import * as s125 from "../tui/screens/waiting_for_me.ts";
130 import * as s126 from "../tui/screens/wayback.ts";
131 import * as s127 from "../tui/screens/weekcard.ts";
7 import * as s3 from "../tui/screens/advisories.ts";
8 import * as s4 from "../tui/screens/agents.ts";
9 import * as s5 from "../tui/screens/app_templates.ts";
10 import * as s6 from "../tui/screens/apps_crew.ts";
11 import * as s7 from "../tui/screens/archived.ts";
12 import * as s8 from "../tui/screens/ask_data.ts";
13 import * as s9 from "../tui/screens/audit.ts";
14 import * as s10 from "../tui/screens/bets.ts";
15 import * as s11 from "../tui/screens/billing.ts";
16 import * as s12 from "../tui/screens/billinglinks.ts";
17 import * as s13 from "../tui/screens/bills.ts";
18 import * as s14 from "../tui/screens/boards.ts";
19 import * as s15 from "../tui/screens/bottleneck.ts";
20 import * as s16 from "../tui/screens/buckets.ts";
21 import * as s17 from "../tui/screens/bugs.ts";
22 import * as s18 from "../tui/screens/bulk.ts";
23 import * as s19 from "../tui/screens/captain.ts";
24 import * as s20 from "../tui/screens/childcredit.ts";
25 import * as s21 from "../tui/screens/claim_link.ts";
26 import * as s22 from "../tui/screens/claim_start.ts";
27 import * as s23 from "../tui/screens/cloud.ts";
28 import * as s24 from "../tui/screens/codes.ts";
29 import * as s25 from "../tui/screens/connections.ts";
30 import * as s26 from "../tui/screens/controls.ts";
31 import * as s27 from "../tui/screens/cores.ts";
32 import * as s28 from "../tui/screens/crewbudgets.ts";
33 import * as s29 from "../tui/screens/crewfallback.ts";
34 import * as s30 from "../tui/screens/crewhandover.ts";
35 import * as s31 from "../tui/screens/crewkey.ts";
36 import * as s32 from "../tui/screens/crewsplits.ts";
37 import * as s33 from "../tui/screens/crewtop.ts";
38 import * as s34 from "../tui/screens/dataset.ts";
39 import * as s35 from "../tui/screens/design.ts";
40 import * as s36 from "../tui/screens/design_gallery.ts";
41 import * as s37 from "../tui/screens/devices.ts";
42 import * as s38 from "../tui/screens/disks.ts";
43 import * as s39 from "../tui/screens/displays.ts";
44 import * as s40 from "../tui/screens/domains.ts";
45 import * as s41 from "../tui/screens/dotfiles.ts";
46 import * as s42 from "../tui/screens/drift.ts";
47 import * as s43 from "../tui/screens/dutybudgets.ts";
48 import * as s44 from "../tui/screens/dutyswitch.ts";
49 import * as s45 from "../tui/screens/economics.ts";
50 import * as s46 from "../tui/screens/edgeonly.ts";
51 import * as s47 from "../tui/screens/experiments.ts";
52 import * as s48 from "../tui/screens/featurefeed.ts";
53 import * as s49 from "../tui/screens/features.ts";
54 import * as s50 from "../tui/screens/featureswitch.ts";
55 import * as s51 from "../tui/screens/feed.ts";
56 import * as s52 from "../tui/screens/flowsall.ts";
57 import * as s53 from "../tui/screens/footing.ts";
58 import * as s54 from "../tui/screens/forgeready.ts";
59 import * as s55 from "../tui/screens/forges.ts";
60 import * as s56 from "../tui/screens/forgeview.ts";
61 import * as s57 from "../tui/screens/front.ts";
62 import * as s58 from "../tui/screens/frontms.ts";
63 import * as s59 from "../tui/screens/funnel.ts";
64 import * as s60 from "../tui/screens/games.ts";
65 import * as s61 from "../tui/screens/gifts.ts";
66 import * as s62 from "../tui/screens/health_voice.ts";
67 import * as s63 from "../tui/screens/home_pins.ts";
68 import * as s64 from "../tui/screens/hostreach.ts";
69 import * as s65 from "../tui/screens/infra.ts";
70 import * as s66 from "../tui/screens/inventory.ts";
71 import * as s67 from "../tui/screens/invites.ts";
72 import * as s68 from "../tui/screens/knobs.ts";
73 import * as s69 from "../tui/screens/lapsed.ts";
74 import * as s70 from "../tui/screens/limits.ts";
75 import * as s71 from "../tui/screens/loopstalls.ts";
76 import * as s72 from "../tui/screens/madefrom.ts";
77 import * as s73 from "../tui/screens/maintainruns.ts";
78 import * as s74 from "../tui/screens/maintenance.ts";
79 import * as s75 from "../tui/screens/maintenanceweek.ts";
80 import * as s76 from "../tui/screens/mergedbranches.ts";
81 import * as s77 from "../tui/screens/mirrorpacks.ts";
82 import * as s78 from "../tui/screens/model.ts";
83 import * as s79 from "../tui/screens/money.ts";
84 import * as s80 from "../tui/screens/newissue.ts";
85 import * as s81 from "../tui/screens/next.ts";
86 import * as s82 from "../tui/screens/nowlist.ts";
87 import * as s83 from "../tui/screens/offers.ts";
88 import * as s84 from "../tui/screens/offsite.ts";
89 import * as s85 from "../tui/screens/orggrants.ts";
90 import * as s86 from "../tui/screens/orgteams.ts";
91 import * as s87 from "../tui/screens/originahead.ts";
92 import * as s88 from "../tui/screens/owner.ts";
93 import * as s89 from "../tui/screens/packrepos.ts";
94 import * as s90 from "../tui/screens/payments.ts";
95 import * as s91 from "../tui/screens/people.ts";
96 import * as s92 from "../tui/screens/pinned.ts";
97 import * as s93 from "../tui/screens/planner.ts";
98 import * as s94 from "../tui/screens/planrow.ts";
99 import * as s95 from "../tui/screens/plans.ts";
100 import * as s96 from "../tui/screens/previewdirs.ts";
101 import * as s97 from "../tui/screens/profile.ts";
102 import * as s98 from "../tui/screens/quotas.ts";
103 import * as s99 from "../tui/screens/recoverykit.ts";
104 import * as s100 from "../tui/screens/refused.ts";
105 import * as s101 from "../tui/screens/registry_items.ts";
106 import * as s102 from "../tui/screens/repolist.ts";
107 import * as s103 from "../tui/screens/requests.ts";
108 import * as s104 from "../tui/screens/resilience.ts";
109 import * as s105 from "../tui/screens/returning.ts";
110 import * as s106 from "../tui/screens/returns.ts";
111 import * as s107 from "../tui/screens/scorecard.ts";
112 import * as s108 from "../tui/screens/scrapes.ts";
113 import * as s109 from "../tui/screens/secrets.ts";
114 import * as s110 from "../tui/screens/sentinel.ts";
115 import * as s111 from "../tui/screens/series.ts";
116 import * as s112 from "../tui/screens/ship_time.ts";
117 import * as s113 from "../tui/screens/slowpages.ts";
118 import * as s114 from "../tui/screens/sold.ts";
119 import * as s115 from "../tui/screens/spend.ts";
120 import * as s116 from "../tui/screens/stalepulls.ts";
121 import * as s117 from "../tui/screens/subscriptions.ts";
122 import * as s118 from "../tui/screens/system.ts";
123 import * as s119 from "../tui/screens/teams.ts";
124 import * as s120 from "../tui/screens/telemetry.ts";
125 import * as s121 from "../tui/screens/tell_undo.ts";
126 import * as s122 from "../tui/screens/traffic.ts";
127 import * as s123 from "../tui/screens/trafficview.ts";
128 import * as s124 from "../tui/screens/valves.ts";
129 import * as s125 from "../tui/screens/waiting.ts";
130 import * as s126 from "../tui/screens/waiting_for_me.ts";
131 import * as s127 from "../tui/screens/wayback.ts";
132 import * as s128 from "../tui/screens/weekcard.ts";
132133
133134 /** Each screen file that declares palette entries: its module and the export names. */
134135 export const SCREEN_MODULES: readonly (readonly [Record<string, unknown>, readonly string[]])[] = [
@@ -152,8 +153,8 @@ export const SCREEN_MODULES: readonly (readonly [Record<string, unknown>, readon
152153 [s17, ["entry"]],
153154 [s18, ["entry"]],
154155 [s19, ["entry"]],
155 [s20, ["entry","recoveryEntry"]],
156 [s21, ["entry"]],
156 [s20, ["entry"]],
157 [s21, ["entry","recoveryEntry"]],
157158 [s22, ["entry"]],
158159 [s23, ["entry"]],
159160 [s24, ["entry"]],
@@ -209,11 +210,11 @@ export const SCREEN_MODULES: readonly (readonly [Record<string, unknown>, readon
209210 [s74, ["entry"]],
210211 [s75, ["entry"]],
211212 [s76, ["entry"]],
212 [s77, ["modelGrantEntry","modelCeilingEntry"]],
213 [s78, ["entry"]],
213 [s77, ["entry"]],
214 [s78, ["modelGrantEntry","modelCeilingEntry"]],
214215 [s79, ["entry"]],
215 [s80, ["nextAllEntry"]],
216 [s81, ["entry"]],
216 [s80, ["entry"]],
217 [s81, ["nextAllEntry"]],
217218 [s82, ["entry"]],
218219 [s83, ["entry"]],
219220 [s84, ["entry"]],
@@ -260,4 +261,5 @@ export const SCREEN_MODULES: readonly (readonly [Record<string, unknown>, readon
260261 [s125, ["entry"]],
261262 [s126, ["entry"]],
262263 [s127, ["entry"]],
264 [s128, ["entry"]],
263265 ];
src/http/lazy_lists.ts +2
@@ -610,6 +610,8 @@ export const OPERATIONS_ROUTES = [
610610 ["POST", "/games/:box/:service/jar"],
611611 ["POST", "/games/:box/:service/settings"],
612612 ["GET", "/resilience"],
613 ["GET", "/advisories"],
614 ["POST", "/advisories"],
613615 ["GET", "/maintenance"],
614616 ["GET", "/maintenance.json"],
615617 ["POST", "/maintenance/prepare"],
src/http/marks/advisories.json added +4
@@ -0,0 +1,4 @@
1 {
2 "head": "/advisories",
3 "mark": "admin"
4 }
src/http/mcp/tools/audit.ts +9 −7
@@ -1,24 +1,26 @@
11 import { audit } from "../../../contract/audit.ts";
22 import { appsOf } from "../../../web/studio/asks.ts";
3 import { good, type Tool, REPO_ARG, repoArg, isAnswer } from "../shared.ts";
3 import { advisoryView } from "../../../core/exposure.ts";
4 import { good, bad, type Tool, REPO_ARG, mayBoards, repoArg, isAnswer } from "../shared.ts";
45
56 export const tool: Tool = {
67 name: "audit",
7 doc: "`{ repo? }`: who can do what, per app (all you can see without `repo`), read from its contract.json in git: yes, own or no per door, and whether outsiders may direct its crew (`crewOutsiders`)",
8 doc: "`{ repo?, advisories? }`: with `advisories` (a search text, empty for all), a forge admin gets the known vulnerabilities and the repositories they hit instead; otherwise who can do what, per app (all you can see without `repo`), read from its contract.json in git: yes, own or no per door, and whether outsiders may direct its crew (`crewOutsiders`)",
89 description:
910 "Who can do what per app: resource × verb, yes, own or no.",
1011 inputSchema: {
1112 type: "object",
1213 properties: {
13 repo: {
14 ...REPO_ARG,
15 description:
16 "owner/name; all when absent.",
17 },
14 repo: REPO_ARG,
15 advisories: { type: "string" },
1816 },
1917 },
2018 writes: false,
2119 async run(ctx, user, args) {
20 if (typeof args["advisories"] === "string") {
21 if (!mayBoards(user)) return bad("forbidden", "advisories are for a forge admin who is a person");
22 return good({ advisories: await advisoryView(ctx.app.db, ctx.app.reposRoot, args["advisories"].slice(0, 80)) });
23 }
2224 const one =
2325 typeof args["repo"] === "string" ? repoArg(ctx, user, args) : undefined;
2426 if (one !== undefined && isAnswer(one)) return one;
src/http/routes/operations.ts +3
@@ -18,6 +18,7 @@ import { forkFlowsPage } from "../../web/pages/fork-flows.ts";
1818 import { maintenanceBudget } from "../../web/pages/maintenance_budgets.ts";
1919 import { maintenancePage, maintenanceJson, maintenancePrepare, maintenanceResume, maintenanceDuty, maintenanceDismiss, maintenanceQuiet, maintenanceUnquiet, maintenanceReopen, staleAction, mergedAction, previewAction } from "../../web/pages/maintenance.ts";
2020 import { pipelinePage } from "../../web/pages/pipeline.ts";
21 import { advisoriesIngest, advisoriesPage } from "../../web/pages/advisories.ts";
2122 import { resiliencePage, nightlyOutputPage } from "../../web/pages/resilience.ts";
2223 import { runRedirect } from "../../web/pages/runs.ts";
2324 import { oauthCallbackUri } from "../api.ts";
@@ -63,6 +64,8 @@ export function operationsRoutes(router: Router<Handler>, knownPatterns: () => s
6364 gamesRoutes(router);
6465 // Each THREATS.md protection against the last gate; literal, above /:owner.
6566 router.add("GET", "/resilience", resiliencePage);
67 router.add("GET", "/advisories", advisoriesPage);
68 router.add("POST", "/advisories", advisoriesIngest);
6669 router.add("GET", "/maintenance", maintenancePage);
6770 router.add("GET", "/maintenance.json", maintenanceJson);
6871 router.add("POST", "/maintenance/prepare", maintenancePrepare);
src/main.ts +4
@@ -50,6 +50,7 @@ import { isPreviewEnv } from "./spawn/preview_who.ts";
5050 import { startHeartbeat } from "./spawn/heartbeat.ts";
5151 import { startMachineBeats } from "./spawn/machine_beats.ts";
5252 import { startUpstreamWatch } from "./spawn/upstream.ts";
53 import { startAdvisoryFeed } from "./core/advisory_feed.ts";
5354 import { followTick, watchLandings } from "./spawn/app_follow.ts";
5455 import { startReachWatch } from "./spawn/reach.ts";
5556 import { isHookName, runHookClient } from "./git/hooks.ts";
@@ -855,6 +856,8 @@ const heartbeatTimer = inert ? undefined : startHeartbeat(app);
855856 const machineBeatTimer = inert ? undefined : startMachineBeats(app);
856857 // ...and looks upstream once an hour (spawn/upstream.ts).
857858 const upstreamTimer = inert ? undefined : startUpstreamWatch(app);
859 // The advisory feeds, read once an hour (core/advisory_feed.ts).
860 const advisoryTimer = inert ? undefined : startAdvisoryFeed(app);
858861 // ...and this forge asks every child's public addresses what a visitor would get, every few minutes
859862 // (spawn/reach.ts).
860863 const reachTimer = inert ? undefined : startReachWatch(app, undefined, (name) => !childAwake(app, name));
@@ -1297,6 +1300,7 @@ function drain(signal: NodeJS.Signals): Promise<unknown> {
12971300 clearInterval(heartbeatTimer);
12981301 clearInterval(machineBeatTimer);
12991302 clearInterval(upstreamTimer);
1303 clearInterval(advisoryTimer);
13001304 clearInterval(reachTimer);
13011305 clearInterval(syncTimer);
13021306 clearInterval(staleTimer);
src/tui/screens/advisories.ts added +78
@@ -0,0 +1,78 @@
1 /**
2 * The Advisories command, a forge admin's who is a person: what /advisories
3 * says, exploited ones first, each with the repositories it hits. A read-only
4 * dialog; Enter, Esc or q closes it.
5 */
6
7 import type { App } from "../../app.ts";
8 import { ingest } from "../../core/advisories.ts";
9 import { advisoryView } from "../../core/exposure.ts";
10 import { binding } from "../app/keys.ts";
11 import type { Ctx, Screen } from "../app/app.ts";
12 import { wrap } from "../term/width.ts";
13 import { dialog } from "../ui/widgets.ts";
14 import type { Session } from "../session.ts";
15 import type { PaletteEntry } from "./entries.ts";
16
17 const WIDTH = 72;
18 const SHOWN = 12;
19
20 /** What /advisories says: advisories matching `q`, those hitting a repo first. */
outdated

Both doors: the page offers search (q) and ingest (paste OSV/KEV), and the terminal offers neither. Add a search line to the screen and a way to ingest, or state in docs/features/advisories.md why the terminal does not. Also, the dialog shows only advisories that hit a repo while the page lists all; make them say the same thing.

21 export async function advisoryLines(app: App, q = ""): Promise<string[]> {
22 const list = await advisoryView(app.db, app.reposRoot, q);
23 if (list.length === 0) return [q === "" ? "Nothing heard yet." : "No advisory matches."];
24 const mine = list.filter((a) => a.repos.length > 0).length;
25 const lines = [mine === 0 ? "You are not exposed today." : `${String(mine)} hit your repos.`];
26 for (const a of list.slice(0, SHOWN))
27 lines.push(
28 ...wrap(
29 `${a.kev ? "EXPLOITED " : ""}${a.id} ${a.package}${a.severity === "" ? "" : ` ${a.severity}`} ${a.fixed === "" ? "no fix yet" : `fixed ${a.fixed}`}${a.repos.length === 0 ? "" : `: ${a.repos.join(", ")}`}`,
30 WIDTH - 6,
31 ),
32 );
33 if (list.length > SHOWN) lines.push(`${String(list.length - SHOWN)} more: narrow the search.`);
34 return lines;
35 }
36
37 function advisoriesScreen(ctx: Ctx, app: App, first: readonly string[]): Screen {
38 let lines = first;
39 let q = "";
40 let note = "";
41 const refresh = (): void => void advisoryLines(app, q).then((l) => ((lines = l), ctx.invalidate()));
42 return {
43 title: "Advisories",
44 keys: [binding(["esc"], "close")],
45 render(area, s) {
46 const body = [`Search (just type): ${q}_`, note === "" ? "Paste an OSV record or the CISA KEV list to add it." : note, "", ...lines];
47 const buttons = dialog(s, area, ctx.theme.c, { title: "Advisories", body, actions: [{ label: "Close" }], selected: 0, width: WIDTH });
48 buttons.forEach((rect) => ctx.hit(rect, () => ctx.pop()));
49 },
50 paste(text) {
51 const done = ingest(app.db, text, "");
52 note = done.ok ? done.value : `Not saved: ${done.error}.`;
53 refresh();
54 return true;
55 },
56 key(e) {
57 if (e.key === "esc" || e.key === "enter") ctx.pop();
58 else if (e.key === "backspace") ((q = [...q].slice(0, -1).join("")), refresh());
59 else if (!e.ctrl && !e.alt && [...e.key].length === 1 && [...q].length < 80) ((q += e.key), refresh());
60 return true;
61 },
62 };
63 }
64
65 /** Opens the dialog; the palette entry below and Resilience's `a` both call it. */
66 export function openAdvisories(session: Session, ctx: Ctx): void {
67 void advisoryLines(session.app).then((lines) => ctx.push(advisoriesScreen(ctx, session.app, lines)));
68 }
69
70 export const entry: PaletteEntry = {
71 rank: 235,
72 id: "advisories",
73 title: "Advisories",
74 hint: "known vulnerabilities in your lockfiles",
75 after: ["resilience"],
76 offered: (session) => session.user?.isAdmin === true && session.user.kind !== "agent",
77 run: openAdvisories,
78 };
src/tui/screens/resilience.ts +4 −2
@@ -36,6 +36,7 @@ import {
3636 type DestinationInput,
3737 } from "../../actions/destination.ts";
3838 import { forgetMirror, saveMirror } from "../../actions/mirror.ts";
39 import { openAdvisories } from "./advisories.ts";
3940 import { JOBS } from "../../nightly/jobs.ts";
4041 import { outputTail } from "../../nightly/output.ts";
4142 import { nightlyLines } from "../../nightly/says.ts";
@@ -350,7 +351,7 @@ export function resilienceScreen(f: Session, ctx: Ctx): Screen {
350351 binding(["l"], "bring the mirror level now"),
351352 binding(["r"], "run a restore drill"),
352353 ]),
353 ...(mayAct() ? [binding(["o"], "nightly output")] : []),
354 ...(mayAct() ? [binding(["o"], "nightly output"), binding(["a"], "advisories")] : []),
354355 ...(mayChange()
355356 ? [
356357 binding(["d"], "set destination"),
@@ -386,7 +387,8 @@ export function resilienceScreen(f: Session, ctx: Ctx): Screen {
386387 if (ask !== undefined && !busy && mayAct()) {
387388 asking = ask;
388389 said = "";
389 } else if (e.key === "o" && mayAct())
390 } else if (e.key === "a" && mayAct()) openAdvisories(f, ctx);
391 else if (e.key === "o" && mayAct())
390392 ctx.push(
391393 confirmScreen(ctx, screen, {
392394 title: "Nightly output",
src/web/pages/advisories.ts added +70
@@ -0,0 +1,70 @@
1 /**
2 * /advisories, for a forge admin: the advisories the forge was handed (OSV
3 * records, the CISA KEV list), exploited ones first, each with the
4 * repositories whose package-lock.json it hits. Admins paste a feed in; the
5 * same words are the MCP tool `advisories`.
6 */
7
8 import { notePhase, takeSessionTime } from "../../core/route_timing.ts";
9 import { ingest } from "../../core/advisories.ts";
10 import { advisoryView, type Seen } from "../../core/exposure.ts";
11 import type { Ctx } from "../../http/context.ts";
12 import { notFoundPage, pageHead, signInFirst } from "../chrome.ts";
13 import { field, readForm } from "../form.ts";
14 import { html } from "../html.ts";
15 import { flashTo, page } from "../layout.ts";
16 import { badge, btn, disclosure, empty, listCard, row } from "../ui.ts";
17
18 const gate = (ctx: Ctx): Response | undefined =>
19 !ctx.auth.user ? signInFirst(ctx) : ctx.auth.user.isAdmin && ctx.auth.user.kind !== "agent" ? undefined : notFoundPage(ctx);
20
21 const line = (a: Seen) =>
22 row({
outdated

Every GET recomputes the whole forge's exposure, even for a q search, and sequential git reads happen on the request path (the terminal does the same at src/tui/screens/advisories.ts:20). Compute exposure once and cache it, invalidating when the feed or an ingest changes the advisory table, so the first paint stays in milliseconds.

23 title: html`${a.id}${a.cve !== "" && a.cve !== a.id ? html` <span class="muted">${a.cve}</span>` : ""}`,
24 meta: html`${a.summary}`,
25 facts: [
26 { label: "Package", value: html`<code>${a.package}</code>` },
27 { label: "Fix", value: a.fixed === "" ? "none yet" : html`<code>${a.fixed}</code>` },
28 { label: "Hits", value: a.repos.length === 0 ? "none of your repos" : a.repos.join(", ") },
29 { label: "Record", value: html`<a href="https://osv.dev/${a.id}">osv.dev</a>` },
30 ],
31 trail: html`${a.kev ? badge("exploited", { tone: "danger" }) : ""} ${a.severity === "" ? "" : badge(a.severity)}`,
32 data: { advisory: a.id },
outdated

Principle 7/3: a <br /> inside meta stacks two facts in one line. Put the repo list on its own row, or use the dl-style row the design system names for facts. The row's title also links off-forge to osv.dev for every advisory; prefer a link inside the row's detail.

33 });
outdated

MEDIUM, principle 1/8 (plain words): when OSV gives no database_specific.severity, severity is the raw CVSS vector (up to 80 chars, e.g. CVSS:3.1/AV:N/...), and it is rendered as a badge. Show a plain word (low, moderate, high, critical) or nothing. Also, two badge tones on every row work against the one-accent calm; keep the danger tone for exploited only.

34
35 // GET /advisories
36 export async function advisoriesPage(ctx: Ctx): Promise<Response> {
37 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
38 const no = gate(ctx);
39 if (no) return no;
40 const q = (ctx.url.searchParams.get("q") ?? "").slice(0, 80);
41 const list = await advisoryView(ctx.app.db, ctx.app.reposRoot, q);
42 const mine = list.filter((a) => a.repos.length > 0);
43 const body = html`${pageHead("Advisories", { sub: mine.length === 0 ? "You are not exposed today." : `${String(mine.length)} advisories hit your repos${mine.some((a) => a.kev) ? ", some exploited in the wild" : ""}.` })}
44 <form method="get" action="/advisories"><input class="input" name="q" value="${q}" placeholder="CVE, package or text" aria-label="Search advisories" /> ${btn("Search", { size: "sm" })}</form>
45 ${list.length === 0 ? empty({ icon: "activity", title: q === "" ? "Nothing heard yet" : "No advisory matches" }) : listCard(list.map(line))}
46 ${disclosure(
47 "Paste a feed",
48 html`<form method="post" action="/advisories">
49 <select class="input" name="feed" aria-label="Feed"><option value="osv">OSV record(s)</option><option value="kev">CISA KEV list</option></select>
50 <textarea class="input mono" name="data" rows="6" aria-label="Feed JSON" required></textarea>
51 ${btn("Ingest", { variant: "primary" })}
52 </form>`,
53 { small: true, extra: "mt" },
54 )}`;
55 const rendering = performance.now();
outdated

Principles 6/7: the ingest form sits in a card with its own <h2>, a box around a thing, and it is shown to every admin on every view even though the forge now feeds itself. Put it behind a quiet link or a <details> row, drop the card, and state the page's one sentence once (the sub line and the empty-state note both explain how to get data).

56 const response = page({ ctx, title: "Advisories", body });
57 notePhase(ctx.request, "render", performance.now() - rendering);
58 return response;
59 }
60
61 // POST /advisories
62 export async function advisoriesIngest(ctx: Ctx): Promise<Response> {
63 const no = gate(ctx);
64 if (no) return no;
65 const form = await readForm(ctx, "admin");
66 if (form instanceof Response) return form;
67 const feed = field(form, "feed");
68 const done = ingest(ctx.app.db, field(form, "data"), feed === "kev" ? "kev" : "osv");
69 return flashTo(ctx, "/advisories", done.ok ? { message: done.value } : { tone: "danger", message: `Not saved: ${done.error}.` });
70 }
src/web/pages/resilience.ts +1
@@ -115,6 +115,7 @@ export function resiliencePage(ctx: Ctx): Response {
115115 </div>
116116 ${backupsLineHtml(ctx)}
117117 <p><a href="/maintenance">Maintenance</a> prepares the forge for a planned power-off.</p>
118 <p><a href="/advisories">Advisories</a> lists the OSV and CISA KEV advisories that hit the pins the forge holds.</p>
118119 ${nightlyHtml(ctx)}
119120 <p id="tally">
120121 ${String(count("green"))} green · ${String(count("red"))} red ·
test/advisories-page.test.ts added +70
@@ -0,0 +1,70 @@
1 import { afterAll, beforeAll, expect, test } from "bun:test";
2 import { mkdtemp, rm } from "node:fs/promises";
3 import { tmpdir } from "node:os";
4 import { join } from "node:path";
5 import { createApp, type App } from "../src/app.ts";
6 import { createUser } from "../src/core/users.ts";
7 import { serve, type Servers } from "../src/http/server.ts";
8
9 let dataDir: string;
10 let app: App;
11 let servers: Servers;
12
13 const login = async (username: string): Promise<string> => {
14 const res = await fetch(`${servers.url}/signin`, {
15 method: "POST",
16 redirect: "manual",
17 headers: { "content-type": "application/x-www-form-urlencoded", origin: servers.url },
18 body: new URLSearchParams({ username, password: "a-good-passphrase" }),
19 });
20 return (res.headers.get("set-cookie") ?? "").split(";")[0] ?? "";
21 };
22
23 beforeAll(async () => {
24 dataDir = await mkdtemp(join(tmpdir(), "forge-advisories-"));
25 app = createApp({ dataDir, port: 0 });
26 servers = await serve(app);
27 for (const [username, adminIfFirst] of [["alice", true], ["bob", false]] as const) {
28 const u = await createUser(app.db, { origin: "seed", trusted: true, username, email: `${username}@forge.local`, password: "a-good-passphrase", adminIfFirst });
29 if (!u.ok) throw new Error("users");
30 }
31 });
32
33 afterAll(async () => {
34 servers.stop();
35 app.close();
36 await rm(dataDir, { recursive: true, force: true });
37 });
38
39 const post = async (cookie: string, feed: string, data: string, origin = servers.url) =>
40 fetch(`${servers.url}/advisories`, {
41 method: "POST",
42 redirect: "manual",
43 headers: { cookie, origin, "content-type": "application/x-www-form-urlencoded" },
44 body: new URLSearchParams({ feed, data }),
45 });
46
47 test("an admin ingests a record and the page lists it, escaped; others get 403", async () => {
48 const cookie = await login("alice");
49 const record = JSON.stringify({ id: "GHSA-test-1234", summary: "<b>bad</b>", affected: [{ package: { ecosystem: "npm", name: "left-pad" }, ranges: [{ events: [{ introduced: "0" }, { fixed: "1.3.0" }] }] }] });
50 expect((await post(cookie, "osv", record)).status).toBe(303);
51 const html = await (await fetch(`${servers.url}/advisories`, { headers: { cookie } })).text();
52 expect(html).toContain("GHSA-test-1234");
53 expect(html).toContain("&lt;b&gt;bad&lt;/b&gt;");
54 expect(html).not.toContain("<b>bad</b>");
55 expect(html).toContain("You are not exposed today.");
56 expect((await fetch(`${servers.url}/advisories`, { headers: { cookie: await login("bob") } })).status).toBe(403);
57 });
58
59 test("a cross-origin ingest is refused", async () => {
60 expect((await post(await login("alice"), "kev", "{}", "https://evil.example")).status).toBe(403);
61 });
62
63 test("the terminal says what the page says, and a pasted feed lands in both", async () => {
64 const { advisoryLines } = await import("../src/tui/screens/advisories.ts");
65 const { ingest } = await import("../src/core/advisories.ts");
66 const osv = JSON.stringify({ id: "GHSA-tui1-tui1-tui1", summary: "tui probe", affected: [{ package: { ecosystem: "npm", name: "tui-probe" }, ranges: [{ events: [{ introduced: "0" }, { fixed: "2.0.0" }] }] }] });
67 expect(ingest(app.db, osv, "").ok).toBe(true);
68 expect((await advisoryLines(app, "tui-probe")).join("\n")).toContain("GHSA-tui1-tui1-tui1");
69 expect((await advisoryLines(app, "zzz-nothing")).join("\n")).toContain("No advisory matches");
70 });
test/advisories.test.ts added +75
@@ -0,0 +1,75 @@
1 import { expect, test } from "bun:test";
2 import { Database } from "bun:sqlite";
3 import { migrations } from "../src/core/schema.ts";
4 import { affects, compareVersions, exposure, ingest, listAdvisories, lockfilePackages, npmIndex, parseOsv, saveAdvisories, saveKev } from "../src/core/advisories.ts";
5
6 const OSV = JSON.stringify({
7 id: "GHSA-aaaa-bbbb-cccc",
8 aliases: ["CVE-2024-12345"],
9 summary: "Prototype pollution in lodash",
10 modified: "2026-10-01T00:00:00Z",
11 database_specific: { severity: "high" },
12 affected: [{ package: { ecosystem: "npm", name: "lodash" }, ranges: [{ type: "SEMVER", events: [{ introduced: "0" }, { fixed: "4.17.21" }] }] }],
13 });
14
15 function db(): Database {
16 const d = new Database(":memory:");
17 for (const m of migrations) d.exec(m);
18 return d;
19 }
20
21 test("versions compare numerically and pre-releases come first", () => {
22 expect(compareVersions("4.9.0", "4.17.21")).toBe(-1);
23 expect(compareVersions("1.0.0-rc.1", "1.0.0")).toBe(-1);
24 expect(compareVersions("2.0", "2.0.0")).toBe(0);
25 });
26
27 test("an OSV record becomes a range that hits only versions below the fix", () => {
28 const parsed = parseOsv(OSV);
29 expect(parsed.ok).toBe(true);
30 const [a] = parsed.ok ? parsed.value : [];
31 expect(a).toMatchObject({ cve: "CVE-2024-12345", severity: "high", fixed: "4.17.21" });
32 expect(affects(a!, "4.17.20")).toBe(true);
33 expect(affects(a!, "4.17.21")).toBe(false);
34 expect(affects(a!, "not a version")).toBe(false);
35 });
36
37 test("malformed feeds are refused at the boundary", () => {
38 expect(parseOsv("{").ok).toBe(false);
39 expect(parseOsv(JSON.stringify({ id: "../x" })).ok).toBe(false);
40 expect(parseOsv(JSON.stringify(Array(501).fill({ id: "A" }))).ok).toBe(false);
41 expect(saveKev(db(), JSON.stringify({ nope: 1 })).ok).toBe(false);
42 });
43
44 test("KEV puts exploited advisories first and exposure reads a lockfile", () => {
45 const d = db();
46 const rows = parseOsv(OSV);
47 if (!rows.ok) throw new Error("parse");
48 saveAdvisories(d, rows.value);
49 saveAdvisories(d, [{ ...rows.value[0]!, id: "GHSA-zzzz", cve: "", modified: "2027-01-01" }]);
50 expect(listAdvisories(d)[0]!.id).toBe("GHSA-zzzz");
51 saveKev(d, JSON.stringify({ vulnerabilities: [{ cveID: "CVE-2024-12345" }, { cveID: "bad" }] }));
52 const [first] = listAdvisories(d);
53 expect(first).toMatchObject({ id: "GHSA-aaaa-bbbb-cccc", kev: true });
54 expect(listAdvisories(d, "100%").length).toBe(0);
55 const lock = JSON.stringify({ packages: { "": {}, "node_modules/a/node_modules/lodash": { version: "4.17.0" }, "node_modules/ok": { version: "1.0.0" } } });
56 const packages = lockfilePackages(lock);
57 expect(packages).toContainEqual({ name: "lodash", version: "4.17.0" });
58 expect(exposure(npmIndex(d), packages).map((h) => h.advisory.id)).toContain("GHSA-aaaa-bbbb-cccc");
59 expect(lockfilePackages("garbage")).toEqual([]);
60 });
61
62 test("severity is a plain word or nothing, never a CVSS vector", () => {
63 const rec = (extra: object) => parseOsv(JSON.stringify({ id: "X-1", affected: [{ package: { ecosystem: "npm", name: "p" }, ranges: [{ events: [{ introduced: "0" }, { fixed: "1.0.0" }] }] }], ...extra }));
64 const sev = (r: ReturnType<typeof rec>) => (r.ok ? r.value[0]!.severity : "bad");
65 expect(sev(rec({ database_specific: { severity: "MODERATE" } }))).toBe("moderate");
66 expect(sev(rec({ database_specific: { severity: "medium" } }))).toBe("moderate");
67 expect(sev(rec({ severity: [{ type: "CVSS_V3", score: "CVSS:3.1/AV:N/AC:L" }] }))).toBe("");
68 });
69
70 test("ingest takes either feed and says which", () => {
71 const d = db();
72 expect(ingest(d, JSON.stringify({ vulnerabilities: [{ cveID: "CVE-2024-1111" }] }), "")).toEqual({ ok: true, value: "1 exploited CVEs noted." });
73 expect(ingest(d, "nope", "").ok).toBe(false);
74 expect(ingest(d, OSV, "osv").ok).toBe(true);
75 });
test/advisory-feed.test.ts added +46
@@ -0,0 +1,46 @@
1 import { expect, test } from "bun:test";
2 import { Database } from "bun:sqlite";
3 import { migrations } from "../src/core/schema.ts";
4 import { listenOnce } from "../src/core/advisory_feed.ts";
5 import { listAdvisories } from "../src/core/advisories.ts";
6
7 const db = (): Database => {
8 const d = new Database(":memory:");
9 for (const m of migrations) d.exec(m);
10 return d;
11 };
12 const VULN = {
13 id: "GHSA-aaaa-bbbb-cccc",
14 aliases: ["CVE-2024-12345"],
15 summary: "Prototype pollution",
16 modified: "2026-10-01T00:00:00Z",
17 affected: [{ package: { ecosystem: "npm", name: "lodash" }, ranges: [{ type: "SEMVER", events: [{ introduced: "0" }, { fixed: "4.17.21" }] }] }],
18 };
19
20 test("one round saves KEV and the OSV records for the named packages", async () => {
21 const d = db();
22 const seen: string[] = [];
23 const f = async (url: string): Promise<Response> => {
24 seen.push(url);
25 if (url.includes("cisa.gov")) return Response.json({ vulnerabilities: [{ cveID: "CVE-2024-12345" }] });
26 if (url.endsWith("/querybatch")) return Response.json({ results: [{ vulns: [{ id: VULN.id }] }] });
27 return Response.json(VULN);
28 };
29 const said = await listenOnce(d, ["lodash"], f);
30 expect(said).toContain("KEV 1");
31 const [a] = listAdvisories(d);
32 expect(a?.id).toBe(VULN.id);
33 expect(a?.kev).toBe(true);
34 // A second round asks for no record it already holds.
35 seen.length = 0;
36 await listenOnce(d, ["lodash"], f);
37 expect(seen.some((u) => u.includes("/vulns/"))).toBe(false);
38 });
39
40 test("the gate's refusal is said in its own words and nothing throws", async () => {
41 const f = async (): Promise<Response> => new Response("no", { status: 403, headers: { "x-forge-egress": "refused" } });
42 const said = await listenOnce(db(), ["lodash"], f);
43 expect(said).toContain("refused by this forge: www.cisa.gov is not in this app's forge.json egress");
44 expect(said).toContain("refused by this forge: api.osv.dev");
45 expect(await listenOnce(db(), [], async () => { throw new Error("down"); })).toContain("down");
46 });
test/egress-literals.test.ts +1
@@ -26,6 +26,7 @@ const LINK = "a link or text rendered for a person; the server never fetches it"
2626 const NOT_CALLED: Record<string, string> = {
2727 "billing.stripe.com": "placeholder in the billing form's portal address hint",
2828 "dashboard.stripe.com": LINK,
29 "osv.dev": LINK,
2930 "cloud.digitalocean.com": LINK,
3031 "console.hetzner.com": LINK,
3132 "dash.cloudflare.com": LINK,
test/job-slices.test.ts +1
@@ -266,6 +266,7 @@ function jobs(): Record<string, () => unknown> {
266266 * on.
267267 */
268268 const UNTIMED: Record<string, string> = {
269 "advisory-feed": "hourly (and once 30 s after boot): one read of each repository's lockfile and two network fetches, KEV and OSV (core/advisory_feed.ts); the network is not timed here and advisory-feed.test.ts drives listenOnce with a fake fetch",
269270 "series-sampler": "every 30 s: one /metrics render and one batched insert (series/store.ts record), bounded by the rows it keeps; series-explore.test.ts drives tick directly",
270271 "dev-cell-sweep": "a minute timer that stops dev cells idle past their limit (apps/dev_cell.ts sweep): a walk of the in-memory entries (one per person and branch), a kill only for an idle one; dev-cell.test.ts drives sweep",
271272 "machine-beats": "a 15 s timer (spawn/machine_beats.ts) whose beat only starts an async import and the machines' asks; its synchronous slice is the call that starts them; machine-load.test.ts drives sampleBeats and placeNew directly",
test/looks-owner.test.ts +1 −1
@@ -322,7 +322,7 @@ describe("the forge's own owner looks, over the preview seed", () => {
322322 test("forge.json takes the seed's other pages as the owner, and the seed's pull is the one the named list pictures", () => {
323323 const manifest = parseManifest(readFileSync(join(import.meta.dir, "..", "forge.json"), "utf8"), undefined);
324324 if (!manifest.ok) throw new Error(JSON.stringify(manifest.error));
325 for (const page of ["next", "bets", "waves"].map((p) => `${repoHome}/${p === "next" ? "next?pick" : p}`)) { // milestones left for the space page (the cap of 24 is spent); the preview's owner list still pictures it (test/milestones-fit.test.ts). The next page is pictured with its first row chosen
325 for (const page of ["next", "bets"].map((p) => `${repoHome}/${p === "next" ? "next?pick" : p}`)) { // milestones left for the space page (the cap of 24 is spent), waves for /advisories (#6005); the preview's owner list still pictures both (test/milestones-fit.test.ts, test/waves-fit.test.ts). The next page is pictured with its first row chosen
326326 expect(manifest.value.looks).toContain(page);
327327 expect(manifest.value.looksAsOwner).toContain(page);
328328 }
test/palette-roster.test.ts +1
@@ -155,6 +155,7 @@ test("a site-admin person is offered the whole roster", () => {
155155 ["dataset", "Dataset", "what the forge's dataset holds, and what it already answers"],
156156 ["capacity", "Capacity", "concurrency and guards, live; e changes a settable one"],
157157 ["resilience", "Resilience", "where snapshots go and the mirror; each protection green, red or untested"],
158 ["advisories", "Advisories", "known vulnerabilities in your lockfiles"],
158159 ["recovery-kit", "Recovery kit", "the bucket's read-only key and the file to keep off this machine"],
159160 ["maintenance", "Maintenance", "prepare the forge for a power-off, check the drain, or end maintenance"],
160161 ["stale-pulls", "Pulls untouched for 14 days", "ask whether a stale pull is still wanted, or close one an agent opened"],

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs