@codyswann/lisa 4.96.2 → 4.96.3
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/README.md +7 -0
- package/all/copy-overwrite/scripts/lisa-audit.mjs +59 -0
- package/all/copy-overwrite/scripts/lisa-gates.mjs +30 -13
- package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +1 -1
- package/dist/cli/doctor-readiness-audit-allowlist.d.ts +19 -2
- package/dist/cli/doctor-readiness-audit-allowlist.d.ts.map +1 -1
- package/dist/cli/doctor-readiness-audit-allowlist.js +70 -17
- package/dist/cli/doctor-readiness-audit-allowlist.js.map +1 -1
- package/dist/cli/doctor-readiness-audit-scope.d.ts +24 -0
- package/dist/cli/doctor-readiness-audit-scope.d.ts.map +1 -0
- package/dist/cli/doctor-readiness-audit-scope.js +165 -0
- package/dist/cli/doctor-readiness-audit-scope.js.map +1 -0
- package/dist/cli/doctor-readiness-supply-chain-scan.js +1 -1
- package/dist/cli/doctor-readiness-supply-chain-scan.js.map +1 -1
- package/dist/cli/doctor-readiness-supply-chain.d.ts.map +1 -1
- package/dist/cli/doctor-readiness-supply-chain.js +4 -2
- package/dist/cli/doctor-readiness-supply-chain.js.map +1 -1
- package/dist/core/audit-capture.d.ts +31 -0
- package/dist/core/audit-capture.d.ts.map +1 -0
- package/dist/core/audit-capture.js +82 -0
- package/dist/core/audit-capture.js.map +1 -0
- package/dist/core/audit-exclusions.d.ts +32 -0
- package/dist/core/audit-exclusions.d.ts.map +1 -0
- package/dist/core/audit-exclusions.js +109 -0
- package/dist/core/audit-exclusions.js.map +1 -0
- package/dist/core/audit-field-names.d.ts +32 -0
- package/dist/core/audit-field-names.d.ts.map +1 -0
- package/dist/core/audit-field-names.js +107 -0
- package/dist/core/audit-field-names.js.map +1 -0
- package/dist/core/audit-lockfile.d.ts +9 -0
- package/dist/core/audit-lockfile.d.ts.map +1 -0
- package/dist/core/audit-lockfile.js +197 -0
- package/dist/core/audit-lockfile.js.map +1 -0
- package/dist/core/audit-manager.d.ts +8 -0
- package/dist/core/audit-manager.d.ts.map +1 -0
- package/dist/core/audit-manager.js +94 -0
- package/dist/core/audit-manager.js.map +1 -0
- package/dist/core/audit-matcher.d.ts +10 -0
- package/dist/core/audit-matcher.d.ts.map +1 -0
- package/dist/core/audit-matcher.js +103 -0
- package/dist/core/audit-matcher.js.map +1 -0
- package/dist/core/audit-report.d.ts +9 -0
- package/dist/core/audit-report.d.ts.map +1 -0
- package/dist/core/audit-report.js +132 -0
- package/dist/core/audit-report.js.map +1 -0
- package/dist/core/audit-types.d.ts +31 -0
- package/dist/core/audit-types.d.ts.map +1 -0
- package/dist/core/audit-types.js +2 -0
- package/dist/core/audit-types.js.map +1 -0
- package/dist/core/audit.d.ts +25 -0
- package/dist/core/audit.d.ts.map +1 -0
- package/dist/core/audit.js +53 -0
- package/dist/core/audit.js.map +1 -0
- package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
- package/dist/core/lisa-owned-hash-ledger.js +40 -0
- package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
- package/dist/core/upstream-evidence-manifest.js +52 -9
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- package/package.json +11 -6
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/rules/eager/security-audit-handling.md +2 -2
- package/plugins/lisa/rules/reference/security-audit-handling.md +9 -0
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/rules/eager/security-audit-handling.md +2 -2
- package/plugins/lisa-copilot/rules/reference/security-audit-handling.md +9 -0
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/rules/security-audit-handling-reference.mdc +9 -0
- package/plugins/lisa-cursor/rules/security-audit-handling.mdc +2 -2
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/rules/eager/security-audit-handling.md +2 -2
- package/plugins/lisa-devin/rules/reference/security-audit-handling.md +9 -0
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-agy/plugin.json +1 -1
- package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/rules/eager/security-audit-handling.md +2 -2
- package/plugins/src/base/rules/reference/security-audit-handling.md +9 -0
- package/scripts/lisa-audit.mjs +59 -0
- package/scripts/two-channel-couplings.json +2 -2
- package/typescript/copy-contents/.husky/pre-push +5 -124
- package/typescript/copy-overwrite/.prettierignore +1 -0
- package/typescript/copy-overwrite/audit.ignore.config.json +6 -6
- package/typescript/package-lisa/package.lisa.json +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor-readiness-supply-chain.js","sourceRoot":"","sources":["../../src/cli/doctor-readiness-supply-chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"doctor-readiness-supply-chain.js","sourceRoot":"","sources":["../../src/cli/doctor-readiness-supply-chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EACL,YAAY,EAEZ,aAAa,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F,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO;YACL,EAAE,EAAE,sCAAsC;YAC1C,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE;gBACR,kBAAkB,CAAC,UAAU,CAAC;gBAC9B,GAAG,qBAAqB,CAAC,YAAY,CAAC;aACvC;SACF,CAAC;IACJ,CAAC;IACD,OAAO;QACL,EAAE,EAAE,sCAAsC;QAC1C,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE;YACR;gBACE,QAAQ,EACN,aAAa,KAAK,CAAC,MAAM,yBAAyB;oBAClD,GAAG,qBAAqB,CAAC,KAAK,CAAC,IAAI;oBACnC,GAAG,uBAAuB,CAAC,UAAU,CAAC,MAAM;oBAC5C,8DAA8D;oBAC9D,gEAAgE;oBAChE,6BAA6B;gBAC/B,OAAO,EAAE,CAAC,uBAAuB,CAAC;aACnC;YACD,GAAG,qBAAqB,CAAC,YAAY,CAAC;SACvC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AuditFinding, AuditManager } from "./audit-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The audit transport produced no usable report, so nothing was audited.
|
|
4
|
+
*
|
|
5
|
+
* Distinct from a configuration or lockfile-scope error on purpose: a gate
|
|
6
|
+
* runner must report this as "not measured, re-run" rather than as a verdict
|
|
7
|
+
* about the project, so CLIs key their wording on `name`, which survives
|
|
8
|
+
* bundling and module boundaries where `instanceof` may not (#4521).
|
|
9
|
+
*/
|
|
10
|
+
export declare class AuditCaptureError extends Error {
|
|
11
|
+
/**
|
|
12
|
+
* Name the error so CLIs can word it as "nothing was audited".
|
|
13
|
+
* @param message - Operator-facing explanation of what came back
|
|
14
|
+
*/
|
|
15
|
+
constructor(message: string);
|
|
16
|
+
}
|
|
17
|
+
/** Optional retry knobs passed by the CLI, separate from the matcher inputs. */
|
|
18
|
+
export interface AuditCaptureOptions {
|
|
19
|
+
readonly attempts?: string;
|
|
20
|
+
readonly retryDelay?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Capture the real production audit, retrying only indeterminate transport/report data.
|
|
24
|
+
* @param root - Project root containing the exact lockfile and exclusion documents
|
|
25
|
+
* @param manager - Package manager whose report and lockfile are evaluated
|
|
26
|
+
* @param options - Retry knobs passed by the calling CLI
|
|
27
|
+
* @param attempt - Current transport attempt, starting at one
|
|
28
|
+
* @returns The validated result described above
|
|
29
|
+
*/
|
|
30
|
+
export declare function captureAudit(root: string, manager: AuditManager, options?: AuditCaptureOptions, attempt?: number): Promise<AuditFinding[]>;
|
|
31
|
+
//# sourceMappingURL=audit-capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-capture.d.ts","sourceRoot":"","sources":["../../src/core/audit-capture.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAyBnE;;;;;;;GAOG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C;;;OAGG;gBACS,OAAO,EAAE,MAAM;CAI5B;AAED,gFAAgF;AAChF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE,mBAAwB,EACjC,OAAO,SAAI,GACV,OAAO,CAAC,YAAY,EAAE,CAAC,CAgCzB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { gunzipSync } from "node:zlib";
|
|
3
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
4
|
+
import { parseAuditReport } from "./audit-report.js";
|
|
5
|
+
/**
|
|
6
|
+
* A numeric retry typo uses the established default; zero cannot skip auditing.
|
|
7
|
+
* @param value - Untrusted input value to validate
|
|
8
|
+
* @param fallback - Established default used for an invalid numeric knob
|
|
9
|
+
* @returns The validated result described above
|
|
10
|
+
*/
|
|
11
|
+
function numeric(value, fallback) {
|
|
12
|
+
return value !== undefined && /^\d+$/u.test(value) ? Number(value) : fallback;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Decode the observed gzip transport without assuming every payload is compressed.
|
|
16
|
+
* @param buffer - Complete audit stdout bytes
|
|
17
|
+
* @returns The validated result described above
|
|
18
|
+
*/
|
|
19
|
+
function decode(buffer) {
|
|
20
|
+
try {
|
|
21
|
+
return gunzipSync(buffer).toString("utf8");
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return buffer.toString("utf8");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The audit transport produced no usable report, so nothing was audited.
|
|
29
|
+
*
|
|
30
|
+
* Distinct from a configuration or lockfile-scope error on purpose: a gate
|
|
31
|
+
* runner must report this as "not measured, re-run" rather than as a verdict
|
|
32
|
+
* about the project, so CLIs key their wording on `name`, which survives
|
|
33
|
+
* bundling and module boundaries where `instanceof` may not (#4521).
|
|
34
|
+
*/
|
|
35
|
+
export class AuditCaptureError extends Error {
|
|
36
|
+
/**
|
|
37
|
+
* Name the error so CLIs can word it as "nothing was audited".
|
|
38
|
+
* @param message - Operator-facing explanation of what came back
|
|
39
|
+
*/
|
|
40
|
+
constructor(message) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.name = "AuditCaptureError";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Capture the real production audit, retrying only indeterminate transport/report data.
|
|
47
|
+
* @param root - Project root containing the exact lockfile and exclusion documents
|
|
48
|
+
* @param manager - Package manager whose report and lockfile are evaluated
|
|
49
|
+
* @param options - Retry knobs passed by the calling CLI
|
|
50
|
+
* @param attempt - Current transport attempt, starting at one
|
|
51
|
+
* @returns The validated result described above
|
|
52
|
+
*/
|
|
53
|
+
export async function captureAudit(root, manager, options = {}, attempt = 1) {
|
|
54
|
+
const attempts = Math.max(1, numeric(options.attempts, 3));
|
|
55
|
+
const initialDelay = numeric(options.retryDelay, 2);
|
|
56
|
+
const args = manager === "yarn"
|
|
57
|
+
? ["audit", "--groups", "dependencies", "--json"]
|
|
58
|
+
: ["audit", "--production", "--json"];
|
|
59
|
+
const result = spawnSync(manager, args, {
|
|
60
|
+
cwd: root,
|
|
61
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
62
|
+
});
|
|
63
|
+
const diagnosis = result.error?.message ?? result.stderr?.toString("utf8") ?? "";
|
|
64
|
+
const output = decode(result.stdout ?? Buffer.alloc(0));
|
|
65
|
+
try {
|
|
66
|
+
if (result.error)
|
|
67
|
+
throw result.error;
|
|
68
|
+
return parseAuditReport(output, manager);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
if (attempt < attempts) {
|
|
72
|
+
console.error(`Security audit attempt ${attempt} of ${attempts} parsed no advisory data (the audit did not run — this is not a finding); retrying...`);
|
|
73
|
+
await delay(initialDelay * 2 ** (attempt - 1) * 1000);
|
|
74
|
+
return captureAudit(root, manager, options, attempt + 1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const shape = output.trim()
|
|
78
|
+
? "output is neither JSON nor gzipped JSON in a recognized advisory report shape"
|
|
79
|
+
: "produced no output";
|
|
80
|
+
throw new AuditCaptureError(`${manager} audit ${shape}; nothing was audited. This is NOT a clean result. Tried ${attempts} attempt(s). ${diagnosis}`);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=audit-capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-capture.js","sourceRoot":"","sources":["../../src/core/audit-capture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE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it-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether an unknown JSON value is an object.
|
|
4
|
+
* @param value - Untrusted input value to validate
|
|
5
|
+
* @returns The validated result described above
|
|
6
|
+
*/
|
|
7
|
+
export declare function auditRecord(value: unknown): value is Record<string, unknown>;
|
|
8
|
+
/** The two scope fields only lockfile copies can satisfy. */
|
|
9
|
+
interface LockfileScopeFields {
|
|
10
|
+
readonly paths?: unknown;
|
|
11
|
+
readonly versions?: unknown;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Whether an exclusion's scope can only be checked against lockfile copies.
|
|
15
|
+
* @param entry - Exclusion fields
|
|
16
|
+
* @returns True when `paths` or `versions` is present
|
|
17
|
+
*/
|
|
18
|
+
export declare function requiresLockfileScope(entry: LockfileScopeFields): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Validate the optional scope without changing legacy advisory-only meaning.
|
|
21
|
+
* @param entry - Exclusion fields to validate or match
|
|
22
|
+
* @returns The validated result described above
|
|
23
|
+
*/
|
|
24
|
+
export declare function auditScopeProblems(entry: Record<string, unknown>): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Read both exclusion files; a broken decision file cannot produce a pass.
|
|
27
|
+
* @param root - Project root containing the exact lockfile and exclusion documents
|
|
28
|
+
* @returns The validated result described above
|
|
29
|
+
*/
|
|
30
|
+
export declare function readAuditExclusions(root: string): AuditExclusion[];
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=audit-exclusions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-exclusions.d.ts","sourceRoot":"","sources":["../../src/core/audit-exclusions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE5E;AAqBD,6DAA6D;AAC7D,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CAoB3E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE,CA+BlE"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { validRange } from "semver";
|
|
4
|
+
import { classifyUnknownFields } from "./audit-field-names.js";
|
|
5
|
+
/**
|
|
6
|
+
* Whether an unknown JSON value is an object.
|
|
7
|
+
* @param value - Untrusted input value to validate
|
|
8
|
+
* @returns The validated result described above
|
|
9
|
+
*/
|
|
10
|
+
export function auditRecord(value) {
|
|
11
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Reject near-misses of a scope field.
|
|
15
|
+
*
|
|
16
|
+
* A misspelled scope (`path`, `Paths`, `version`) used to be ignored, which
|
|
17
|
+
* turned the entry into an advisory- or package-wide exclusion — the opposite
|
|
18
|
+
* of what its author wrote — so it fails closed. Any other unrecognized key is
|
|
19
|
+
* harmless documentation and keeps its existing meaning: ignored.
|
|
20
|
+
* @param entry - Exclusion fields to validate
|
|
21
|
+
* @returns One problem per misspelled scope field
|
|
22
|
+
*/
|
|
23
|
+
function misspelledScopeProblems(entry) {
|
|
24
|
+
return classifyUnknownFields(entry).misspelledScope.map(({ key, meant }) => `unknown field "${key}" (did you mean "${meant}"?); a misspelled scope ` +
|
|
25
|
+
"field would otherwise be ignored and excuse more copies than written, " +
|
|
26
|
+
"so the exclusion is rejected");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether an exclusion's scope can only be checked against lockfile copies.
|
|
30
|
+
* @param entry - Exclusion fields
|
|
31
|
+
* @returns True when `paths` or `versions` is present
|
|
32
|
+
*/
|
|
33
|
+
export function requiresLockfileScope(entry) {
|
|
34
|
+
return entry.paths !== undefined || entry.versions !== undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Validate the optional scope without changing legacy advisory-only meaning.
|
|
38
|
+
* @param entry - Exclusion fields to validate or match
|
|
39
|
+
* @returns The validated result described above
|
|
40
|
+
*/
|
|
41
|
+
export function auditScopeProblems(entry) {
|
|
42
|
+
return [
|
|
43
|
+
...misspelledScopeProblems(entry),
|
|
44
|
+
...(Object.hasOwn(entry, "package") &&
|
|
45
|
+
(typeof entry.package !== "string" || !entry.package.trim())
|
|
46
|
+
? ["package must be a non-empty package name"]
|
|
47
|
+
: []),
|
|
48
|
+
...(Object.hasOwn(entry, "versions") &&
|
|
49
|
+
(typeof entry.versions !== "string" ||
|
|
50
|
+
!entry.versions.trim() ||
|
|
51
|
+
validRange(entry.versions) === null)
|
|
52
|
+
? ["versions must be a non-empty valid semver range"]
|
|
53
|
+
: []),
|
|
54
|
+
...(Object.hasOwn(entry, "paths") &&
|
|
55
|
+
(!Array.isArray(entry.paths) ||
|
|
56
|
+
entry.paths.length === 0 ||
|
|
57
|
+
entry.paths.some(value => typeof value !== "string" || !value.trim()))
|
|
58
|
+
? ["paths must be a non-empty array of lockfile key paths"]
|
|
59
|
+
: []),
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Read both exclusion files; a broken decision file cannot produce a pass.
|
|
64
|
+
* @param root - Project root containing the exact lockfile and exclusion documents
|
|
65
|
+
* @returns The validated result described above
|
|
66
|
+
*/
|
|
67
|
+
export function readAuditExclusions(root) {
|
|
68
|
+
return ["audit.ignore.config.json", "audit.ignore.local.json"].flatMap(file => {
|
|
69
|
+
const source = readExclusionFile(root, file);
|
|
70
|
+
if (source === null)
|
|
71
|
+
return [];
|
|
72
|
+
const parsed = JSON.parse(source);
|
|
73
|
+
if (!auditRecord(parsed) || !Array.isArray(parsed.exclusions)) {
|
|
74
|
+
throw new Error(`${file}: exclusions must be an array`);
|
|
75
|
+
}
|
|
76
|
+
return parsed.exclusions.flatMap((entry, index) => {
|
|
77
|
+
if (auditRecord(entry) && entry.active === false)
|
|
78
|
+
return [];
|
|
79
|
+
if (!auditRecord(entry) ||
|
|
80
|
+
!["string", "number"].includes(typeof entry.id) ||
|
|
81
|
+
!String(entry.id).trim()) {
|
|
82
|
+
throw new Error(`${file}: exclusion #${index + 1} has no advisory id`);
|
|
83
|
+
}
|
|
84
|
+
const problems = auditScopeProblems(entry);
|
|
85
|
+
if (problems.length)
|
|
86
|
+
throw new Error(`${file}: ${String(entry.id)}: ${problems.join("; ")}`);
|
|
87
|
+
return [
|
|
88
|
+
{ ...entry, id: String(entry.id) },
|
|
89
|
+
];
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Read an optional exclusion document while preserving access failures.
|
|
95
|
+
* @param root - Project root
|
|
96
|
+
* @param file - Exclusion filename
|
|
97
|
+
* @returns The source text, or null for an absent file
|
|
98
|
+
*/
|
|
99
|
+
function readExclusionFile(root, file) {
|
|
100
|
+
try {
|
|
101
|
+
return readFileSync(join(root, file), "utf8");
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (error.code === "ENOENT")
|
|
105
|
+
return null;
|
|
106
|
+
throw new Error(`Cannot read audit exclusions ${file}`, { cause: error });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=audit-exclusions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-exclusions.js","sourceRoot":"","sources":["../../src/core/audit-exclus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-0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classify the field names an audit exclusion carries (#4521).
|
|
3
|
+
*
|
|
4
|
+
* Only five fields decide what an exclusion excuses: `id`, `cve`, `package`,
|
|
5
|
+
* `versions` and `paths`. A misspelling of one of those (`path`, `Paths`,
|
|
6
|
+
* `pathes`, `version`) used to be ignored, which silently turned a scoped entry
|
|
7
|
+
* into an advisory- or package-wide one, so a near-miss of a scope-bearing
|
|
8
|
+
* field fails closed. Any other unrecognized key (`url`, `title`, `expires`) is
|
|
9
|
+
* harmless documentation: the audit ignores it, exactly as before, and doctor
|
|
10
|
+
* mentions it so nobody believes it does something.
|
|
11
|
+
* @module core/audit-field-names
|
|
12
|
+
*/
|
|
13
|
+
/** One unrecognized key that nearly matches a scope field. */
|
|
14
|
+
export interface MisspelledScopeField {
|
|
15
|
+
readonly key: string;
|
|
16
|
+
readonly meant: string;
|
|
17
|
+
}
|
|
18
|
+
/** How an exclusion's unrecognized fields are classified. */
|
|
19
|
+
export interface UnknownFields {
|
|
20
|
+
/** Near-misses of a scope field: each one fails closed. */
|
|
21
|
+
readonly misspelledScope: readonly MisspelledScopeField[];
|
|
22
|
+
/** Other unrecognized keys: ignored by the audit, noted by doctor. */
|
|
23
|
+
readonly ignored: readonly string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Classify every key the documented contract does not name.
|
|
27
|
+
* Keys starting with `//` are the JSON comment convention and are skipped.
|
|
28
|
+
* @param entry - Exclusion fields
|
|
29
|
+
* @returns The near-miss scope fields and the ignored keys
|
|
30
|
+
*/
|
|
31
|
+
export declare function classifyUnknownFields(entry: Readonly<Record<string, unknown>>): UnknownFields;
|
|
32
|
+
//# sourceMappingURL=audit-field-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-field-names.d.ts","sourceRoot":"","sources":["../../src/core/audit-field-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAuGH,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,QAAQ,CAAC,eAAe,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC1D,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACvC,aAAa,CAcf"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classify the field names an audit exclusion carries (#4521).
|
|
3
|
+
*
|
|
4
|
+
* Only five fields decide what an exclusion excuses: `id`, `cve`, `package`,
|
|
5
|
+
* `versions` and `paths`. A misspelling of one of those (`path`, `Paths`,
|
|
6
|
+
* `pathes`, `version`) used to be ignored, which silently turned a scoped entry
|
|
7
|
+
* into an advisory- or package-wide one, so a near-miss of a scope-bearing
|
|
8
|
+
* field fails closed. Any other unrecognized key (`url`, `title`, `expires`) is
|
|
9
|
+
* harmless documentation: the audit ignores it, exactly as before, and doctor
|
|
10
|
+
* mentions it so nobody believes it does something.
|
|
11
|
+
* @module core/audit-field-names
|
|
12
|
+
*/
|
|
13
|
+
/** The fields whose values decide what an exclusion excuses. */
|
|
14
|
+
const SCOPE_FIELDS = ["id", "cve", "package", "versions", "paths"];
|
|
15
|
+
/** Fields an exclusion is documented to carry: scope plus decision record. */
|
|
16
|
+
const KNOWN_FIELDS = new Set([
|
|
17
|
+
...SCOPE_FIELDS,
|
|
18
|
+
"active",
|
|
19
|
+
"reason",
|
|
20
|
+
"notes",
|
|
21
|
+
"justification",
|
|
22
|
+
"decision",
|
|
23
|
+
"rationale",
|
|
24
|
+
"comment",
|
|
25
|
+
"owner",
|
|
26
|
+
"tracking",
|
|
27
|
+
"review_by",
|
|
28
|
+
"expiry_enforced",
|
|
29
|
+
// Advisory metadata people copy out of an audit report alongside the id.
|
|
30
|
+
// `cwe` is one edit from `cve`, so without this it read as a misspelling.
|
|
31
|
+
"cwe",
|
|
32
|
+
"ghsa",
|
|
33
|
+
"url",
|
|
34
|
+
"title",
|
|
35
|
+
"severity",
|
|
36
|
+
"cvss",
|
|
37
|
+
"advisory",
|
|
38
|
+
]);
|
|
39
|
+
/**
|
|
40
|
+
* Lowercase and drop separators, so `Paths`, `pa_ths` and `PATHS` compare equal.
|
|
41
|
+
* @param key - A field name
|
|
42
|
+
* @returns The normalized name
|
|
43
|
+
*/
|
|
44
|
+
function normalize(key) {
|
|
45
|
+
return key.toLowerCase().replace(/[\s_.-]/gu, "");
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Optimal-string-alignment (restricted Damerau-Levenshtein) distance.
|
|
49
|
+
* @param a - First string
|
|
50
|
+
* @param b - Second string
|
|
51
|
+
* @returns Single-character edits, counting an adjacent swap as one
|
|
52
|
+
*/
|
|
53
|
+
function editDistance(a, b) {
|
|
54
|
+
const first = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
55
|
+
const { last } = [...a].reduce(({ beforeLast, last: above }, aChar, aIndex) => {
|
|
56
|
+
const i = aIndex + 1;
|
|
57
|
+
const row = [...b].reduce((cells, bChar, bIndex) => {
|
|
58
|
+
const j = bIndex + 1;
|
|
59
|
+
const substitution = (above[j - 1] ?? 0) + (aChar === bChar ? 0 : 1);
|
|
60
|
+
const best = Math.min((above[j] ?? 0) + 1, (cells[j - 1] ?? 0) + 1, substitution);
|
|
61
|
+
const swapped = i > 1 && j > 1 && aChar === b[j - 2] && a[i - 2] === bChar
|
|
62
|
+
? (beforeLast[j - 2] ?? 0) + 1
|
|
63
|
+
: Number.POSITIVE_INFINITY;
|
|
64
|
+
return [...cells, Math.min(best, swapped)];
|
|
65
|
+
}, [i]);
|
|
66
|
+
return { beforeLast: above, last: row };
|
|
67
|
+
}, { beforeLast: first, last: first });
|
|
68
|
+
return last[b.length] ?? 0;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The scope field an unknown key was probably meant to be, if any.
|
|
72
|
+
*
|
|
73
|
+
* A near-miss is a case or separator variant, a singular/plural swap, or an
|
|
74
|
+
* edit distance of at most 2 — at most 1 for the two-letter `id` and the
|
|
75
|
+
* three-letter `cve`, where distance 2 would capture unrelated short keys such
|
|
76
|
+
* as `by` or `pr`.
|
|
77
|
+
* @param key - An unrecognized field name
|
|
78
|
+
* @returns The scope field it nearly matches, or undefined
|
|
79
|
+
*/
|
|
80
|
+
function nearScopeField(key) {
|
|
81
|
+
const name = normalize(key);
|
|
82
|
+
return SCOPE_FIELDS.find(field => {
|
|
83
|
+
const stem = field.endsWith("s") ? field.slice(0, -1) : field;
|
|
84
|
+
const pluralSwap = [stem, `${stem}s`, `${stem}es`, `${field}s`];
|
|
85
|
+
return (name === field ||
|
|
86
|
+
pluralSwap.includes(name) ||
|
|
87
|
+
editDistance(name, field) <= (field.length <= 3 ? 1 : 2));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Classify every key the documented contract does not name.
|
|
92
|
+
* Keys starting with `//` are the JSON comment convention and are skipped.
|
|
93
|
+
* @param entry - Exclusion fields
|
|
94
|
+
* @returns The near-miss scope fields and the ignored keys
|
|
95
|
+
*/
|
|
96
|
+
export function classifyUnknownFields(entry) {
|
|
97
|
+
const unknown = Object.keys(entry).filter(key => !KNOWN_FIELDS.has(key) && !key.startsWith("//"));
|
|
98
|
+
const misspelledScope = unknown.flatMap(key => {
|
|
99
|
+
const meant = nearScopeField(key);
|
|
100
|
+
return meant === undefined ? [] : [{ key, meant }];
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
misspelledScope,
|
|
104
|
+
ignored: unknown.filter(key => !misspelledScope.some(near => near.key === key)),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=audit-field-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-field-names.js","sourceRoot":"","sources":["../../src/core/audit-field-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,gEAAgE;AAChE,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC;AAE5E,8EAA8E;AAC9E,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC;IAChD,GAAG,YAAY;IACf,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,eAAe;IACf,UAAU;IACV,WAAW;IACX,SAAS;IACT,OAAO;IACP,UAAU;IACV,WAAW;IACX,iBAAiB;IACjB,yEAAyE;IACzE,0EAA0E;IAC1E,KAAK;IACL,MAAM;IACN,KAAK;IACL,OAAO;IACP,UAAU;IACV,MAAM;IACN,UAAU;CACX,CAAC,CAAC;AAEH;;;;GAIG;AACH,SAAS,SAAS,CAAC,GAAW;IAC5B,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AACpD,CAAC;AAQD;;;;;GAKG;AACH,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS;IACxC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAChE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAC5B,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QAC7C,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC;QACrB,MAAM,GAAG,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,eAAe;QACf,OAAO,EAAE,OAAO,CAAC,MAAM,CACrB,GAAG,CAAC,EAAE,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CACvD;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AuditCopy, AuditManager } from "./audit-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Read the selected manager's actual lockfile, without fallback to id-wide scope.
|
|
4
|
+
* @param root - Project root containing the exact lockfile and exclusion documents
|
|
5
|
+
* @param manager - Package manager whose report and lockfile are evaluated
|
|
6
|
+
* @returns The validated result described above
|
|
7
|
+
*/
|
|
8
|
+
export declare function readAuditCopies(root: string, manager: AuditManager): AuditCopy[];
|
|
9
|
+
//# sourceMappingURL=audit-lockfile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-lockfile.d.ts","sourceRoot":"","sources":["../../src/core/audit-lockfile.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA8LhE;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,YAAY,GACpB,SAAS,EAAE,CAeb"}
|