@llblab/pi-telegram 0.24.6 → 0.24.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/threads.ts CHANGED
@@ -92,6 +92,9 @@ export interface TelegramThreadPendingProvision {
92
92
  leaderEpoch?: number | string;
93
93
  }
94
94
 
95
+ export type TelegramThreadCleanupIntent =
96
+ ThreadReconciler.TelegramThreadCleanupIntent;
97
+
95
98
  type TelegramProvisionRecoveryFile = Record<
96
99
  string,
97
100
  {
@@ -160,6 +163,7 @@ export interface TelegramTopicTargetFile {
160
163
  identities?: TelegramThreadIdentityRecord[];
161
164
  reservations?: TelegramThreadReservation[];
162
165
  pendingProvisions?: TelegramThreadPendingProvision[];
166
+ pendingCleanups?: TelegramThreadCleanupIntent[];
163
167
  syncObservations?: TelegramTopicSyncObservation[];
164
168
  }
165
169
 
@@ -229,6 +233,7 @@ export interface TelegramTopicTargetStore {
229
233
  ) => { slot?: string; threadName?: string } | undefined;
230
234
  listReservations: () => TelegramThreadReservation[];
231
235
  listPendingProvisions: () => TelegramThreadPendingProvision[];
236
+ listPendingCleanups: () => TelegramThreadCleanupIntent[];
232
237
  listSyncObservations: () => TelegramTopicSyncObservation[];
233
238
  reserveThread: (reservation: TelegramThreadReservation) => void;
234
239
  upsertPendingProvision: (provision: TelegramThreadPendingProvision) => void;
@@ -237,6 +242,8 @@ export interface TelegramTopicTargetStore {
237
242
  target: TelegramTarget & { threadId: number },
238
243
  ) => Promise<boolean>;
239
244
  removePendingProvision: (id: string) => boolean;
245
+ upsertPendingCleanup: (intent: TelegramThreadCleanupIntent) => void;
246
+ removePendingCleanup: (id: string) => boolean;
240
247
  getBotState: () => TelegramBotStateSnapshot;
241
248
  setBotState: (state: Partial<TelegramBotStateSnapshot>) => void;
242
249
  setStatusSnapshot: (snapshot: {
@@ -876,6 +883,56 @@ function normalizePendingProvision(
876
883
  };
877
884
  }
878
885
 
886
+ function normalizePendingCleanup(
887
+ value: unknown,
888
+ ): TelegramThreadCleanupIntent | undefined {
889
+ if (!value || typeof value !== "object" || Array.isArray(value))
890
+ return undefined;
891
+ const record = value as Record<string, unknown>;
892
+ const targetValue = record.target;
893
+ if (
894
+ !targetValue ||
895
+ typeof targetValue !== "object" ||
896
+ Array.isArray(targetValue)
897
+ ) {
898
+ return undefined;
899
+ }
900
+ const targetRecord = targetValue as Record<string, unknown>;
901
+ const owner = record.owner;
902
+ if (owner !== "leader" && owner !== "manual-follower") return undefined;
903
+ if (typeof record.id !== "string" || record.id.length === 0) return undefined;
904
+ if (typeof record.instanceId !== "string" || record.instanceId.length === 0)
905
+ return undefined;
906
+ if (
907
+ typeof record.runtimeGeneration !== "string" ||
908
+ record.runtimeGeneration.length === 0
909
+ ) {
910
+ return undefined;
911
+ }
912
+ if (
913
+ typeof targetRecord.chatId !== "number" ||
914
+ typeof targetRecord.threadId !== "number" ||
915
+ !Number.isInteger(targetRecord.threadId) ||
916
+ typeof record.requestedAtMs !== "number"
917
+ ) {
918
+ return undefined;
919
+ }
920
+ return {
921
+ id: record.id,
922
+ owner,
923
+ instanceId: record.instanceId,
924
+ runtimeGeneration: record.runtimeGeneration,
925
+ ...(typeof record.profileKey === "string"
926
+ ? { profileKey: record.profileKey }
927
+ : {}),
928
+ target: {
929
+ chatId: targetRecord.chatId,
930
+ threadId: targetRecord.threadId,
931
+ },
932
+ requestedAtMs: record.requestedAtMs,
933
+ };
934
+ }
935
+
879
936
  function normalizeReservation(
880
937
  value: unknown,
881
938
  ): TelegramThreadReservation | undefined {
@@ -970,6 +1027,12 @@ function parseTopicTargetFile(value: unknown): TelegramTopicTargetFile {
970
1027
  return normalized ? [normalized] : [];
971
1028
  })
972
1029
  : [],
1030
+ pendingCleanups: Array.isArray(file.pendingCleanups)
1031
+ ? file.pendingCleanups.flatMap((intent) => {
1032
+ const normalized = normalizePendingCleanup(intent);
1033
+ return normalized ? [normalized] : [];
1034
+ })
1035
+ : [],
973
1036
  syncObservations: Array.isArray(file.syncObservations)
974
1037
  ? file.syncObservations.flatMap((observation) => {
975
1038
  const normalized = normalizeSyncObservation(observation);
@@ -1084,6 +1147,7 @@ export function createTelegramTopicTargetStore(
1084
1147
  let identities = new Map<string, TelegramThreadIdentityRecord>();
1085
1148
  let reservations: TelegramThreadReservation[] = [];
1086
1149
  let pendingProvisions: TelegramThreadPendingProvision[] = [];
1150
+ let pendingCleanups: TelegramThreadCleanupIntent[] = [];
1087
1151
  let syncObservations: TelegramTopicSyncObservation[] = [];
1088
1152
  let followerRecoveryHints = new Map<
1089
1153
  string,
@@ -1140,6 +1204,7 @@ export function createTelegramTopicTargetStore(
1140
1204
  identities = new Map();
1141
1205
  reservations = [];
1142
1206
  pendingProvisions = [];
1207
+ pendingCleanups = [];
1143
1208
  syncObservations = [];
1144
1209
  followerRecoveryHints = new Map();
1145
1210
  statusSnapshot = {};
@@ -1157,6 +1222,7 @@ export function createTelegramTopicTargetStore(
1157
1222
  identities = new Map();
1158
1223
  reservations = [];
1159
1224
  pendingProvisions = [];
1225
+ pendingCleanups = [];
1160
1226
  syncObservations = [];
1161
1227
  followerRecoveryHints = new Map();
1162
1228
  loaded = true;
@@ -1207,6 +1273,10 @@ export function createTelegramTopicTargetStore(
1207
1273
  : {}),
1208
1274
  };
1209
1275
  });
1276
+ pendingCleanups = (file.pendingCleanups ?? []).map((intent) => ({
1277
+ ...intent,
1278
+ target: { ...intent.target },
1279
+ }));
1210
1280
  syncObservations = (file.syncObservations ?? []).map((observation) => ({
1211
1281
  ...observation,
1212
1282
  target: { ...observation.target },
@@ -1269,6 +1339,10 @@ export function createTelegramTopicTargetStore(
1269
1339
  ...provision,
1270
1340
  ...(provision.target ? { target: { ...provision.target } } : {}),
1271
1341
  })),
1342
+ pendingCleanups: pendingCleanups.map((intent) => ({
1343
+ ...intent,
1344
+ target: { ...intent.target },
1345
+ })),
1272
1346
  syncObservations: syncObservations.map((observation) => ({
1273
1347
  ...observation,
1274
1348
  target: { ...observation.target },
@@ -1355,6 +1429,12 @@ export function createTelegramTopicTargetStore(
1355
1429
  ...(provision.target ? { target: { ...provision.target } } : {}),
1356
1430
  }));
1357
1431
  },
1432
+ listPendingCleanups() {
1433
+ return pendingCleanups.map((intent) => ({
1434
+ ...intent,
1435
+ target: { ...intent.target },
1436
+ }));
1437
+ },
1358
1438
  listSyncObservations() {
1359
1439
  return syncObservations.map((observation) => ({
1360
1440
  ...observation,
@@ -1425,6 +1505,21 @@ export function createTelegramTopicTargetStore(
1425
1505
  if (changed) markDirty();
1426
1506
  return changed;
1427
1507
  },
1508
+ upsertPendingCleanup(intent) {
1509
+ const next = { ...intent, target: { ...intent.target } };
1510
+ pendingCleanups = pendingCleanups.filter(
1511
+ (existing) => existing.id !== next.id,
1512
+ );
1513
+ pendingCleanups.push(next);
1514
+ markDirty();
1515
+ },
1516
+ removePendingCleanup(id) {
1517
+ const before = pendingCleanups.length;
1518
+ pendingCleanups = pendingCleanups.filter((intent) => intent.id !== id);
1519
+ const changed = pendingCleanups.length !== before;
1520
+ if (changed) markDirty();
1521
+ return changed;
1522
+ },
1428
1523
  getBotState() {
1429
1524
  return Object.fromEntries(
1430
1525
  Object.entries(botState).filter(([, value]) => value !== undefined),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-telegram",
3
- "version": "0.24.6",
3
+ "version": "0.24.8",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -30,7 +30,8 @@
30
30
  "test": "node --experimental-strip-types --test --test-reporter=dot tests/*.test.ts",
31
31
  "test:verbose": "node --experimental-strip-types --test --test-reporter=spec tests/*.test.ts",
32
32
  "typecheck": "tsc --noEmit",
33
- "audit": "node --experimental-strip-types scripts/audit-dependencies.ts",
33
+ "audit": "npm audit --omit=peer",
34
+ "audit:host": "npm audit",
34
35
  "pack:check": "npm pack --dry-run",
35
36
  "validate": "npm run typecheck && npm test && npm run audit && npm run pack:check"
36
37
  },
@@ -74,29 +75,5 @@
74
75
  "devDependencies": {
75
76
  "@types/node": "latest",
76
77
  "typescript": "latest"
77
- },
78
- "overrides": {
79
- "brace-expansion": "5.0.7",
80
- "protobufjs": "7.6.5",
81
- "undici": "8.5.0",
82
- "ws": "8.21.0",
83
- "@earendil-works/pi-coding-agent": {
84
- "brace-expansion": "5.0.7",
85
- "protobufjs": "7.6.5",
86
- "undici": "8.5.0",
87
- "ws": "8.21.0",
88
- "@google/genai": {
89
- "protobufjs": "7.6.5",
90
- "ws": "8.21.0"
91
- },
92
- "@earendil-works/pi-ai": {
93
- "protobufjs": "7.6.5",
94
- "ws": "8.21.0",
95
- "@google/genai": {
96
- "protobufjs": "7.6.5",
97
- "ws": "8.21.0"
98
- }
99
- }
100
- }
101
78
  }
102
79
  }
@@ -1,78 +0,0 @@
1
- /**
2
- * Dependency audit command adapter
3
- * Runs raw npm audit, prints its output, and applies the fail-closed repository policy
4
- */
5
-
6
- import { spawnSync } from "node:child_process";
7
- import { readFileSync } from "node:fs";
8
- import path from "node:path";
9
-
10
- import {
11
- evaluateDependencyAudit,
12
- type AuditReport,
13
- } from "./dependency-audit-policy.ts";
14
-
15
- function readInstalledPackageVersion(root: string, nodePath: string): string {
16
- if (
17
- path.isAbsolute(nodePath) ||
18
- nodePath.includes("..") ||
19
- !nodePath.startsWith("node_modules/")
20
- ) {
21
- throw new Error(`unsafe installed package path: ${nodePath}`);
22
- }
23
- const packageJsonPath = path.join(root, nodePath, "package.json");
24
- const parsed = JSON.parse(readFileSync(packageJsonPath, "utf8")) as {
25
- version?: unknown;
26
- };
27
- if (typeof parsed.version !== "string") {
28
- throw new Error(`installed package has no valid version: ${nodePath}`);
29
- }
30
- return parsed.version;
31
- }
32
-
33
- function run(): void {
34
- const result = spawnSync("npm", ["audit", "--json"], {
35
- cwd: process.cwd(),
36
- encoding: "utf8",
37
- stdio: ["ignore", "pipe", "pipe"],
38
- });
39
- if (result.stdout) process.stdout.write(result.stdout);
40
- if (result.stderr) process.stderr.write(result.stderr);
41
- if (result.error) throw result.error;
42
- if (result.signal || (result.status !== 0 && result.status !== 1)) {
43
- throw new Error(
44
- `npm audit command failed: status=${String(result.status)} signal=${String(result.signal)}`,
45
- );
46
- }
47
-
48
- let report: AuditReport;
49
- try {
50
- report = JSON.parse(result.stdout) as AuditReport;
51
- } catch (error) {
52
- throw new Error(`could not parse npm audit JSON: ${String(error)}`);
53
- }
54
- const evaluation = evaluateDependencyAudit(
55
- report,
56
- (nodePath) => readInstalledPackageVersion(process.cwd(), nodePath),
57
- );
58
- const expectedStatus = evaluation.vulnerabilityCount === 0 ? 0 : 1;
59
- if (result.status !== expectedStatus) {
60
- throw new Error(
61
- `npm audit exit status mismatch: expected ${expectedStatus}, got ${String(result.status)}`,
62
- );
63
- }
64
- if (evaluation.vulnerabilityCount === 0) {
65
- console.log("Dependency audit passed with zero vulnerabilities.");
66
- return;
67
- }
68
- console.warn(
69
- `Accepted ${evaluation.vulnerabilityCount} audit graph entries rooted only in approved sources ${evaluation.acceptedAdvisorySources.join(", ")}; exception expires after 2026-08-21 UTC.`,
70
- );
71
- }
72
-
73
- try {
74
- run();
75
- } catch (error) {
76
- console.error(error instanceof Error ? error.message : String(error));
77
- process.exitCode = 1;
78
- }
@@ -1,300 +0,0 @@
1
- /**
2
- * Fail-closed dependency audit policy
3
- * Zones: repository validation, dependency security
4
- * Validates the exact expiring Pi-shrinkwrap exception and installed package evidence
5
- */
6
-
7
- const EXCEPTION_EXPIRES_AT = Date.parse("2026-08-22T00:00:00Z");
8
-
9
- interface AuditAdvisory {
10
- source: number;
11
- name: string;
12
- url: string;
13
- severity: string;
14
- }
15
-
16
- interface AuditVulnerability {
17
- name: string;
18
- severity: string;
19
- via: Array<string | AuditAdvisory>;
20
- nodes: string[];
21
- }
22
-
23
- export interface AuditReport {
24
- error?: unknown;
25
- metadata?: {
26
- vulnerabilities?: {
27
- info?: number;
28
- low?: number;
29
- moderate?: number;
30
- high?: number;
31
- critical?: number;
32
- total?: number;
33
- };
34
- };
35
- vulnerabilities?: Record<string, AuditVulnerability>;
36
- }
37
-
38
- interface AllowedAdvisory {
39
- source: number;
40
- packageName: string;
41
- version: string;
42
- severity: string;
43
- url: string;
44
- nodes: readonly string[];
45
- }
46
-
47
- const ALLOWED_ADVISORIES = new Map<number, AllowedAdvisory>([
48
- [
49
- 1123898,
50
- {
51
- source: 1123898,
52
- packageName: "brace-expansion",
53
- version: "5.0.6",
54
- severity: "high",
55
- url: "https://github.com/advisories/GHSA-3jxr-9vmj-r5cp",
56
- nodes: [
57
- "node_modules/@earendil-works/pi-coding-agent/node_modules/brace-expansion",
58
- ],
59
- },
60
- ],
61
- [
62
- 1123964,
63
- {
64
- source: 1123964,
65
- packageName: "protobufjs",
66
- version: "7.6.4",
67
- severity: "moderate",
68
- url: "https://github.com/advisories/GHSA-j3f2-48v5-ccww",
69
- nodes: [
70
- "node_modules/@earendil-works/pi-coding-agent/node_modules/protobufjs",
71
- ],
72
- },
73
- ],
74
- ]);
75
-
76
- const ALLOWED_GRAPH: Readonly<Record<string, readonly string[]>> = {
77
- "brace-expansion": [],
78
- protobufjs: [],
79
- "@google/genai": ["protobufjs"],
80
- "@earendil-works/pi-ai": ["@google/genai"],
81
- "@earendil-works/pi-agent-core": ["@earendil-works/pi-ai"],
82
- "@earendil-works/pi-coding-agent": [
83
- "@earendil-works/pi-agent-core",
84
- "@earendil-works/pi-ai",
85
- ],
86
- };
87
-
88
- const ALLOWED_GRAPH_SEVERITIES: Readonly<Record<string, string>> = {
89
- "brace-expansion": "high",
90
- protobufjs: "moderate",
91
- "@google/genai": "moderate",
92
- "@earendil-works/pi-ai": "moderate",
93
- "@earendil-works/pi-agent-core": "moderate",
94
- "@earendil-works/pi-coding-agent": "moderate",
95
- };
96
-
97
- const ALLOWED_GRAPH_NODES: Readonly<Record<string, readonly string[]>> = {
98
- "brace-expansion": [
99
- "node_modules/@earendil-works/pi-coding-agent/node_modules/brace-expansion",
100
- ],
101
- protobufjs: [
102
- "node_modules/@earendil-works/pi-coding-agent/node_modules/protobufjs",
103
- ],
104
- "@google/genai": [
105
- "node_modules/@google/genai",
106
- "node_modules/@earendil-works/pi-coding-agent/node_modules/@google/genai",
107
- ],
108
- "@earendil-works/pi-ai": [
109
- "node_modules/@earendil-works/pi-ai",
110
- "node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-ai",
111
- ],
112
- "@earendil-works/pi-agent-core": [
113
- "node_modules/@earendil-works/pi-agent-core",
114
- "node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-agent-core",
115
- ],
116
- "@earendil-works/pi-coding-agent": [
117
- "node_modules/@earendil-works/pi-coding-agent",
118
- ],
119
- };
120
-
121
- export interface AuditEvaluation {
122
- acceptedAdvisorySources: number[];
123
- vulnerabilityCount: number;
124
- }
125
-
126
- function hasExactMembers(actual: readonly string[], expected: readonly string[]): boolean {
127
- return (
128
- actual.length === expected.length &&
129
- new Set(actual).size === actual.length &&
130
- expected.every((value) => actual.includes(value))
131
- );
132
- }
133
-
134
- export function evaluateDependencyAudit(
135
- report: AuditReport,
136
- readInstalledVersion: (nodePath: string) => string,
137
- nowMs = Date.now(),
138
- ): AuditEvaluation {
139
- if (report.error !== undefined) {
140
- throw new Error("npm audit returned an error payload");
141
- }
142
- const vulnerabilities = report.vulnerabilities;
143
- if (!vulnerabilities || typeof vulnerabilities !== "object") {
144
- throw new Error("npm audit output is missing vulnerabilities");
145
- }
146
-
147
- const entries = Object.entries(vulnerabilities);
148
- const counts = report.metadata?.vulnerabilities;
149
- if (!counts) {
150
- throw new Error("npm audit output is missing vulnerability metadata");
151
- }
152
- const countKeys = [
153
- "info",
154
- "low",
155
- "moderate",
156
- "high",
157
- "critical",
158
- "total",
159
- ] as const;
160
- for (const key of countKeys) {
161
- if (!Number.isInteger(counts[key]) || (counts[key] ?? -1) < 0) {
162
- throw new Error(`npm audit metadata has invalid ${key} count`);
163
- }
164
- }
165
- const severityTotal =
166
- (counts.info ?? 0) +
167
- (counts.low ?? 0) +
168
- (counts.moderate ?? 0) +
169
- (counts.high ?? 0) +
170
- (counts.critical ?? 0);
171
- if (severityTotal !== counts.total || counts.total !== entries.length) {
172
- throw new Error(
173
- `npm audit vulnerability total mismatch: metadata=${String(counts.total)}, severities=${severityTotal}, graph=${entries.length}`,
174
- );
175
- }
176
- if (entries.length === 0) {
177
- return { acceptedAdvisorySources: [], vulnerabilityCount: 0 };
178
- }
179
- if (nowMs >= EXCEPTION_EXPIRES_AT) {
180
- throw new Error(
181
- "approved dependency audit exception expired at 2026-08-22T00:00:00Z",
182
- );
183
- }
184
-
185
- const acceptedSources = new Set<number>();
186
- for (const [name, vulnerability] of entries) {
187
- if (vulnerability.name !== name) {
188
- throw new Error(`npm audit graph key/name mismatch for ${name}`);
189
- }
190
- const allowedParents = ALLOWED_GRAPH[name];
191
- const allowedNodes = ALLOWED_GRAPH_NODES[name];
192
- const allowedSeverity = ALLOWED_GRAPH_SEVERITIES[name];
193
- if (!allowedParents || !allowedNodes || !allowedSeverity) {
194
- throw new Error(`unapproved vulnerable package: ${name}`);
195
- }
196
- if (vulnerability.severity !== allowedSeverity) {
197
- throw new Error(
198
- `unapproved severity for ${name}: expected ${allowedSeverity}, got ${vulnerability.severity}`,
199
- );
200
- }
201
- if (!Array.isArray(vulnerability.via) || !Array.isArray(vulnerability.nodes)) {
202
- throw new Error(`malformed npm audit graph entry for ${name}`);
203
- }
204
- if (!hasExactMembers(vulnerability.nodes, allowedNodes)) {
205
- throw new Error(
206
- `audit graph paths differ for ${name}: expected ${allowedNodes.join(",")}, got ${vulnerability.nodes.join(",")}`,
207
- );
208
- }
209
-
210
- const parentEdges = vulnerability.via.filter(
211
- (via): via is string => typeof via === "string",
212
- );
213
- const advisories = vulnerability.via.filter(
214
- (via): via is AuditAdvisory => typeof via !== "string",
215
- );
216
- if (allowedParents.length > 0) {
217
- if (advisories.length > 0 || !hasExactMembers(parentEdges, allowedParents)) {
218
- throw new Error(
219
- `audit graph edges differ for ${name}: expected ${allowedParents.join(",")}, got ${parentEdges.join(",")}`,
220
- );
221
- }
222
- for (const parent of parentEdges) {
223
- if (!vulnerabilities[parent]) {
224
- throw new Error(`missing npm audit graph node: ${parent}`);
225
- }
226
- }
227
- continue;
228
- }
229
- if (parentEdges.length > 0 || advisories.length !== 1) {
230
- throw new Error(`audit leaf shape differs for ${name}`);
231
- }
232
- const advisory = advisories[0];
233
- const allowed = ALLOWED_ADVISORIES.get(advisory.source);
234
- if (
235
- !allowed ||
236
- advisory.name !== allowed.packageName ||
237
- advisory.url !== allowed.url ||
238
- advisory.severity !== allowed.severity ||
239
- name !== allowed.packageName ||
240
- vulnerability.severity !== allowed.severity
241
- ) {
242
- throw new Error(
243
- `unapproved advisory for ${name}: source=${String(advisory.source)} url=${advisory.url}`,
244
- );
245
- }
246
- acceptedSources.add(advisory.source);
247
- }
248
-
249
- const rootsByPackage = new Map<string, Set<number>>();
250
- const resolveRoots = (name: string, stack: Set<string>): Set<number> => {
251
- const cached = rootsByPackage.get(name);
252
- if (cached) return cached;
253
- if (stack.has(name)) throw new Error(`cycle in npm audit graph at ${name}`);
254
- const vulnerability = vulnerabilities[name];
255
- if (!vulnerability) throw new Error(`missing npm audit graph node: ${name}`);
256
- const nextStack = new Set(stack).add(name);
257
- const roots = new Set<number>();
258
- for (const via of vulnerability.via) {
259
- if (typeof via === "string") {
260
- for (const source of resolveRoots(via, nextStack)) roots.add(source);
261
- } else {
262
- roots.add(via.source);
263
- }
264
- }
265
- if (roots.size === 0) {
266
- throw new Error(`npm audit graph node has no approved advisory root: ${name}`);
267
- }
268
- rootsByPackage.set(name, roots);
269
- return roots;
270
- };
271
-
272
- for (const name of Object.keys(vulnerabilities)) resolveRoots(name, new Set());
273
-
274
- for (const source of acceptedSources) {
275
- const allowed = ALLOWED_ADVISORIES.get(source);
276
- if (!allowed) throw new Error(`missing policy for advisory source ${source}`);
277
- const vulnerability = vulnerabilities[allowed.packageName];
278
- if (!vulnerability) {
279
- throw new Error(`missing leaf package for advisory source ${source}`);
280
- }
281
- for (const nodePath of vulnerability.nodes) {
282
- if (!allowed.nodes.includes(nodePath)) {
283
- throw new Error(
284
- `unapproved installed path for advisory source ${source}: ${nodePath}`,
285
- );
286
- }
287
- const version = readInstalledVersion(nodePath);
288
- if (version !== allowed.version) {
289
- throw new Error(
290
- `unapproved installed version at ${nodePath}: expected ${allowed.version}, got ${version}`,
291
- );
292
- }
293
- }
294
- }
295
-
296
- return {
297
- acceptedAdvisorySources: [...acceptedSources].sort((a, b) => a - b),
298
- vulnerabilityCount: entries.length,
299
- };
300
- }