@exploitlens/manifest 0.0.0-stage → 0.1.0
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/dist/canonical.d.ts +5 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +34 -0
- package/dist/canonical.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/parse.d.ts +39 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +101 -0
- package/dist/parse.js.map +1 -0
- package/dist/paths.d.ts +27 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +81 -0
- package/dist/paths.js.map +1 -0
- package/dist/redact.d.ts +2 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/redact.js +35 -0
- package/dist/redact.js.map +1 -0
- package/dist/schema.d.ts +92 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +81 -0
- package/dist/schema.js.map +1 -0
- package/package.json +42 -4
- package/README.md +0 -3
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** A stable JSON string: object keys sorted recursively, no whitespace. */
|
|
2
|
+
export declare function canonicalizeJson(value: unknown): string;
|
|
3
|
+
/** SHA-256 of the canonical JSON form, hex-encoded. */
|
|
4
|
+
export declare function hashCanonicalJson(canonicalJson: string): string;
|
|
5
|
+
//# sourceMappingURL=canonical.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../src/canonical.ts"],"names":[],"mappings":"AA2BA,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEvD;AAED,uDAAuD;AACvD,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAE/D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic JSON canonicalization and hashing for Exploit Bundle
|
|
3
|
+
* manifests. Object keys are sorted recursively (array order is left
|
|
4
|
+
* untouched, since array order is semantically meaningful) so the resulting
|
|
5
|
+
* string, and therefore its hash, depends only on the manifest's content —
|
|
6
|
+
* never on the key order used in the source file.
|
|
7
|
+
*/
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
9
|
+
function sortKeysDeep(value) {
|
|
10
|
+
if (Array.isArray(value)) {
|
|
11
|
+
return value.map(sortKeysDeep);
|
|
12
|
+
}
|
|
13
|
+
if (value !== null && typeof value === "object") {
|
|
14
|
+
// `Object.create(null)`, not `{}`: assigning a `__proto__` key on an
|
|
15
|
+
// ordinary object literal sets the prototype instead of creating an own
|
|
16
|
+
// property, so the key would vanish from the canonical form and two
|
|
17
|
+
// different documents could hash identically.
|
|
18
|
+
const sorted = Object.create(null);
|
|
19
|
+
for (const key of Object.keys(value).sort()) {
|
|
20
|
+
sorted[key] = sortKeysDeep(value[key]);
|
|
21
|
+
}
|
|
22
|
+
return sorted;
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
/** A stable JSON string: object keys sorted recursively, no whitespace. */
|
|
27
|
+
export function canonicalizeJson(value) {
|
|
28
|
+
return JSON.stringify(sortKeysDeep(value));
|
|
29
|
+
}
|
|
30
|
+
/** SHA-256 of the canonical JSON form, hex-encoded. */
|
|
31
|
+
export function hashCanonicalJson(canonicalJson) {
|
|
32
|
+
return createHash("sha256").update(canonicalJson, "utf8").digest("hex");
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=canonical.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical.js","sourceRoot":"","sources":["../src/canonical.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,qEAAqE;QACrE,wEAAwE;QACxE,oEAAoE;QACpE,8CAA8C;QAC9C,MAAM,MAAM,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,CAA4B,CAAC;QACvF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAgC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACvE,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAE,KAAiC,CAAC,GAAG,CAAC,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,iBAAiB,CAAC,aAAqB;IACrD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1E,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @exploitlens/manifest
|
|
3
|
+
*
|
|
4
|
+
* Exploit Bundle parsing, path policy, canonical JSON, and manifest hashing.
|
|
5
|
+
*
|
|
6
|
+
* Scaffolded by EL-001. The Exploit Bundle contract landed in EL-002;
|
|
7
|
+
* parsing, path policy, canonicalization, and hashing behavior landed in
|
|
8
|
+
* EL-020 (`parse.ts`, `paths.ts`, `canonical.ts`, `redact.ts`).
|
|
9
|
+
*/
|
|
10
|
+
/** Package identity, asserted against package.json by the workspace structure test. */
|
|
11
|
+
export declare const PACKAGE_NAME: "@exploitlens/manifest";
|
|
12
|
+
/** Artifact contract version this package will read and write. */
|
|
13
|
+
export declare const SCHEMA_VERSION: "1.0";
|
|
14
|
+
export * from "./schema.js";
|
|
15
|
+
export * from "./canonical.js";
|
|
16
|
+
export * from "./paths.js";
|
|
17
|
+
export * from "./redact.js";
|
|
18
|
+
export * from "./parse.js";
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,uFAAuF;AACvF,eAAO,MAAM,YAAY,EAAG,uBAAgC,CAAC;AAE7D,kEAAkE;AAClE,eAAO,MAAM,cAAc,EAAG,KAAc,CAAC;AAE7C,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @exploitlens/manifest
|
|
3
|
+
*
|
|
4
|
+
* Exploit Bundle parsing, path policy, canonical JSON, and manifest hashing.
|
|
5
|
+
*
|
|
6
|
+
* Scaffolded by EL-001. The Exploit Bundle contract landed in EL-002;
|
|
7
|
+
* parsing, path policy, canonicalization, and hashing behavior landed in
|
|
8
|
+
* EL-020 (`parse.ts`, `paths.ts`, `canonical.ts`, `redact.ts`).
|
|
9
|
+
*/
|
|
10
|
+
/** Package identity, asserted against package.json by the workspace structure test. */
|
|
11
|
+
export const PACKAGE_NAME = "@exploitlens/manifest";
|
|
12
|
+
/** Artifact contract version this package will read and write. */
|
|
13
|
+
export const SCHEMA_VERSION = "1.0";
|
|
14
|
+
export * from "./schema.js";
|
|
15
|
+
export * from "./canonical.js";
|
|
16
|
+
export * from "./paths.js";
|
|
17
|
+
export * from "./redact.js";
|
|
18
|
+
export * from "./parse.js";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,uFAAuF;AACvF,MAAM,CAAC,MAAM,YAAY,GAAG,uBAAgC,CAAC;AAE7D,kEAAkE;AAClE,MAAM,CAAC,MAAM,cAAc,GAAG,KAAc,CAAC;AAE7C,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/parse.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Result } from "@exploitlens/trace-ir";
|
|
2
|
+
import { type ExploitBundle } from "./schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* Largest manifest file this parser will read.
|
|
5
|
+
*
|
|
6
|
+
* Every real manifest is a few hundred bytes to a few kilobytes; this is
|
|
7
|
+
* generous next to that and small enough that the worst case is bounded work
|
|
8
|
+
* rather than an out-of-memory read. Checked via `stat` before any content is
|
|
9
|
+
* read, so an oversized file costs a stat rather than a buffer — the same
|
|
10
|
+
* discipline `@exploitlens/verifier`'s `safe-read.ts` applies to bundle
|
|
11
|
+
* artifacts. This was the one manifest-ingestion point in the codebase
|
|
12
|
+
* without such a cap: the GitHub Action reads a manifest a pull request can
|
|
13
|
+
* edit, and `apps/mcp` reads one from a path a model can name, so both are
|
|
14
|
+
* real ingestion points for a file this parser did not previously bound.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MAX_MANIFEST_BYTES: number;
|
|
17
|
+
export interface ManifestFieldError {
|
|
18
|
+
/** Dot-delimited path into the manifest, e.g. "repository.baselineCommit". */
|
|
19
|
+
path: string;
|
|
20
|
+
message: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ParsedManifest {
|
|
23
|
+
bundle: ExploitBundle;
|
|
24
|
+
/** Stable JSON form of `bundle`, keys sorted recursively. */
|
|
25
|
+
canonicalJson: string;
|
|
26
|
+
/** SHA-256 of `canonicalJson`, hex-encoded. */
|
|
27
|
+
hash: string;
|
|
28
|
+
/** `repository.path` resolved to an absolute path inside `baseDir`. */
|
|
29
|
+
repositoryPath: string;
|
|
30
|
+
}
|
|
31
|
+
/** Validates raw, JSON-decoded input against the Exploit Bundle contract. */
|
|
32
|
+
export declare function parseManifestValue(raw: unknown): Result<ExploitBundle>;
|
|
33
|
+
/**
|
|
34
|
+
* Loads, validates, canonicalizes, and hashes a manifest file, and confirms
|
|
35
|
+
* every path-like field resolves safely: `repository.path` must stay inside
|
|
36
|
+
* `baseDir`, and `foundry.testPath` must not be absolute or escape upward.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseManifestFile(filePath: string, baseDir: string): Result<ParsedManifest>;
|
|
39
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAcA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAK7D,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,QAAkB,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,aAAa,CAAC;IACtB,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAC;CACxB;AAeD,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,CAQtE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,CAoD3F"}
|
package/dist/parse.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads an Exploit Bundle manifest from disk: schema validation with
|
|
3
|
+
* field-specific errors (PRD US01), repository/test path policy, and a
|
|
4
|
+
* reproducible canonical hash.
|
|
5
|
+
*
|
|
6
|
+
* The hash covers the manifest exactly as authored — after schema parsing,
|
|
7
|
+
* before any path resolution — so it is identical across machines
|
|
8
|
+
* regardless of the base directory a caller resolves paths against, or the
|
|
9
|
+
* key order in the source file. `fork.rpcAlias`, if present, is hashed as
|
|
10
|
+
* the opaque alias string declared in the manifest; see `redact.ts` for
|
|
11
|
+
* this package's secret-handling policy.
|
|
12
|
+
*/
|
|
13
|
+
import { readFileSync, statSync } from "node:fs";
|
|
14
|
+
import { err, ok } from "@exploitlens/trace-ir";
|
|
15
|
+
import { canonicalizeJson, hashCanonicalJson } from "./canonical.js";
|
|
16
|
+
import { isSafeRelativePath, resolveWithinBase } from "./paths.js";
|
|
17
|
+
import { ExploitBundleSchema } from "./schema.js";
|
|
18
|
+
/**
|
|
19
|
+
* Largest manifest file this parser will read.
|
|
20
|
+
*
|
|
21
|
+
* Every real manifest is a few hundred bytes to a few kilobytes; this is
|
|
22
|
+
* generous next to that and small enough that the worst case is bounded work
|
|
23
|
+
* rather than an out-of-memory read. Checked via `stat` before any content is
|
|
24
|
+
* read, so an oversized file costs a stat rather than a buffer — the same
|
|
25
|
+
* discipline `@exploitlens/verifier`'s `safe-read.ts` applies to bundle
|
|
26
|
+
* artifacts. This was the one manifest-ingestion point in the codebase
|
|
27
|
+
* without such a cap: the GitHub Action reads a manifest a pull request can
|
|
28
|
+
* edit, and `apps/mcp` reads one from a path a model can name, so both are
|
|
29
|
+
* real ingestion points for a file this parser did not previously bound.
|
|
30
|
+
*/
|
|
31
|
+
export const MAX_MANIFEST_BYTES = 1 * 1024 * 1024;
|
|
32
|
+
function toFieldErrors(zodError) {
|
|
33
|
+
return zodError.issues.map((issue) => ({
|
|
34
|
+
path: issue.path.length > 0 ? issue.path.join(".") : "(root)",
|
|
35
|
+
message: issue.message,
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
function pathPolicyError(field, message) {
|
|
39
|
+
return err("PATH_POLICY_VIOLATION", message, {
|
|
40
|
+
fieldErrors: [{ path: field, message }],
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** Validates raw, JSON-decoded input against the Exploit Bundle contract. */
|
|
44
|
+
export function parseManifestValue(raw) {
|
|
45
|
+
const parsed = ExploitBundleSchema.safeParse(raw);
|
|
46
|
+
if (!parsed.success) {
|
|
47
|
+
return err("SCHEMA_VALIDATION", "manifest failed schema validation", {
|
|
48
|
+
fieldErrors: toFieldErrors(parsed.error),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return ok(parsed.data);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Loads, validates, canonicalizes, and hashes a manifest file, and confirms
|
|
55
|
+
* every path-like field resolves safely: `repository.path` must stay inside
|
|
56
|
+
* `baseDir`, and `foundry.testPath` must not be absolute or escape upward.
|
|
57
|
+
*/
|
|
58
|
+
export function parseManifestFile(filePath, baseDir) {
|
|
59
|
+
let sizeBytes;
|
|
60
|
+
try {
|
|
61
|
+
sizeBytes = statSync(filePath).size;
|
|
62
|
+
}
|
|
63
|
+
catch (cause) {
|
|
64
|
+
return err("SCHEMA_VALIDATION", `failed to read or parse manifest file: ${filePath}`, {
|
|
65
|
+
cause: cause instanceof Error ? cause.message : String(cause),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (sizeBytes > MAX_MANIFEST_BYTES) {
|
|
69
|
+
return err("SCHEMA_VALIDATION", `manifest file "${filePath}" is ${sizeBytes} bytes, above the ${MAX_MANIFEST_BYTES}-byte limit this parser will read`);
|
|
70
|
+
}
|
|
71
|
+
let raw;
|
|
72
|
+
try {
|
|
73
|
+
raw = JSON.parse(readFileSync(filePath, "utf8"));
|
|
74
|
+
}
|
|
75
|
+
catch (cause) {
|
|
76
|
+
return err("SCHEMA_VALIDATION", `failed to read or parse manifest file: ${filePath}`, {
|
|
77
|
+
cause: cause instanceof Error ? cause.message : String(cause),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const parsedBundle = parseManifestValue(raw);
|
|
81
|
+
if (!parsedBundle.ok) {
|
|
82
|
+
return parsedBundle;
|
|
83
|
+
}
|
|
84
|
+
const bundle = parsedBundle.value;
|
|
85
|
+
const resolvedRepository = resolveWithinBase(bundle.repository.path, baseDir);
|
|
86
|
+
if (!resolvedRepository.ok) {
|
|
87
|
+
return pathPolicyError("repository.path", resolvedRepository.error.message);
|
|
88
|
+
}
|
|
89
|
+
if (!isSafeRelativePath(bundle.foundry.testPath)) {
|
|
90
|
+
return pathPolicyError("foundry.testPath", `"${bundle.foundry.testPath}" must be a repository-relative path with no absolute prefix and no upward traversal`);
|
|
91
|
+
}
|
|
92
|
+
const canonicalJson = canonicalizeJson(bundle);
|
|
93
|
+
const hash = hashCanonicalJson(canonicalJson);
|
|
94
|
+
return ok({
|
|
95
|
+
bundle,
|
|
96
|
+
canonicalJson,
|
|
97
|
+
hash,
|
|
98
|
+
repositoryPath: resolvedRepository.value,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEjD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe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AC9E,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC;QAC3B,OAAO,eAAe,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9E,CAAC;IAED,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjD,OAAO,eAAe,CACpB,kBAAkB,EAClB,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,sFAAsF,CAClH,CAAC;IACJ,CAAC;IAED,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAE9C,OAAO,EAAE,CAAC;QACR,MAAM;QACN,aAAa;QACb,IAAI;QACJ,cAAc,EAAE,kBAAkB,CAAC,KAAK;KACzC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/paths.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Result } from "@exploitlens/trace-ir";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves `candidatePath` against `baseDir` and confirms the result stays
|
|
4
|
+
* inside `baseDir`. Returns the resolved absolute path on success.
|
|
5
|
+
*
|
|
6
|
+
* Containment is checked twice: once lexically (which is all that is
|
|
7
|
+
* possible when the path does not exist yet) and, when both the base and the
|
|
8
|
+
* candidate do exist on disk, again on their `realpath`s. The second check
|
|
9
|
+
* is what makes a symlink under `baseDir` that points elsewhere fail this
|
|
10
|
+
* function — the lexical check alone cannot see it, and this module's
|
|
11
|
+
* contract has always been described as a containment boundary rather than
|
|
12
|
+
* a string comparison.
|
|
13
|
+
*
|
|
14
|
+
* A candidate that does not exist is not an error here: `foundry.testPath`
|
|
15
|
+
* and other manifest paths are legitimately checked before the workspace
|
|
16
|
+
* that will contain them is materialized. Only the lexical guarantee applies
|
|
17
|
+
* in that case, which is the strongest guarantee available.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveWithinBase(candidatePath: string, baseDir: string): Result<string>;
|
|
20
|
+
/**
|
|
21
|
+
* True if a manifest-declared relative path, taken as a portable POSIX-style
|
|
22
|
+
* identifier, stays within its own root once `.` and `..` segments are
|
|
23
|
+
* resolved. Rejects absolute paths (POSIX or Windows-drive-letter form) and
|
|
24
|
+
* any traversal that would climb above the path's own starting point.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isSafeRelativePath(candidatePath: string): boolean;
|
|
27
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAgCxF;AAID;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAMjE"}
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path policy for manifest-declared paths.
|
|
3
|
+
*
|
|
4
|
+
* Two different checks are needed because the two path-like manifest fields
|
|
5
|
+
* mean different things:
|
|
6
|
+
*
|
|
7
|
+
* - `repository.path` names a location that already exists on disk relative
|
|
8
|
+
* to a known workspace root, so `resolveWithinBase` resolves it for real
|
|
9
|
+
* (via `node:path`, native to the host OS) and confirms the result stays
|
|
10
|
+
* inside that root. Containment is checked by comparing resolved paths
|
|
11
|
+
* (`path.relative`), not by string-prefix matching, so a sibling
|
|
12
|
+
* directory that merely shares a name prefix with the base is not
|
|
13
|
+
* mistaken for being inside it.
|
|
14
|
+
* - `foundry.testPath` is a path inside a repository checkout that does not
|
|
15
|
+
* exist yet at manifest-parse time (EL-022 creates it later), so there is
|
|
16
|
+
* no real base to resolve against. `isSafeRelativePath` is a purely
|
|
17
|
+
* syntactic check instead: it normalizes the path and rejects anything
|
|
18
|
+
* that is absolute or that still escapes upward after normalization.
|
|
19
|
+
* Manifest paths are portable identifiers written with forward slashes
|
|
20
|
+
* (see the fixture), so this always uses POSIX path semantics regardless
|
|
21
|
+
* of host OS.
|
|
22
|
+
*/
|
|
23
|
+
import { realpathSync } from "node:fs";
|
|
24
|
+
import { isAbsolute, posix, relative, resolve, sep } from "node:path";
|
|
25
|
+
import { err, ok } from "@exploitlens/trace-ir";
|
|
26
|
+
/**
|
|
27
|
+
* Resolves `candidatePath` against `baseDir` and confirms the result stays
|
|
28
|
+
* inside `baseDir`. Returns the resolved absolute path on success.
|
|
29
|
+
*
|
|
30
|
+
* Containment is checked twice: once lexically (which is all that is
|
|
31
|
+
* possible when the path does not exist yet) and, when both the base and the
|
|
32
|
+
* candidate do exist on disk, again on their `realpath`s. The second check
|
|
33
|
+
* is what makes a symlink under `baseDir` that points elsewhere fail this
|
|
34
|
+
* function — the lexical check alone cannot see it, and this module's
|
|
35
|
+
* contract has always been described as a containment boundary rather than
|
|
36
|
+
* a string comparison.
|
|
37
|
+
*
|
|
38
|
+
* A candidate that does not exist is not an error here: `foundry.testPath`
|
|
39
|
+
* and other manifest paths are legitimately checked before the workspace
|
|
40
|
+
* that will contain them is materialized. Only the lexical guarantee applies
|
|
41
|
+
* in that case, which is the strongest guarantee available.
|
|
42
|
+
*/
|
|
43
|
+
export function resolveWithinBase(candidatePath, baseDir) {
|
|
44
|
+
const resolvedBase = resolve(baseDir);
|
|
45
|
+
const resolvedCandidate = resolve(resolvedBase, candidatePath);
|
|
46
|
+
const rel = relative(resolvedBase, resolvedCandidate);
|
|
47
|
+
const escapesBase = rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel);
|
|
48
|
+
if (escapesBase) {
|
|
49
|
+
return err("PATH_POLICY_VIOLATION", `"${candidatePath}" resolves outside the allowed root "${resolvedBase}"`);
|
|
50
|
+
}
|
|
51
|
+
let realBase;
|
|
52
|
+
let realCandidate;
|
|
53
|
+
try {
|
|
54
|
+
realBase = realpathSync(resolvedBase);
|
|
55
|
+
realCandidate = realpathSync(resolvedCandidate);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// One of them does not exist yet; the lexical check above stands alone.
|
|
59
|
+
return ok(resolvedCandidate);
|
|
60
|
+
}
|
|
61
|
+
const realRel = relative(realBase, realCandidate);
|
|
62
|
+
if (realRel === ".." || realRel.startsWith(`..${sep}`) || isAbsolute(realRel)) {
|
|
63
|
+
return err("PATH_POLICY_VIOLATION", `"${candidatePath}" resolves through a link to "${realCandidate}", outside the allowed root "${realBase}"`);
|
|
64
|
+
}
|
|
65
|
+
return ok(resolvedCandidate);
|
|
66
|
+
}
|
|
67
|
+
const WINDOWS_DRIVE_PREFIX = /^[a-zA-Z]:[\\/]/;
|
|
68
|
+
/**
|
|
69
|
+
* True if a manifest-declared relative path, taken as a portable POSIX-style
|
|
70
|
+
* identifier, stays within its own root once `.` and `..` segments are
|
|
71
|
+
* resolved. Rejects absolute paths (POSIX or Windows-drive-letter form) and
|
|
72
|
+
* any traversal that would climb above the path's own starting point.
|
|
73
|
+
*/
|
|
74
|
+
export function isSafeRelativePath(candidatePath) {
|
|
75
|
+
if (WINDOWS_DRIVE_PREFIX.test(candidatePath)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const normalized = posix.normalize(candidatePath.replace(/\\/g, "/"));
|
|
79
|
+
return normalized !== ".." && !normalized.startsWith("../") && !posix.isAbsolute(normalized);
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACv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,GAAG,CAC3G,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,CAAC,iBAAiB,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,aAAqB;IACtD,IAAI,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IACtE,OAAO,UAAU,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AAC/F,CAAC"}
|
package/dist/redact.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAsBA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAYrD"}
|
package/dist/redact.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defense-in-depth redaction for anything derived from a manifest that might
|
|
3
|
+
* be logged, printed, or embedded in an error report.
|
|
4
|
+
*
|
|
5
|
+
* Secret-handling policy for this package: manifest fields that name an
|
|
6
|
+
* environment resource — currently only `fork.rpcAlias` — are treated as
|
|
7
|
+
* opaque identifiers, never resolved. This package does not read
|
|
8
|
+
* `process.env` anywhere, so no resolved secret value ever exists in memory
|
|
9
|
+
* here to leak; the alias name itself is safe to hash and log as-is (see
|
|
10
|
+
* `docs/03_SYSTEM_ARCHITECTURE.md` section 11: "RPC secrets remain
|
|
11
|
+
* environment variables and are replaced with aliases in artifacts").
|
|
12
|
+
* Resolving an alias to an actual RPC URL/credential is the executor's
|
|
13
|
+
* responsibility (EL-021+) and must happen outside this package.
|
|
14
|
+
*
|
|
15
|
+
* `redactSecrets` is the backstop for that policy, not the primary control:
|
|
16
|
+
* it walks any object this package emits (e.g. schema-validation error
|
|
17
|
+
* details built from caller-supplied input) and masks values under
|
|
18
|
+
* secret-shaped keys, in case a future field or a malformed manifest ever
|
|
19
|
+
* carries something that looks like a credential.
|
|
20
|
+
*/
|
|
21
|
+
const SECRET_LIKE_KEY = /token|secret|password|passwd|api[-_]?key|private[-_]?key|credential/i;
|
|
22
|
+
export function redactSecrets(value) {
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
return value.map(redactSecrets);
|
|
25
|
+
}
|
|
26
|
+
if (value !== null && typeof value === "object") {
|
|
27
|
+
const redacted = {};
|
|
28
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
29
|
+
redacted[key] = SECRET_LIKE_KEY.test(key) ? "[REDACTED]" : redactSecrets(entry);
|
|
30
|
+
}
|
|
31
|
+
return redacted;
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,eAAe,GAAG,sEAAsE,CAAC;AAE/F,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAClC,CAAC;IACD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,QAAQ,GAA4B,EAAE,CAAC;QAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YAC5E,QAAQ,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const RepositorySchema: z.ZodObject<{
|
|
3
|
+
path: z.ZodString;
|
|
4
|
+
baselineCommit: z.ZodString;
|
|
5
|
+
patchedCommit: z.ZodString;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
/**
|
|
8
|
+
* A Solidity function identifier, and nothing else (P8).
|
|
9
|
+
*
|
|
10
|
+
* `testSelector`/`controlSelector` are passed to `forge test --match-test`,
|
|
11
|
+
* which treats its argument as a **regular expression**. Accepting any
|
|
12
|
+
* non-empty string therefore let a manifest run tests it never named: `.`
|
|
13
|
+
* matches every test in the suite, and a bare prefix like `test_` matches
|
|
14
|
+
* every test sharing it. The process exit code that the baseline and control
|
|
15
|
+
* gates depend on then aggregates unrelated tests.
|
|
16
|
+
*
|
|
17
|
+
* Constraining the field to an identifier removes every regex metacharacter,
|
|
18
|
+
* and the executor additionally anchors the pattern (`^…$`) so even an exact
|
|
19
|
+
* identifier cannot match a longer test name by prefix.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SolidityIdentifierSchema: z.ZodString;
|
|
22
|
+
export declare const FoundryConfigSchema: z.ZodObject<{
|
|
23
|
+
testPath: z.ZodString;
|
|
24
|
+
testSelector: z.ZodString;
|
|
25
|
+
controlSelector: z.ZodString;
|
|
26
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
27
|
+
fuzzSeed: z.ZodString;
|
|
28
|
+
compilerVersion: z.ZodString;
|
|
29
|
+
evmVersion: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export declare const ForkConfigSchema: z.ZodObject<{
|
|
32
|
+
chainId: z.ZodNumber;
|
|
33
|
+
blockNumber: z.ZodNumber;
|
|
34
|
+
rpcAlias: z.ZodString;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
export declare const ExpectedExploitSchema: z.ZodObject<{
|
|
37
|
+
effectType: z.ZodString;
|
|
38
|
+
asset: z.ZodOptional<z.ZodString>;
|
|
39
|
+
minimumDelta: z.ZodOptional<z.ZodString>;
|
|
40
|
+
attackerAddress: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export declare const InvariantRefSchema: z.ZodObject<{
|
|
43
|
+
id: z.ZodString;
|
|
44
|
+
description: z.ZodString;
|
|
45
|
+
evaluator: z.ZodString;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export declare const VariantConfigSchema: z.ZodObject<{
|
|
48
|
+
strategy: z.ZodString;
|
|
49
|
+
count: z.ZodNumber;
|
|
50
|
+
seed: z.ZodString;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export declare const ExploitBundleSchema: z.ZodObject<{
|
|
53
|
+
schemaVersion: z.ZodLiteral<"1.0">;
|
|
54
|
+
caseId: z.ZodString;
|
|
55
|
+
repository: z.ZodObject<{
|
|
56
|
+
path: z.ZodString;
|
|
57
|
+
baselineCommit: z.ZodString;
|
|
58
|
+
patchedCommit: z.ZodString;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
foundry: z.ZodObject<{
|
|
61
|
+
testPath: z.ZodString;
|
|
62
|
+
testSelector: z.ZodString;
|
|
63
|
+
controlSelector: z.ZodString;
|
|
64
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
65
|
+
fuzzSeed: z.ZodString;
|
|
66
|
+
compilerVersion: z.ZodString;
|
|
67
|
+
evmVersion: z.ZodString;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
fork: z.ZodOptional<z.ZodObject<{
|
|
70
|
+
chainId: z.ZodNumber;
|
|
71
|
+
blockNumber: z.ZodNumber;
|
|
72
|
+
rpcAlias: z.ZodString;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
expectedExploit: z.ZodObject<{
|
|
75
|
+
effectType: z.ZodString;
|
|
76
|
+
asset: z.ZodOptional<z.ZodString>;
|
|
77
|
+
minimumDelta: z.ZodOptional<z.ZodString>;
|
|
78
|
+
attackerAddress: z.ZodOptional<z.ZodString>;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
invariant: z.ZodObject<{
|
|
81
|
+
id: z.ZodString;
|
|
82
|
+
description: z.ZodString;
|
|
83
|
+
evaluator: z.ZodString;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
variants: z.ZodObject<{
|
|
86
|
+
strategy: z.ZodString;
|
|
87
|
+
count: z.ZodNumber;
|
|
88
|
+
seed: z.ZodString;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
export type ExploitBundle = z.infer<typeof ExploitBundleSchema>;
|
|
92
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,aAMQ,CAAC;AAE9C,eAAO,MAAM,mBAAmB;;;;;;;;iBAQ9B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;iBAehC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;iBAI7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;iBAI9B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAS9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Exploit Bundle manifest: the frozen input every run starts from. Path
|
|
3
|
+
* traversal policy and canonical-JSON hashing (EL-020) both operate on values
|
|
4
|
+
* that already satisfy this schema.
|
|
5
|
+
*/
|
|
6
|
+
import { GitCommitShaSchema, HexAddressSchema } from "@exploitlens/trace-ir";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
export const RepositorySchema = z.object({
|
|
9
|
+
path: z.string().min(1),
|
|
10
|
+
baselineCommit: GitCommitShaSchema,
|
|
11
|
+
patchedCommit: GitCommitShaSchema,
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* A Solidity function identifier, and nothing else (P8).
|
|
15
|
+
*
|
|
16
|
+
* `testSelector`/`controlSelector` are passed to `forge test --match-test`,
|
|
17
|
+
* which treats its argument as a **regular expression**. Accepting any
|
|
18
|
+
* non-empty string therefore let a manifest run tests it never named: `.`
|
|
19
|
+
* matches every test in the suite, and a bare prefix like `test_` matches
|
|
20
|
+
* every test sharing it. The process exit code that the baseline and control
|
|
21
|
+
* gates depend on then aggregates unrelated tests.
|
|
22
|
+
*
|
|
23
|
+
* Constraining the field to an identifier removes every regex metacharacter,
|
|
24
|
+
* and the executor additionally anchors the pattern (`^…$`) so even an exact
|
|
25
|
+
* identifier cannot match a longer test name by prefix.
|
|
26
|
+
*/
|
|
27
|
+
export const SolidityIdentifierSchema = z
|
|
28
|
+
.string()
|
|
29
|
+
.regex(/^[A-Za-z_][A-Za-z0-9_]*$/, "must be a Solidity function identifier (letters, digits and underscore; not starting with a digit) — regular expressions are not accepted")
|
|
30
|
+
.max(128, "must be at most 128 characters");
|
|
31
|
+
export const FoundryConfigSchema = z.object({
|
|
32
|
+
testPath: z.string().min(1),
|
|
33
|
+
testSelector: SolidityIdentifierSchema,
|
|
34
|
+
controlSelector: SolidityIdentifierSchema,
|
|
35
|
+
profile: z.string().optional(),
|
|
36
|
+
fuzzSeed: z.string().min(1),
|
|
37
|
+
compilerVersion: z.string().min(1),
|
|
38
|
+
evmVersion: z.string().min(1),
|
|
39
|
+
});
|
|
40
|
+
export const ForkConfigSchema = z.object({
|
|
41
|
+
chainId: z.number().int().positive(),
|
|
42
|
+
blockNumber: z.number().int().nonnegative(),
|
|
43
|
+
rpcAlias: z.string().min(1),
|
|
44
|
+
});
|
|
45
|
+
export const ExpectedExploitSchema = z.object({
|
|
46
|
+
effectType: z.string().min(1),
|
|
47
|
+
asset: z.string().optional(),
|
|
48
|
+
minimumDelta: z.string().regex(/^\d+$/, "must be a base-10 integer string").optional(),
|
|
49
|
+
/**
|
|
50
|
+
* The attacker's own address. Kept for schema/view-model compatibility
|
|
51
|
+
* with `@exploitlens/ui-contracts`' `ExpectedExploitView` (ported from the
|
|
52
|
+
* Workbench branch) -- no evaluator in this package's `evaluate.ts`
|
|
53
|
+
* reads this field. `vaultSolvencyEvaluator` here infers beneficiary and
|
|
54
|
+
* counterparty from the effect flow itself rather than a declared
|
|
55
|
+
* address (see that module's doc for why). Optional and inert: a
|
|
56
|
+
* manifest may set it for documentation purposes, but nothing in the
|
|
57
|
+
* evaluation path depends on it being present or correct.
|
|
58
|
+
*/
|
|
59
|
+
attackerAddress: HexAddressSchema.optional(),
|
|
60
|
+
});
|
|
61
|
+
export const InvariantRefSchema = z.object({
|
|
62
|
+
id: z.string().min(1),
|
|
63
|
+
description: z.string().min(1),
|
|
64
|
+
evaluator: z.string().min(1),
|
|
65
|
+
});
|
|
66
|
+
export const VariantConfigSchema = z.object({
|
|
67
|
+
strategy: z.string().min(1),
|
|
68
|
+
count: z.number().int().positive(),
|
|
69
|
+
seed: z.string().min(1),
|
|
70
|
+
});
|
|
71
|
+
export const ExploitBundleSchema = z.object({
|
|
72
|
+
schemaVersion: z.literal("1.0"),
|
|
73
|
+
caseId: z.string().min(1),
|
|
74
|
+
repository: RepositorySchema,
|
|
75
|
+
foundry: FoundryConfigSchema,
|
|
76
|
+
fork: ForkConfigSchema.optional(),
|
|
77
|
+
expectedExploit: ExpectedExploitSchema,
|
|
78
|
+
invariant: InvariantRefSchema,
|
|
79
|
+
variants: VariantConfigSchema,
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,cAAc,EAAE,kBAAkB;IAClC,aAAa,EAAE,kBAAkB;CAClC,CAAC,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC;KACtC,MAAM,EAAE;KACR,KAAK,CACJ,0BAA0B,EAC1B,2IAA2I,CAC5I;KACA,GAAG,CAAC,GAAG,EAAE,gCAAgC,CAAC,CAAC;AAE9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,YAAY,EAAE,wBAAwB;IACtC,eAAe,EAAE,wBAAwB;IACzC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,e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AQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAC/B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,UAAU,EAAE,gBAAgB;IAC5B,OAAO,EAAE,mBAAmB;IAC5B,IAAI,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IACjC,eAAe,EAAE,qBAAqB;IACtC,SAAS,EAAE,kBAAkB;IAC7B,QAAQ,EAAE,mBAAmB;CAC9B,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exploitlens/manifest",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Exploit Bundle parsing, path policy, canonical JSON, and manifest hashing.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"homepage": "https://github.com/solutiono1/exploitlens#readme",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/solutiono1/exploitlens.git",
|
|
14
|
+
"directory": "packages/manifest"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/solutiono1/exploitlens/security/advisories/new"
|
|
18
|
+
},
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=20"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -p tsconfig.build.json",
|
|
35
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
38
|
+
"prepublishOnly": "pnpm run clean && pnpm run build"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@exploitlens/trace-ir": "workspace:*",
|
|
42
|
+
"zod": "^4.4.3"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/README.md
DELETED