@nulladrift/core 0.6.1 → 0.7.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/{chunk-NDWUEGNI.js → chunk-3WQMGWBE.js} +4 -4
- package/dist/{chunk-SUY3NGZP.js → chunk-DF52BV5H.js} +5 -5
- package/dist/chunk-DF52BV5H.js.map +1 -0
- package/dist/{chunk-42ZE5O5I.js → chunk-NDE6WVMW.js} +3 -3
- package/dist/{chunk-HLTEHLNF.js → chunk-SZKRNTJP.js} +2 -2
- package/dist/{chunk-HLTEHLNF.js.map → chunk-SZKRNTJP.js.map} +1 -1
- package/dist/{chunk-DR7M6VO6.js → chunk-TBVL7XVR.js} +30 -10
- package/dist/chunk-TBVL7XVR.js.map +1 -0
- package/dist/chunk-WEU7FBSB.js +264 -0
- package/dist/chunk-WEU7FBSB.js.map +1 -0
- package/dist/{chunk-DGEHI25T.js → chunk-YLQ4N6RF.js} +2 -2
- package/dist/diff/index.js +6 -6
- package/dist/diff/schema.js +3 -3
- package/dist/index.js +7 -7
- package/dist/lock/canonical.js +1 -1
- package/dist/lock/credentials.d.ts +2 -1
- package/dist/lock/credentials.js +3 -1
- package/dist/lock/jsonschema.js +1 -1
- package/dist/lock/normalize.d.ts +3 -1
- package/dist/lock/normalize.js +5 -3
- package/dist/lock/reseal.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-5NXUTMLT.js +0 -123
- package/dist/chunk-5NXUTMLT.js.map +0 -1
- package/dist/chunk-DR7M6VO6.js.map +0 -1
- package/dist/chunk-SUY3NGZP.js.map +0 -1
- /package/dist/{chunk-NDWUEGNI.js.map → chunk-3WQMGWBE.js.map} +0 -0
- /package/dist/{chunk-42ZE5O5I.js.map → chunk-NDE6WVMW.js.map} +0 -0
- /package/dist/{chunk-DGEHI25T.js.map → chunk-YLQ4N6RF.js.map} +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isEscalation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TBVL7XVR.js";
|
|
4
4
|
import {
|
|
5
5
|
classifySchemaChange
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NDE6WVMW.js";
|
|
7
7
|
import {
|
|
8
8
|
SEVERITY,
|
|
9
9
|
sortChanges
|
|
10
10
|
} from "./chunk-JCJXSMBS.js";
|
|
11
11
|
import {
|
|
12
12
|
stableKey
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-SZKRNTJP.js";
|
|
14
14
|
|
|
15
15
|
// src/risk/untrusted.ts
|
|
16
16
|
function objectsIn(value) {
|
|
@@ -432,4 +432,4 @@ export {
|
|
|
432
432
|
surfaceCapabilities,
|
|
433
433
|
diffLockfiles
|
|
434
434
|
};
|
|
435
|
-
//# sourceMappingURL=chunk-
|
|
435
|
+
//# sourceMappingURL=chunk-3WQMGWBE.js.map
|
|
@@ -29,20 +29,20 @@ function effectiveSchema(node, root, seenRefs = /* @__PURE__ */ new Set(), depth
|
|
|
29
29
|
const object = asObject(node);
|
|
30
30
|
if (object === void 0) return void 0;
|
|
31
31
|
if (depth > MAX_REF_DEPTH) return object;
|
|
32
|
-
const out =
|
|
32
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
33
33
|
const merge = (source) => {
|
|
34
34
|
for (const [key, value] of Object.entries(source)) {
|
|
35
35
|
if (key === "$ref" || key === "allOf") continue;
|
|
36
36
|
if (key === "properties") {
|
|
37
|
-
const merged =
|
|
37
|
+
const merged = Object.assign(/* @__PURE__ */ Object.create(null), asObject(out["properties"]) ?? {});
|
|
38
38
|
for (const [name, schema] of Object.entries(asObject(value) ?? {})) {
|
|
39
|
-
if (!(name
|
|
39
|
+
if (!Object.hasOwn(merged, name)) Object.defineProperty(merged, name, { value: schema, enumerable: true, writable: true, configurable: true });
|
|
40
40
|
}
|
|
41
41
|
out["properties"] = merged;
|
|
42
42
|
} else if (key === "required" && Array.isArray(value)) {
|
|
43
43
|
const already = Array.isArray(out["required"]) ? out["required"] : [];
|
|
44
44
|
out["required"] = [...new Set([...already, ...value].filter((entry) => typeof entry === "string"))];
|
|
45
|
-
} else if (!(key
|
|
45
|
+
} else if (!Object.hasOwn(out, key)) {
|
|
46
46
|
out[key] = value;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -84,4 +84,4 @@ export {
|
|
|
84
84
|
effectiveSchema,
|
|
85
85
|
alternatives
|
|
86
86
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-DF52BV5H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lock/jsonschema.ts"],"sourcesContent":["/**\n * Just enough JSON Schema to see through the indirection servers actually use.\n *\n * Two parts of this tool have to look inside a tool's `inputSchema`: the widening heuristic and\n * the `x-mcp-header` scan. Both used to read only the literal node in front of them, so a schema\n * that put its properties behind `$ref` or `allOf` -- which the generators for Pydantic, Zod and\n * most OpenAPI toolchains do by default -- looked empty to both. A widened parameter went out as\n * a bare `.changed`, and a parameter newly mirrored into an HTTP header was missed entirely.\n *\n * This is not a validator. It resolves local `$ref`, flattens `allOf`, and leaves the\n * alternation keywords for the caller to branch on. Remote `$ref` is never fetched: an audit\n * that reaches out to a URL named by the thing it is auditing is not an audit.\n */\nimport type { JsonObject, JsonValue } from \"./types\";\n\n/** Depth caps. A hostile or merely recursive schema must not be able to hang the run. */\nexport const MAX_REF_DEPTH = 32;\nexport const MAX_VISIT_DEPTH = 12;\nexport const MAX_FACTS = 5_000;\n\nexport function asObject(value: JsonValue | undefined): JsonObject | undefined {\n return value !== null && value !== undefined && typeof value === \"object\" && !Array.isArray(value) ? (value as JsonObject) : undefined;\n}\n\n/** RFC 6901 token decoding: `~1` is `/` and `~0` is `~`, in that order. */\nfunction decodeToken(token: string): string {\n let decoded = token;\n try {\n decoded = decodeURIComponent(token);\n } catch {\n // A malformed escape is a literal, not a reason to abandon the schema.\n }\n return decoded.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n}\n\n/** Resolves a local JSON pointer. Anything with a non-empty URI part is left unresolved. */\nexport function resolvePointer(root: JsonValue, ref: string): JsonValue | undefined {\n if (!ref.startsWith(\"#\")) return undefined;\n const pointer = ref.slice(1);\n if (pointer !== \"\" && !pointer.startsWith(\"/\")) return undefined; // `#anchor`, which needs an anchor index.\n\n let node: JsonValue | undefined = root;\n for (const token of pointer.split(\"/\").slice(1)) {\n const object = asObject(node);\n if (object === undefined) return undefined;\n node = object[decodeToken(token)];\n }\n return node;\n}\n\n/**\n * The keywords in effect at a node, with `$ref` followed and `allOf` folded in.\n *\n * The node's own keywords win over anything it inherits, `properties` are unioned, and\n * `required` is the union of every contributor -- which is what `allOf` means. Alternation\n * (`anyOf` / `oneOf` / `then` / `else`) is deliberately left in place: a caller that wants to\n * treat branches as separate possibilities can, and one that does not is no worse off.\n */\nexport function effectiveSchema(node: JsonValue | undefined, root: JsonValue, seenRefs: ReadonlySet<string> = new Set(), depth = 0): JsonObject | undefined {\n const object = asObject(node);\n if (object === undefined) return undefined;\n if (depth > MAX_REF_DEPTH) return object;\n\n /*\n * No prototype, and own-property checks rather than `in`. `name in merged` on a plain object is\n * true for `constructor`, `toString` and `__proto__`, so a property with one of those names was\n * skipped as already merged, and `merged[\"__proto__\"] = ...` set the prototype instead.\n */\n const out = Object.create(null) as JsonObject;\n const merge = (source: JsonObject): void => {\n for (const [key, value] of Object.entries(source)) {\n if (key === \"$ref\" || key === \"allOf\") continue;\n if (key === \"properties\") {\n // First contributor wins on a conflict, and keeps its position: the merged object reads\n // in the order a person wrote it, not inside-out from the inheritance chain.\n const merged = Object.assign(Object.create(null) as JsonObject, asObject(out[\"properties\"]) ?? {});\n for (const [name, schema] of Object.entries(asObject(value) ?? {})) {\n if (!Object.hasOwn(merged, name)) Object.defineProperty(merged, name, { value: schema, enumerable: true, writable: true, configurable: true });\n }\n out[\"properties\"] = merged;\n } else if (key === \"required\" && Array.isArray(value)) {\n const already = Array.isArray(out[\"required\"]) ? (out[\"required\"] as JsonValue[]) : [];\n out[\"required\"] = [...new Set([...already, ...value].filter((entry): entry is string => typeof entry === \"string\"))];\n } else if (!Object.hasOwn(out, key)) {\n out[key] = value;\n }\n }\n };\n\n // The node itself first, so its own keywords take precedence over what it inherits.\n merge(object);\n\n const ref = object[\"$ref\"];\n if (typeof ref === \"string\" && !seenRefs.has(ref)) {\n const resolved = effectiveSchema(resolvePointer(root, ref), root, new Set([...seenRefs, ref]), depth + 1);\n if (resolved) merge(resolved);\n }\n\n const allOf = object[\"allOf\"];\n if (Array.isArray(allOf)) {\n for (const branch of allOf) {\n const resolved = effectiveSchema(branch, root, seenRefs, depth + 1);\n if (resolved) merge(resolved);\n }\n }\n\n return out;\n}\n\n/** The alternation branches at a node, labelled so a caller can key facts by them. */\nexport function alternatives(object: JsonObject): Array<{ label: string; schema: JsonValue }> {\n const branches: Array<{ label: string; schema: JsonValue }> = [];\n for (const keyword of [\"anyOf\", \"oneOf\"] as const) {\n const value = object[keyword];\n if (!Array.isArray(value)) continue;\n value.forEach((schema, index) => branches.push({ label: `${keyword}[${index}]`, schema }));\n }\n for (const keyword of [\"then\", \"else\", \"not\"] as const) {\n if (object[keyword] !== undefined) branches.push({ label: keyword, schema: object[keyword] as JsonValue });\n }\n return branches;\n}\n"],"mappings":";AAgBO,IAAM,gBAAgB;AACtB,IAAM,kBAAkB;AACxB,IAAM,YAAY;AAElB,SAAS,SAAS,OAAsD;AAC7E,SAAO,UAAU,QAAQ,UAAU,UAAa,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAuB;AAC/H;AAGA,SAAS,YAAY,OAAuB;AAC1C,MAAI,UAAU;AACd,MAAI;AACF,cAAU,mBAAmB,KAAK;AAAA,EACpC,QAAQ;AAAA,EAER;AACA,SAAO,QAAQ,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG;AACvD;AAGO,SAAS,eAAe,MAAiB,KAAoC;A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@@
|
|
|
1
1
|
import {
|
|
2
2
|
canonicalize,
|
|
3
3
|
stableKey
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SZKRNTJP.js";
|
|
5
5
|
import {
|
|
6
6
|
MAX_FACTS,
|
|
7
7
|
MAX_VISIT_DEPTH,
|
|
8
8
|
alternatives,
|
|
9
9
|
asObject,
|
|
10
10
|
effectiveSchema
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-DF52BV5H.js";
|
|
12
12
|
|
|
13
13
|
// src/diff/schema.ts
|
|
14
14
|
function numberAt(node, key) {
|
|
@@ -122,4 +122,4 @@ function classifySchemaChange(before, after) {
|
|
|
122
122
|
export {
|
|
123
123
|
classifySchemaChange
|
|
124
124
|
};
|
|
125
|
-
//# sourceMappingURL=chunk-
|
|
125
|
+
//# sourceMappingURL=chunk-NDE6WVMW.js.map
|
|
@@ -41,7 +41,7 @@ function toJson(value, depth = 0) {
|
|
|
41
41
|
if (value === null) return null;
|
|
42
42
|
if (Array.isArray(value)) return value.map((member) => toJson(member, depth + 1));
|
|
43
43
|
if (typeof value === "object") {
|
|
44
|
-
const out =
|
|
44
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
45
45
|
for (const [key, member] of Object.entries(value)) {
|
|
46
46
|
if (member === void 0) continue;
|
|
47
47
|
out[key] = toJson(member, depth + 1);
|
|
@@ -63,4 +63,4 @@ export {
|
|
|
63
63
|
toJson,
|
|
64
64
|
stableKey
|
|
65
65
|
};
|
|
66
|
-
//# sourceMappingURL=chunk-
|
|
66
|
+
//# sourceMappingURL=chunk-SZKRNTJP.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lock/canonical.ts"],"sourcesContent":["/**\n * RFC 8785 (JSON Canonicalization Scheme) and the digests built on it.\n *\n * JCS rather than a scheme of our own: the hard parts -- key ordering, string escaping, number\n * formatting -- are already specified, so a second implementation can reproduce our digests from\n * the RFC alone rather than from our source.\n *\n * This is separate from how the lockfile is laid out on disk (see io.ts). Hashing sorts every\n * key; the file keeps a declared, readable order. One is for machines, the other for reviewers.\n */\nimport { createHash } from \"node:crypto\";\nimport type { JsonValue } from \"./types\";\n\n/**\n * How deep a surface is allowed to be before we refuse to hash it.\n *\n * Both functions below walk their argument with ordinary recursion, and both are handed JSON\n * that came from somewhere we do not control: a third-party MCP server answering the collector,\n * or a reading posted to the control plane. V8 parses deeply nested JSON iteratively, so a body\n * that nests further than the call stack reaches arrives intact and the overflow happens here.\n * At 16 MB, the ingest allowance, that costs an attacker about a hundred kilobytes.\n *\n * Neither caller breaks when it happens -- the collector reports the server unreachable and the\n * control plane answers 500 -- but both report a stack overflow, which describes our\n * implementation rather than their input. A bound makes it a fact about the input, and a limit\n * the caller can act on.\n *\n * A hundred is far above any real surface. A tool's input schema is JSON Schema, and the\n * elaborate ones nest tens of levels, not hundreds.\n */\nexport const MAX_DEPTH = 100;\n\nconst tooDeep = () =>\n new TypeError(`cannot canonicalize JSON nested deeper than ${MAX_DEPTH} levels; this is not a surface we can hash`);\n\n/**\n * JCS sorts object members by the UTF-16 code units of their keys, which is exactly what\n * `Array.prototype.sort` does by default. Numbers go through `JSON.stringify`, whose output\n * for finite numbers is the ES6 Number-to-String the RFC requires.\n */\nexport function canonicalize(value: JsonValue, depth = 0): string {\n if (depth > MAX_DEPTH) throw tooDeep();\n if (value === null || typeof value === \"boolean\" || typeof value === \"string\") {\n return JSON.stringify(value);\n }\n if (value === undefined) {\n // JSON has no undefined. Reaching here means a caller skipped `toJson`, which would\n // otherwise surface much later as a digest that silently disagrees with itself.\n throw new TypeError(\"cannot canonicalize undefined; pass the value through toJson first\");\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) throw new TypeError(`cannot canonicalize non-finite number: ${value}`);\n // `-0` serializes as `0`, matching the RFC.\n return JSON.stringify(value === 0 ? 0 : value);\n }\n if (Array.isArray(value)) {\n // `map(canonicalize)` would hand the callback the array index as the second argument, which\n // is now the depth. Passing it explicitly is the whole reason this is not point-free.\n return `[${value.map((member) => canonicalize(member, depth + 1)).join(\",\")}]`;\n }\n const keys = Object.keys(value).sort();\n const members = keys.map((key) => `${JSON.stringify(key)}:${canonicalize(value[key] as JsonValue, depth + 1)}`);\n return `{${members.join(\",\")}}`;\n}\n\n/**\n * Whether a value is too deep to hash, answered without recursing.\n *\n * Deliberately iterative: a guard against stack exhaustion that walks the value recursively\n * exhausts the stack on exactly the input it exists to catch. An explicit stack moves the\n * problem to the heap, where the body-size limit already bounds it.\n *\n * This is for request validation, so that a reading too deep to hash is refused at the edge\n * with a message naming the field, rather than hashed and refused as an internal error.\n */\nexport function exceedsMaxDepth(value: unknown): boolean {\n const pending: Array<{ node: unknown; depth: number }> = [{ node: value, depth: 0 }];\n while (pending.length > 0) {\n const next = pending.pop();\n if (next === undefined) break;\n if (next.depth > MAX_DEPTH) return true;\n if (next.node === null || typeof next.node !== \"object\") continue;\n const members = Array.isArray(next.node) ? next.node : Object.values(next.node);\n for (const member of members) pending.push({ node: member, depth: next.depth + 1 });\n }\n return false;\n}\n\nexport function digest(value: JsonValue): string {\n return `sha256:${createHash(\"sha256\").update(canonicalize(value), \"utf8\").digest(\"hex\")}`;\n}\n\n/**\n * Drops `undefined` members so that an absent optional field and a field explicitly set to\n * `undefined` hash identically. Without this, building the same tool through two code paths could\n * produce two digests for one capability.\n */\nexport function toJson(value: unknown, depth = 0): JsonValue {\n // Bounded for the same reason `canonicalize` is, and it matters more here: `digest` and\n // `stableKey` both run this first, so this is where an oversized surface lands.\n if (depth > MAX_DEPTH) throw tooDeep();\n if (value === null) return null;\n // Not `map(toJson)`: that would pass the array index as the depth.\n if (Array.isArray(value)) return value.map((member) => toJson(member, depth + 1));\n if (typeof value === \"object\") {\n
|
|
1
|
+
{"version":3,"sources":["../src/lock/canonical.ts"],"sourcesContent":["/**\n * RFC 8785 (JSON Canonicalization Scheme) and the digests built on it.\n *\n * JCS rather than a scheme of our own: the hard parts -- key ordering, string escaping, number\n * formatting -- are already specified, so a second implementation can reproduce our digests from\n * the RFC alone rather than from our source.\n *\n * This is separate from how the lockfile is laid out on disk (see io.ts). Hashing sorts every\n * key; the file keeps a declared, readable order. One is for machines, the other for reviewers.\n */\nimport { createHash } from \"node:crypto\";\nimport type { JsonValue } from \"./types\";\n\n/**\n * How deep a surface is allowed to be before we refuse to hash it.\n *\n * Both functions below walk their argument with ordinary recursion, and both are handed JSON\n * that came from somewhere we do not control: a third-party MCP server answering the collector,\n * or a reading posted to the control plane. V8 parses deeply nested JSON iteratively, so a body\n * that nests further than the call stack reaches arrives intact and the overflow happens here.\n * At 16 MB, the ingest allowance, that costs an attacker about a hundred kilobytes.\n *\n * Neither caller breaks when it happens -- the collector reports the server unreachable and the\n * control plane answers 500 -- but both report a stack overflow, which describes our\n * implementation rather than their input. A bound makes it a fact about the input, and a limit\n * the caller can act on.\n *\n * A hundred is far above any real surface. A tool's input schema is JSON Schema, and the\n * elaborate ones nest tens of levels, not hundreds.\n */\nexport const MAX_DEPTH = 100;\n\nconst tooDeep = () =>\n new TypeError(`cannot canonicalize JSON nested deeper than ${MAX_DEPTH} levels; this is not a surface we can hash`);\n\n/**\n * JCS sorts object members by the UTF-16 code units of their keys, which is exactly what\n * `Array.prototype.sort` does by default. Numbers go through `JSON.stringify`, whose output\n * for finite numbers is the ES6 Number-to-String the RFC requires.\n */\nexport function canonicalize(value: JsonValue, depth = 0): string {\n if (depth > MAX_DEPTH) throw tooDeep();\n if (value === null || typeof value === \"boolean\" || typeof value === \"string\") {\n return JSON.stringify(value);\n }\n if (value === undefined) {\n // JSON has no undefined. Reaching here means a caller skipped `toJson`, which would\n // otherwise surface much later as a digest that silently disagrees with itself.\n throw new TypeError(\"cannot canonicalize undefined; pass the value through toJson first\");\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) throw new TypeError(`cannot canonicalize non-finite number: ${value}`);\n // `-0` serializes as `0`, matching the RFC.\n return JSON.stringify(value === 0 ? 0 : value);\n }\n if (Array.isArray(value)) {\n // `map(canonicalize)` would hand the callback the array index as the second argument, which\n // is now the depth. Passing it explicitly is the whole reason this is not point-free.\n return `[${value.map((member) => canonicalize(member, depth + 1)).join(\",\")}]`;\n }\n const keys = Object.keys(value).sort();\n const members = keys.map((key) => `${JSON.stringify(key)}:${canonicalize(value[key] as JsonValue, depth + 1)}`);\n return `{${members.join(\",\")}}`;\n}\n\n/**\n * Whether a value is too deep to hash, answered without recursing.\n *\n * Deliberately iterative: a guard against stack exhaustion that walks the value recursively\n * exhausts the stack on exactly the input it exists to catch. An explicit stack moves the\n * problem to the heap, where the body-size limit already bounds it.\n *\n * This is for request validation, so that a reading too deep to hash is refused at the edge\n * with a message naming the field, rather than hashed and refused as an internal error.\n */\nexport function exceedsMaxDepth(value: unknown): boolean {\n const pending: Array<{ node: unknown; depth: number }> = [{ node: value, depth: 0 }];\n while (pending.length > 0) {\n const next = pending.pop();\n if (next === undefined) break;\n if (next.depth > MAX_DEPTH) return true;\n if (next.node === null || typeof next.node !== \"object\") continue;\n const members = Array.isArray(next.node) ? next.node : Object.values(next.node);\n for (const member of members) pending.push({ node: member, depth: next.depth + 1 });\n }\n return false;\n}\n\nexport function digest(value: JsonValue): string {\n return `sha256:${createHash(\"sha256\").update(canonicalize(value), \"utf8\").digest(\"hex\")}`;\n}\n\n/**\n * Drops `undefined` members so that an absent optional field and a field explicitly set to\n * `undefined` hash identically. Without this, building the same tool through two code paths could\n * produce two digests for one capability.\n */\nexport function toJson(value: unknown, depth = 0): JsonValue {\n // Bounded for the same reason `canonicalize` is, and it matters more here: `digest` and\n // `stableKey` both run this first, so this is where an oversized surface lands.\n if (depth > MAX_DEPTH) throw tooDeep();\n if (value === null) return null;\n // Not `map(toJson)`: that would pass the array index as the depth.\n if (Array.isArray(value)) return value.map((member) => toJson(member, depth + 1));\n if (typeof value === \"object\") {\n /*\n * No prototype. `out[key] = ...` on a plain `{}` sends a key named `__proto__` to the\n * prototype setter instead of making it a property, so a schema property called `__proto__`\n * vanished from the lock and the digest while real clients passed it to the model: a server\n * could add or rewrite it and `check` reported a match. JSON.parse keeps such a key as an own\n * property; this has to as well.\n */\n const out = Object.create(null) as Record<string, JsonValue>;\n for (const [key, member] of Object.entries(value as Record<string, unknown>)) {\n if (member === undefined) continue;\n out[key] = toJson(member, depth + 1);\n }\n return out;\n }\n if (typeof value === \"number\" || typeof value === \"string\" || typeof value === \"boolean\") return value;\n // Functions, symbols and bigints cannot reach here from parsed JSON; treat as absent.\n return null;\n}\n\n/**\n * Canonical form of a value that may carry `undefined` members -- an in-memory lock entry, say,\n * where optional fields are present but unset. Comparing two of those directly is the common\n * case in the diff engine, and it must agree with the digest of the same value.\n */\nexport function stableKey(value: unknown): string {\n return canonicalize(toJson(value));\n}\n"],"mappings":";AAUA,SAAS,kBAAkB;AAoBpB,IAAM,YAAY;AAEzB,IAAM,UAAU,MACd,IAAI,UAAU,+CAA+C,SAAS,4CAA4C;AAO7G,SAAS,aAAa,OAAkB,QAAQ,GAAW;AAChE,MAAI,QAAQ,UAAW,OAAM,QAAQ;AACrC,MAAI,UAAU,QAAQ,OAAO,UAAU,aAAa,OAAO,UAAU,UAAU;AAC7E,WAAO,KAAK,UAAU,KAAK;AAAA,EAC7B;AACA,MAAI,UAAU,QAAW;AAGvB,UAAM,IAAI,UAAU,oEAAoE;AAAA,EAC1F;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI,CAAC,OAAO,SAAS,KAAK,EAAG,OAAM,IAAI,UAAU,0CAA0C,KAAK,EAAE;AAElG,WAAO,KAAK,UAAU,UAAU,IAAI,IAAI,KAAK;AAAA,EAC/C;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AAGxB,WAAO,IAAI,MAAM,IAAI,CAAC,WAAW,aAAa,QAAQ,QAAQ,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC;AAAA,EAC7E;AACA,QAAM,OAAO,OAAO,KAAK,KAAK,EAAE,KAAK;AACrC,QAAM,UAAU,KAAK,IAAI,CAAC,QAAQ,GA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AAO,UAAU,UAAW,QAAO;AAEjG,SAAO;AACT;AAOO,SAAS,UAAU,OAAwB;AAChD,SAAO,aAAa,OAAO,KAAK,CAAC;AACnC;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
redactPath
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WEU7FBSB.js";
|
|
4
4
|
import {
|
|
5
5
|
MAX_VISIT_DEPTH,
|
|
6
6
|
alternatives,
|
|
7
7
|
asObject,
|
|
8
8
|
effectiveSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DF52BV5H.js";
|
|
10
10
|
|
|
11
11
|
// src/lock/normalize.ts
|
|
12
12
|
function resolveBehavior(annotations) {
|
|
@@ -24,7 +24,7 @@ function isEscalation(previous, next) {
|
|
|
24
24
|
function normalizeSchema(value) {
|
|
25
25
|
if (Array.isArray(value)) return value.map(normalizeSchema);
|
|
26
26
|
if (value === null || typeof value !== "object") return value;
|
|
27
|
-
const out =
|
|
27
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
28
28
|
for (const [key, member] of Object.entries(value)) {
|
|
29
29
|
if (key === "required" && Array.isArray(member) && member.every((entry) => typeof entry === "string")) {
|
|
30
30
|
out[key] = [...member].sort();
|
|
@@ -36,8 +36,11 @@ function normalizeSchema(value) {
|
|
|
36
36
|
}
|
|
37
37
|
function extractHeaderParams(schema) {
|
|
38
38
|
const found = [];
|
|
39
|
-
|
|
39
|
+
let budget = MAX_HEADER_VISITS;
|
|
40
|
+
const walk = (node, path, depth, refsOnPath) => {
|
|
40
41
|
if (depth > MAX_VISIT_DEPTH) return;
|
|
42
|
+
if (budget <= 0) return;
|
|
43
|
+
budget -= 1;
|
|
41
44
|
const object = effectiveSchema(node, schema);
|
|
42
45
|
if (!object) return;
|
|
43
46
|
const properties = asObject(object["properties"]);
|
|
@@ -47,17 +50,26 @@ function extractHeaderParams(schema) {
|
|
|
47
50
|
if (!resolved) continue;
|
|
48
51
|
const header = resolved["x-mcp-header"];
|
|
49
52
|
if (typeof header === "string" && header.length > 0) found.push(`${[...path, name].join(".")} -> ${header}`);
|
|
50
|
-
|
|
53
|
+
const ref = asObject(child)?.["$ref"];
|
|
54
|
+
if (typeof ref === "string" && refsOnPath.has(ref)) continue;
|
|
55
|
+
walk(child, [...path, name], depth + 1, typeof ref === "string" ? /* @__PURE__ */ new Set([...refsOnPath, ref]) : refsOnPath);
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
|
-
for (const branch of alternatives(object))
|
|
58
|
+
for (const branch of alternatives(object)) {
|
|
59
|
+
const ref = asObject(branch.schema)?.["$ref"];
|
|
60
|
+
if (typeof ref === "string" && refsOnPath.has(ref)) continue;
|
|
61
|
+
walk(branch.schema, path, depth + 1, typeof ref === "string" ? /* @__PURE__ */ new Set([...refsOnPath, ref]) : refsOnPath);
|
|
62
|
+
}
|
|
54
63
|
};
|
|
55
|
-
|
|
64
|
+
const rootRef = asObject(schema)?.["$ref"];
|
|
65
|
+
walk(schema, [], 0, new Set(typeof rootRef === "string" ? [rootRef] : []));
|
|
66
|
+
if (budget <= 0) found.push(`(schema too large to scan for headers past ${MAX_HEADER_VISITS} nodes)`);
|
|
56
67
|
return [...new Set(found)].sort();
|
|
57
68
|
}
|
|
69
|
+
var MAX_HEADER_VISITS = 2e4;
|
|
58
70
|
function stripIgnoredMeta(meta, ignoredPrefixes) {
|
|
59
71
|
if (meta === null || meta === void 0 || typeof meta !== "object" || Array.isArray(meta)) return void 0;
|
|
60
|
-
const out =
|
|
72
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
61
73
|
for (const [key, value] of Object.entries(meta)) {
|
|
62
74
|
if (ignoredPrefixes.some((prefix) => key.startsWith(prefix))) continue;
|
|
63
75
|
out[key] = value;
|
|
@@ -65,6 +77,7 @@ function stripIgnoredMeta(meta, ignoredPrefixes) {
|
|
|
65
77
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
66
78
|
}
|
|
67
79
|
function sanitizeUrl(raw) {
|
|
80
|
+
if (raw.includes("${")) return sanitizeText(raw);
|
|
68
81
|
try {
|
|
69
82
|
const url = new URL(raw);
|
|
70
83
|
url.search = "";
|
|
@@ -74,16 +87,23 @@ function sanitizeUrl(raw) {
|
|
|
74
87
|
url.pathname = redactPath(url.pathname);
|
|
75
88
|
return url.toString();
|
|
76
89
|
} catch {
|
|
77
|
-
return raw;
|
|
90
|
+
return sanitizeText(raw);
|
|
78
91
|
}
|
|
79
92
|
}
|
|
93
|
+
function sanitizeText(raw) {
|
|
94
|
+
const withoutUser = raw.replace(/^([a-z][a-z0-9+.-]*:\/\/)[^/@]*@/i, "$1");
|
|
95
|
+
const base = withoutUser.split(/[?#]/)[0] ?? withoutUser;
|
|
96
|
+
const parts = /^([a-z][a-z0-9+.-]*:\/\/[^/]*)(\/.*)?$/i.exec(base);
|
|
97
|
+
return parts ? `${parts[1]}${parts[2] ? redactPath(parts[2]) : ""}` : base;
|
|
98
|
+
}
|
|
80
99
|
|
|
81
100
|
export {
|
|
82
101
|
resolveBehavior,
|
|
83
102
|
isEscalation,
|
|
84
103
|
normalizeSchema,
|
|
85
104
|
extractHeaderParams,
|
|
105
|
+
MAX_HEADER_VISITS,
|
|
86
106
|
stripIgnoredMeta,
|
|
87
107
|
sanitizeUrl
|
|
88
108
|
};
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
109
|
+
//# sourceMappingURL=chunk-TBVL7XVR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lock/normalize.ts"],"sourcesContent":["/** Turning what a server sent into the stable, reviewable form the lock stores. */\nimport { redactPath } from \"./credentials\";\nimport { alternatives, asObject, effectiveSchema, MAX_VISIT_DEPTH } from \"./jsonschema\";\nimport type { JsonObject, JsonValue, LockedAnnotations, LockedBehavior } from \"./types\";\n\n/**\n * Resolves the four behavioural annotations against the spec's defaults, which are not neutral:\n * an absent `readOnlyHint` means \"may modify\" and an absent `destructiveHint` means \"may\n * destroy\". A server deleting an annotation is therefore an escalation, and the lock has to be\n * able to show it as a changed value rather than a removed line. See docs/lockfile.md §4.\n *\n * `destructiveHint` and `idempotentHint` are defined to be meaningful only when `readOnlyHint`\n * is false, so a read-only tool resolves to non-destructive and idempotent regardless of what\n * it claims: a tool that changes nothing cannot destroy anything, and repeating it has no\n * additional effect.\n */\nexport function resolveBehavior(annotations: LockedAnnotations | undefined): LockedBehavior {\n const readOnly = annotations?.readOnlyHint ?? false;\n return {\n readOnly,\n destructive: readOnly ? false : (annotations?.destructiveHint ?? true),\n idempotent: readOnly ? true : (annotations?.idempotentHint ?? false),\n openWorld: annotations?.openWorldHint ?? true,\n };\n}\n\n/** True when `next` claims any power `previous` did not. */\nexport function isEscalation(previous: LockedBehavior, next: LockedBehavior): boolean {\n return (\n (previous.readOnly && !next.readOnly) ||\n (!previous.destructive && next.destructive) ||\n (previous.idempotent && !next.idempotent) ||\n (!previous.openWorld && next.openWorld)\n );\n}\n\n/**\n * Sorts `required` arrays wherever they appear. Member order there is semantically\n * insignificant and is the most common source of diffs that mean nothing. Every other array\n * keeps server order, because order *is* significant in `prefixItems`, `allOf` and `icons`, and\n * we only reorder where we can show it is safe.\n *\n * The rule is positional rather than schema-aware: a non-schema object with a string-array\n * member literally named `required` would also be sorted. That costs nothing we can observe and\n * avoids carrying a JSON Schema interpreter around.\n */\nexport function normalizeSchema(value: JsonValue): JsonValue {\n if (Array.isArray(value)) return value.map(normalizeSchema);\n if (value === null || typeof value !== \"object\") return value;\n\n // No prototype, so a member named `__proto__` is kept (see toJson in canonical.ts).\n const out = Object.create(null) as JsonObject;\n for (const [key, member] of Object.entries(value)) {\n if (key === \"required\" && Array.isArray(member) && member.every((entry) => typeof entry === \"string\")) {\n out[key] = [...(member as string[])].sort();\n continue;\n }\n out[key] = normalizeSchema(member);\n }\n return out;\n}\n\n/**\n * Finds input properties carrying an `x-mcp-header` annotation, which mirrors the argument's\n * value into an `Mcp-Param-*` HTTP header on Streamable HTTP, where proxies and WAFs can read\n * it. A server adding this to an existing parameter redirects that argument's data with no\n * visible change to the tool's signature, so it gets its own line in the lock.\n *\n * `$ref` and `allOf` are resolved first. Schema generators put properties behind `$defs` as a\n * matter of course, and a scan that only read literal nodes found nothing in those -- which is\n * the worst outcome for a field whose entire purpose is to move data somewhere new.\n */\nexport function extractHeaderParams(schema: JsonValue): string[] {\n const found: string[] = [];\n /*\n * Bounded twice. A `$ref` already on the way down is not followed again: a definition whose\n * properties point back at it was walked once per property per level, P^12 calls, so a\n * 200-byte schema held `check` for minutes on a blocked event loop that no timeout could\n * interrupt. Headers inside a recursion are the ones its first pass already found. And a hard\n * ceiling on visits, which leaves a marker in the lock rather than an incomplete list that\n * looks complete.\n */\n let budget = MAX_HEADER_VISITS;\n\n const walk = (node: JsonValue, path: string[], depth: number, refsOnPath: ReadonlySet<string>): void => {\n if (depth > MAX_VISIT_DEPTH) return;\n if (budget <= 0) return;\n budget -= 1;\n const object = effectiveSchema(node, schema);\n if (!object) return;\n\n const properties = asObject(object[\"properties\"]);\n if (properties) {\n for (const [name, child] of Object.entries(properties)) {\n const resolved = effectiveSchema(child, schema);\n if (!resolved) continue;\n const header = resolved[\"x-mcp-header\"];\n if (typeof header === \"string\" && header.length > 0) found.push(`${[...path, name].join(\".\")} -> ${header}`);\n const ref = asObject(child)?.[\"$ref\"];\n if (typeof ref === \"string\" && refsOnPath.has(ref)) continue;\n walk(child, [...path, name], depth + 1, typeof ref === \"string\" ? new Set([...refsOnPath, ref]) : refsOnPath);\n }\n }\n\n // A parameter reachable only through one branch of an `anyOf` is still reachable.\n for (const branch of alternatives(object)) {\n const ref = asObject(branch.schema)?.[\"$ref\"];\n if (typeof ref === \"string\" && refsOnPath.has(ref)) continue;\n walk(branch.schema, path, depth + 1, typeof ref === \"string\" ? new Set([...refsOnPath, ref]) : refsOnPath);\n }\n };\n\n const rootRef = asObject(schema)?.[\"$ref\"];\n walk(schema, [], 0, new Set(typeof rootRef === \"string\" ? [rootRef] : []));\n if (budget <= 0) found.push(`(schema too large to scan for headers past ${MAX_HEADER_VISITS} nodes)`);\n return [...new Set(found)].sort();\n}\n\n/** How many schema nodes the header scan visits before it stops and says so. */\nexport const MAX_HEADER_VISITS = 20_000;\n\n/** Drops `_meta` keys under any ignored prefix. Returns undefined when nothing is left to pin. */\nexport function stripIgnoredMeta(meta: JsonValue | undefined, ignoredPrefixes: readonly string[]): JsonObject | undefined {\n if (meta === null || meta === undefined || typeof meta !== \"object\" || Array.isArray(meta)) return undefined;\n const out = Object.create(null) as JsonObject;\n for (const [key, value] of Object.entries(meta)) {\n if (ignoredPrefixes.some((prefix) => key.startsWith(prefix))) continue;\n out[key] = value;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/** Strips the query string: query strings routinely carry tokens, and the lock is committed. */\nexport function sanitizeUrl(raw: string): string {\n /*\n * A placeholder (`${HOST}`, `${PORT}`) is kept exactly as written. Parsing first lowercased a\n * placeholder in the host, so the lock named a variable the config never used, and failed on one\n * in the port, which wrote the address raw, query string and all.\n */\n if (raw.includes(\"${\")) return sanitizeText(raw);\n try {\n const url = new URL(raw);\n url.search = \"\";\n url.hash = \"\";\n /*\n * `https://alice:s3cr3t@host/mcp` survived this untouched, because `toString()` keeps\n * userinfo. The query string was stripped on the grounds that credentials usually sit there;\n * userinfo is the one place a credential sits by definition.\n */\n url.username = \"\";\n url.password = \"\";\n // A hosted server whose address embeds the key keeps it in the path, past both of the above.\n url.pathname = redactPath(url.pathname);\n return url.toString();\n } catch {\n return sanitizeText(raw);\n }\n}\n\n/** The same, as text, for an address a URL parser cannot or should not normalize. */\nfunction sanitizeText(raw: string): string {\n const withoutUser = raw.replace(/^([a-z][a-z0-9+.-]*:\\/\\/)[^/@]*@/i, \"$1\");\n const base = withoutUser.split(/[?#]/)[0] ?? withoutUser;\n const parts = /^([a-z][a-z0-9+.-]*:\\/\\/[^/]*)(\\/.*)?$/i.exec(base);\n return parts ? `${parts[1]}${parts[2] ? redactPath(parts[2]) : \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QAAO;AACnG,QAAM,MAAM,uBAAO,OAAO,IAAI;AAC9B,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAC/C,QAAI,gBAAgB,KAAK,CAAC,WAAW,IAAI,WAAW,MAAM,CAAC,EAAG;AAC9D,QAAI,GAAG,IAAI;AAAA,EACb;AACA,SAAO,OAAO,KAAK,GAAG,EAAE,SAAS,IAAI,MAAM;AAC7C;AAGO,SAAS,YAAY,KAAqB;AAM/C,MAAI,IAAI,SAAS,IAAI,EAAG,QAAO,aAAa,GAAG;AAC/C,MAAI;AACF,UAAM,MAAM,IAAI,IAAI,GAAG;AACvB,QAAI,SAAS;AACb,QAAI,OAAO;AAMX,QAAI,WAAW;AACf,QAAI,WAAW;AAEf,QAAI,WAAW,WAAW,IAAI,QAAQ;AACtC,WAAO,IAAI,SAAS;AAAA,EACtB,QAAQ;AACN,WAAO,aAAa,GAAG;AAAA,EACzB;AACF;AAGA,SAAS,aAAa,KAAqB;AACzC,QAAM,cAAc,IAAI,QAAQ,qCAAqC,IAAI;AACzE,QAAM,OAAO,YAAY,MAAM,MAAM,EAAE,CAAC,KAAK;AAC7C,QAAM,QAAQ,0CAA0C,KAAK,IAAI;AACjE,SAAO,QAAQ,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,WAAW,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK;AACxE;","names":[]}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// src/lock/credentials.ts
|
|
2
|
+
var REDACTED = "REDACTED";
|
|
3
|
+
var CREDENTIAL_WORDS = /* @__PURE__ */ new Set([
|
|
4
|
+
"key",
|
|
5
|
+
"apikey",
|
|
6
|
+
"token",
|
|
7
|
+
"secret",
|
|
8
|
+
"password",
|
|
9
|
+
"passwd",
|
|
10
|
+
"pwd",
|
|
11
|
+
"pass",
|
|
12
|
+
"pat",
|
|
13
|
+
"auth",
|
|
14
|
+
"bearer",
|
|
15
|
+
"credential",
|
|
16
|
+
"credentials",
|
|
17
|
+
"privatekey",
|
|
18
|
+
"accesskey",
|
|
19
|
+
"clientsecret",
|
|
20
|
+
"sig",
|
|
21
|
+
"signature",
|
|
22
|
+
"jwt",
|
|
23
|
+
"cookie"
|
|
24
|
+
]);
|
|
25
|
+
var DESCRIBES_IT = /* @__PURE__ */ new Set([
|
|
26
|
+
"file",
|
|
27
|
+
"path",
|
|
28
|
+
"dir",
|
|
29
|
+
"directory",
|
|
30
|
+
"url",
|
|
31
|
+
"uri",
|
|
32
|
+
"endpoint",
|
|
33
|
+
"host",
|
|
34
|
+
"type",
|
|
35
|
+
"mode",
|
|
36
|
+
"method",
|
|
37
|
+
"header",
|
|
38
|
+
"name",
|
|
39
|
+
"id",
|
|
40
|
+
"env",
|
|
41
|
+
"var",
|
|
42
|
+
"length",
|
|
43
|
+
"limit",
|
|
44
|
+
"count",
|
|
45
|
+
"max",
|
|
46
|
+
"min",
|
|
47
|
+
"size",
|
|
48
|
+
"timeout",
|
|
49
|
+
"ttl",
|
|
50
|
+
"format",
|
|
51
|
+
"prefix",
|
|
52
|
+
"location",
|
|
53
|
+
"store",
|
|
54
|
+
"provider",
|
|
55
|
+
"region",
|
|
56
|
+
"scope",
|
|
57
|
+
"scopes",
|
|
58
|
+
"version",
|
|
59
|
+
"algorithm",
|
|
60
|
+
"kind",
|
|
61
|
+
"expiry"
|
|
62
|
+
]);
|
|
63
|
+
function nameWords(name) {
|
|
64
|
+
return name.replace(/^-+/, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
65
|
+
}
|
|
66
|
+
function isCredentialName(name) {
|
|
67
|
+
const words = nameWords(name);
|
|
68
|
+
const last = words[words.length - 1];
|
|
69
|
+
if (last === void 0 || DESCRIBES_IT.has(last) || words[0] === "no") return false;
|
|
70
|
+
return words.some((word) => CREDENTIAL_WORDS.has(word));
|
|
71
|
+
}
|
|
72
|
+
var CREDENTIAL_HEADERS = /* @__PURE__ */ new Set(["authorization", "proxy-authorization", "cookie", "set-cookie"]);
|
|
73
|
+
var ISSUER_FORMATS = [
|
|
74
|
+
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
75
|
+
// AWS access key id
|
|
76
|
+
/\bgh[pousr]_[A-Za-z0-9]{36,}\b/g,
|
|
77
|
+
// GitHub
|
|
78
|
+
/\bgithub_pat_[A-Za-z0-9_]{40,}\b/g,
|
|
79
|
+
/\bglpat-[A-Za-z0-9_-]{20,}/g,
|
|
80
|
+
// GitLab
|
|
81
|
+
/\bxox[abprs]-[A-Za-z0-9-]{10,}/g,
|
|
82
|
+
// Slack
|
|
83
|
+
/\b[rs]k_(?:live|test)_[A-Za-z0-9]{16,}\b/g,
|
|
84
|
+
// Stripe
|
|
85
|
+
/\bsk-ant-[A-Za-z0-9_-]{20,}/g,
|
|
86
|
+
// Anthropic
|
|
87
|
+
/\bsk-(?:proj-|svcacct-|admin-)?[A-Za-z0-9_-]{32,}/g,
|
|
88
|
+
// OpenAI
|
|
89
|
+
/\bAIza[0-9A-Za-z_-]{35}\b/g,
|
|
90
|
+
// Google API key
|
|
91
|
+
/\bnpm_[A-Za-z0-9]{36}\b/g,
|
|
92
|
+
/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
|
|
93
|
+
// JWT
|
|
94
|
+
];
|
|
95
|
+
var PLACEHOLDER = /\$\{|^\$[A-Za-z_]/;
|
|
96
|
+
function looksRandom(value) {
|
|
97
|
+
if (value.length < 32 || !/^[A-Za-z0-9_-]+$/.test(value)) return false;
|
|
98
|
+
if (!/[a-z]/.test(value) || !/[A-Z]/.test(value) || !/[0-9]/.test(value)) return false;
|
|
99
|
+
const kind = (character) => /[a-z]/.test(character) ? 0 : /[A-Z]/.test(character) ? 1 : /[0-9]/.test(character) ? 2 : 3;
|
|
100
|
+
let switches = 0;
|
|
101
|
+
for (let index = 1; index < value.length; index += 1) {
|
|
102
|
+
if (kind(value[index] ?? "") !== kind(value[index - 1] ?? "")) switches += 1;
|
|
103
|
+
}
|
|
104
|
+
return switches >= value.length / 3;
|
|
105
|
+
}
|
|
106
|
+
function decoded(value) {
|
|
107
|
+
try {
|
|
108
|
+
return decodeURIComponent(value);
|
|
109
|
+
} catch {
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function isSecretValue(value) {
|
|
114
|
+
if (value === "" || value === REDACTED || PLACEHOLDER.test(value)) return false;
|
|
115
|
+
if (/^(?:[./~]|[A-Za-z]:\\|[a-z][a-z0-9+.-]*:\/\/)/i.test(value)) return false;
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
function redactFormats(value) {
|
|
119
|
+
let out = value;
|
|
120
|
+
for (const format of ISSUER_FORMATS) out = out.replace(format, REDACTED);
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
function redactUrl(value) {
|
|
124
|
+
if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(value)) return value;
|
|
125
|
+
let url;
|
|
126
|
+
try {
|
|
127
|
+
url = new URL(value);
|
|
128
|
+
} catch {
|
|
129
|
+
return redactPairs(value);
|
|
130
|
+
}
|
|
131
|
+
let changed = false;
|
|
132
|
+
if (url.password && !PLACEHOLDER.test(decoded(url.password))) {
|
|
133
|
+
url.password = REDACTED;
|
|
134
|
+
changed = true;
|
|
135
|
+
}
|
|
136
|
+
for (const [key, parameter] of [...url.searchParams]) {
|
|
137
|
+
if (isCredentialName(key) && isSecretValue(parameter)) {
|
|
138
|
+
url.searchParams.set(key, REDACTED);
|
|
139
|
+
changed = true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const path = redactPath(url.pathname);
|
|
143
|
+
if (path !== url.pathname) {
|
|
144
|
+
url.pathname = path;
|
|
145
|
+
changed = true;
|
|
146
|
+
}
|
|
147
|
+
const hash = url.hash ? redactPairs(url.hash) : url.hash;
|
|
148
|
+
if (hash !== url.hash) {
|
|
149
|
+
url.hash = hash;
|
|
150
|
+
changed = true;
|
|
151
|
+
}
|
|
152
|
+
return changed ? url.toString() : value;
|
|
153
|
+
}
|
|
154
|
+
function redactPairs(text) {
|
|
155
|
+
return text.replace(
|
|
156
|
+
/(^|[?&;#\s,])([A-Za-z_][A-Za-z0-9_.-]*)=([^&;#\s,]*)/g,
|
|
157
|
+
(whole, lead, name, value) => isCredentialName(name) && isSecretValue(value) ? `${lead}${name}=${REDACTED}` : whole
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
function redactHeader(text) {
|
|
161
|
+
const header = /^([A-Za-z][A-Za-z0-9-]*)\s*:\s*(\S.*)$/s.exec(text);
|
|
162
|
+
if (!header) return void 0;
|
|
163
|
+
const [, name = "", value = ""] = header;
|
|
164
|
+
if (!(CREDENTIAL_HEADERS.has(name.toLowerCase()) || isCredentialName(name)) || PLACEHOLDER.test(value)) return void 0;
|
|
165
|
+
return `${name}: ${REDACTED}`;
|
|
166
|
+
}
|
|
167
|
+
function redactJson(text) {
|
|
168
|
+
if (!/^\s*[[{]/.test(text)) return void 0;
|
|
169
|
+
let parsed;
|
|
170
|
+
try {
|
|
171
|
+
parsed = JSON.parse(text);
|
|
172
|
+
} catch {
|
|
173
|
+
return void 0;
|
|
174
|
+
}
|
|
175
|
+
let changed = false;
|
|
176
|
+
const walk = (node) => {
|
|
177
|
+
if (Array.isArray(node)) return node.map(walk);
|
|
178
|
+
if (node !== null && typeof node === "object") {
|
|
179
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
180
|
+
for (const [key, child] of Object.entries(node)) {
|
|
181
|
+
if (typeof child === "string" && isCredentialName(key) && isSecretValue(child)) {
|
|
182
|
+
out[key] = REDACTED;
|
|
183
|
+
changed = true;
|
|
184
|
+
} else if (typeof child === "string") {
|
|
185
|
+
const next = redactText(child);
|
|
186
|
+
if (next !== child) changed = true;
|
|
187
|
+
out[key] = next;
|
|
188
|
+
} else {
|
|
189
|
+
out[key] = walk(child);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return out;
|
|
193
|
+
}
|
|
194
|
+
return node;
|
|
195
|
+
};
|
|
196
|
+
const result = walk(parsed);
|
|
197
|
+
return changed ? JSON.stringify(result) : void 0;
|
|
198
|
+
}
|
|
199
|
+
function redactText(text) {
|
|
200
|
+
if (PLACEHOLDER.test(text) && !/[?&;#]/.test(text)) return text;
|
|
201
|
+
if (looksRandom(text)) return REDACTED;
|
|
202
|
+
const json = redactJson(text);
|
|
203
|
+
if (json !== void 0) return json;
|
|
204
|
+
const header = redactHeader(text);
|
|
205
|
+
if (header !== void 0) return header;
|
|
206
|
+
return redactFormats(redactPairs(redactUrl(text)));
|
|
207
|
+
}
|
|
208
|
+
function redactArgs(args) {
|
|
209
|
+
const out = [...args];
|
|
210
|
+
for (let index = 0; index < out.length; index += 1) {
|
|
211
|
+
const argument = out[index] ?? "";
|
|
212
|
+
const assignment = /^(-{0,2}[A-Za-z][A-Za-z0-9_.-]*)=(.*)$/s.exec(argument);
|
|
213
|
+
if (assignment) {
|
|
214
|
+
const [, name = "", value = ""] = assignment;
|
|
215
|
+
if (isCredentialName(name) && isSecretValue(value)) {
|
|
216
|
+
out[index] = `${name}=${REDACTED}`;
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (!PLACEHOLDER.test(value) || /[?&;#]/.test(value)) out[index] = `${name}=${redactText(value)}`;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const flag = /^-{1,2}([A-Za-z][A-Za-z0-9_.-]*)$/.exec(argument);
|
|
223
|
+
const next = out[index + 1];
|
|
224
|
+
if (flag && next !== void 0 && !next.startsWith("-")) {
|
|
225
|
+
const name = flag[1] ?? "";
|
|
226
|
+
if (isCredentialName(name) && isSecretValue(next) && !looksLikeAnOperand(next)) {
|
|
227
|
+
out[index + 1] = REDACTED;
|
|
228
|
+
index += 1;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (["u", "user", "basic-auth"].includes(name.toLowerCase()) && /^[^:\s]+:[^\s]+$/.test(next) && !PLACEHOLDER.test(next)) {
|
|
232
|
+
out[index + 1] = `${next.slice(0, next.indexOf(":"))}:${REDACTED}`;
|
|
233
|
+
index += 1;
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
out[index] = redactText(argument);
|
|
238
|
+
}
|
|
239
|
+
return out;
|
|
240
|
+
}
|
|
241
|
+
function looksLikeAnOperand(value) {
|
|
242
|
+
return value.startsWith("@") || value.includes("/") || /\.(m?[jt]s|cjs|py|json|ya?ml|toml|sh|exe)$/i.test(value);
|
|
243
|
+
}
|
|
244
|
+
function redactPath(pathname) {
|
|
245
|
+
return pathname.split("/").map((segment) => {
|
|
246
|
+
if (segment === "" || PLACEHOLDER.test(decoded(segment))) return segment;
|
|
247
|
+
if (looksRandom(segment)) return REDACTED;
|
|
248
|
+
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(segment) || /^[0-9a-f]{32,}$/i.test(segment)) return REDACTED;
|
|
249
|
+
return redactFormats(segment);
|
|
250
|
+
}).join("/");
|
|
251
|
+
}
|
|
252
|
+
function countRedacted(transport) {
|
|
253
|
+
const occurrences = (text) => text.split(REDACTED).length - 1;
|
|
254
|
+
return (transport.args ?? []).reduce((total, argument) => total + occurrences(argument), 0) + occurrences(transport.url ?? "");
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export {
|
|
258
|
+
REDACTED,
|
|
259
|
+
isCredentialName,
|
|
260
|
+
redactArgs,
|
|
261
|
+
redactPath,
|
|
262
|
+
countRedacted
|
|
263
|
+
};
|
|
264
|
+
//# sourceMappingURL=chunk-WEU7FBSB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lock/credentials.ts"],"sourcesContent":["/**\n * Credentials a config writes literally, found so the lock can leave them out.\n *\n * Environment and header values were never written to the lock, only their names, and a URL\n * loses its query string and its user:password. That covered every place a credential belongs.\n * It did not cover the places configs actually put them: `--api-key sk-...` in `args`,\n * `-e GITHUB_TOKEN=ghp_...` in a `docker run`, a connection string with a password, a token as a\n * segment of a hosted server's URL. The lock is the file the README tells you to commit, and the\n * reading `push` sends is the same data, so each of those went into git and over the wire.\n *\n * A credential is replaced, not hashed. A rotated key is not a change to what a server can do,\n * so there is nothing for drift to see in it, and a hash of a short password is something a\n * dictionary can be run against. This matches what already happens to an `env` value.\n *\n * Everything here errs toward leaving a value alone. A false positive hides a real change to how\n * a server is started, which is the thing the lock exists to show; a value is only replaced when\n * its name says it is a credential, its issuer's format does, or it is too random to be anything\n * else. A `${VAR}` placeholder is never touched: that is how a config is supposed to do this.\n */\n\n/** What a credential is replaced with. Plain ASCII, so it survives a URL path unescaped. */\nexport const REDACTED = \"REDACTED\";\n\n/**\n * Whether a name says its value is a credential: a flag (`--github-token`, `--key`), an\n * environment assignment (`GITHUB_PAT=`, `DD_API_KEY_SECONDARY=`), a JSON key (`braveApiKey`), a\n * query or connection-string parameter (`api_key=`, `Password=`).\n *\n * Read as words, camelCase split, so the credential word can sit anywhere in the name. It was a\n * suffix match, which missed `--key`, `GITHUB_PAT`, `braveApiKey` and every name with a word after\n * the credential one. A name whose last word says it holds something *about* a credential (where\n * it is, what kind it is) is left alone: `--token-file`, `--key-id`, `--auth-type`, `--max-tokens`.\n */\nconst CREDENTIAL_WORDS = new Set([\n \"key\", \"apikey\", \"token\", \"secret\", \"password\", \"passwd\", \"pwd\", \"pass\", \"pat\", \"auth\", \"bearer\",\n \"credential\", \"credentials\", \"privatekey\", \"accesskey\", \"clientsecret\", \"sig\", \"signature\", \"jwt\", \"cookie\",\n]);\nconst DESCRIBES_IT = new Set([\n \"file\", \"path\", \"dir\", \"directory\", \"url\", \"uri\", \"endpoint\", \"host\", \"type\", \"mode\", \"method\", \"header\",\n \"name\", \"id\", \"env\", \"var\", \"length\", \"limit\", \"count\", \"max\", \"min\", \"size\", \"timeout\", \"ttl\", \"format\",\n \"prefix\", \"location\", \"store\", \"provider\", \"region\", \"scope\", \"scopes\", \"version\", \"algorithm\", \"kind\", \"expiry\",\n]);\n\nfunction nameWords(name: string): string[] {\n return name\n .replace(/^-+/, \"\")\n .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter(Boolean);\n}\n\nexport function isCredentialName(name: string): boolean {\n const words = nameWords(name);\n const last = words[words.length - 1];\n if (last === undefined || DESCRIBES_IT.has(last) || words[0] === \"no\") return false;\n return words.some((word) => CREDENTIAL_WORDS.has(word));\n}\n\n/** Headers that carry a credential whatever their value looks like. */\nconst CREDENTIAL_HEADERS = new Set([\"authorization\", \"proxy-authorization\", \"cookie\", \"set-cookie\"]);\n\n/**\n * Formats a credential has wherever it appears, because its issuer made it recognisable on\n * purpose (so leaked ones can be found). Each is specific enough not to match a package name.\n */\nconst ISSUER_FORMATS: RegExp[] = [\n /\\b(?:AKIA|ASIA)[0-9A-Z]{16}\\b/g, // AWS access key id\n /\\bgh[pousr]_[A-Za-z0-9]{36,}\\b/g, // GitHub\n /\\bgithub_pat_[A-Za-z0-9_]{40,}\\b/g,\n /\\bglpat-[A-Za-z0-9_-]{20,}/g, // GitLab\n /\\bxox[abprs]-[A-Za-z0-9-]{10,}/g, // Slack\n /\\b[rs]k_(?:live|test)_[A-Za-z0-9]{16,}\\b/g, // Stripe\n /\\bsk-ant-[A-Za-z0-9_-]{20,}/g, // Anthropic\n /\\bsk-(?:proj-|svcacct-|admin-)?[A-Za-z0-9_-]{32,}/g, // OpenAI\n /\\bAIza[0-9A-Za-z_-]{35}\\b/g, // Google API key\n /\\bnpm_[A-Za-z0-9]{36}\\b/g,\n /\\beyJ[A-Za-z0-9_-]{8,}\\.eyJ[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]{8,}/g, // JWT\n];\n\n/** A value written as a placeholder for the client to fill in, which is the safe way to do this. */\nconst PLACEHOLDER = /\\$\\{|^\\$[A-Za-z_]/;\n\n/**\n * A token with no issuer format: long, URL-safe, mixing upper case, lower case and digits, and\n * switching between them constantly.\n *\n * Requiring all three classes leaves out UUIDs, hex digests and commit hashes, which are lower\n * case and far more often an identifier than a secret. Requiring the switching leaves out long\n * names: `AnthropicClaudeDesktopExtension2025` has every class but changes class six times in\n * thirty-five characters, where a random token changes on most of them.\n */\nfunction looksRandom(value: string): boolean {\n if (value.length < 32 || !/^[A-Za-z0-9_-]+$/.test(value)) return false;\n if (!/[a-z]/.test(value) || !/[A-Z]/.test(value) || !/[0-9]/.test(value)) return false;\n const kind = (character: string) => (/[a-z]/.test(character) ? 0 : /[A-Z]/.test(character) ? 1 : /[0-9]/.test(character) ? 2 : 3);\n let switches = 0;\n for (let index = 1; index < value.length; index += 1) {\n if (kind(value[index] ?? \"\") !== kind(value[index - 1] ?? \"\")) switches += 1;\n }\n return switches >= value.length / 3;\n}\n\n/** `decodeURIComponent`, for a check: a malformed escape is just text. */\nfunction decoded(value: string): string {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\n/** A value worth replacing when its name already says it is a credential. */\nfunction isSecretValue(value: string): boolean {\n if (value === \"\" || value === REDACTED || PLACEHOLDER.test(value)) return false;\n // A path or a URL names where the secret lives, not the secret: `--token-file`-style use.\n if (/^(?:[./~]|[A-Za-z]:\\\\|[a-z][a-z0-9+.-]*:\\/\\/)/i.test(value)) return false;\n return true;\n}\n\n/** Replaces each issuer-formatted credential inside a value, leaving the rest of it readable. */\nfunction redactFormats(value: string): string {\n let out = value;\n for (const format of ISSUER_FORMATS) out = out.replace(format, REDACTED);\n return out;\n}\n\n/** In a URL inside an argument: the password, credential parameters in the query or fragment, key path segments. */\nfunction redactUrl(value: string): string {\n if (!/^[a-z][a-z0-9+.-]*:\\/\\//i.test(value)) return value;\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n return redactPairs(value);\n }\n let changed = false;\n if (url.password && !PLACEHOLDER.test(decoded(url.password))) {\n url.password = REDACTED;\n changed = true;\n }\n for (const [key, parameter] of [...url.searchParams]) {\n if (isCredentialName(key) && isSecretValue(parameter)) {\n url.searchParams.set(key, REDACTED);\n changed = true;\n }\n }\n const path = redactPath(url.pathname);\n if (path !== url.pathname) {\n url.pathname = path;\n changed = true;\n }\n const hash = url.hash ? redactPairs(url.hash) : url.hash;\n if (hash !== url.hash) {\n url.hash = hash;\n changed = true;\n }\n return changed ? url.toString() : value;\n}\n\n/**\n * `name=value` pairs inside a larger string whose name is a credential: a query string a URL\n * parser would not take (`jdbc:postgresql://...&password=`), a fragment (`#access_token=`), a\n * connection string (`Server=db;Password=...`).\n */\nfunction redactPairs(text: string): string {\n return text.replace(/(^|[?&;#\\s,])([A-Za-z_][A-Za-z0-9_.-]*)=([^&;#\\s,]*)/g, (whole, lead: string, name: string, value: string) =>\n isCredentialName(name) && isSecretValue(value) ? `${lead}${name}=${REDACTED}` : whole,\n );\n}\n\n/** A header written as `Name: value`, for a header that is a credential. */\nfunction redactHeader(text: string): string | undefined {\n const header = /^([A-Za-z][A-Za-z0-9-]*)\\s*:\\s*(\\S.*)$/s.exec(text);\n if (!header) return undefined;\n const [, name = \"\", value = \"\"] = header;\n if (!(CREDENTIAL_HEADERS.has(name.toLowerCase()) || isCredentialName(name)) || PLACEHOLDER.test(value)) return undefined;\n return `${name}: ${REDACTED}`;\n}\n\n/** JSON in an argument (`--config {\"braveApiKey\":\"...\"}`), its credential-named values replaced. */\nfunction redactJson(text: string): string | undefined {\n if (!/^\\s*[[{]/.test(text)) return undefined;\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n return undefined;\n }\n let changed = false;\n const walk = (node: unknown): unknown => {\n if (Array.isArray(node)) return node.map(walk);\n if (node !== null && typeof node === \"object\") {\n const out: Record<string, unknown> = Object.create(null) as Record<string, unknown>;\n for (const [key, child] of Object.entries(node)) {\n if (typeof child === \"string\" && isCredentialName(key) && isSecretValue(child)) {\n out[key] = REDACTED;\n changed = true;\n } else if (typeof child === \"string\") {\n const next = redactText(child);\n if (next !== child) changed = true;\n out[key] = next;\n } else {\n out[key] = walk(child);\n }\n }\n return out;\n }\n return node;\n };\n const result = walk(parsed);\n return changed ? JSON.stringify(result) : undefined;\n}\n\n/** Everything that can hide a credential inside one string, in the order that keeps the rest readable. */\nfunction redactText(text: string): string {\n if (PLACEHOLDER.test(text) && !/[?&;#]/.test(text)) return text;\n if (looksRandom(text)) return REDACTED;\n const json = redactJson(text);\n if (json !== undefined) return json;\n const header = redactHeader(text);\n if (header !== undefined) return header;\n return redactFormats(redactPairs(redactUrl(text)));\n}\n\n/**\n * `args` with every credential written literally in them replaced by {@link REDACTED}.\n *\n * Handles a flag and its value (`--api-key KEY`, `--api-key=KEY`), an environment assignment in\n * an argument (`-e GITHUB_TOKEN=ghp_...`, as `docker run` takes them), a URL's password or\n * credential query parameter, an issuer-formatted token anywhere, and an argument that is nothing\n * but a long random token. Arguments are returned in place and in order, so a change to anything\n * else about how a server is started is still drift.\n */\nexport function redactArgs(args: readonly string[]): string[] {\n const out = [...args];\n for (let index = 0; index < out.length; index += 1) {\n const argument = out[index] ?? \"\";\n\n // `--name=value`, `-n=value`, and `NAME=value` (an environment assignment).\n const assignment = /^(-{0,2}[A-Za-z][A-Za-z0-9_.-]*)=(.*)$/s.exec(argument);\n if (assignment) {\n const [, name = \"\", value = \"\"] = assignment;\n if (isCredentialName(name) && isSecretValue(value)) {\n out[index] = `${name}=${REDACTED}`;\n continue;\n }\n // Any other assignment: its value can still hold a header, a URL with a password, JSON, a token.\n if (!PLACEHOLDER.test(value) || /[?&;#]/.test(value)) out[index] = `${name}=${redactText(value)}`;\n continue;\n }\n\n // `--name value`: the flag names a credential, so the next argument is one.\n const flag = /^-{1,2}([A-Za-z][A-Za-z0-9_.-]*)$/.exec(argument);\n const next = out[index + 1];\n if (flag && next !== undefined && !next.startsWith(\"-\")) {\n const name = flag[1] ?? \"\";\n if (isCredentialName(name) && isSecretValue(next) && !looksLikeAnOperand(next)) {\n out[index + 1] = REDACTED;\n index += 1;\n continue;\n }\n // `-u user:password`, `--user user:password`: curl's form, and every tool that copied it.\n if ([\"u\", \"user\", \"basic-auth\"].includes(name.toLowerCase()) && /^[^:\\s]+:[^\\s]+$/.test(next) && !PLACEHOLDER.test(next)) {\n out[index + 1] = `${next.slice(0, next.indexOf(\":\"))}:${REDACTED}`;\n index += 1;\n continue;\n }\n }\n\n out[index] = redactText(argument);\n }\n return out;\n}\n\n/**\n * Whether the word after a flag is more likely the next operand than the flag's value: a script, a\n * package, a path. A boolean credential flag (`--auth`) followed by `server.js` is not a key.\n */\nfunction looksLikeAnOperand(value: string): boolean {\n return value.startsWith(\"@\") || value.includes(\"/\") || /\\.(m?[jt]s|cjs|py|json|ya?ml|toml|sh|exe)$/i.test(value);\n}\n\n/**\n * A URL path with any segment that is a credential replaced, for hosted servers whose address\n * embeds the key (`https://host/api/<token>/mcp`). The rest of the path stays, so a server that\n * moves to a different path or host is still drift.\n */\nexport function redactPath(pathname: string): string {\n return pathname\n .split(\"/\")\n .map((segment) => {\n if (segment === \"\" || PLACEHOLDER.test(decoded(segment))) return segment;\n if (looksRandom(segment)) return REDACTED;\n // A UUID or a long hex string in a hosted server's address is its key far more often than\n // not (Pipedream, Composio and the like put the account's key there).\n if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(segment) || /^[0-9a-f]{32,}$/i.test(segment)) return REDACTED;\n return redactFormats(segment);\n })\n .join(\"/\");\n}\n\n/** How many credentials were left out of a locked transport, for saying so. */\nexport function countRedacted(transport: { args?: readonly string[]; url?: string }): number {\n const occurrences = (text: string) => text.split(REDACTED).length - 1;\n return (transport.args ?? []).reduce((total, argument) => total + occurrences(argument), 0) + occurrences(transport.url ?? \"\");\n}\n"],"mappings":";AAqBO,IAAM,WAAW;AAYxB,IAAM,mBAAmB,oBAAI,IAAI;AAAA,EAC/B;AAAA,EAAO;AAAA,EAA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,QAAI,YAAY,MAAM,YAAY,KAAK,QAAQ,OAAO,CAAC,EAAG,QAAO;AACjE,QAAI,YAAY,OAAO,EAAG,QAAO;AAGjC,QAAI,kEAAkE,KAAK,OAAO,KAAK,mBAAmB,KAAK,OAAO,EAAG,QAAO;AAChI,WAAO,cAAc,OAAO;AAAA,EAC9B,CAAC,EACA,KAAK,GAAG;AACb;AAGO,SAAS,cAAc,WAA+D;AAC3F,QAAM,cAAc,CAAC,SAAiB,KAAK,MAAM,QAAQ,EAAE,SAAS;AACpE,UAAQ,UAAU,QAAQ,CAAC,GAAG,OAAO,CAAC,OAAO,aAAa,QAAQ,YAAY,QAAQ,GAAG,CAAC,IAAI,YAAY,UAAU,OAAO,EAAE;AAC/H;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
digest,
|
|
3
3
|
toJson
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SZKRNTJP.js";
|
|
5
5
|
|
|
6
6
|
// src/lock/reseal.ts
|
|
7
7
|
function sealMember(member) {
|
|
@@ -43,4 +43,4 @@ function resealMcpServer(entry) {
|
|
|
43
43
|
export {
|
|
44
44
|
reseal
|
|
45
45
|
};
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
46
|
+
//# sourceMappingURL=chunk-YLQ4N6RF.js.map
|
package/dist/diff/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
diffLockfiles
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-3WQMGWBE.js";
|
|
4
|
+
import "../chunk-TBVL7XVR.js";
|
|
5
|
+
import "../chunk-NDE6WVMW.js";
|
|
6
6
|
import "../chunk-ALHOTOM6.js";
|
|
7
7
|
import "../chunk-JCJXSMBS.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-SZKRNTJP.js";
|
|
9
|
+
import "../chunk-WEU7FBSB.js";
|
|
10
|
+
import "../chunk-DF52BV5H.js";
|
|
11
11
|
export {
|
|
12
12
|
diffLockfiles
|
|
13
13
|
};
|
package/dist/diff/schema.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
classifySchemaChange
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-NDE6WVMW.js";
|
|
4
|
+
import "../chunk-SZKRNTJP.js";
|
|
5
|
+
import "../chunk-DF52BV5H.js";
|
|
6
6
|
export {
|
|
7
7
|
classifySchemaChange
|
|
8
8
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
reseal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YLQ4N6RF.js";
|
|
4
4
|
import {
|
|
5
5
|
LOCKFILE_VERSION,
|
|
6
6
|
SUBJECT_KINDS
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
stringOr,
|
|
15
15
|
surfaceCapabilities,
|
|
16
16
|
toolCapabilities
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-3WQMGWBE.js";
|
|
18
18
|
import {
|
|
19
19
|
extractHeaderParams,
|
|
20
20
|
isEscalation,
|
|
@@ -22,10 +22,10 @@ import {
|
|
|
22
22
|
resolveBehavior,
|
|
23
23
|
sanitizeUrl,
|
|
24
24
|
stripIgnoredMeta
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-TBVL7XVR.js";
|
|
26
26
|
import {
|
|
27
27
|
classifySchemaChange
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-NDE6WVMW.js";
|
|
29
29
|
import "./chunk-ALHOTOM6.js";
|
|
30
30
|
import {
|
|
31
31
|
CHANGE_KINDS,
|
|
@@ -42,14 +42,14 @@ import {
|
|
|
42
42
|
exceedsMaxDepth,
|
|
43
43
|
stableKey,
|
|
44
44
|
toJson
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-SZKRNTJP.js";
|
|
46
46
|
import {
|
|
47
47
|
REDACTED,
|
|
48
48
|
countRedacted,
|
|
49
49
|
redactArgs,
|
|
50
50
|
redactPath
|
|
51
|
-
} from "./chunk-
|
|
52
|
-
import "./chunk-
|
|
51
|
+
} from "./chunk-WEU7FBSB.js";
|
|
52
|
+
import "./chunk-DF52BV5H.js";
|
|
53
53
|
|
|
54
54
|
// src/risk/steering.ts
|
|
55
55
|
var STEERING_KINDS = ["model-directive", "credential-path", "exfiltration", "hidden-text"];
|
package/dist/lock/canonical.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
/** What a credential is replaced with. Plain ASCII, so it survives a URL path unescaped. */
|
|
21
21
|
declare const REDACTED = "REDACTED";
|
|
22
|
+
declare function isCredentialName(name: string): boolean;
|
|
22
23
|
/**
|
|
23
24
|
* `args` with every credential written literally in them replaced by {@link REDACTED}.
|
|
24
25
|
*
|
|
@@ -41,4 +42,4 @@ declare function countRedacted(transport: {
|
|
|
41
42
|
url?: string;
|
|
42
43
|
}): number;
|
|
43
44
|
|
|
44
|
-
export { REDACTED, countRedacted, redactArgs, redactPath };
|
|
45
|
+
export { REDACTED, countRedacted, isCredentialName, redactArgs, redactPath };
|
package/dist/lock/credentials.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
REDACTED,
|
|
3
3
|
countRedacted,
|
|
4
|
+
isCredentialName,
|
|
4
5
|
redactArgs,
|
|
5
6
|
redactPath
|
|
6
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-WEU7FBSB.js";
|
|
7
8
|
export {
|
|
8
9
|
REDACTED,
|
|
9
10
|
countRedacted,
|
|
11
|
+
isCredentialName,
|
|
10
12
|
redactArgs,
|
|
11
13
|
redactPath
|
|
12
14
|
};
|
package/dist/lock/jsonschema.js
CHANGED
package/dist/lock/normalize.d.ts
CHANGED
|
@@ -36,9 +36,11 @@ declare function normalizeSchema(value: JsonValue): JsonValue;
|
|
|
36
36
|
* the worst outcome for a field whose entire purpose is to move data somewhere new.
|
|
37
37
|
*/
|
|
38
38
|
declare function extractHeaderParams(schema: JsonValue): string[];
|
|
39
|
+
/** How many schema nodes the header scan visits before it stops and says so. */
|
|
40
|
+
declare const MAX_HEADER_VISITS = 20000;
|
|
39
41
|
/** Drops `_meta` keys under any ignored prefix. Returns undefined when nothing is left to pin. */
|
|
40
42
|
declare function stripIgnoredMeta(meta: JsonValue | undefined, ignoredPrefixes: readonly string[]): JsonObject | undefined;
|
|
41
43
|
/** Strips the query string: query strings routinely carry tokens, and the lock is committed. */
|
|
42
44
|
declare function sanitizeUrl(raw: string): string;
|
|
43
45
|
|
|
44
|
-
export { extractHeaderParams, isEscalation, normalizeSchema, resolveBehavior, sanitizeUrl, stripIgnoredMeta };
|
|
46
|
+
export { MAX_HEADER_VISITS, extractHeaderParams, isEscalation, normalizeSchema, resolveBehavior, sanitizeUrl, stripIgnoredMeta };
|
package/dist/lock/normalize.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
MAX_HEADER_VISITS,
|
|
2
3
|
extractHeaderParams,
|
|
3
4
|
isEscalation,
|
|
4
5
|
normalizeSchema,
|
|
5
6
|
resolveBehavior,
|
|
6
7
|
sanitizeUrl,
|
|
7
8
|
stripIgnoredMeta
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-TBVL7XVR.js";
|
|
10
|
+
import "../chunk-WEU7FBSB.js";
|
|
11
|
+
import "../chunk-DF52BV5H.js";
|
|
11
12
|
export {
|
|
13
|
+
MAX_HEADER_VISITS,
|
|
12
14
|
extractHeaderParams,
|
|
13
15
|
isEscalation,
|
|
14
16
|
normalizeSchema,
|
package/dist/lock/reseal.js
CHANGED
package/package.json
CHANGED
package/dist/chunk-5NXUTMLT.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
// src/lock/credentials.ts
|
|
2
|
-
var REDACTED = "REDACTED";
|
|
3
|
-
var CREDENTIAL_NAME = /(?:^|[-_.])(?:api[-_]?key|apikey|access[-_]?key|secret(?:[-_]?key)?|client[-_]?secret|token|access[-_]?token|auth[-_]?token|refresh[-_]?token|bearer|password|passwd|pass|pwd|private[-_]?key|credentials?)$/i;
|
|
4
|
-
var ISSUER_FORMATS = [
|
|
5
|
-
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
6
|
-
// AWS access key id
|
|
7
|
-
/\bgh[pousr]_[A-Za-z0-9]{36,}\b/g,
|
|
8
|
-
// GitHub
|
|
9
|
-
/\bgithub_pat_[A-Za-z0-9_]{40,}\b/g,
|
|
10
|
-
/\bglpat-[A-Za-z0-9_-]{20,}/g,
|
|
11
|
-
// GitLab
|
|
12
|
-
/\bxox[abprs]-[A-Za-z0-9-]{10,}/g,
|
|
13
|
-
// Slack
|
|
14
|
-
/\b[rs]k_(?:live|test)_[A-Za-z0-9]{16,}\b/g,
|
|
15
|
-
// Stripe
|
|
16
|
-
/\bsk-ant-[A-Za-z0-9_-]{20,}/g,
|
|
17
|
-
// Anthropic
|
|
18
|
-
/\bsk-(?:proj-|svcacct-|admin-)?[A-Za-z0-9_-]{32,}/g,
|
|
19
|
-
// OpenAI
|
|
20
|
-
/\bAIza[0-9A-Za-z_-]{35}\b/g,
|
|
21
|
-
// Google API key
|
|
22
|
-
/\bnpm_[A-Za-z0-9]{36}\b/g,
|
|
23
|
-
/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
|
|
24
|
-
// JWT
|
|
25
|
-
];
|
|
26
|
-
var PLACEHOLDER = /\$\{|^\$[A-Za-z_]/;
|
|
27
|
-
function looksRandom(value) {
|
|
28
|
-
if (value.length < 32 || !/^[A-Za-z0-9_-]+$/.test(value)) return false;
|
|
29
|
-
if (!/[a-z]/.test(value) || !/[A-Z]/.test(value) || !/[0-9]/.test(value)) return false;
|
|
30
|
-
const kind = (character) => /[a-z]/.test(character) ? 0 : /[A-Z]/.test(character) ? 1 : /[0-9]/.test(character) ? 2 : 3;
|
|
31
|
-
let switches = 0;
|
|
32
|
-
for (let index = 1; index < value.length; index += 1) {
|
|
33
|
-
if (kind(value[index] ?? "") !== kind(value[index - 1] ?? "")) switches += 1;
|
|
34
|
-
}
|
|
35
|
-
return switches >= value.length / 3;
|
|
36
|
-
}
|
|
37
|
-
function decoded(value) {
|
|
38
|
-
try {
|
|
39
|
-
return decodeURIComponent(value);
|
|
40
|
-
} catch {
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function isSecretValue(value) {
|
|
45
|
-
if (value === "" || value === REDACTED || PLACEHOLDER.test(value)) return false;
|
|
46
|
-
if (/^(?:[./~]|[A-Za-z]:\\|[a-z][a-z0-9+.-]*:\/\/)/i.test(value)) return false;
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
function redactFormats(value) {
|
|
50
|
-
let out = value;
|
|
51
|
-
for (const format of ISSUER_FORMATS) out = out.replace(format, REDACTED);
|
|
52
|
-
return out;
|
|
53
|
-
}
|
|
54
|
-
function redactUrl(value) {
|
|
55
|
-
if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(value)) return value;
|
|
56
|
-
let url;
|
|
57
|
-
try {
|
|
58
|
-
url = new URL(value);
|
|
59
|
-
} catch {
|
|
60
|
-
return value;
|
|
61
|
-
}
|
|
62
|
-
let changed = false;
|
|
63
|
-
if (url.password && !PLACEHOLDER.test(decoded(url.password))) {
|
|
64
|
-
url.password = REDACTED;
|
|
65
|
-
changed = true;
|
|
66
|
-
}
|
|
67
|
-
for (const [key, parameter] of [...url.searchParams]) {
|
|
68
|
-
if (CREDENTIAL_NAME.test(key) && isSecretValue(parameter)) {
|
|
69
|
-
url.searchParams.set(key, REDACTED);
|
|
70
|
-
changed = true;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return changed ? url.toString() : value;
|
|
74
|
-
}
|
|
75
|
-
function redactArgs(args) {
|
|
76
|
-
const out = [...args];
|
|
77
|
-
for (let index = 0; index < out.length; index += 1) {
|
|
78
|
-
const argument = out[index] ?? "";
|
|
79
|
-
const assignment = /^(-{0,2}[A-Za-z][A-Za-z0-9_.-]*)=(.*)$/s.exec(argument);
|
|
80
|
-
if (assignment) {
|
|
81
|
-
const [, name = "", value = ""] = assignment;
|
|
82
|
-
if (CREDENTIAL_NAME.test(name.replace(/^-+/, "")) && isSecretValue(value)) {
|
|
83
|
-
out[index] = `${name}=${REDACTED}`;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (!PLACEHOLDER.test(value)) out[index] = `${name}=${looksRandom(value) ? REDACTED : redactFormats(redactUrl(value))}`;
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
const flag = /^-{1,2}([A-Za-z][A-Za-z0-9_.-]*)$/.exec(argument);
|
|
90
|
-
const next = out[index + 1];
|
|
91
|
-
if (flag && next !== void 0 && !next.startsWith("-") && CREDENTIAL_NAME.test(flag[1] ?? "") && isSecretValue(next)) {
|
|
92
|
-
out[index + 1] = REDACTED;
|
|
93
|
-
index += 1;
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
if (PLACEHOLDER.test(argument)) continue;
|
|
97
|
-
if (looksRandom(argument)) {
|
|
98
|
-
out[index] = REDACTED;
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
out[index] = redactFormats(redactUrl(argument));
|
|
102
|
-
}
|
|
103
|
-
return out;
|
|
104
|
-
}
|
|
105
|
-
function redactPath(pathname) {
|
|
106
|
-
return pathname.split("/").map((segment) => {
|
|
107
|
-
if (segment === "" || PLACEHOLDER.test(decoded(segment))) return segment;
|
|
108
|
-
if (looksRandom(segment)) return REDACTED;
|
|
109
|
-
return redactFormats(segment);
|
|
110
|
-
}).join("/");
|
|
111
|
-
}
|
|
112
|
-
function countRedacted(transport) {
|
|
113
|
-
const occurrences = (text) => text.split(REDACTED).length - 1;
|
|
114
|
-
return (transport.args ?? []).reduce((total, argument) => total + occurrences(argument), 0) + occurrences(transport.url ?? "");
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export {
|
|
118
|
-
REDACTED,
|
|
119
|
-
redactArgs,
|
|
120
|
-
redactPath,
|
|
121
|
-
countRedacted
|
|
122
|
-
};
|
|
123
|
-
//# sourceMappingURL=chunk-5NXUTMLT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lock/credentials.ts"],"sourcesContent":["/**\n * Credentials a config writes literally, found so the lock can leave them out.\n *\n * Environment and header values were never written to the lock, only their names, and a URL\n * loses its query string and its user:password. That covered every place a credential belongs.\n * It did not cover the places configs actually put them: `--api-key sk-...` in `args`,\n * `-e GITHUB_TOKEN=ghp_...` in a `docker run`, a connection string with a password, a token as a\n * segment of a hosted server's URL. The lock is the file the README tells you to commit, and the\n * reading `push` sends is the same data, so each of those went into git and over the wire.\n *\n * A credential is replaced, not hashed. A rotated key is not a change to what a server can do,\n * so there is nothing for drift to see in it, and a hash of a short password is something a\n * dictionary can be run against. This matches what already happens to an `env` value.\n *\n * Everything here errs toward leaving a value alone. A false positive hides a real change to how\n * a server is started, which is the thing the lock exists to show; a value is only replaced when\n * its name says it is a credential, its issuer's format does, or it is too random to be anything\n * else. A `${VAR}` placeholder is never touched: that is how a config is supposed to do this.\n */\n\n/** What a credential is replaced with. Plain ASCII, so it survives a URL path unescaped. */\nexport const REDACTED = \"REDACTED\";\n\n/**\n * Names that mean the value is a credential: as a flag (`--github-token`), or as an environment\n * assignment inside an argument (`GITHUB_PERSONAL_ACCESS_TOKEN=...`). Matched as the last word of\n * the name, so `--max-tokens`, `--tokenizer` and `--password-file` are left alone.\n */\nconst CREDENTIAL_NAME =\n /(?:^|[-_.])(?:api[-_]?key|apikey|access[-_]?key|secret(?:[-_]?key)?|client[-_]?secret|token|access[-_]?token|auth[-_]?token|refresh[-_]?token|bearer|password|passwd|pass|pwd|private[-_]?key|credentials?)$/i;\n\n/**\n * Formats a credential has wherever it appears, because its issuer made it recognisable on\n * purpose (so leaked ones can be found). Each is specific enough not to match a package name.\n */\nconst ISSUER_FORMATS: RegExp[] = [\n /\\b(?:AKIA|ASIA)[0-9A-Z]{16}\\b/g, // AWS access key id\n /\\bgh[pousr]_[A-Za-z0-9]{36,}\\b/g, // GitHub\n /\\bgithub_pat_[A-Za-z0-9_]{40,}\\b/g,\n /\\bglpat-[A-Za-z0-9_-]{20,}/g, // GitLab\n /\\bxox[abprs]-[A-Za-z0-9-]{10,}/g, // Slack\n /\\b[rs]k_(?:live|test)_[A-Za-z0-9]{16,}\\b/g, // Stripe\n /\\bsk-ant-[A-Za-z0-9_-]{20,}/g, // Anthropic\n /\\bsk-(?:proj-|svcacct-|admin-)?[A-Za-z0-9_-]{32,}/g, // OpenAI\n /\\bAIza[0-9A-Za-z_-]{35}\\b/g, // Google API key\n /\\bnpm_[A-Za-z0-9]{36}\\b/g,\n /\\beyJ[A-Za-z0-9_-]{8,}\\.eyJ[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]{8,}/g, // JWT\n];\n\n/** A value written as a placeholder for the client to fill in, which is the safe way to do this. */\nconst PLACEHOLDER = /\\$\\{|^\\$[A-Za-z_]/;\n\n/**\n * A token with no issuer format: long, URL-safe, mixing upper case, lower case and digits, and\n * switching between them constantly.\n *\n * Requiring all three classes leaves out UUIDs, hex digests and commit hashes, which are lower\n * case and far more often an identifier than a secret. Requiring the switching leaves out long\n * names: `AnthropicClaudeDesktopExtension2025` has every class but changes class six times in\n * thirty-five characters, where a random token changes on most of them.\n */\nfunction looksRandom(value: string): boolean {\n if (value.length < 32 || !/^[A-Za-z0-9_-]+$/.test(value)) return false;\n if (!/[a-z]/.test(value) || !/[A-Z]/.test(value) || !/[0-9]/.test(value)) return false;\n const kind = (character: string) => (/[a-z]/.test(character) ? 0 : /[A-Z]/.test(character) ? 1 : /[0-9]/.test(character) ? 2 : 3);\n let switches = 0;\n for (let index = 1; index < value.length; index += 1) {\n if (kind(value[index] ?? \"\") !== kind(value[index - 1] ?? \"\")) switches += 1;\n }\n return switches >= value.length / 3;\n}\n\n/** `decodeURIComponent`, for a check: a malformed escape is just text. */\nfunction decoded(value: string): string {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\n/** A value worth replacing when its name already says it is a credential. */\nfunction isSecretValue(value: string): boolean {\n if (value === \"\" || value === REDACTED || PLACEHOLDER.test(value)) return false;\n // A path or a URL names where the secret lives, not the secret: `--token-file`-style use.\n if (/^(?:[./~]|[A-Za-z]:\\\\|[a-z][a-z0-9+.-]*:\\/\\/)/i.test(value)) return false;\n return true;\n}\n\n/** Replaces each issuer-formatted credential inside a value, leaving the rest of it readable. */\nfunction redactFormats(value: string): string {\n let out = value;\n for (const format of ISSUER_FORMATS) out = out.replace(format, REDACTED);\n return out;\n}\n\n/** In a URL inside an argument: the password, and the value of any query parameter named as a credential. */\nfunction redactUrl(value: string): string {\n if (!/^[a-z][a-z0-9+.-]*:\\/\\//i.test(value)) return value;\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n return value;\n }\n let changed = false;\n if (url.password && !PLACEHOLDER.test(decoded(url.password))) {\n url.password = REDACTED;\n changed = true;\n }\n for (const [key, parameter] of [...url.searchParams]) {\n if (CREDENTIAL_NAME.test(key) && isSecretValue(parameter)) {\n url.searchParams.set(key, REDACTED);\n changed = true;\n }\n }\n return changed ? url.toString() : value;\n}\n\n/**\n * `args` with every credential written literally in them replaced by {@link REDACTED}.\n *\n * Handles a flag and its value (`--api-key KEY`, `--api-key=KEY`), an environment assignment in\n * an argument (`-e GITHUB_TOKEN=ghp_...`, as `docker run` takes them), a URL's password or\n * credential query parameter, an issuer-formatted token anywhere, and an argument that is nothing\n * but a long random token. Arguments are returned in place and in order, so a change to anything\n * else about how a server is started is still drift.\n */\nexport function redactArgs(args: readonly string[]): string[] {\n const out = [...args];\n for (let index = 0; index < out.length; index += 1) {\n const argument = out[index] ?? \"\";\n\n // `--name=value`, `-n=value`, and `NAME=value` (an environment assignment).\n const assignment = /^(-{0,2}[A-Za-z][A-Za-z0-9_.-]*)=(.*)$/s.exec(argument);\n if (assignment) {\n const [, name = \"\", value = \"\"] = assignment;\n if (CREDENTIAL_NAME.test(name.replace(/^-+/, \"\")) && isSecretValue(value)) {\n out[index] = `${name}=${REDACTED}`;\n continue;\n }\n // Any other assignment: its value can still hold a URL with a password, or a token.\n if (!PLACEHOLDER.test(value)) out[index] = `${name}=${looksRandom(value) ? REDACTED : redactFormats(redactUrl(value))}`;\n continue;\n }\n\n // `--name value`: the flag names a credential, so the next argument is one.\n const flag = /^-{1,2}([A-Za-z][A-Za-z0-9_.-]*)$/.exec(argument);\n const next = out[index + 1];\n if (flag && next !== undefined && !next.startsWith(\"-\") && CREDENTIAL_NAME.test(flag[1] ?? \"\") && isSecretValue(next)) {\n out[index + 1] = REDACTED;\n index += 1;\n continue;\n }\n\n if (PLACEHOLDER.test(argument)) continue;\n if (looksRandom(argument)) {\n out[index] = REDACTED;\n continue;\n }\n out[index] = redactFormats(redactUrl(argument));\n }\n return out;\n}\n\n/**\n * A URL path with any segment that is a credential replaced, for hosted servers whose address\n * embeds the key (`https://host/api/<token>/mcp`). The rest of the path stays, so a server that\n * moves to a different path or host is still drift.\n */\nexport function redactPath(pathname: string): string {\n return pathname\n .split(\"/\")\n .map((segment) => {\n if (segment === \"\" || PLACEHOLDER.test(decoded(segment))) return segment;\n if (looksRandom(segment)) return REDACTED;\n return redactFormats(segment);\n })\n .join(\"/\");\n}\n\n/** How many credentials were left out of a locked transport, for saying so. */\nexport function countRedacted(transport: { args?: readonly string[]; url?: string }): number {\n const occurrences = (text: string) => text.split(REDACTED).length - 1;\n return (transport.args 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AAQ,SAAS,UAAa,CAAC,KAAK,WAAW,GAAG,KAAK,gBAAgB,KAAK,KAAK,CAAC,KAAK,EAAE,KAAK,cAAc,IAAI,GAAG;AACrH,UAAI,QAAQ,CAAC,IAAI;AACjB,eAAS;AACT;AAAA,IACF;AAEA,QAAI,YAAY,KAAK,QAAQ,EAAG;AAChC,QAAI,YAAY,QAAQ,GAAG;AACzB,UAAI,KAAK,IAAI;AACb;AAAA,IACF;AACA,QAAI,KAAK,IAAI,cAAc,UAAU,QAAQ,CAAC;AAAA,EAChD;AACA,SAAO;AACT;AAOO,SAAS,WAAW,UAA0B;AACnD,SAAO,SACJ,MAAM,GAAG,EACT,IAAI,CAAC,YAAY;AAChB,QAAI,YAAY,MAAM,YAAY,KAAK,QAAQ,OAAO,CAAC,EAAG,QAAO;AACjE,QAAI,YAAY,OAAO,EAAG,QAAO;AACjC,WAAO,cAAc,OAAO;AAAA,EAC9B,CAAC,EACA,KAAK,GAAG;AACb;AAGO,SAAS,cAAc,WAA+D;AAC3F,QAAM,cAAc,CAAC,SAAiB,KAAK,MAAM,QAAQ,EAAE,SAAS;AACpE,UAAQ,UAAU,QAAQ,CAAC,GAAG,OAAO,CAAC,OAAO,aAAa,QAAQ,YAAY,QAAQ,GAAG,CAAC,IAAI,YAAY,UAAU,OAAO,EAAE;AAC/H;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lock/normalize.ts"],"sourcesContent":["/** Turning what a server sent into the stable, reviewable form the lock stores. */\nimport { redactPath } from \"./credentials\";\nimport { alternatives, asObject, effectiveSchema, MAX_VISIT_DEPTH } from \"./jsonschema\";\nimport type { JsonObject, JsonValue, LockedAnnotations, LockedBehavior } from \"./types\";\n\n/**\n * Resolves the four behavioural annotations against the spec's defaults, which are not neutral:\n * an absent `readOnlyHint` means \"may modify\" and an absent `destructiveHint` means \"may\n * destroy\". A server deleting an annotation is therefore an escalation, and the lock has to be\n * able to show it as a changed value rather than a removed line. See docs/lockfile.md §4.\n *\n * `destructiveHint` and `idempotentHint` are defined to be meaningful only when `readOnlyHint`\n * is false, so a read-only tool resolves to non-destructive and idempotent regardless of what\n * it claims: a tool that changes nothing cannot destroy anything, and repeating it has no\n * additional effect.\n */\nexport function resolveBehavior(annotations: LockedAnnotations | undefined): LockedBehavior {\n const readOnly = annotations?.readOnlyHint ?? false;\n return {\n readOnly,\n destructive: readOnly ? false : (annotations?.destructiveHint ?? true),\n idempotent: readOnly ? true : (annotations?.idempotentHint ?? false),\n openWorld: annotations?.openWorldHint ?? true,\n };\n}\n\n/** True when `next` claims any power `previous` did not. */\nexport function isEscalation(previous: LockedBehavior, next: LockedBehavior): boolean {\n return (\n (previous.readOnly && !next.readOnly) ||\n (!previous.destructive && next.destructive) ||\n (previous.idempotent && !next.idempotent) ||\n (!previous.openWorld && next.openWorld)\n );\n}\n\n/**\n * Sorts `required` arrays wherever they appear. Member order there is semantically\n * insignificant and is the most common source of diffs that mean nothing. Every other array\n * keeps server order, because order *is* significant in `prefixItems`, `allOf` and `icons`, and\n * we only reorder where we can show it is safe.\n *\n * The rule is positional rather than schema-aware: a non-schema object with a string-array\n * member literally named `required` would also be sorted. That costs nothing we can observe and\n * avoids carrying a JSON Schema interpreter around.\n */\nexport function normalizeSchema(value: JsonValue): JsonValue {\n if (Array.isArray(value)) return value.map(normalizeSchema);\n if (value === null || typeof value !== \"object\") return value;\n\n const out: JsonObject = {};\n for (const [key, member] of Object.entries(value)) {\n if (key === \"required\" && Array.isArray(member) && member.every((entry) => typeof entry === \"string\")) {\n out[key] = [...(member as string[])].sort();\n continue;\n }\n out[key] = normalizeSchema(member);\n }\n return out;\n}\n\n/**\n * Finds input properties carrying an `x-mcp-header` annotation, which mirrors the argument's\n * value into an `Mcp-Param-*` HTTP header on Streamable HTTP, where proxies and WAFs can read\n * it. A server adding this to an existing parameter redirects that argument's data with no\n * visible change to the tool's signature, so it gets its own line in the lock.\n *\n * `$ref` and `allOf` are resolved first. Schema generators put properties behind `$defs` as a\n * matter of course, and a scan that only read literal nodes found nothing in those -- which is\n * the worst outcome for a field whose entire purpose is to move data somewhere new.\n */\nexport function extractHeaderParams(schema: JsonValue): string[] {\n const found: string[] = [];\n\n const walk = (node: JsonValue, path: string[], depth: number): void => {\n if (depth > MAX_VISIT_DEPTH) return;\n const object = effectiveSchema(node, schema);\n if (!object) return;\n\n const properties = asObject(object[\"properties\"]);\n if (properties) {\n for (const [name, child] of Object.entries(properties)) {\n const resolved = effectiveSchema(child, schema);\n if (!resolved) continue;\n const header = resolved[\"x-mcp-header\"];\n if (typeof header === \"string\" && header.length > 0) found.push(`${[...path, name].join(\".\")} -> ${header}`);\n walk(child, [...path, name], depth + 1);\n }\n }\n\n // A parameter reachable only through one branch of an `anyOf` is still reachable.\n for (const branch of alternatives(object)) walk(branch.schema, path, depth + 1);\n };\n\n walk(schema, [], 0);\n return [...new Set(found)].sort();\n}\n\n/** Drops `_meta` keys under any ignored prefix. Returns undefined when nothing is left to pin. */\nexport function stripIgnoredMeta(meta: JsonValue | undefined, ignoredPrefixes: readonly string[]): JsonObject | undefined {\n if (meta === null || meta === undefined || typeof meta !== \"object\" || Array.isArray(meta)) return undefined;\n const out: JsonObject = {};\n for (const [key, value] of Object.entries(meta)) {\n if (ignoredPrefixes.some((prefix) => key.startsWith(prefix))) continue;\n out[key] = value;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/** Strips the query string: query strings routinely carry tokens, and the lock is committed. */\nexport function sanitizeUrl(raw: string): string {\n try {\n const url = new URL(raw);\n url.search = \"\";\n url.hash = \"\";\n /*\n * `https://alice:s3cr3t@host/mcp` survived this untouched, because `toString()` keeps\n * userinfo. The query string was stripped on the grounds that credentials usually sit there;\n * userinfo is the one place a credential sits by definition.\n */\n url.username = \"\";\n url.password = \"\";\n // A hosted server whose address embeds the key keeps it in the path, past both of the above.\n url.pathname = redactPath(url.pathname);\n return url.toString();\n } catch {\n // Not a parseable URL. Keep it as configured so the mismatch is visible rather than silent.\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,gBAAgB,OAAO,MAAM;AAC9C,YAAI,CAAC,SAAU;AACf,cAAM,SAAS,SAAS,cAAc;AACtC,YAAI,OAAO,WAAW,YAAY,OAAO,SAAS,EAAG,OAAM,KAAK,GAAG,CAAC,GAAG,MAAM,IAAI,EAAE,KAAK,GAAG,CAAC,OAAO,MAAM,EAAE;AAC3G,aAAK,OAAO,CAAC,GAAG,MAAM,IAAI,GAAG,QAAQ,CAAC;AAAA,MACxC;AAAA,IACF;AAGA,eAAW,UAAU,aAAa,MAAM,EAAG,MAAK,OAAO,QAAQ,MAAM,QAAQ,CAAC;AAAA,EAChF;AAEA,OAAK,QAAQ,CAAC,GAAG,CAAC;AAClB,SAAO,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,EAAE,KAAK;AAClC;AAGO,SAAS,iBAAiB,MAA6B,iBAA4D;AACxH,MAAI,SAAS,QAAQ,SAAS,UAAa,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI,EAAG,QAAO;AACnG,QAAM,MAAkB,CAAC;AACzB,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAC/C,QAAI,gBAAgB,KAAK,CAAC,WAAW,IAAI,WAAW,MAAM,CAAC,EAAG;AAC9D,QAAI,GAAG,IAAI;AAAA,EACb;AACA,SAAO,OAAO,KAAK,GAAG,EAAE,SAAS,IAAI,MAAM;AAC7C;AAGO,SAAS,YAAY,KAAqB;AAC/C,MAAI;AACF,UAAM,MAAM,IAAI,IAAI,GAAG;AACvB,QAAI,SAAS;AACb,QAAI,OAAO;AAMX,QAAI,WAAW;AACf,QAAI,WAAW;AAEf,QAAI,WAAW,WAAW,IAAI,QAAQ;AACtC,WAAO,IAAI,SAAS;AAAA,EACtB,QAAQ;AAEN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lock/jsonschema.ts"],"sourcesContent":["/**\n * Just enough JSON Schema to see through the indirection servers actually use.\n *\n * Two parts of this tool have to look inside a tool's `inputSchema`: the widening heuristic and\n * the `x-mcp-header` scan. Both used to read only the literal node in front of them, so a schema\n * that put its properties behind `$ref` or `allOf` -- which the generators for Pydantic, Zod and\n * most OpenAPI toolchains do by default -- looked empty to both. A widened parameter went out as\n * a bare `.changed`, and a parameter newly mirrored into an HTTP header was missed entirely.\n *\n * This is not a validator. It resolves local `$ref`, flattens `allOf`, and leaves the\n * alternation keywords for the caller to branch on. Remote `$ref` is never fetched: an audit\n * that reaches out to a URL named by the thing it is auditing is not an audit.\n */\nimport type { JsonObject, JsonValue } from \"./types\";\n\n/** Depth caps. A hostile or merely recursive schema must not be able to hang the run. */\nexport const MAX_REF_DEPTH = 32;\nexport const MAX_VISIT_DEPTH = 12;\nexport const MAX_FACTS = 5_000;\n\nexport function asObject(value: JsonValue | undefined): JsonObject | undefined {\n return value !== null && value !== undefined && typeof value === \"object\" && !Array.isArray(value) ? (value as JsonObject) : undefined;\n}\n\n/** RFC 6901 token decoding: `~1` is `/` and `~0` is `~`, in that order. */\nfunction decodeToken(token: string): string {\n let decoded = token;\n try {\n decoded = decodeURIComponent(token);\n } catch {\n // A malformed escape is a literal, not a reason to abandon the schema.\n }\n return decoded.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n}\n\n/** Resolves a local JSON pointer. Anything with a non-empty URI part is left unresolved. */\nexport function resolvePointer(root: JsonValue, ref: string): JsonValue | undefined {\n if (!ref.startsWith(\"#\")) return undefined;\n const pointer = ref.slice(1);\n if (pointer !== \"\" && !pointer.startsWith(\"/\")) return undefined; // `#anchor`, which needs an anchor index.\n\n let node: JsonValue | undefined = root;\n for (const token of pointer.split(\"/\").slice(1)) {\n const object = asObject(node);\n if (object === undefined) return undefined;\n node = object[decodeToken(token)];\n }\n return node;\n}\n\n/**\n * The keywords in effect at a node, with `$ref` followed and `allOf` folded in.\n *\n * The node's own keywords win over anything it inherits, `properties` are unioned, and\n * `required` is the union of every contributor -- which is what `allOf` means. Alternation\n * (`anyOf` / `oneOf` / `then` / `else`) is deliberately left in place: a caller that wants to\n * treat branches as separate possibilities can, and one that does not is no worse off.\n */\nexport function effectiveSchema(node: JsonValue | undefined, root: JsonValue, seenRefs: ReadonlySet<string> = new Set(), depth = 0): JsonObject | undefined {\n const object = asObject(node);\n if (object === undefined) return undefined;\n if (depth > MAX_REF_DEPTH) return object;\n\n const out: JsonObject = {};\n const merge = (source: JsonObject): void => {\n for (const [key, value] of Object.entries(source)) {\n if (key === \"$ref\" || key === \"allOf\") continue;\n if (key === \"properties\") {\n // First contributor wins on a conflict, and keeps its position: the merged object reads\n // in the order a person wrote it, not inside-out from the inheritance chain.\n const merged: JsonObject = { ...(asObject(out[\"properties\"]) ?? {}) };\n for (const [name, schema] of Object.entries(asObject(value) ?? {})) {\n if (!(name in merged)) merged[name] = schema;\n }\n out[\"properties\"] = merged;\n } else if (key === \"required\" && Array.isArray(value)) {\n const already = Array.isArray(out[\"required\"]) ? (out[\"required\"] as JsonValue[]) : [];\n out[\"required\"] = [...new Set([...already, ...value].filter((entry): entry is string => typeof entry === \"string\"))];\n } else if (!(key in out)) {\n out[key] = value;\n }\n }\n };\n\n // The node itself first, so its own keywords take precedence over what it inherits.\n merge(object);\n\n const ref = object[\"$ref\"];\n if (typeof ref === \"string\" && !seenRefs.has(ref)) {\n const resolved = effectiveSchema(resolvePointer(root, ref), root, new Set([...seenRefs, ref]), depth + 1);\n if (resolved) merge(resolved);\n }\n\n const allOf = object[\"allOf\"];\n if (Array.isArray(allOf)) {\n for (const branch of allOf) {\n const resolved = effectiveSchema(branch, root, seenRefs, depth + 1);\n if (resolved) merge(resolved);\n }\n }\n\n return out;\n}\n\n/** The alternation branches at a node, labelled so a caller can key facts by them. */\nexport function alternatives(object: JsonObject): Array<{ label: string; schema: JsonValue }> {\n const branches: Array<{ label: string; schema: JsonValue }> = [];\n for (const keyword of [\"anyOf\", \"oneOf\"] as const) {\n const value = object[keyword];\n if (!Array.isArray(value)) continue;\n value.forEach((schema, index) => branches.push({ label: `${keyword}[${index}]`, schema }));\n }\n for (const keyword of [\"then\", \"else\", \"not\"] as const) {\n if (object[keyword] !== undefined) branches.push({ label: keyword, schema: object[keyword] as JsonValue });\n }\n return branches;\n}\n"],"mappings":";AAgBO,IAAM,gBAAgB;AACtB,IAAM,kBAAkB;AACxB,IAAM,YAAY;AAElB,SAAS,SAAS,OAAsD;AAC7E,SAAO,UAAU,QAAQ,UAAU,UAAa,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAuB;AAC/H;AAGA,SAAS,YAAY,OAAuB;AAC1C,MAAI,UAAU;AACd,MAAI;AACF,cAAU,mBAAmB,KAAK;AAAA,EACpC,QAAQ;AAAA,EAER;AACA,SAAO,QAAQ,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG;AACvD;AAGO,SAAS,eAAe,MAAiB,KAAoC;AAClF,MAAI,CAAC,IAAI,WAAW,GAAG,EAAG,QAAO;AACjC,QAAM,UAAU,IAAI,MAAM,CAAC;AAC3B,MAAI,YAAY,MAAM,CAAC,QAAQ,WAAW,GAAG,EAAG,QAAO;AAEvD,MAAI,OAA8B;AAClC,aAAW,SAAS,QAAQ,MAAM,GAAG,EAAE,MAAM,CAAC,GAAG;AAC/C,UAAM,SAAS,SAAS,IAAI;AAC5B,QAAI,WAAW,OAAW,QAAO;AACjC,WAAO,OAAO,YAAY,KAAK,CAAC;AAAA,EAClC;AACA,SAAO;AACT;AAUO,SAAS,gBAAgB,MAA6B,MAAiB,WAAgC,oBAAI,IAAI,GAAG,QAAQ,GAA2B;AAC1J,QAAM,SAAS,SAAS,IAAI;AAC5B,MAAI,WAAW,OAAW,QAAO;AACjC,MAAI,QAAQ,cAAe,QAAO;AAElC,QAAM,MAAkB,CAAC;AACzB,QAAM,QAAQ,CAAC,WAA6B;AAC1C,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,UAAI,QAAQ,UAAU,QAAQ,QA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