@vantageos/mcp-doctor 0.14.0 → 0.16.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/CHANGELOG.md +21 -0
- package/README.md +79 -0
- package/dist/doctor.d.ts +5 -0
- package/dist/doctor.js +1165 -205
- package/package.json +1 -1
package/dist/doctor.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/doctor.ts
|
|
4
|
-
import { readFileSync as
|
|
5
|
-
import { dirname as dirname18, join as
|
|
4
|
+
import { readFileSync as readFileSync19, realpathSync } from "fs";
|
|
5
|
+
import { dirname as dirname18, join as join30, resolve as resolve4 } from "path";
|
|
6
6
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
7
7
|
|
|
8
8
|
// src/scan.ts
|
|
@@ -767,7 +767,7 @@ function enclosingBlock(file, line, col, levels = 0) {
|
|
|
767
767
|
}
|
|
768
768
|
|
|
769
769
|
// src/detectors/standardPin.ts
|
|
770
|
-
var STANDARD_PIN = "
|
|
770
|
+
var STANDARD_PIN = "6870b7754393a2fb45d4cb536309f20ba91b67c1";
|
|
771
771
|
|
|
772
772
|
// src/detectors/dLocalIdentity.ts
|
|
773
773
|
var CLOUD_IDENTITY_PACKAGE = "@vantageos/cloud-identity";
|
|
@@ -3937,9 +3937,9 @@ function stringValueAt(file, line, col) {
|
|
|
3937
3937
|
return { kind: "string", value: m[2] };
|
|
3938
3938
|
}
|
|
3939
3939
|
function identReturned(file, name) {
|
|
3940
|
-
const
|
|
3940
|
+
const esc7 = name.replace(/[$]/g, "\\$&");
|
|
3941
3941
|
const re = new RegExp(
|
|
3942
|
-
`(?:\\breturn|=>)\\s*(?:\\(\\s*)*${
|
|
3942
|
+
`(?:\\breturn|=>)\\s*(?:\\(\\s*)*${esc7}(?![\\w$])(?!\\s*(?:\\?\\.|\\.|\\(|\\[|=))`
|
|
3943
3943
|
);
|
|
3944
3944
|
return re.test(uncommentedLines(file).join("\n"));
|
|
3945
3945
|
}
|
|
@@ -8127,7 +8127,12 @@ function evalShape(n, ctx) {
|
|
|
8127
8127
|
props.push({ label: "[computed]", schema: unread(e.form, e.s), at: e.s });
|
|
8128
8128
|
}
|
|
8129
8129
|
}
|
|
8130
|
-
return {
|
|
8130
|
+
return {
|
|
8131
|
+
k: "object",
|
|
8132
|
+
props,
|
|
8133
|
+
at: n.s,
|
|
8134
|
+
closed: { form: "raw shape (wrapped in z.object)", at: n.s }
|
|
8135
|
+
};
|
|
8131
8136
|
}
|
|
8132
8137
|
function unionArgs(arg, ctx, at) {
|
|
8133
8138
|
let a = arg;
|
|
@@ -8180,7 +8185,7 @@ function zodFactory(m, n, ctx) {
|
|
|
8180
8185
|
const a = n.args;
|
|
8181
8186
|
if (SCALAR_FACTORIES.has(m)) return SCALAR;
|
|
8182
8187
|
if (ANY_FACTORIES.has(m)) return { k: "any" };
|
|
8183
|
-
if (NULL_FACTORIES.has(m)) return { k: "null" };
|
|
8188
|
+
if (NULL_FACTORIES.has(m)) return m === "never" ? { k: "null", never: true } : { k: "null" };
|
|
8184
8189
|
switch (m) {
|
|
8185
8190
|
case "array":
|
|
8186
8191
|
case "set":
|
|
@@ -8191,8 +8196,11 @@ function zodFactory(m, n, ctx) {
|
|
|
8191
8196
|
}
|
|
8192
8197
|
case "object":
|
|
8193
8198
|
case "strictObject":
|
|
8194
|
-
case "looseObject":
|
|
8195
|
-
|
|
8199
|
+
case "looseObject": {
|
|
8200
|
+
const base = a[0] ? evalZod(a[0], ctx) : { k: "object", props: [], at: n.s };
|
|
8201
|
+
if (base.k !== "object") return base;
|
|
8202
|
+
return m === "looseObject" ? { ...base, closed: void 0 } : { ...base, closed: { form: `z.${m}(...)`, at: n.s } };
|
|
8203
|
+
}
|
|
8196
8204
|
case "record":
|
|
8197
8205
|
case "partialRecord":
|
|
8198
8206
|
case "looseRecord":
|
|
@@ -8238,6 +8246,17 @@ function zodFactory(m, n, ctx) {
|
|
|
8238
8246
|
}
|
|
8239
8247
|
function zodMethod(base, m, n, ctx) {
|
|
8240
8248
|
if (base.k === "unread") return base;
|
|
8249
|
+
if (base.k === "object" && (m === "strict" || m === "strip"))
|
|
8250
|
+
return { ...base, closed: { form: `.${m}()`, at: n.s } };
|
|
8251
|
+
if (base.k === "object" && ["passthrough", "loose", "nonstrict"].includes(m))
|
|
8252
|
+
return { ...base, closed: void 0 };
|
|
8253
|
+
if (base.k === "object" && m === "catchall") {
|
|
8254
|
+
const extra = n.args[0] ? evalZod(n.args[0], ctx) : unread(".catchall() with no argument", n.s);
|
|
8255
|
+
if (extra.k === "unread") return unread(`.catchall(...): ${extra.form}`, extra.at ?? n.s);
|
|
8256
|
+
if (extra.k === "null" && extra.never)
|
|
8257
|
+
return { ...base, closed: { form: ".catchall(z.never())", at: n.s } };
|
|
8258
|
+
return { ...base, closed: void 0 };
|
|
8259
|
+
}
|
|
8241
8260
|
if (IDENTITY_METHODS.has(m)) return base;
|
|
8242
8261
|
const a = n.args;
|
|
8243
8262
|
switch (m) {
|
|
@@ -8385,7 +8404,8 @@ function jsonToS(v, root, seen, depth = 0) {
|
|
|
8385
8404
|
if (isObj(v.patternProperties))
|
|
8386
8405
|
for (const s of Object.values(v.patternProperties))
|
|
8387
8406
|
props.push({ label: "*", schema: sub(s), at });
|
|
8388
|
-
|
|
8407
|
+
const closer = ["additionalProperties", "unevaluatedProperties"].find((kw) => v[kw] === false);
|
|
8408
|
+
return closer ? { k: "object", props, at, closed: { form: `${closer}: false`, at } } : { k: "object", props, at };
|
|
8389
8409
|
};
|
|
8390
8410
|
const type = v.type;
|
|
8391
8411
|
if (Array.isArray(type)) {
|
|
@@ -8485,14 +8505,16 @@ function isJsonLiteral(n) {
|
|
|
8485
8505
|
function schemaValue(n) {
|
|
8486
8506
|
return isJsonLiteral(n) ? { kind: "json", node: n } : { kind: "zod", node: n };
|
|
8487
8507
|
}
|
|
8488
|
-
function fromConfig(obj, ctx) {
|
|
8508
|
+
function fromConfig(obj, ctx, key = "inputSchema") {
|
|
8489
8509
|
const props = obj.entries.filter((e) => e.kind === "prop");
|
|
8490
|
-
const input = props.find((e) => e.key ===
|
|
8510
|
+
const input = props.find((e) => e.key === key);
|
|
8491
8511
|
if (input) return schemaValue(input.value);
|
|
8492
8512
|
const literalValued = (e) => isStringish(e.value, ctx) || e.value.k === "lit" && typeof e.value.v !== "string";
|
|
8493
8513
|
if (props.some((e) => (e.key === "description" || e.key === "title") && isStringish(e.value, ctx)))
|
|
8494
8514
|
return { kind: "none" };
|
|
8495
|
-
if (props.some(
|
|
8515
|
+
if (props.some(
|
|
8516
|
+
(e) => e.key === "inputSchema" || e.key === "outputSchema" || e.key === "annotations" || e.key === "_meta"
|
|
8517
|
+
))
|
|
8496
8518
|
return { kind: "none" };
|
|
8497
8519
|
if (props.length > 0 && props.every((e) => ANNOTATION_KEYS.has(e.key) && literalValued(e)))
|
|
8498
8520
|
return { kind: "none" };
|
|
@@ -8507,7 +8529,7 @@ function isStringish(n, ctx) {
|
|
|
8507
8529
|
}
|
|
8508
8530
|
return false;
|
|
8509
8531
|
}
|
|
8510
|
-
function locateSchema(file, toolName, anchorLine) {
|
|
8532
|
+
function locateSchema(file, toolName, anchorLine, key = "inputSchema") {
|
|
8511
8533
|
const lx = lex(file);
|
|
8512
8534
|
const ctx = moduleCtx(file, null);
|
|
8513
8535
|
const lineStart = lx.base + (lx.lineStarts[anchorLine - 1] ?? 0);
|
|
@@ -8573,7 +8595,7 @@ function locateSchema(file, toolName, anchorLine) {
|
|
|
8573
8595
|
if (open.v === "{") {
|
|
8574
8596
|
const obj = new Parser(lx, openIdx).parseExpr();
|
|
8575
8597
|
if (obj.k !== "obj") return { kind: "unread", form: `descriptor of ${toolName}`, at: open.s };
|
|
8576
|
-
const input = obj.entries.find((e) => e.kind === "prop" && e.key ===
|
|
8598
|
+
const input = obj.entries.find((e) => e.kind === "prop" && e.key === key);
|
|
8577
8599
|
return input && input.kind === "prop" ? schemaValue(input.value) : { kind: "none" };
|
|
8578
8600
|
}
|
|
8579
8601
|
if (open.v !== "(")
|
|
@@ -8586,6 +8608,7 @@ function locateSchema(file, toolName, anchorLine) {
|
|
|
8586
8608
|
form: `registration of ${toolName}: name argument not at top level`,
|
|
8587
8609
|
at: open.s
|
|
8588
8610
|
};
|
|
8611
|
+
if (key === "outputSchema") return outputOf(args.slice(k + 1), ctx, lx, openIdx, toolName);
|
|
8589
8612
|
for (const a of args.slice(k + 1)) {
|
|
8590
8613
|
if (a.k === "fn") return { kind: "none" };
|
|
8591
8614
|
if (isStringish(a, ctx)) continue;
|
|
@@ -8596,11 +8619,34 @@ function locateSchema(file, toolName, anchorLine) {
|
|
|
8596
8619
|
else if (d && d.length === 1 && d[0].k === "fn") return { kind: "none" };
|
|
8597
8620
|
}
|
|
8598
8621
|
if (node.k === "obj") {
|
|
8599
|
-
const cfg = fromConfig(node, ctx);
|
|
8622
|
+
const cfg = fromConfig(node, ctx, key);
|
|
8600
8623
|
if (cfg) return cfg;
|
|
8601
|
-
return schemaValue(node);
|
|
8624
|
+
return key === "inputSchema" ? schemaValue(node) : { kind: "none" };
|
|
8625
|
+
}
|
|
8626
|
+
return key === "inputSchema" ? { kind: "zod", node: a } : { kind: "none" };
|
|
8627
|
+
}
|
|
8628
|
+
return { kind: "none" };
|
|
8629
|
+
}
|
|
8630
|
+
function outputOf(args, ctx, lx, openIdx, toolName) {
|
|
8631
|
+
for (const a of args) {
|
|
8632
|
+
let node = a;
|
|
8633
|
+
if (node.k === "id") {
|
|
8634
|
+
const d = ctx.b.decls.get(node.name);
|
|
8635
|
+
if (d && d.length === 1 && d[0].k === "obj") node = d[0];
|
|
8602
8636
|
}
|
|
8603
|
-
|
|
8637
|
+
if (node.k !== "obj") continue;
|
|
8638
|
+
const out = node.entries.find((e) => e.kind === "prop" && e.key === "outputSchema");
|
|
8639
|
+
if (out && out.kind === "prop") return schemaValue(out.value);
|
|
8640
|
+
}
|
|
8641
|
+
const end = new Parser(lx, openIdx).skipGroup(openIdx);
|
|
8642
|
+
for (let j = openIdx; j < end; j++) {
|
|
8643
|
+
const t = lx.toks[j];
|
|
8644
|
+
if (t.t === "id" && t.v === "outputSchema")
|
|
8645
|
+
return {
|
|
8646
|
+
kind: "unread",
|
|
8647
|
+
form: `registration of ${toolName}: outputSchema is named at a position the reader does not take it from`,
|
|
8648
|
+
at: t.s
|
|
8649
|
+
};
|
|
8604
8650
|
}
|
|
8605
8651
|
return { kind: "none" };
|
|
8606
8652
|
}
|
|
@@ -8998,6 +9044,93 @@ var s43UnionInput = {
|
|
|
8998
9044
|
run: runStatic,
|
|
8999
9045
|
runServed: (runtime) => runServedHalf(runtime)
|
|
9000
9046
|
};
|
|
9047
|
+
function walkClosed(s, path, out) {
|
|
9048
|
+
switch (s.k) {
|
|
9049
|
+
case "object":
|
|
9050
|
+
if (s.closed)
|
|
9051
|
+
out.push({ path, kind: "violation", form: s.closed.form, at: s.closed.at ?? s.at });
|
|
9052
|
+
for (const p of s.props) walkClosed(p.schema, `${path}.${p.label}`, out);
|
|
9053
|
+
return;
|
|
9054
|
+
case "union":
|
|
9055
|
+
for (const b of flatten(s.branches)) walkClosed(b, path, out);
|
|
9056
|
+
return;
|
|
9057
|
+
case "array":
|
|
9058
|
+
if (s.items) walkClosed(s.items, `${path}[]`, out);
|
|
9059
|
+
s.prefix.forEach((p, i) => walkClosed(p, `${path}[${i}]`, out));
|
|
9060
|
+
return;
|
|
9061
|
+
case "all":
|
|
9062
|
+
for (const p of s.parts) walkClosed(p, path, out);
|
|
9063
|
+
return;
|
|
9064
|
+
case "unread":
|
|
9065
|
+
out.push({ path, kind: "unread", form: s.form, at: s.at });
|
|
9066
|
+
return;
|
|
9067
|
+
default:
|
|
9068
|
+
return;
|
|
9069
|
+
}
|
|
9070
|
+
}
|
|
9071
|
+
var CLOSED_MARKER_RE = /\/\/\s*allow-closed-output:\s*(.*)$/;
|
|
9072
|
+
function closedExemption(off) {
|
|
9073
|
+
const at = off === void 0 ? null : locate(off);
|
|
9074
|
+
if (!at) return void 0;
|
|
9075
|
+
const lx = lex(at.file);
|
|
9076
|
+
for (const ln of [at.line, at.line - 1]) {
|
|
9077
|
+
const m = lx.comments.get(ln)?.match(CLOSED_MARKER_RE);
|
|
9078
|
+
if (m && m[1].trim().length >= MIN_REASON) return m[1].trim();
|
|
9079
|
+
}
|
|
9080
|
+
return void 0;
|
|
9081
|
+
}
|
|
9082
|
+
function closedOutputSites(tree, toolName, anchor) {
|
|
9083
|
+
const cut = anchor.lastIndexOf(":");
|
|
9084
|
+
const file = tree.files.find((f) => f.rel === anchor.slice(0, cut));
|
|
9085
|
+
if (!file)
|
|
9086
|
+
return {
|
|
9087
|
+
kind: "read",
|
|
9088
|
+
sites: [
|
|
9089
|
+
{
|
|
9090
|
+
path: toolName,
|
|
9091
|
+
kind: "unread",
|
|
9092
|
+
form: "registration file not in the scanned tree",
|
|
9093
|
+
anchor
|
|
9094
|
+
}
|
|
9095
|
+
]
|
|
9096
|
+
};
|
|
9097
|
+
const located = locateSchema(file, toolName, Number(anchor.slice(cut + 1)), "outputSchema");
|
|
9098
|
+
if (located.kind === "none") return { kind: "none" };
|
|
9099
|
+
const where = (off) => {
|
|
9100
|
+
const at = off === void 0 ? null : locate(off);
|
|
9101
|
+
return at ? `${at.file.rel}:${at.line}` : anchor;
|
|
9102
|
+
};
|
|
9103
|
+
if (located.kind === "unread")
|
|
9104
|
+
return {
|
|
9105
|
+
kind: "read",
|
|
9106
|
+
sites: [{ path: toolName, kind: "unread", form: located.form, anchor: where(located.at) }]
|
|
9107
|
+
};
|
|
9108
|
+
const ctx = moduleCtx(file, tree);
|
|
9109
|
+
const schema = located.kind === "json" ? jsonSchemaOf(located.node, ctx) : evalZod(located.node, ctx);
|
|
9110
|
+
const raw = [];
|
|
9111
|
+
walkClosed(schema, toolName, raw);
|
|
9112
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9113
|
+
const sites = [];
|
|
9114
|
+
for (const r of raw) {
|
|
9115
|
+
const key = `${r.kind}|${r.path}|${r.form}`;
|
|
9116
|
+
if (seen.has(key)) continue;
|
|
9117
|
+
seen.add(key);
|
|
9118
|
+
const exempt = r.kind === "violation" ? closedExemption(r.at) : void 0;
|
|
9119
|
+
sites.push({
|
|
9120
|
+
path: r.path,
|
|
9121
|
+
kind: r.kind,
|
|
9122
|
+
form: r.form,
|
|
9123
|
+
anchor: where(r.at),
|
|
9124
|
+
...exempt ? { exempt } : {}
|
|
9125
|
+
});
|
|
9126
|
+
}
|
|
9127
|
+
return { kind: "read", sites };
|
|
9128
|
+
}
|
|
9129
|
+
function closedServedSites(schema, toolName, anchor) {
|
|
9130
|
+
const raw = [];
|
|
9131
|
+
walkClosed(jsonToS(schema, { root: schema }, /* @__PURE__ */ new Set()), toolName, raw);
|
|
9132
|
+
return raw.map((r) => ({ path: r.path, kind: r.kind, form: r.form, anchor }));
|
|
9133
|
+
}
|
|
9001
9134
|
|
|
9002
9135
|
// src/detectors/c11-pagination.ts
|
|
9003
9136
|
var PIN2 = STANDARD_PIN;
|
|
@@ -10030,8 +10163,8 @@ var RECORD_LINE_RE = /^[\s>*_\-+]*Provenance\s*:\s*(.*)$/i;
|
|
|
10030
10163
|
var SHASUM_HEX_RE = /\bshasum\b[^\n]*?\b([0-9a-f]{40})\b/i;
|
|
10031
10164
|
function judgeProvenanceRecord(line, name, version) {
|
|
10032
10165
|
const body = line.match(RECORD_LINE_RE)?.[1] ?? "";
|
|
10033
|
-
const
|
|
10034
|
-
const named = new RegExp(`(?:^|[\\s(])${
|
|
10166
|
+
const esc7 = (x) => x.replace(/[.+*?^$()[\]{}|\\/]/g, "\\$&");
|
|
10167
|
+
const named = new RegExp(`(?:^|[\\s(])${esc7(name)}@v?${esc7(version)}(?![\\w.-]*\\d)`);
|
|
10035
10168
|
if (!named.test(body)) {
|
|
10036
10169
|
return { ok: false, why: `it does not name ${name}@${version}, the artifact being published` };
|
|
10037
10170
|
}
|
|
@@ -12918,6 +13051,96 @@ var c33IdentityTool = {
|
|
|
12918
13051
|
}
|
|
12919
13052
|
};
|
|
12920
13053
|
|
|
13054
|
+
// src/detectors/c36-readme-npm-limit.ts
|
|
13055
|
+
import { lstatSync, readFileSync as readFileSync11, readdirSync as readdirSync9 } from "fs";
|
|
13056
|
+
import { join as join13 } from "path";
|
|
13057
|
+
var ID2 = "C36 readme-npm-limit";
|
|
13058
|
+
var RULE2 = "C-36";
|
|
13059
|
+
var LIMIT = 61440;
|
|
13060
|
+
var NPM_CUT = 65536;
|
|
13061
|
+
var README_RE = /^readme(\.[^/]*)?$/i;
|
|
13062
|
+
function runStatic2(tree) {
|
|
13063
|
+
const pkgPath = join13(tree.root, "package.json");
|
|
13064
|
+
let pkg;
|
|
13065
|
+
try {
|
|
13066
|
+
pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
13067
|
+
} catch (err) {
|
|
13068
|
+
if (fsErrorCode(err) === "ENOENT")
|
|
13069
|
+
return {
|
|
13070
|
+
id: ID2,
|
|
13071
|
+
anchor: tree.root,
|
|
13072
|
+
state: "absent",
|
|
13073
|
+
verdict: `no package.json: not published to npm \u2014 ${RULE2} n/a`
|
|
13074
|
+
};
|
|
13075
|
+
return couldNotJudge(
|
|
13076
|
+
ID2,
|
|
13077
|
+
pkgPath,
|
|
13078
|
+
`package.json could not be read or parsed (${fsErrorCode(err)}) (${RULE2})`
|
|
13079
|
+
);
|
|
13080
|
+
}
|
|
13081
|
+
if (pkg?.private === true)
|
|
13082
|
+
return {
|
|
13083
|
+
id: ID2,
|
|
13084
|
+
anchor: pkgPath,
|
|
13085
|
+
state: "absent",
|
|
13086
|
+
verdict: `"private": true: not published to npm \u2014 ${RULE2} n/a`
|
|
13087
|
+
};
|
|
13088
|
+
let names;
|
|
13089
|
+
try {
|
|
13090
|
+
names = readdirSync9(tree.root).filter((n) => README_RE.test(n));
|
|
13091
|
+
} catch (err) {
|
|
13092
|
+
return couldNotJudge(
|
|
13093
|
+
ID2,
|
|
13094
|
+
tree.root,
|
|
13095
|
+
`the package root could not be listed (${fsErrorCode(err)}) (${RULE2})`
|
|
13096
|
+
);
|
|
13097
|
+
}
|
|
13098
|
+
if (names.length === 0)
|
|
13099
|
+
return {
|
|
13100
|
+
id: ID2,
|
|
13101
|
+
anchor: tree.root,
|
|
13102
|
+
state: "absent",
|
|
13103
|
+
verdict: `no README (no readme* file) at the package root: nothing to measure (its presence is C-1 / C-31's subject) \u2014 ${RULE2} n/a`
|
|
13104
|
+
};
|
|
13105
|
+
const sized = [];
|
|
13106
|
+
for (const name of names.sort()) {
|
|
13107
|
+
const path = join13(tree.root, name);
|
|
13108
|
+
try {
|
|
13109
|
+
const st = lstatSync(path);
|
|
13110
|
+
if (!st.isFile())
|
|
13111
|
+
return couldNotJudge(
|
|
13112
|
+
ID2,
|
|
13113
|
+
path,
|
|
13114
|
+
`${name} is not a regular file, so its shipped size is unread (${RULE2})`
|
|
13115
|
+
);
|
|
13116
|
+
sized.push({ name, size: st.size });
|
|
13117
|
+
} catch (err) {
|
|
13118
|
+
return couldNotJudge(ID2, path, `${name} could not be read (${fsErrorCode(err)}) (${RULE2})`);
|
|
13119
|
+
}
|
|
13120
|
+
}
|
|
13121
|
+
const over = sized.filter((r) => r.size > LIMIT);
|
|
13122
|
+
const list = sized.map((r) => `${r.name} ${r.size} bytes`).join(", ");
|
|
13123
|
+
if (over.length > 0)
|
|
13124
|
+
return {
|
|
13125
|
+
id: ID2,
|
|
13126
|
+
anchor: join13(tree.root, over[0].name),
|
|
13127
|
+
state: "non-conforming",
|
|
13128
|
+
verdict: `${over.map((r) => `${r.name} is ${r.size} bytes${r.size > NPM_CUT ? ` (the last ${r.size - NPM_CUT} bytes are already missing from the package page)` : ""}`).join("; ")}, above the ${LIMIT}-byte limit (npm truncates at ${NPM_CUT}); move long sections to docs/ pages with the README as their index. Shipped: ${list} (${RULE2})`
|
|
13129
|
+
};
|
|
13130
|
+
return {
|
|
13131
|
+
id: ID2,
|
|
13132
|
+
anchor: join13(tree.root, sized[0].name),
|
|
13133
|
+
state: "present",
|
|
13134
|
+
verdict: `${list}: at or under the ${LIMIT}-byte limit (npm truncates at ${NPM_CUT}) (${RULE2})`
|
|
13135
|
+
};
|
|
13136
|
+
}
|
|
13137
|
+
var c36ReadmeNpmLimit = {
|
|
13138
|
+
id: ID2,
|
|
13139
|
+
rule: RULE2,
|
|
13140
|
+
pin: STANDARD_PIN,
|
|
13141
|
+
run: runStatic2
|
|
13142
|
+
};
|
|
13143
|
+
|
|
12921
13144
|
// src/detectors/d2.ts
|
|
12922
13145
|
var SESSION_RE = /mcp-session-id/i;
|
|
12923
13146
|
var GENERATOR_RE = /\bsessionIdGenerator\s*:\s*(?!undefined\b)\S/;
|
|
@@ -13591,10 +13814,10 @@ var RESULT_PAYLOAD_KEYS = [
|
|
|
13591
13814
|
var RESULT_ANCHOR_KEYS = ["content", "structuredContent", "resultType"];
|
|
13592
13815
|
function baseIsResult(file, base, tree) {
|
|
13593
13816
|
if (!base) return false;
|
|
13594
|
-
const
|
|
13817
|
+
const esc7 = base.replace(/[$]/g, "\\$&");
|
|
13595
13818
|
const keys = RESULT_PAYLOAD_KEYS.join("|");
|
|
13596
13819
|
const assigned = new RegExp(
|
|
13597
|
-
`\\b${
|
|
13820
|
+
`\\b${esc7}\\s*(?:\\.\\s*(?:${keys})|\\[\\s*["'](?:${keys})["']\\s*\\])\\s*=(?![=>])`
|
|
13598
13821
|
);
|
|
13599
13822
|
if (file.lines.some((l) => !l.comment && assigned.test(l.raw))) return true;
|
|
13600
13823
|
const one = { ...tree, files: [file] };
|
|
@@ -13744,7 +13967,7 @@ var d7 = guardUnreadablePackageJson(d7Inner, { authoritative: true });
|
|
|
13744
13967
|
|
|
13745
13968
|
// src/detectors/d8.ts
|
|
13746
13969
|
import { existsSync as existsSync12, statSync as statSync12 } from "fs";
|
|
13747
|
-
import { dirname as dirname6, join as
|
|
13970
|
+
import { dirname as dirname6, join as join14, relative as relative9 } from "path";
|
|
13748
13971
|
var POSITIVE_CONTROL2 = 'server.registerTool("list_items", { ... }, handler);';
|
|
13749
13972
|
function d8PositiveControl() {
|
|
13750
13973
|
return {
|
|
@@ -13764,7 +13987,7 @@ function resolveBaseDir(tree) {
|
|
|
13764
13987
|
function findEvalsFile(tree) {
|
|
13765
13988
|
let dir = resolveBaseDir(tree);
|
|
13766
13989
|
for (let depth = 0; depth < 8; depth++) {
|
|
13767
|
-
const candidate =
|
|
13990
|
+
const candidate = join14(dir, "evals", "evals.json");
|
|
13768
13991
|
if (existsSync12(candidate)) return candidate;
|
|
13769
13992
|
const parent = dirname6(dir);
|
|
13770
13993
|
if (parent === dir) break;
|
|
@@ -13918,7 +14141,7 @@ var d8 = {
|
|
|
13918
14141
|
|
|
13919
14142
|
// src/detectors/d9.ts
|
|
13920
14143
|
import { existsSync as existsSync13 } from "fs";
|
|
13921
|
-
import { dirname as dirname7, join as
|
|
14144
|
+
import { dirname as dirname7, join as join15 } from "path";
|
|
13922
14145
|
var SEMVER_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
13923
14146
|
var POSITIVE_CONTROL3 = "1.2.3-beta.1+build.7";
|
|
13924
14147
|
function d9PositiveControl() {
|
|
@@ -13967,7 +14190,7 @@ var d9Inner = {
|
|
|
13967
14190
|
};
|
|
13968
14191
|
}
|
|
13969
14192
|
const projectDir = dirname7(pkgPath);
|
|
13970
|
-
const changelogPath =
|
|
14193
|
+
const changelogPath = join15(projectDir, "CHANGELOG.md");
|
|
13971
14194
|
const hasChangelog = existsSync13(changelogPath);
|
|
13972
14195
|
const validSemver = SEMVER_RE.test(version);
|
|
13973
14196
|
if (validSemver && hasChangelog) {
|
|
@@ -13998,7 +14221,7 @@ var d9 = guardUnreadablePackageJson(d9Inner, { authoritative: false });
|
|
|
13998
14221
|
|
|
13999
14222
|
// src/detectors/d10.ts
|
|
14000
14223
|
import { existsSync as existsSync14 } from "fs";
|
|
14001
|
-
import { dirname as dirname8, join as
|
|
14224
|
+
import { dirname as dirname8, join as join16 } from "path";
|
|
14002
14225
|
var DESCRIPTION_FR_RE = /"description_fr"\s*:\s*"[^"]+"/;
|
|
14003
14226
|
var POSITIVE_CONTROL4 = '"description_fr": "Un serveur MCP conforme.",';
|
|
14004
14227
|
function d10PositiveControl() {
|
|
@@ -14131,7 +14354,7 @@ var d10Inner = {
|
|
|
14131
14354
|
};
|
|
14132
14355
|
}
|
|
14133
14356
|
const hasDescriptionFr = hasDescriptionFrJson || sourceScan.present;
|
|
14134
|
-
const readmeFrPath =
|
|
14357
|
+
const readmeFrPath = join16(root, "README.fr.md");
|
|
14135
14358
|
const hasReadmeFr = existsSync14(readmeFrPath);
|
|
14136
14359
|
const missing = [];
|
|
14137
14360
|
if (!hasDescriptionFr) missing.push("description_fr (package.json or source _meta)");
|
|
@@ -14540,8 +14763,8 @@ var d15 = {
|
|
|
14540
14763
|
};
|
|
14541
14764
|
|
|
14542
14765
|
// src/detectors/d16.ts
|
|
14543
|
-
import { existsSync as existsSync15, readFileSync as
|
|
14544
|
-
import { dirname as dirname9, join as
|
|
14766
|
+
import { existsSync as existsSync15, readFileSync as readFileSync12, statSync as statSync13 } from "fs";
|
|
14767
|
+
import { dirname as dirname9, join as join17 } from "path";
|
|
14545
14768
|
var DISCOVER_RE2 = /server\/discover|DiscoverResult|ServerDiscover|handleServerDiscover/;
|
|
14546
14769
|
var HEALTH_ROUTE_FRAMEWORK_RE = /\b[A-Za-z_$][\w$]*\.(?:get|post|put|patch|delete|all|route|use)\s*\(\s*["'`][^"'`]*\/health/;
|
|
14547
14770
|
var HEALTH_ROUTE_RAWPATH_RE = /\bpathname\s*===?\s*["'`][^"'`]*\/health/;
|
|
@@ -14625,7 +14848,7 @@ function manifestVersionEqualsPackage(tree) {
|
|
|
14625
14848
|
if (typeof pkgVersion !== "string" || pkgVersion.length === 0 || !tree.packageJson) return false;
|
|
14626
14849
|
try {
|
|
14627
14850
|
const manifest = JSON.parse(
|
|
14628
|
-
|
|
14851
|
+
readFileSync12(join17(dirname9(tree.packageJson.path), "mcp-server.json"), "utf8")
|
|
14629
14852
|
);
|
|
14630
14853
|
return manifest.version === pkgVersion;
|
|
14631
14854
|
} catch {
|
|
@@ -14913,10 +15136,10 @@ function readPackageVersion(root) {
|
|
|
14913
15136
|
try {
|
|
14914
15137
|
let dir = statSync13(root).isDirectory() ? root : dirname9(root);
|
|
14915
15138
|
for (let depth = 0; depth < 8; depth++) {
|
|
14916
|
-
const candidate =
|
|
15139
|
+
const candidate = join17(dir, "package.json");
|
|
14917
15140
|
if (existsSync15(candidate)) {
|
|
14918
15141
|
if (!statSync13(candidate).isFile()) return null;
|
|
14919
|
-
const pkg = JSON.parse(
|
|
15142
|
+
const pkg = JSON.parse(readFileSync12(candidate, "utf8"));
|
|
14920
15143
|
return typeof pkg.version === "string" ? pkg.version : null;
|
|
14921
15144
|
}
|
|
14922
15145
|
const parent = dirname9(dir);
|
|
@@ -14930,8 +15153,8 @@ function readPackageVersion(root) {
|
|
|
14930
15153
|
}
|
|
14931
15154
|
|
|
14932
15155
|
// src/detectors/dAppI18n.ts
|
|
14933
|
-
import { existsSync as existsSync16, readFileSync as
|
|
14934
|
-
import { dirname as dirname10, join as
|
|
15156
|
+
import { existsSync as existsSync16, readFileSync as readFileSync13, statSync as statSync14 } from "fs";
|
|
15157
|
+
import { dirname as dirname10, join as join18 } from "path";
|
|
14935
15158
|
function flattenKeys(obj, prefix = "") {
|
|
14936
15159
|
if (obj === null || typeof obj !== "object" || Array.isArray(obj)) {
|
|
14937
15160
|
return prefix ? [prefix] : [];
|
|
@@ -14965,7 +15188,7 @@ function dAppI18nPositiveControls() {
|
|
|
14965
15188
|
function readJson2(path) {
|
|
14966
15189
|
try {
|
|
14967
15190
|
if (!statSync14(path).isFile()) return { ok: false };
|
|
14968
|
-
return { ok: true, value: JSON.parse(
|
|
15191
|
+
return { ok: true, value: JSON.parse(readFileSync13(path, "utf8")) };
|
|
14969
15192
|
} catch {
|
|
14970
15193
|
return { ok: false };
|
|
14971
15194
|
}
|
|
@@ -14982,9 +15205,9 @@ var dAppI18n = {
|
|
|
14982
15205
|
);
|
|
14983
15206
|
}
|
|
14984
15207
|
const root = tree.packageJson ? dirname10(tree.packageJson.path) : tree.root;
|
|
14985
|
-
const i18nDir =
|
|
14986
|
-
const enPath =
|
|
14987
|
-
const frPath =
|
|
15208
|
+
const i18nDir = join18(root, "i18n");
|
|
15209
|
+
const enPath = join18(i18nDir, "en.json");
|
|
15210
|
+
const frPath = join18(i18nDir, "fr.json");
|
|
14988
15211
|
const hasI18n = existsSync16(i18nDir);
|
|
14989
15212
|
const hasFr = existsSync16(frPath);
|
|
14990
15213
|
if (!hasI18n && !hasFr) {
|
|
@@ -15163,27 +15386,27 @@ var dDebugOptIn = {
|
|
|
15163
15386
|
};
|
|
15164
15387
|
|
|
15165
15388
|
// src/detectors/extManifests.ts
|
|
15166
|
-
import { readdirSync as
|
|
15167
|
-
import { join as
|
|
15389
|
+
import { readdirSync as readdirSync10, statSync as statSync15 } from "fs";
|
|
15390
|
+
import { join as join19 } from "path";
|
|
15168
15391
|
function findExtensionManifests(tree) {
|
|
15169
15392
|
const out = [];
|
|
15170
15393
|
const root = tree.root;
|
|
15171
15394
|
let base;
|
|
15172
15395
|
try {
|
|
15173
|
-
base = statSync15(root).isDirectory() ? root :
|
|
15396
|
+
base = statSync15(root).isDirectory() ? root : join19(root, "..");
|
|
15174
15397
|
} catch {
|
|
15175
15398
|
return out;
|
|
15176
15399
|
}
|
|
15177
15400
|
const walk3 = (dir) => {
|
|
15178
15401
|
let entries;
|
|
15179
15402
|
try {
|
|
15180
|
-
entries =
|
|
15403
|
+
entries = readdirSync10(dir);
|
|
15181
15404
|
} catch (err) {
|
|
15182
15405
|
recordSkip(tree, dir, base, `could not be listed (${fsErrorCode(err)}) \u2014 not read`);
|
|
15183
15406
|
return;
|
|
15184
15407
|
}
|
|
15185
15408
|
for (const name of entries) {
|
|
15186
|
-
const full =
|
|
15409
|
+
const full = join19(dir, name);
|
|
15187
15410
|
let st;
|
|
15188
15411
|
try {
|
|
15189
15412
|
st = statSync15(full);
|
|
@@ -15211,8 +15434,8 @@ function findExtensionManifests(tree) {
|
|
|
15211
15434
|
}
|
|
15212
15435
|
|
|
15213
15436
|
// src/detectors/vendorRegistry.ts
|
|
15214
|
-
import { existsSync as existsSync17, readFileSync as
|
|
15215
|
-
import { dirname as dirname11, join as
|
|
15437
|
+
import { existsSync as existsSync17, readFileSync as readFileSync14 } from "fs";
|
|
15438
|
+
import { dirname as dirname11, join as join20 } from "path";
|
|
15216
15439
|
import { fileURLToPath } from "url";
|
|
15217
15440
|
function locateRegistry() {
|
|
15218
15441
|
let dir;
|
|
@@ -15222,7 +15445,7 @@ function locateRegistry() {
|
|
|
15222
15445
|
return null;
|
|
15223
15446
|
}
|
|
15224
15447
|
for (let depth = 0; depth < 5; depth++) {
|
|
15225
|
-
const candidate =
|
|
15448
|
+
const candidate = join20(dir, "vendor-namespaces.json");
|
|
15226
15449
|
if (existsSync17(candidate)) return candidate;
|
|
15227
15450
|
const parent = dirname11(dir);
|
|
15228
15451
|
if (parent === dir) break;
|
|
@@ -15240,7 +15463,7 @@ function loadRegistry(path) {
|
|
|
15240
15463
|
}
|
|
15241
15464
|
let parsed;
|
|
15242
15465
|
try {
|
|
15243
|
-
parsed = JSON.parse(
|
|
15466
|
+
parsed = JSON.parse(readFileSync14(p, "utf8"));
|
|
15244
15467
|
} catch (err) {
|
|
15245
15468
|
return {
|
|
15246
15469
|
ok: false,
|
|
@@ -15818,8 +16041,8 @@ var dExt3 = {
|
|
|
15818
16041
|
};
|
|
15819
16042
|
|
|
15820
16043
|
// src/detectors/dExt4.ts
|
|
15821
|
-
import { readdirSync as
|
|
15822
|
-
import { join as
|
|
16044
|
+
import { readdirSync as readdirSync11, statSync as statSync16 } from "fs";
|
|
16045
|
+
import { join as join21, relative as relative10 } from "path";
|
|
15823
16046
|
function canonical(name) {
|
|
15824
16047
|
return name.replace(/[-_]/g, "").toLowerCase();
|
|
15825
16048
|
}
|
|
@@ -15843,7 +16066,7 @@ function findHooksDirs(tree, unreadable, gaps) {
|
|
|
15843
16066
|
const out = [];
|
|
15844
16067
|
let base;
|
|
15845
16068
|
try {
|
|
15846
|
-
base = statSync16(root).isDirectory() ? root :
|
|
16069
|
+
base = statSync16(root).isDirectory() ? root : join21(root, "..");
|
|
15847
16070
|
} catch {
|
|
15848
16071
|
return out;
|
|
15849
16072
|
}
|
|
@@ -15858,13 +16081,13 @@ function findHooksDirs(tree, unreadable, gaps) {
|
|
|
15858
16081
|
const walk3 = (dir) => {
|
|
15859
16082
|
let entries;
|
|
15860
16083
|
try {
|
|
15861
|
-
entries =
|
|
16084
|
+
entries = readdirSync11(dir);
|
|
15862
16085
|
} catch (err) {
|
|
15863
16086
|
noteUnread(dir, "could not be listed", err);
|
|
15864
16087
|
return;
|
|
15865
16088
|
}
|
|
15866
16089
|
for (const name of entries) {
|
|
15867
|
-
const full =
|
|
16090
|
+
const full = join21(dir, name);
|
|
15868
16091
|
let st;
|
|
15869
16092
|
try {
|
|
15870
16093
|
st = statSync16(full);
|
|
@@ -15882,7 +16105,7 @@ function findHooksDirs(tree, unreadable, gaps) {
|
|
|
15882
16105
|
const tokens = /* @__PURE__ */ new Set();
|
|
15883
16106
|
let files;
|
|
15884
16107
|
try {
|
|
15885
|
-
files =
|
|
16108
|
+
files = readdirSync11(full);
|
|
15886
16109
|
} catch (err) {
|
|
15887
16110
|
noteUnread(full, "could not be listed", err);
|
|
15888
16111
|
files = [];
|
|
@@ -16046,7 +16269,7 @@ var dExt4 = {
|
|
|
16046
16269
|
|
|
16047
16270
|
// src/detectors/dExt5.ts
|
|
16048
16271
|
import { existsSync as existsSync18 } from "fs";
|
|
16049
|
-
import { dirname as dirname12, join as
|
|
16272
|
+
import { dirname as dirname12, join as join22 } from "path";
|
|
16050
16273
|
function nonEmptyString(v) {
|
|
16051
16274
|
return typeof v === "string" && v.trim().length > 0;
|
|
16052
16275
|
}
|
|
@@ -16108,7 +16331,7 @@ var dExt5 = {
|
|
|
16108
16331
|
if (!nonEmptyString(parsed.description_fr)) {
|
|
16109
16332
|
missing.push("description_fr (extension.json)");
|
|
16110
16333
|
}
|
|
16111
|
-
if (!existsSync18(
|
|
16334
|
+
if (!existsSync18(join22(root, "README.fr.md"))) {
|
|
16112
16335
|
missing.push("README.fr.md");
|
|
16113
16336
|
}
|
|
16114
16337
|
if (isToolExtension(parsed.type) && "tools" in parsed) {
|
|
@@ -16152,7 +16375,7 @@ var dExt5 = {
|
|
|
16152
16375
|
|
|
16153
16376
|
// src/detectors/dExt7.ts
|
|
16154
16377
|
import { existsSync as existsSync19 } from "fs";
|
|
16155
|
-
import { dirname as dirname13, join as
|
|
16378
|
+
import { dirname as dirname13, join as join23 } from "path";
|
|
16156
16379
|
var ABSENCE_FLAG_FIELDS = [
|
|
16157
16380
|
"extensionAbsent",
|
|
16158
16381
|
"extension_absent",
|
|
@@ -16220,7 +16443,7 @@ var dExt7 = {
|
|
|
16220
16443
|
for (const manifestPath2 of manifests) {
|
|
16221
16444
|
const extDir = dirname13(manifestPath2);
|
|
16222
16445
|
const extLabel = extDir.split("/").pop() ?? extDir;
|
|
16223
|
-
const evalsPath =
|
|
16446
|
+
const evalsPath = join23(extDir, "evals", "evals.json");
|
|
16224
16447
|
const shortPath = `${extLabel}/evals/evals.json`;
|
|
16225
16448
|
if (!existsSync19(evalsPath)) {
|
|
16226
16449
|
return {
|
|
@@ -16287,7 +16510,7 @@ var dExt7 = {
|
|
|
16287
16510
|
|
|
16288
16511
|
// src/detectors/dExt8.ts
|
|
16289
16512
|
import { existsSync as existsSync20 } from "fs";
|
|
16290
|
-
import { dirname as dirname14, join as
|
|
16513
|
+
import { dirname as dirname14, join as join24 } from "path";
|
|
16291
16514
|
var SEMVER_RE2 = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
16292
16515
|
var POSITIVE_CONTROL5 = "1.2.3-beta.1+build.7";
|
|
16293
16516
|
function dExt8PositiveControl() {
|
|
@@ -16323,7 +16546,7 @@ var dExt8 = {
|
|
|
16323
16546
|
for (const manifestPath2 of manifests) {
|
|
16324
16547
|
const extDir = dirname14(manifestPath2);
|
|
16325
16548
|
const extLabel = extDir.split("/").pop() ?? extDir;
|
|
16326
|
-
const pkgPath =
|
|
16549
|
+
const pkgPath = join24(extDir, "package.json");
|
|
16327
16550
|
const shortPkgPath = `${extLabel}/package.json`;
|
|
16328
16551
|
if (!existsSync20(pkgPath)) {
|
|
16329
16552
|
unreadable.push({
|
|
@@ -16360,7 +16583,7 @@ var dExt8 = {
|
|
|
16360
16583
|
continue;
|
|
16361
16584
|
}
|
|
16362
16585
|
const validSemver = SEMVER_RE2.test(version);
|
|
16363
|
-
const changelogPath =
|
|
16586
|
+
const changelogPath = join24(extDir, "CHANGELOG.md");
|
|
16364
16587
|
const hasChangelog = existsSync20(changelogPath);
|
|
16365
16588
|
if (!validSemver) {
|
|
16366
16589
|
finding ??= {
|
|
@@ -16395,14 +16618,14 @@ var dExt8 = {
|
|
|
16395
16618
|
};
|
|
16396
16619
|
|
|
16397
16620
|
// src/detectors/dExt9.ts
|
|
16398
|
-
import { readFileSync as
|
|
16399
|
-
import { join as
|
|
16621
|
+
import { readFileSync as readFileSync15, readdirSync as readdirSync12, statSync as statSync17 } from "fs";
|
|
16622
|
+
import { join as join25, relative as relative11 } from "path";
|
|
16400
16623
|
function collectHooksDirSources(tree, unreadable, gaps) {
|
|
16401
16624
|
const root = tree.root;
|
|
16402
16625
|
const out = [];
|
|
16403
16626
|
let base;
|
|
16404
16627
|
try {
|
|
16405
|
-
base = statSync17(root).isDirectory() ? root :
|
|
16628
|
+
base = statSync17(root).isDirectory() ? root : join25(root, "..");
|
|
16406
16629
|
} catch {
|
|
16407
16630
|
return out;
|
|
16408
16631
|
}
|
|
@@ -16417,13 +16640,13 @@ function collectHooksDirSources(tree, unreadable, gaps) {
|
|
|
16417
16640
|
const walk3 = (dir) => {
|
|
16418
16641
|
let entries;
|
|
16419
16642
|
try {
|
|
16420
|
-
entries =
|
|
16643
|
+
entries = readdirSync12(dir);
|
|
16421
16644
|
} catch (err) {
|
|
16422
16645
|
noteUnread(dir, "could not be listed", err);
|
|
16423
16646
|
return;
|
|
16424
16647
|
}
|
|
16425
16648
|
for (const name of entries) {
|
|
16426
|
-
const full =
|
|
16649
|
+
const full = join25(dir, name);
|
|
16427
16650
|
let st;
|
|
16428
16651
|
try {
|
|
16429
16652
|
st = statSync17(full);
|
|
@@ -16440,7 +16663,7 @@ function collectHooksDirSources(tree, unreadable, gaps) {
|
|
|
16440
16663
|
if (name === "hooks") {
|
|
16441
16664
|
let files;
|
|
16442
16665
|
try {
|
|
16443
|
-
files =
|
|
16666
|
+
files = readdirSync12(full);
|
|
16444
16667
|
} catch (err) {
|
|
16445
16668
|
noteUnread(full, "could not be listed", err);
|
|
16446
16669
|
files = [];
|
|
@@ -16449,11 +16672,11 @@ function collectHooksDirSources(tree, unreadable, gaps) {
|
|
|
16449
16672
|
if (!f.endsWith(".ts") || f.endsWith(".d.ts")) continue;
|
|
16450
16673
|
const stem = f.replace(/\.ts$/, "");
|
|
16451
16674
|
if (stem === "index") continue;
|
|
16452
|
-
const filePath =
|
|
16675
|
+
const filePath = join25(full, f);
|
|
16453
16676
|
let body;
|
|
16454
16677
|
try {
|
|
16455
16678
|
if (!statSync17(filePath).isFile()) throw new Error("not a regular file");
|
|
16456
|
-
body =
|
|
16679
|
+
body = readFileSync15(filePath, "utf8");
|
|
16457
16680
|
} catch {
|
|
16458
16681
|
const shortPath = filePath.split("/").slice(-2).join("/");
|
|
16459
16682
|
unreadable.push({
|
|
@@ -18083,7 +18306,7 @@ var e10MrtrOnly = {
|
|
|
18083
18306
|
|
|
18084
18307
|
// src/detectors/e11-surfaces-derived.ts
|
|
18085
18308
|
import { existsSync as existsSync21, statSync as statSync18 } from "fs";
|
|
18086
|
-
import { dirname as dirname15, join as
|
|
18309
|
+
import { dirname as dirname15, join as join26, relative as relative12, sep as sep6 } from "path";
|
|
18087
18310
|
var ALL = ["chat", "cowork", "claude-code"];
|
|
18088
18311
|
function excludedSurfaces(c) {
|
|
18089
18312
|
const cause = /* @__PURE__ */ new Map();
|
|
@@ -18172,7 +18395,7 @@ var e11SurfacesDerived = {
|
|
|
18172
18395
|
text: `${m.rel} surfaces ${unknown.join(", ")} are not in {${ALL.join(", ")}}`
|
|
18173
18396
|
});
|
|
18174
18397
|
}
|
|
18175
|
-
const mcp =
|
|
18398
|
+
const mcp = join26(folder, ".mcp.json");
|
|
18176
18399
|
let localMcp = false;
|
|
18177
18400
|
if (existsSync21(mcp)) {
|
|
18178
18401
|
const mj = readJsonRecord(mcp);
|
|
@@ -18191,9 +18414,9 @@ var e11SurfacesDerived = {
|
|
|
18191
18414
|
}
|
|
18192
18415
|
}
|
|
18193
18416
|
const cause = excludedSurfaces({
|
|
18194
|
-
bin: isDir(
|
|
18195
|
-
hooks: isDir(
|
|
18196
|
-
agents: isDir(
|
|
18417
|
+
bin: isDir(join26(folder, "bin"), rel(join26(folder, "bin")), unreadable),
|
|
18418
|
+
hooks: isDir(join26(folder, "hooks"), rel(join26(folder, "hooks")), unreadable),
|
|
18419
|
+
agents: isDir(join26(folder, "agents"), rel(join26(folder, "agents")), unreadable),
|
|
18197
18420
|
localMcp
|
|
18198
18421
|
});
|
|
18199
18422
|
for (const s of declared) {
|
|
@@ -18317,8 +18540,8 @@ var e12HostCapabilityPlacement = {
|
|
|
18317
18540
|
};
|
|
18318
18541
|
|
|
18319
18542
|
// src/detectors/installedAs.ts
|
|
18320
|
-
import { readdirSync as
|
|
18321
|
-
import { join as
|
|
18543
|
+
import { readdirSync as readdirSync13, statSync as statSync19 } from "fs";
|
|
18544
|
+
import { join as join27 } from "path";
|
|
18322
18545
|
var KEY = (k) => `(?:["']${k}["']|\\b${k}\\b)`;
|
|
18323
18546
|
function flagTrueRe(key) {
|
|
18324
18547
|
return new RegExp(`${KEY(key)}\\s*:\\s*true\\b`);
|
|
@@ -18343,7 +18566,7 @@ function declaredDependencies(tree) {
|
|
|
18343
18566
|
}
|
|
18344
18567
|
function readInstalledAs(tree) {
|
|
18345
18568
|
const out = { installed: false, missing: [], publishers: [], unread: [] };
|
|
18346
|
-
const nm =
|
|
18569
|
+
const nm = join27(baseOf(tree), "node_modules");
|
|
18347
18570
|
try {
|
|
18348
18571
|
out.installed = statSync19(nm).isDirectory();
|
|
18349
18572
|
} catch {
|
|
@@ -18352,7 +18575,7 @@ function readInstalledAs(tree) {
|
|
|
18352
18575
|
if (!out.installed) return out;
|
|
18353
18576
|
const methods = authMethodsRe();
|
|
18354
18577
|
for (const dep of declaredDependencies(tree)) {
|
|
18355
|
-
const dir =
|
|
18578
|
+
const dir = join27(nm, dep);
|
|
18356
18579
|
try {
|
|
18357
18580
|
if (!statSync19(dir).isDirectory()) throw new Error("not a directory");
|
|
18358
18581
|
} catch {
|
|
@@ -18363,7 +18586,7 @@ function readInstalledAs(tree) {
|
|
|
18363
18586
|
const walk3 = (d) => {
|
|
18364
18587
|
let names;
|
|
18365
18588
|
try {
|
|
18366
|
-
names =
|
|
18589
|
+
names = readdirSync13(d).sort();
|
|
18367
18590
|
} catch (e) {
|
|
18368
18591
|
out.unread.push(
|
|
18369
18592
|
`${d.slice(nm.length + 1)} (directory not listed: ${e.message})`
|
|
@@ -18373,7 +18596,7 @@ function readInstalledAs(tree) {
|
|
|
18373
18596
|
for (const n of names) {
|
|
18374
18597
|
if (files.length >= MAX_FILES_PER_PACKAGE) return;
|
|
18375
18598
|
if (n === "node_modules") continue;
|
|
18376
|
-
const full =
|
|
18599
|
+
const full = join27(d, n);
|
|
18377
18600
|
let st;
|
|
18378
18601
|
try {
|
|
18379
18602
|
st = statSync19(full);
|
|
@@ -21526,8 +21749,55 @@ var s27ElicitationFloor = {
|
|
|
21526
21749
|
};
|
|
21527
21750
|
|
|
21528
21751
|
// src/detectors/s28-claim-forwarded.ts
|
|
21529
|
-
import { existsSync as existsSync22, readFileSync as
|
|
21530
|
-
import { dirname as dirname16, join as
|
|
21752
|
+
import { existsSync as existsSync22, readFileSync as readFileSync16, readdirSync as readdirSync14, statSync as statSync20 } from "fs";
|
|
21753
|
+
import { dirname as dirname16, join as join28, relative as relative13 } from "path";
|
|
21754
|
+
|
|
21755
|
+
// src/detectors/backendReceiver.ts
|
|
21756
|
+
var CLIENT_NAME = /convex|client/i;
|
|
21757
|
+
var CLIENT_TYPE = /\bConvex\w*Client\b/;
|
|
21758
|
+
function esc4(s) {
|
|
21759
|
+
return s.replace(/\$/g, "\\$");
|
|
21760
|
+
}
|
|
21761
|
+
function backendReceiver(m, recv, at, depth = 0) {
|
|
21762
|
+
if (CLIENT_NAME.test(recv)) return { kind: "client", how: `named ${recv}` };
|
|
21763
|
+
if (depth > 4) return { kind: "unresolved", why: `${recv}: alias chain too deep` };
|
|
21764
|
+
if (/\.\s*$/.test(m.slice(Math.max(0, at - 4), at)))
|
|
21765
|
+
return {
|
|
21766
|
+
kind: "unresolved",
|
|
21767
|
+
why: `${recv} is a property whose value this scan does not follow`
|
|
21768
|
+
};
|
|
21769
|
+
const head = m.slice(0, at);
|
|
21770
|
+
const r = esc4(recv);
|
|
21771
|
+
if (new RegExp(`(?<![\\w$.])${r}\\s*\\??\\s*:\\s*[\\w$.<>|\\s]*${CLIENT_TYPE.source}`).test(head))
|
|
21772
|
+
return { kind: "client", how: `${recv} typed as a Convex client` };
|
|
21773
|
+
const destr = new RegExp(`[{,]\\s*([A-Za-z_$][\\w$]*)\\s*:\\s*${r}\\s*[,}=]`).exec(head);
|
|
21774
|
+
if (destr && CLIENT_NAME.test(destr[1]))
|
|
21775
|
+
return { kind: "client", how: `${recv} destructured from ${destr[1]}` };
|
|
21776
|
+
let init;
|
|
21777
|
+
for (const b of head.matchAll(
|
|
21778
|
+
new RegExp(`\\b(?:const|let|var)\\s+${r}\\s*(?::[^=;]*)?=\\s*([^;\\n]+)`, "g")
|
|
21779
|
+
))
|
|
21780
|
+
init = b[1].trim();
|
|
21781
|
+
if (init !== void 0) {
|
|
21782
|
+
if (/^(?:new\s+)?Convex\w*Client\s*\(/.test(init))
|
|
21783
|
+
return { kind: "client", how: `${recv} = ${init.split("(")[0]}(\u2026)` };
|
|
21784
|
+
const id = /^([A-Za-z_$][\w$]*)\s*(?:as\s+[\w$.<>]+)?\s*$/.exec(init);
|
|
21785
|
+
if (id) {
|
|
21786
|
+
const inner = backendReceiver(m, id[1], head.lastIndexOf(init), depth + 1);
|
|
21787
|
+
return inner.kind === "client" ? { kind: "client", how: `${recv} = ${id[1]} (${inner.how})` } : { kind: "unresolved", why: `${recv} = ${id[1]}: ${inner.why}` };
|
|
21788
|
+
}
|
|
21789
|
+
return {
|
|
21790
|
+
kind: "unresolved",
|
|
21791
|
+
why: `${recv} is bound to an expression this scan does not resolve (${init.slice(0, 40)})`
|
|
21792
|
+
};
|
|
21793
|
+
}
|
|
21794
|
+
return { kind: "unresolved", why: `${recv} has no binding this scan can read` };
|
|
21795
|
+
}
|
|
21796
|
+
function importsConvex(m, raw) {
|
|
21797
|
+
return /\bfrom\s+["']convex\/[\w/-]+["']|\brequire\(\s*["']convex\//.test(raw) || CLIENT_TYPE.test(m);
|
|
21798
|
+
}
|
|
21799
|
+
|
|
21800
|
+
// src/detectors/s28-claim-forwarded.ts
|
|
21531
21801
|
var PIN11 = STANDARD_PIN;
|
|
21532
21802
|
var CLAIM_TOKEN = /\bverified(?:Org|Person)\b/;
|
|
21533
21803
|
var ANY_CLAIM = /\bverified(?:Actor|Org|Person)\b/g;
|
|
@@ -21588,14 +21858,14 @@ function splitTop2(m, from, to) {
|
|
|
21588
21858
|
function listTs(dir, unread2, out = []) {
|
|
21589
21859
|
let names;
|
|
21590
21860
|
try {
|
|
21591
|
-
names =
|
|
21861
|
+
names = readdirSync14(dir);
|
|
21592
21862
|
} catch (err) {
|
|
21593
21863
|
unread2.push(`${dir} could not be listed (${fsErrorCode(err)})`);
|
|
21594
21864
|
return out;
|
|
21595
21865
|
}
|
|
21596
21866
|
for (const n of names) {
|
|
21597
21867
|
if (n === "node_modules" || n === "_generated" || n === "__tests__") continue;
|
|
21598
|
-
const p =
|
|
21868
|
+
const p = join28(dir, n);
|
|
21599
21869
|
let st;
|
|
21600
21870
|
try {
|
|
21601
21871
|
st = statSync20(p);
|
|
@@ -21619,8 +21889,8 @@ function discoverBackend(root) {
|
|
|
21619
21889
|
return void 0;
|
|
21620
21890
|
}
|
|
21621
21891
|
for (let up = 0; up < 5; up++) {
|
|
21622
|
-
const cand =
|
|
21623
|
-
if (existsSync22(
|
|
21892
|
+
const cand = join28(dir, "convex");
|
|
21893
|
+
if (existsSync22(join28(cand, "schema.ts"))) return cand;
|
|
21624
21894
|
const parent = dirname16(dir);
|
|
21625
21895
|
if (parent === dir) break;
|
|
21626
21896
|
dir = parent;
|
|
@@ -21632,7 +21902,7 @@ function readDoors(backendRoot, unread2) {
|
|
|
21632
21902
|
for (const path of listTs(backendRoot, unread2)) {
|
|
21633
21903
|
let text;
|
|
21634
21904
|
try {
|
|
21635
|
-
text =
|
|
21905
|
+
text = readFileSync16(path, "utf8");
|
|
21636
21906
|
} catch (err) {
|
|
21637
21907
|
unread2.push(`${path} could not be read (${fsErrorCode(err)})`);
|
|
21638
21908
|
continue;
|
|
@@ -21697,8 +21967,8 @@ function readDoors(backendRoot, unread2) {
|
|
|
21697
21967
|
return doors;
|
|
21698
21968
|
}
|
|
21699
21969
|
function definitionOf(name, files) {
|
|
21700
|
-
const
|
|
21701
|
-
const re = new RegExp(`(?:\\b(?:const|let|var)\\s+${
|
|
21970
|
+
const esc7 = name.replace(/\$/g, "\\$");
|
|
21971
|
+
const re = new RegExp(`(?:\\b(?:const|let|var)\\s+${esc7}\\b|\\bfunction\\s+${esc7}\\b)`);
|
|
21702
21972
|
for (const f of files) {
|
|
21703
21973
|
const hit = re.exec(f.m);
|
|
21704
21974
|
if (!hit) continue;
|
|
@@ -21738,9 +22008,273 @@ function readHelper(name, files, seen = /* @__PURE__ */ new Set(), depth = 0) {
|
|
|
21738
22008
|
}
|
|
21739
22009
|
return { forwards, optional };
|
|
21740
22010
|
}
|
|
22011
|
+
var IDENT2 = /^\s*([A-Za-z_$][\w$]*)\s*(?:as\s+[\w$.<>[\]]+\s*)?$/;
|
|
22012
|
+
function esc5(name) {
|
|
22013
|
+
return name.replace(/\$/g, "\\$");
|
|
22014
|
+
}
|
|
22015
|
+
function enclosingFn(m, at, x) {
|
|
22016
|
+
let best;
|
|
22017
|
+
for (const hit of m.slice(0, at).matchAll(new RegExp(`\\(\\s*${esc5(x)}\\s*[?:,)]`, "g"))) {
|
|
22018
|
+
const close = matchClose2(m, hit.index);
|
|
22019
|
+
if (close < 0 || close > at) continue;
|
|
22020
|
+
if (/^\s*(?::[^{=;]*?)?\s*(?:=>|\{)/.test(m.slice(close + 1, close + 240)))
|
|
22021
|
+
best = { open: hit.index, close };
|
|
22022
|
+
}
|
|
22023
|
+
return best;
|
|
22024
|
+
}
|
|
22025
|
+
function enclosingCall(m, offset) {
|
|
22026
|
+
let depth = 0;
|
|
22027
|
+
for (let i = offset - 1; i >= 0; i--) {
|
|
22028
|
+
const ch = m[i];
|
|
22029
|
+
if (ch === ")" || ch === "]" || ch === "}") depth++;
|
|
22030
|
+
else if (ch === "(" || ch === "[" || ch === "{") {
|
|
22031
|
+
if (depth > 0) {
|
|
22032
|
+
depth--;
|
|
22033
|
+
continue;
|
|
22034
|
+
}
|
|
22035
|
+
if (ch !== "(") return void 0;
|
|
22036
|
+
const callee = /([A-Za-z_$][\w$]*)\s*(?:<[^<>]*>)?\s*$/.exec(
|
|
22037
|
+
m.slice(Math.max(0, i - 200), i)
|
|
22038
|
+
);
|
|
22039
|
+
if (!callee || /^(?:if|for|while|switch|catch|function|return)$/.test(callee[1]))
|
|
22040
|
+
return void 0;
|
|
22041
|
+
const close = matchClose2(m, i);
|
|
22042
|
+
if (close < 0) return void 0;
|
|
22043
|
+
const index = splitTop2(m, i + 1, close).findIndex(([a, b]) => offset >= a && offset < b);
|
|
22044
|
+
return index < 0 ? void 0 : { callee: callee[1], index };
|
|
22045
|
+
}
|
|
22046
|
+
}
|
|
22047
|
+
return void 0;
|
|
22048
|
+
}
|
|
22049
|
+
function paramOf(callee, index, files) {
|
|
22050
|
+
const c = esc5(callee);
|
|
22051
|
+
const re = new RegExp(
|
|
22052
|
+
`(?:\\bfunction\\s*\\*?\\s*${c}\\s*(?:<[^<>]*>)?\\s*\\(|\\b(?:const|let|var)\\s+${c}\\s*(?::[^=]*)?=\\s*(?:async\\s*)?(?:function\\s*)?\\()`
|
|
22053
|
+
);
|
|
22054
|
+
for (const fr of files) {
|
|
22055
|
+
const hit = re.exec(fr.m);
|
|
22056
|
+
if (!hit) continue;
|
|
22057
|
+
const open = hit.index + hit[0].length - 1;
|
|
22058
|
+
const close = matchClose2(fr.m, open);
|
|
22059
|
+
if (close < 0) return { file: fr, text: void 0 };
|
|
22060
|
+
const part = splitTop2(fr.m, open + 1, close)[index];
|
|
22061
|
+
return part ? { file: fr, text: fr.m.slice(part[0], part[1]).trim(), span: part } : { file: fr, text: void 0 };
|
|
22062
|
+
}
|
|
22063
|
+
return void 0;
|
|
22064
|
+
}
|
|
22065
|
+
function paramItem(param, key, callee) {
|
|
22066
|
+
const t = param.text;
|
|
22067
|
+
if (t === void 0) return `is handed to ${callee}, whose parameter cannot be read`;
|
|
22068
|
+
if (t.startsWith("{")) {
|
|
22069
|
+
if (key === void 0) return `is handed to ${callee}, whose parameter destructures it`;
|
|
22070
|
+
const k = esc5(key);
|
|
22071
|
+
const alias = new RegExp(`(?<![\\w$.])${k}\\s*:\\s*([A-Za-z_$][\\w$]*)`).exec(t);
|
|
22072
|
+
if (alias) return { name: alias[1], scope: [param.file], skip: param.span };
|
|
22073
|
+
if (new RegExp(`(?<![\\w$.])${k}\\s*[,}=]`).test(t))
|
|
22074
|
+
return { name: key, scope: [param.file], skip: param.span };
|
|
22075
|
+
return `is handed to ${callee} as property ${key}, which its parameter does not take`;
|
|
22076
|
+
}
|
|
22077
|
+
const id = /^(?:\.\.\.)?([A-Za-z_$][\w$]*)/.exec(t);
|
|
22078
|
+
if (!id) return `is handed to ${callee}, whose parameter cannot be read`;
|
|
22079
|
+
return {
|
|
22080
|
+
name: key === void 0 ? id[1] : `${id[1]}.${key}`,
|
|
22081
|
+
scope: [param.file],
|
|
22082
|
+
skip: param.span
|
|
22083
|
+
};
|
|
22084
|
+
}
|
|
22085
|
+
function handOff(at, o, len, files, propertyOf, expression = false) {
|
|
22086
|
+
const pre = at.m.slice(Math.max(0, o - 160), o);
|
|
22087
|
+
const after = at.m.slice(o + len, o + len + 40);
|
|
22088
|
+
let argAt = o;
|
|
22089
|
+
let key = propertyOf;
|
|
22090
|
+
if (!(/[(,]\s*$/.test(pre) && (expression || /^\s*[,)]/.test(after)))) {
|
|
22091
|
+
const prop = /[{,]\s*([A-Za-z_$][\w$]*)\s*:\s*$/.exec(pre);
|
|
22092
|
+
const short = !expression && /[{,]\s*$/.test(pre) && /^\s*[,}]/.test(after);
|
|
22093
|
+
if (!prop && !short) return void 0;
|
|
22094
|
+
if (key !== void 0) return "is nested two objects deep, which this scan does not follow";
|
|
22095
|
+
key = prop ? prop[1] : at.m.slice(o, o + len);
|
|
22096
|
+
let depth = 0;
|
|
22097
|
+
let brace = -1;
|
|
22098
|
+
for (let i = o - 1; i >= 0; i--) {
|
|
22099
|
+
const ch = at.m[i];
|
|
22100
|
+
if (ch === ")" || ch === "]" || ch === "}") depth++;
|
|
22101
|
+
else if (ch === "(" || ch === "[" || ch === "{") {
|
|
22102
|
+
if (depth > 0) depth--;
|
|
22103
|
+
else {
|
|
22104
|
+
brace = ch === "{" ? i : -1;
|
|
22105
|
+
break;
|
|
22106
|
+
}
|
|
22107
|
+
}
|
|
22108
|
+
}
|
|
22109
|
+
const end = brace < 0 ? -1 : matchClose2(at.m, brace);
|
|
22110
|
+
if (end < 0 || !/[(,]\s*$/.test(at.m.slice(Math.max(0, brace - 40), brace)) || !/^\s*[,)]/.test(at.m.slice(end + 1, end + 40)))
|
|
22111
|
+
return `is property ${key} of an object that is not passed directly to a function`;
|
|
22112
|
+
argAt = brace;
|
|
22113
|
+
}
|
|
22114
|
+
const call = enclosingCall(at.m, argAt);
|
|
22115
|
+
if (!call) return "is passed in a form this scan does not follow";
|
|
22116
|
+
const param = paramOf(call.callee, call.index, files);
|
|
22117
|
+
if (!param) return `is handed to ${call.callee}, whose definition is not in the scanned tree`;
|
|
22118
|
+
return paramItem(param, key, call.callee);
|
|
22119
|
+
}
|
|
22120
|
+
function readFetchers(files, scan, onCall) {
|
|
22121
|
+
const wrappers = /* @__PURE__ */ new Set();
|
|
22122
|
+
for (const fr of files) {
|
|
22123
|
+
const calls = new RegExp(CALL_RE2.source, "g");
|
|
22124
|
+
for (let hit = calls.exec(fr.m); hit; hit = calls.exec(fr.m)) {
|
|
22125
|
+
const open = hit.index + hit[0].length - 1;
|
|
22126
|
+
const close = matchClose2(fr.m, open);
|
|
22127
|
+
if (close < 0) continue;
|
|
22128
|
+
const parts = splitTop2(fr.m, open + 1, close);
|
|
22129
|
+
const first = parts[0] ? IDENT2.exec(fr.m.slice(parts[0][0], parts[0][1])) : null;
|
|
22130
|
+
if (!first) continue;
|
|
22131
|
+
const fn = enclosingFn(fr.m, hit.index, first[1]);
|
|
22132
|
+
if (!fn) continue;
|
|
22133
|
+
const rcv = backendReceiver(fr.m, hit[1], hit.index);
|
|
22134
|
+
wrappers.add(`${fr.f.rel}:${hit.index}`);
|
|
22135
|
+
if (rcv.kind === "unresolved") {
|
|
22136
|
+
scan.cnj.push({
|
|
22137
|
+
file: fr.f.rel,
|
|
22138
|
+
line: lineAt2(fr.text, hit.index),
|
|
22139
|
+
door: "?",
|
|
22140
|
+
tool: toolNameBefore(fr.text, hit.index).name,
|
|
22141
|
+
note: `a fetcher-shaped call (its door is the enclosing function's first parameter) on a receiver not resolved to a backend client \u2014 ${rcv.why}: the doors it reaches are unknown`
|
|
22142
|
+
});
|
|
22143
|
+
continue;
|
|
22144
|
+
}
|
|
22145
|
+
const argText2 = parts[1] ? fr.m.slice(parts[1][0], parts[1][1]) : "";
|
|
22146
|
+
let wrapperClaim = CLAIM_TOKEN.test(argText2);
|
|
22147
|
+
if (!wrapperClaim) {
|
|
22148
|
+
for (const h of argText2.matchAll(/(?:\.\.\.\s*|\b)([A-Za-z_$][\w$]*)\s*(?:\(\s*\))?/g))
|
|
22149
|
+
if (h[1] !== first[1] && readHelper(h[1], files).forwards) {
|
|
22150
|
+
wrapperClaim = true;
|
|
22151
|
+
break;
|
|
22152
|
+
}
|
|
22153
|
+
}
|
|
22154
|
+
const label = toolNameBefore(fr.text, hit.index).name;
|
|
22155
|
+
const before = fr.m.slice(Math.max(0, fn.open - 240), fn.open);
|
|
22156
|
+
const named = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=]*)?=\s*(?:async\s*)?$/.exec(before) ?? /\bfunction\s*\*?\s*([A-Za-z_$][\w$]*)\s*(?:<[^<>]*>)?\s*$/.exec(before);
|
|
22157
|
+
const where = `${fr.f.rel}:${lineAt2(fr.text, fn.open)}`;
|
|
22158
|
+
const name = named ? named[1] : "(anonymous)";
|
|
22159
|
+
const via = { name, where, label, wrapperClaim };
|
|
22160
|
+
const cnj = (at, offset, note) => scan.cnj.push({
|
|
22161
|
+
file: at.f.rel,
|
|
22162
|
+
line: lineAt2(at.text, offset),
|
|
22163
|
+
door: "?",
|
|
22164
|
+
tool: label,
|
|
22165
|
+
note: `the fetcher ${name} injected at ${where} ${note}: the doors it reaches are unknown`
|
|
22166
|
+
});
|
|
22167
|
+
const queue = [];
|
|
22168
|
+
if (named) queue.push({ name: named[1], scope: [fr] });
|
|
22169
|
+
else {
|
|
22170
|
+
const asyncAt = /async\s*$/.exec(before);
|
|
22171
|
+
const start = asyncAt ? fn.open - (before.length - asyncAt.index) : fn.open;
|
|
22172
|
+
const h = handOff(fr, start, fn.open - start + 1, files, void 0, true);
|
|
22173
|
+
if (h === void 0 || typeof h === "string") {
|
|
22174
|
+
cnj(fr, fn.open, h ?? "is not handed to a named function");
|
|
22175
|
+
continue;
|
|
22176
|
+
}
|
|
22177
|
+
queue.push(h);
|
|
22178
|
+
}
|
|
22179
|
+
const seen = /* @__PURE__ */ new Set();
|
|
22180
|
+
let reached = 0;
|
|
22181
|
+
let unknown = 0;
|
|
22182
|
+
while (queue.length > 0) {
|
|
22183
|
+
const item = queue.shift();
|
|
22184
|
+
for (const at of item.scope) {
|
|
22185
|
+
const key = `${item.name}@${at.f.rel}`;
|
|
22186
|
+
if (seen.has(key)) continue;
|
|
22187
|
+
seen.add(key);
|
|
22188
|
+
const segs = item.name.split(".");
|
|
22189
|
+
const pattern = segs.map(esc5).join("\\s*\\.\\s*");
|
|
22190
|
+
for (const occ of at.m.matchAll(new RegExp(`(?<![\\w$.])${pattern}(?![\\w$])`, "g"))) {
|
|
22191
|
+
const o = occ.index;
|
|
22192
|
+
const len = occ[0].length;
|
|
22193
|
+
if (item.skip && at === item.scope[0] && o >= item.skip[0] && o < item.skip[1])
|
|
22194
|
+
continue;
|
|
22195
|
+
const after = at.m.slice(o + len, o + len + 240);
|
|
22196
|
+
const pre = at.m.slice(Math.max(0, o - 60), o);
|
|
22197
|
+
if (/\b(?:const|let|var|function)\s*\*?\s*$/.test(pre)) continue;
|
|
22198
|
+
if (/^\s*\??\s*:/.test(after)) continue;
|
|
22199
|
+
if (/^\s*(?:<[^<>]*>)?\s*\(/.test(after)) {
|
|
22200
|
+
const po = o + len + after.indexOf("(");
|
|
22201
|
+
const pc = matchClose2(at.m, po);
|
|
22202
|
+
if (pc < 0) {
|
|
22203
|
+
unknown++;
|
|
22204
|
+
cnj(at, o, "has a call here that could not be read");
|
|
22205
|
+
continue;
|
|
22206
|
+
}
|
|
22207
|
+
const cp = splitTop2(at.m, po + 1, pc);
|
|
22208
|
+
const raw = cp[0] ? at.text.slice(cp[0][0], cp[0][1]) : "";
|
|
22209
|
+
const lit = /^\s*(?:\/\/[^\n]*\n\s*)*["'`]([\w/]+:[\w]+)["'`]/.exec(raw);
|
|
22210
|
+
const ref = /^\s*(?:api|internal)\.([\w]+)\.([\w]+)/.exec(raw);
|
|
22211
|
+
const door = lit ? lit[1] : ref ? `${ref[1]}:${ref[2]}` : void 0;
|
|
22212
|
+
scan.calls++;
|
|
22213
|
+
if (!door) {
|
|
22214
|
+
unknown++;
|
|
22215
|
+
cnj(
|
|
22216
|
+
at,
|
|
22217
|
+
o,
|
|
22218
|
+
"is called here with its door named by an expression (not statically resolvable)"
|
|
22219
|
+
);
|
|
22220
|
+
continue;
|
|
22221
|
+
}
|
|
22222
|
+
reached++;
|
|
22223
|
+
onCall(at, o, door, cp[1] ? at.m.slice(cp[1][0], cp[1][1]) : "", via);
|
|
22224
|
+
continue;
|
|
22225
|
+
}
|
|
22226
|
+
const h = handOff(at, o, len, files);
|
|
22227
|
+
if (h !== void 0) {
|
|
22228
|
+
if (typeof h === "string") {
|
|
22229
|
+
unknown++;
|
|
22230
|
+
cnj(at, o, h);
|
|
22231
|
+
} else queue.push(h);
|
|
22232
|
+
continue;
|
|
22233
|
+
}
|
|
22234
|
+
unknown++;
|
|
22235
|
+
cnj(at, o, "is used here in a form this scan does not follow");
|
|
22236
|
+
}
|
|
22237
|
+
if (segs.length === 2) {
|
|
22238
|
+
for (const occ of at.m.matchAll(
|
|
22239
|
+
new RegExp(`(?<![\\w$.])${esc5(segs[0])}(?![\\w$])(?!\\s*\\.)`, "g")
|
|
22240
|
+
)) {
|
|
22241
|
+
const pre = at.m.slice(Math.max(0, occ.index - 60), occ.index);
|
|
22242
|
+
const after = at.m.slice(occ.index + segs[0].length, occ.index + segs[0].length + 40);
|
|
22243
|
+
if (!(/[(,]\s*$/.test(pre) && /^\s*[,)]/.test(after))) continue;
|
|
22244
|
+
const call = enclosingCall(at.m, occ.index);
|
|
22245
|
+
const param = call ? paramOf(call.callee, call.index, files) : void 0;
|
|
22246
|
+
if (!call) continue;
|
|
22247
|
+
if (!param) {
|
|
22248
|
+
unknown++;
|
|
22249
|
+
cnj(
|
|
22250
|
+
at,
|
|
22251
|
+
occ.index,
|
|
22252
|
+
`travels in ${segs[0]}, handed to ${call.callee}, whose definition is not in the scanned tree`
|
|
22253
|
+
);
|
|
22254
|
+
continue;
|
|
22255
|
+
}
|
|
22256
|
+
const next = paramItem(param, segs[1], call.callee);
|
|
22257
|
+
if (typeof next === "string") {
|
|
22258
|
+
unknown++;
|
|
22259
|
+
cnj(at, occ.index, next);
|
|
22260
|
+
} else queue.push(next);
|
|
22261
|
+
}
|
|
22262
|
+
}
|
|
22263
|
+
}
|
|
22264
|
+
}
|
|
22265
|
+
if (reached === 0 && unknown === 0) cnj(fr, fn.open, "has no call site in the scanned tree");
|
|
22266
|
+
}
|
|
22267
|
+
}
|
|
22268
|
+
return { wrappers };
|
|
22269
|
+
}
|
|
21741
22270
|
function toolNameBefore(text, offset) {
|
|
21742
22271
|
const head = text.slice(0, offset);
|
|
21743
22272
|
const open = Math.max(head.lastIndexOf("defineTool("), head.lastIndexOf("registerTool("));
|
|
22273
|
+
const res = head.lastIndexOf("registerResource(");
|
|
22274
|
+
if (res > open) {
|
|
22275
|
+
const r = /registerResource\(\s*["'`]([^"'`]+)["'`]/.exec(head.slice(res));
|
|
22276
|
+
return { name: r ? `resource ${r[1]}` : "resource (unnamed)", start: res };
|
|
22277
|
+
}
|
|
21744
22278
|
if (open >= 0) {
|
|
21745
22279
|
const m = /^\s*"([a-z][a-z0-9_]*)",?\s*$/m.exec(head.slice(open));
|
|
21746
22280
|
if (m) return { name: m[1], start: open };
|
|
@@ -21765,10 +22299,127 @@ function scanS28(tree) {
|
|
|
21765
22299
|
const hit = ACTOR_SET_RE.exec(text);
|
|
21766
22300
|
if (hit) for (const s of hit[2].matchAll(/["'`]([\w/]+:[\w]+)["'`]/g)) actorDoors.add(s[1]);
|
|
21767
22301
|
}
|
|
22302
|
+
const judge2 = (text, m, at, door, argText2, tool, site) => {
|
|
22303
|
+
const region = m.slice(tool.start, at);
|
|
22304
|
+
const regionRaw = text.slice(tool.start, at);
|
|
22305
|
+
const guard = GUARD_RE.test(region) || GUARD_RE.test(regionRaw);
|
|
22306
|
+
let direct = CLAIM_TOKEN.test(argText2);
|
|
22307
|
+
let viaHelper;
|
|
22308
|
+
let virtual = argText2;
|
|
22309
|
+
const bare = /^\s*([A-Za-z_$][\w$]*)\s*$/.exec(argText2);
|
|
22310
|
+
if (bare && !direct) {
|
|
22311
|
+
const v = bare[1].replace(/\$/g, "\\$");
|
|
22312
|
+
const pieces = [];
|
|
22313
|
+
for (const a of region.matchAll(new RegExp(`Object\\.assign\\s*\\(\\s*${v}\\s*,`, "g"))) {
|
|
22314
|
+
const o = a.index + a[0].length - 1;
|
|
22315
|
+
const c = matchClose2(region, region.lastIndexOf("(", o));
|
|
22316
|
+
pieces.push(region.slice(o, c < 0 ? o + 400 : c));
|
|
22317
|
+
}
|
|
22318
|
+
for (const a of region.matchAll(new RegExp(`\\b${v}\\.verified(?:Org|Person|Actor)\\b`, "g")))
|
|
22319
|
+
pieces.push(a[0]);
|
|
22320
|
+
const decl = new RegExp(`\\b(?:const|let)\\s+${v}\\b[^=]*=\\s*\\{`).exec(region);
|
|
22321
|
+
if (decl) {
|
|
22322
|
+
const o = decl.index + decl[0].length - 1;
|
|
22323
|
+
const c = matchClose2(region, o);
|
|
22324
|
+
pieces.push(region.slice(o, c < 0 ? o + 600 : c + 1));
|
|
22325
|
+
}
|
|
22326
|
+
virtual = pieces.join("\n");
|
|
22327
|
+
direct = CLAIM_TOKEN.test(virtual);
|
|
22328
|
+
}
|
|
22329
|
+
if (!direct) {
|
|
22330
|
+
for (const sp of virtual.matchAll(/\.\.\.\s*([A-Za-z_$][\w$]*)/g)) {
|
|
22331
|
+
const h = readHelper(sp[1], files);
|
|
22332
|
+
if (h.forwards) {
|
|
22333
|
+
viaHelper = h;
|
|
22334
|
+
break;
|
|
22335
|
+
}
|
|
22336
|
+
}
|
|
22337
|
+
if (!viaHelper) {
|
|
22338
|
+
for (const sp of virtual.matchAll(/\b([A-Za-z_$][\w$]*)\s*\(\s*\)/g)) {
|
|
22339
|
+
const h = readHelper(sp[1], files);
|
|
22340
|
+
if (h.forwards) {
|
|
22341
|
+
viaHelper = h;
|
|
22342
|
+
break;
|
|
22343
|
+
}
|
|
22344
|
+
}
|
|
22345
|
+
}
|
|
22346
|
+
}
|
|
22347
|
+
if (direct) {
|
|
22348
|
+
scan.conform.push(site("forwards the verified claim in the call"));
|
|
22349
|
+
return;
|
|
22350
|
+
}
|
|
22351
|
+
if (viaHelper) {
|
|
22352
|
+
if (viaHelper.optional && !guard) {
|
|
22353
|
+
scan.violate.push(
|
|
22354
|
+
site(
|
|
22355
|
+
"forwards its claim through an optional helper (it returns {} when the bearer holds none) and no refusal precedes the call in the handler: a bearer with no resolvable organisation is sent claimless"
|
|
22356
|
+
)
|
|
22357
|
+
);
|
|
22358
|
+
} else {
|
|
22359
|
+
scan.conform.push(
|
|
22360
|
+
site(
|
|
22361
|
+
viaHelper.optional ? "forwards the verified claim through a helper and refuses before the call when it holds none" : "forwards the verified claim through a helper"
|
|
22362
|
+
)
|
|
22363
|
+
);
|
|
22364
|
+
}
|
|
22365
|
+
return;
|
|
22366
|
+
}
|
|
22367
|
+
if (!doors) {
|
|
22368
|
+
scan.cnj.push(
|
|
22369
|
+
site(
|
|
22370
|
+
"forwards no verified claim and no backend source was found above the scanned tree (no convex/ with a schema.ts, and no backend root given): whether the door is an exit cannot be read"
|
|
22371
|
+
)
|
|
22372
|
+
);
|
|
22373
|
+
return;
|
|
22374
|
+
}
|
|
22375
|
+
const info = doors.get(door);
|
|
22376
|
+
if (!info) {
|
|
22377
|
+
scan.cnj.push(
|
|
22378
|
+
site(
|
|
22379
|
+
`forwards no verified claim and the door ${door} is not defined in the supplied backend (${backendRoot})${unreadNote}`
|
|
22380
|
+
)
|
|
22381
|
+
);
|
|
22382
|
+
return;
|
|
22383
|
+
}
|
|
22384
|
+
if (info.exit) {
|
|
22385
|
+
scan.conform.push(site(`needs no claim: the door is ${info.exit}`));
|
|
22386
|
+
return;
|
|
22387
|
+
}
|
|
22388
|
+
if (!info.resolvesCaller) {
|
|
22389
|
+
scan.cnj.push(
|
|
22390
|
+
site(
|
|
22391
|
+
`forwards no verified claim and the door ${door} shows no caller resolution in its own source (its scope comes from a helper or a run call that this scan does not follow)`
|
|
22392
|
+
)
|
|
22393
|
+
);
|
|
22394
|
+
return;
|
|
22395
|
+
}
|
|
22396
|
+
const accepts = info.claims.length > 0 ? `the door accepts ${info.claims.join(", ")} and the tool omits it` : "the door accepts no claim argument, so R-54 must add one before the tool can forward it";
|
|
22397
|
+
const actorNote = actorDoors.has(door) ? "; verifiedActor is added by the wrapped client only for a bearer that resolved an agent, and a bearer that resolved no agent (a seat or person token, an org-level token) is sent claimless" : "";
|
|
22398
|
+
scan.violate.push(site(`forwards no verified claim \u2014 ${accepts}${actorNote}`));
|
|
22399
|
+
};
|
|
22400
|
+
const fetchers = readFetchers(files, scan, (fr, at, door, argText2, via) => {
|
|
22401
|
+
const tool = toolNameBefore(fr.text, at);
|
|
22402
|
+
const line = lineAt2(fr.text, at);
|
|
22403
|
+
const where = ` (through the fetcher ${via.name} injected at ${via.where}${via.label ? `, ${via.label}` : ""})`;
|
|
22404
|
+
const site = (note) => ({
|
|
22405
|
+
file: fr.f.rel,
|
|
22406
|
+
line,
|
|
22407
|
+
door,
|
|
22408
|
+
tool: tool.name ?? via.label,
|
|
22409
|
+
note: note + where
|
|
22410
|
+
});
|
|
22411
|
+
if (via.wrapperClaim) {
|
|
22412
|
+
scan.conform.push(
|
|
22413
|
+
site(`forwards the verified claim: the fetcher ${via.name} adds it to every call`)
|
|
22414
|
+
);
|
|
22415
|
+
return;
|
|
22416
|
+
}
|
|
22417
|
+
judge2(fr.text, fr.m, at, door, argText2, tool, site);
|
|
22418
|
+
});
|
|
21768
22419
|
for (const { f, text, m } of files) {
|
|
21769
22420
|
for (let hit = CALL_RE2.exec(m); hit; hit = CALL_RE2.exec(m)) {
|
|
21770
22421
|
const recv = hit[1];
|
|
21771
|
-
|
|
22422
|
+
const rcv = backendReceiver(m, recv, hit.index);
|
|
21772
22423
|
const open = hit.index + hit[0].length - 1;
|
|
21773
22424
|
const close = matchClose2(m, open);
|
|
21774
22425
|
if (close < 0) continue;
|
|
@@ -21791,113 +22442,30 @@ function scanS28(tree) {
|
|
|
21791
22442
|
tool: tool.name,
|
|
21792
22443
|
note
|
|
21793
22444
|
});
|
|
21794
|
-
if (
|
|
21795
|
-
|
|
21796
|
-
|
|
21797
|
-
|
|
21798
|
-
|
|
21799
|
-
);
|
|
21800
|
-
continue;
|
|
21801
|
-
}
|
|
21802
|
-
const argText2 = parts[1] ? m.slice(parts[1][0], parts[1][1]) : "";
|
|
21803
|
-
const region = m.slice(tool.start, hit.index);
|
|
21804
|
-
const regionRaw = text.slice(tool.start, hit.index);
|
|
21805
|
-
const guard = GUARD_RE.test(region) || GUARD_RE.test(regionRaw);
|
|
21806
|
-
let direct = CLAIM_TOKEN.test(argText2);
|
|
21807
|
-
let viaHelper;
|
|
21808
|
-
let virtual = argText2;
|
|
21809
|
-
const bare = /^\s*([A-Za-z_$][\w$]*)\s*$/.exec(argText2);
|
|
21810
|
-
if (bare && !direct) {
|
|
21811
|
-
const v = bare[1].replace(/\$/g, "\\$");
|
|
21812
|
-
const pieces = [];
|
|
21813
|
-
for (const a of region.matchAll(new RegExp(`Object\\.assign\\s*\\(\\s*${v}\\s*,`, "g"))) {
|
|
21814
|
-
const o = a.index + a[0].length - 1;
|
|
21815
|
-
const c = matchClose2(region, region.lastIndexOf("(", o));
|
|
21816
|
-
pieces.push(region.slice(o, c < 0 ? o + 400 : c));
|
|
21817
|
-
}
|
|
21818
|
-
for (const a of region.matchAll(
|
|
21819
|
-
new RegExp(`\\b${v}\\.verified(?:Org|Person|Actor)\\b`, "g")
|
|
21820
|
-
))
|
|
21821
|
-
pieces.push(a[0]);
|
|
21822
|
-
const decl = new RegExp(`\\b(?:const|let)\\s+${v}\\b[^=]*=\\s*\\{`).exec(region);
|
|
21823
|
-
if (decl) {
|
|
21824
|
-
const o = decl.index + decl[0].length - 1;
|
|
21825
|
-
const c = matchClose2(region, o);
|
|
21826
|
-
pieces.push(region.slice(o, c < 0 ? o + 600 : c + 1));
|
|
21827
|
-
}
|
|
21828
|
-
virtual = pieces.join("\n");
|
|
21829
|
-
direct = CLAIM_TOKEN.test(virtual);
|
|
21830
|
-
}
|
|
21831
|
-
if (!direct) {
|
|
21832
|
-
for (const sp of virtual.matchAll(/\.\.\.\s*([A-Za-z_$][\w$]*)/g)) {
|
|
21833
|
-
const h = readHelper(sp[1], files);
|
|
21834
|
-
if (h.forwards) {
|
|
21835
|
-
viaHelper = h;
|
|
21836
|
-
break;
|
|
21837
|
-
}
|
|
21838
|
-
}
|
|
21839
|
-
if (!viaHelper) {
|
|
21840
|
-
for (const sp of virtual.matchAll(/\b([A-Za-z_$][\w$]*)\s*\(\s*\)/g)) {
|
|
21841
|
-
const h = readHelper(sp[1], files);
|
|
21842
|
-
if (h.forwards) {
|
|
21843
|
-
viaHelper = h;
|
|
21844
|
-
break;
|
|
21845
|
-
}
|
|
21846
|
-
}
|
|
21847
|
-
}
|
|
21848
|
-
}
|
|
21849
|
-
if (direct) {
|
|
21850
|
-
scan.conform.push(site("forwards the verified claim in the call"));
|
|
21851
|
-
continue;
|
|
21852
|
-
}
|
|
21853
|
-
if (viaHelper) {
|
|
21854
|
-
if (viaHelper.optional && !guard) {
|
|
21855
|
-
scan.violate.push(
|
|
21856
|
-
site(
|
|
21857
|
-
"forwards its claim through an optional helper (it returns {} when the bearer holds none) and no refusal precedes the call in the handler: a bearer with no resolvable organisation is sent claimless"
|
|
21858
|
-
)
|
|
21859
|
-
);
|
|
21860
|
-
} else {
|
|
21861
|
-
scan.conform.push(
|
|
21862
|
-
site(
|
|
21863
|
-
viaHelper.optional ? "forwards the verified claim through a helper and refuses before the call when it holds none" : "forwards the verified claim through a helper"
|
|
21864
|
-
)
|
|
21865
|
-
);
|
|
21866
|
-
}
|
|
22445
|
+
if (fetchers.wrappers.has(`${f.rel}:${hit.index}`)) continue;
|
|
22446
|
+
if (rcv.kind === "unresolved") {
|
|
22447
|
+
if (door !== void 0 || importsConvex(m, text))
|
|
22448
|
+
scan.cnj.push(site(`the receiver is not resolved to a backend client \u2014 ${rcv.why}`));
|
|
22449
|
+
else scan.calls--;
|
|
21867
22450
|
continue;
|
|
21868
22451
|
}
|
|
21869
|
-
if (
|
|
21870
|
-
scan.cnj.push(
|
|
21871
|
-
site(
|
|
21872
|
-
"forwards no verified claim and no backend source was found above the scanned tree (no convex/ with a schema.ts, and no backend root given): whether the door is an exit cannot be read"
|
|
21873
|
-
)
|
|
21874
|
-
);
|
|
21875
|
-
continue;
|
|
21876
|
-
}
|
|
21877
|
-
const info = doors.get(door);
|
|
21878
|
-
if (!info) {
|
|
21879
|
-
scan.cnj.push(
|
|
21880
|
-
site(
|
|
21881
|
-
`forwards no verified claim and the door ${door} is not defined in the supplied backend (${backendRoot})${unreadNote}`
|
|
21882
|
-
)
|
|
21883
|
-
);
|
|
21884
|
-
continue;
|
|
21885
|
-
}
|
|
21886
|
-
if (info.exit) {
|
|
21887
|
-
scan.conform.push(site(`needs no claim: the door is ${info.exit}`));
|
|
21888
|
-
continue;
|
|
21889
|
-
}
|
|
21890
|
-
if (!info.resolvesCaller) {
|
|
22452
|
+
if (door === void 0) {
|
|
21891
22453
|
scan.cnj.push(
|
|
21892
22454
|
site(
|
|
21893
|
-
|
|
22455
|
+
"the door is named by an expression the scan cannot resolve (not statically resolvable)"
|
|
21894
22456
|
)
|
|
21895
22457
|
);
|
|
21896
22458
|
continue;
|
|
21897
22459
|
}
|
|
21898
|
-
|
|
21899
|
-
|
|
21900
|
-
|
|
22460
|
+
judge2(
|
|
22461
|
+
text,
|
|
22462
|
+
m,
|
|
22463
|
+
hit.index,
|
|
22464
|
+
door,
|
|
22465
|
+
parts[1] ? m.slice(parts[1][0], parts[1][1]) : "",
|
|
22466
|
+
tool,
|
|
22467
|
+
site
|
|
22468
|
+
);
|
|
21901
22469
|
}
|
|
21902
22470
|
}
|
|
21903
22471
|
return scan;
|
|
@@ -22338,7 +22906,7 @@ function blockEnd(m, at) {
|
|
|
22338
22906
|
return m.length;
|
|
22339
22907
|
}
|
|
22340
22908
|
var lineAt3 = (m, offset) => m.slice(0, offset).split("\n").length;
|
|
22341
|
-
var
|
|
22909
|
+
var esc6 = (s) => s.replace(/\$/g, "\\$");
|
|
22342
22910
|
function boundNames(m, callStart) {
|
|
22343
22911
|
const lineStart = m.lastIndexOf("\n", callStart - 1) + 1;
|
|
22344
22912
|
const before = m.slice(lineStart, callStart);
|
|
@@ -22423,7 +22991,7 @@ function rebound(m, names, from, to) {
|
|
|
22423
22991
|
for (const name of names) {
|
|
22424
22992
|
for (const hit of region.matchAll(
|
|
22425
22993
|
new RegExp(
|
|
22426
|
-
`\\b(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)\\s*(?::[^=]+)?=\\s*${
|
|
22994
|
+
`\\b(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)\\s*(?::[^=]+)?=\\s*${esc6(name)}\\s*(?:;|$)`,
|
|
22427
22995
|
"gm"
|
|
22428
22996
|
)
|
|
22429
22997
|
)) {
|
|
@@ -22436,7 +23004,7 @@ function narrowingsOver(m, names, from, to) {
|
|
|
22436
23004
|
const out = [];
|
|
22437
23005
|
const region = m.slice(from, to);
|
|
22438
23006
|
for (const name of names) {
|
|
22439
|
-
const n =
|
|
23007
|
+
const n = esc6(name);
|
|
22440
23008
|
for (const hit of region.matchAll(/\bscopeFilter(List|Get)\s*\(/g)) {
|
|
22441
23009
|
const open = from + (hit.index ?? 0) + hit[0].length - 1;
|
|
22442
23010
|
const close = matchClose3(m, open);
|
|
@@ -22483,8 +23051,8 @@ function scanS35(tree) {
|
|
|
22483
23051
|
const m = masked2(file);
|
|
22484
23052
|
const raw = file.lines.map((l) => l.raw).join("\n");
|
|
22485
23053
|
for (const hit of m.matchAll(CALL_RE3)) {
|
|
22486
|
-
if (!/convex|client/i.test(hit[1])) continue;
|
|
22487
23054
|
const start = hit.index ?? 0;
|
|
23055
|
+
const rcv = backendReceiver(m, hit[1], start);
|
|
22488
23056
|
const open = start + hit[0].length - 1;
|
|
22489
23057
|
const close = matchClose3(m, open);
|
|
22490
23058
|
if (close < 0) continue;
|
|
@@ -22496,6 +23064,15 @@ function scanS35(tree) {
|
|
|
22496
23064
|
const lit = new RegExp(String.raw`^\s*["'\x60]([\w/]+:[\w]+)["'\x60]${cast}`).exec(first);
|
|
22497
23065
|
const ref = new RegExp(String.raw`^\s*(?:api|internal)\.([\w]+)\.([\w]+)${cast}`).exec(first);
|
|
22498
23066
|
const door = lit ? lit[1] : ref ? `${ref[1]}:${ref[2]}` : void 0;
|
|
23067
|
+
if (rcv.kind === "unresolved") {
|
|
23068
|
+
if (door !== void 0 || importsConvex(m, raw))
|
|
23069
|
+
res.cnj.push({
|
|
23070
|
+
anchor,
|
|
23071
|
+
note: `${anchor}: the receiver is not resolved to a backend client \u2014 ${rcv.why}`
|
|
23072
|
+
});
|
|
23073
|
+
else res.calls--;
|
|
23074
|
+
continue;
|
|
23075
|
+
}
|
|
22499
23076
|
if (door === void 0) {
|
|
22500
23077
|
res.cnj.push({
|
|
22501
23078
|
anchor,
|
|
@@ -24823,6 +25400,383 @@ var s41LakeReader = {
|
|
|
24823
25400
|
}
|
|
24824
25401
|
};
|
|
24825
25402
|
|
|
25403
|
+
// src/detectors/s42-write-read-claims.ts
|
|
25404
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
25405
|
+
import { relative as relative14 } from "path";
|
|
25406
|
+
var ID3 = "S42 write-read-claims";
|
|
25407
|
+
var RULE3 = "S-42";
|
|
25408
|
+
var CLAIMS = ["verifiedOrg", "verifiedPerson", "verifiedActor", "seatOrgSlug"];
|
|
25409
|
+
var KEY_RE = new RegExp(`\\b(${CLAIMS.join("|")})\\s*\\??\\s*:`, "g");
|
|
25410
|
+
var CALL_RE4 = /\b([A-Za-z_$][\w$]*)\s*\.\s*(query|mutation|action)\s*\(/g;
|
|
25411
|
+
var ACTOR_SET_RE2 = /\bconst\s+(VERIFIED_\w*DOORS)\b[^=]*=\s*new\s+Set\s*(?:<[^>]*>)?\s*\(\s*\[([\s\S]*?)\]\s*\)/;
|
|
25412
|
+
function definitionText(name, files) {
|
|
25413
|
+
const esc7 = name.replace(/\$/g, "\\$");
|
|
25414
|
+
const re = new RegExp(`(?:\\b(?:const|let|var)\\s+${esc7}\\b[^=]*=|\\bfunction\\s+${esc7}\\b)`);
|
|
25415
|
+
for (const { m } of files) {
|
|
25416
|
+
const hit = re.exec(m);
|
|
25417
|
+
if (!hit) continue;
|
|
25418
|
+
let i = hit.index + hit[0].length;
|
|
25419
|
+
let depth = 0;
|
|
25420
|
+
for (; i < m.length; i++) {
|
|
25421
|
+
const c = m[i];
|
|
25422
|
+
if (c === "(" || c === "{" || c === "[") depth++;
|
|
25423
|
+
else if (c === ")" || c === "}" || c === "]") depth--;
|
|
25424
|
+
else if ((c === ";" || c === "\n") && depth <= 0 && i > hit.index + hit[0].length + 2) {
|
|
25425
|
+
if (c === ";" || /^\s*(?:const|let|var|function|export|\/\/|$)/.test(m.slice(i + 1, i + 40)))
|
|
25426
|
+
break;
|
|
25427
|
+
}
|
|
25428
|
+
if (depth < 0) break;
|
|
25429
|
+
}
|
|
25430
|
+
return m.slice(hit.index, i);
|
|
25431
|
+
}
|
|
25432
|
+
return void 0;
|
|
25433
|
+
}
|
|
25434
|
+
function helperClaims(name, files, seen = /* @__PURE__ */ new Set(), depth = 0) {
|
|
25435
|
+
if (seen.has(name) || depth > 3) return void 0;
|
|
25436
|
+
seen.add(name);
|
|
25437
|
+
const def = definitionText(name, files);
|
|
25438
|
+
if (def === void 0) return void 0;
|
|
25439
|
+
const keys = new Set([...def.matchAll(KEY_RE)].map((k) => k[1]));
|
|
25440
|
+
if (keys.size > 0) return keys;
|
|
25441
|
+
for (const r of def.matchAll(/(?:\breturn\s+|[:?]\s*|=>\s*)([A-Za-z_$][\w$]*)\s*\(/g)) {
|
|
25442
|
+
const sub = helperClaims(r[1], files, seen, depth + 1);
|
|
25443
|
+
if (sub && sub.size > 0) return sub;
|
|
25444
|
+
}
|
|
25445
|
+
return /\{\s*\}/.test(def) ? /* @__PURE__ */ new Set() : void 0;
|
|
25446
|
+
}
|
|
25447
|
+
function readDoorAccess(backendRoot, unread2) {
|
|
25448
|
+
const out = /* @__PURE__ */ new Map();
|
|
25449
|
+
for (const path of listTs(backendRoot, unread2)) {
|
|
25450
|
+
let text;
|
|
25451
|
+
try {
|
|
25452
|
+
text = readFileSync17(path, "utf8");
|
|
25453
|
+
} catch (err) {
|
|
25454
|
+
unread2.push(`${path} could not be read (${fsErrorCode(err)})`);
|
|
25455
|
+
continue;
|
|
25456
|
+
}
|
|
25457
|
+
const file = {
|
|
25458
|
+
path,
|
|
25459
|
+
rel: relative14(backendRoot, path),
|
|
25460
|
+
lines: text.split("\n").map((raw, i) => ({ n: i + 1, raw, comment: false }))
|
|
25461
|
+
};
|
|
25462
|
+
const m = masked(file);
|
|
25463
|
+
const module = relative14(backendRoot, path).replace(/\.ts$/, "").split("\\").join("/");
|
|
25464
|
+
const re = /\bexport\s+const\s+([A-Za-z_$][\w$]*)\s*=\s*(query|mutation|action|internalMutation|internalQuery)\s*\(/g;
|
|
25465
|
+
for (let hit = re.exec(m); hit; hit = re.exec(m)) {
|
|
25466
|
+
const open = hit.index + hit[0].length - 1;
|
|
25467
|
+
const close = matchClose2(m, open);
|
|
25468
|
+
if (close < 0) continue;
|
|
25469
|
+
const raw = text.slice(hit.index, close + 1);
|
|
25470
|
+
const argTables = /* @__PURE__ */ new Map();
|
|
25471
|
+
for (const a of raw.matchAll(/\b(\w+)\s*:\s*v\s*\.\s*id\s*\(\s*["'`](\w+)["'`]/g))
|
|
25472
|
+
argTables.set(a[1], a[2]);
|
|
25473
|
+
const acc = { writes: /* @__PURE__ */ new Set(), reads: /* @__PURE__ */ new Set() };
|
|
25474
|
+
const fnBodyRaw = (name) => {
|
|
25475
|
+
const r2 = new RegExp(
|
|
25476
|
+
`(?:\\bfunction\\s+${name}\\s*\\(|\\b(?:const|let)\\s+${name}\\s*=\\s*(?:async\\s*)?\\()`
|
|
25477
|
+
);
|
|
25478
|
+
const h2 = r2.exec(m);
|
|
25479
|
+
if (!h2) return void 0;
|
|
25480
|
+
const paren = h2.index + h2[0].length - 1;
|
|
25481
|
+
const pclose = matchClose2(m, paren);
|
|
25482
|
+
if (pclose < 0) return void 0;
|
|
25483
|
+
const o = m.indexOf("{", pclose);
|
|
25484
|
+
const c = o < 0 ? -1 : matchClose2(m, o);
|
|
25485
|
+
return c < 0 ? void 0 : text.slice(o, c + 1);
|
|
25486
|
+
};
|
|
25487
|
+
const walk3 = (body, seen, depth) => {
|
|
25488
|
+
for (const h of body.matchAll(/\bdb\s*\.\s*insert\s*\(\s*["'`](\w+)["'`]/g))
|
|
25489
|
+
acc.writes.add(h[1]);
|
|
25490
|
+
for (const h of body.matchAll(/\bdb\s*\.\s*query\s*\(\s*["'`](\w+)["'`]/g))
|
|
25491
|
+
acc.reads.add(h[1]);
|
|
25492
|
+
for (const h of body.matchAll(/\bdb\s*\.\s*get\s*\(\s*args\s*\.\s*(\w+)/g)) {
|
|
25493
|
+
const t = argTables.get(h[1]);
|
|
25494
|
+
if (t) acc.reads.add(t);
|
|
25495
|
+
}
|
|
25496
|
+
if (depth >= 3) return;
|
|
25497
|
+
for (const c of body.matchAll(/\b([A-Za-z_$][\w$]*)\s*\(/g)) {
|
|
25498
|
+
if (seen.has(c[1])) continue;
|
|
25499
|
+
seen.add(c[1]);
|
|
25500
|
+
const sub = fnBodyRaw(c[1]);
|
|
25501
|
+
if (sub) walk3(sub, seen, depth + 1);
|
|
25502
|
+
}
|
|
25503
|
+
};
|
|
25504
|
+
walk3(raw, /* @__PURE__ */ new Set([hit[1]]), 0);
|
|
25505
|
+
out.set(`${module}:${hit[1]}`, acc);
|
|
25506
|
+
}
|
|
25507
|
+
}
|
|
25508
|
+
return out;
|
|
25509
|
+
}
|
|
25510
|
+
function scanS42(tree) {
|
|
25511
|
+
const unread2 = [];
|
|
25512
|
+
const files = tree.files.map((f) => ({ f, text: rawText(f), m: masked(f) }));
|
|
25513
|
+
const actorDoors = /* @__PURE__ */ new Set();
|
|
25514
|
+
for (const { text } of files) {
|
|
25515
|
+
const hit = ACTOR_SET_RE2.exec(text);
|
|
25516
|
+
if (hit) for (const s of hit[2].matchAll(/["'`]([\w/]+:[\w]+)["'`]/g)) actorDoors.add(s[1]);
|
|
25517
|
+
}
|
|
25518
|
+
const calls = [];
|
|
25519
|
+
for (const { f, text, m } of files) {
|
|
25520
|
+
for (let hit = CALL_RE4.exec(m); hit; hit = CALL_RE4.exec(m)) {
|
|
25521
|
+
const rcv = backendReceiver(m, hit[1], hit.index);
|
|
25522
|
+
const open = hit.index + hit[0].length - 1;
|
|
25523
|
+
const close = matchClose2(m, open);
|
|
25524
|
+
if (close < 0) continue;
|
|
25525
|
+
const at = `${f.rel}:${lineAt2(text, hit.index)}`;
|
|
25526
|
+
const tool = toolNameBefore(text, hit.index).name ?? "(unnamed tool)";
|
|
25527
|
+
const parts = splitTop2(m, open + 1, close);
|
|
25528
|
+
const first = parts[0] ? text.slice(parts[0][0], parts[0][1]) : "";
|
|
25529
|
+
const lit = /^\s*["'`]([\w/]+:[\w]+)["'`]/.exec(first);
|
|
25530
|
+
const ref = /^\s*(?:api|internal)\.([\w]+)\.([\w]+)/.exec(first);
|
|
25531
|
+
const door = lit ? lit[1] : ref ? `${ref[1]}:${ref[2]}` : void 0;
|
|
25532
|
+
if (rcv.kind === "unresolved") {
|
|
25533
|
+
if (door !== void 0 || importsConvex(m, text))
|
|
25534
|
+
unread2.push({
|
|
25535
|
+
anchor: at,
|
|
25536
|
+
reason: `${tool}: the receiver is not resolved to a backend client \u2014 ${rcv.why} (${RULE3})`
|
|
25537
|
+
});
|
|
25538
|
+
continue;
|
|
25539
|
+
}
|
|
25540
|
+
if (door === void 0) {
|
|
25541
|
+
unread2.push({
|
|
25542
|
+
anchor: at,
|
|
25543
|
+
reason: `${tool}: a backend door named by an expression (${RULE3})`
|
|
25544
|
+
});
|
|
25545
|
+
continue;
|
|
25546
|
+
}
|
|
25547
|
+
const argMasked = parts[1] ? m.slice(parts[1][0], parts[1][1]) : "";
|
|
25548
|
+
const argRaw = parts[1] ? text.slice(parts[1][0], parts[1][1]) : "";
|
|
25549
|
+
const claims = new Set([...argMasked.matchAll(KEY_RE)].map((k) => k[1]));
|
|
25550
|
+
let keyed = false;
|
|
25551
|
+
let unresolved;
|
|
25552
|
+
for (const sp of argRaw.matchAll(
|
|
25553
|
+
/\.\.\.\s*([A-Za-z_$][\w$]*)\s*\(\s*(["'`]([\w/]+:[\w]+)["'`])?/g
|
|
25554
|
+
)) {
|
|
25555
|
+
if (sp[3] === door) {
|
|
25556
|
+
keyed = true;
|
|
25557
|
+
continue;
|
|
25558
|
+
}
|
|
25559
|
+
const h = helperClaims(sp[1], files);
|
|
25560
|
+
if (h === void 0) {
|
|
25561
|
+
unresolved = sp[1];
|
|
25562
|
+
continue;
|
|
25563
|
+
}
|
|
25564
|
+
for (const c of h) claims.add(c);
|
|
25565
|
+
}
|
|
25566
|
+
if (unresolved !== void 0) {
|
|
25567
|
+
unread2.push({
|
|
25568
|
+
anchor: at,
|
|
25569
|
+
reason: `${tool}: the claims spread by ${unresolved}(...) cannot be resolved (no definition with readable claim keys in the tree) (${RULE3})`
|
|
25570
|
+
});
|
|
25571
|
+
continue;
|
|
25572
|
+
}
|
|
25573
|
+
calls.push({ tool, door, at, claims, keyed });
|
|
25574
|
+
}
|
|
25575
|
+
}
|
|
25576
|
+
const backendRoot = tree.backendRoot ?? discoverBackend(tree.root);
|
|
25577
|
+
if (calls.length > 0 && !backendRoot)
|
|
25578
|
+
unread2.push({
|
|
25579
|
+
anchor: tree.root,
|
|
25580
|
+
reason: `no backend source found above the scanned tree, so no door's table can be read (${RULE3})`
|
|
25581
|
+
});
|
|
25582
|
+
const fsUnread = [];
|
|
25583
|
+
const access = backendRoot ? readDoorAccess(backendRoot, fsUnread) : /* @__PURE__ */ new Map();
|
|
25584
|
+
for (const u of fsUnread)
|
|
25585
|
+
unread2.push({ anchor: backendRoot ?? tree.root, reason: `${u} (${RULE3})` });
|
|
25586
|
+
return { calls, unread: unread2, backend: backendRoot, access };
|
|
25587
|
+
}
|
|
25588
|
+
function runStatic3(tree) {
|
|
25589
|
+
const { calls, unread: unread2, access } = scanS42(tree);
|
|
25590
|
+
if (calls.length === 0 && unread2.length === 0)
|
|
25591
|
+
return {
|
|
25592
|
+
id: ID3,
|
|
25593
|
+
anchor: tree.root,
|
|
25594
|
+
state: "absent",
|
|
25595
|
+
verdict: `no backend door call in the tree \u2014 ${RULE3} n/a`
|
|
25596
|
+
};
|
|
25597
|
+
const writesOf = /* @__PURE__ */ new Map();
|
|
25598
|
+
const readsOf = /* @__PURE__ */ new Map();
|
|
25599
|
+
for (const c of calls) {
|
|
25600
|
+
const a = access.get(c.door);
|
|
25601
|
+
if (!a) {
|
|
25602
|
+
if (c.claims.size > 0 || c.keyed)
|
|
25603
|
+
unread2.push({
|
|
25604
|
+
anchor: c.at,
|
|
25605
|
+
reason: `${c.tool}: door ${c.door} is not defined in the backend read (${RULE3})`
|
|
25606
|
+
});
|
|
25607
|
+
continue;
|
|
25608
|
+
}
|
|
25609
|
+
for (const t of a.writes) writesOf.set(t, [...writesOf.get(t) ?? [], c]);
|
|
25610
|
+
for (const t of a.reads) readsOf.set(t, [...readsOf.get(t) ?? [], c]);
|
|
25611
|
+
}
|
|
25612
|
+
const red = [];
|
|
25613
|
+
const keyedTables = [];
|
|
25614
|
+
let compared = 0;
|
|
25615
|
+
for (const [table, writers] of writesOf) {
|
|
25616
|
+
const readers = readsOf.get(table) ?? [];
|
|
25617
|
+
if (readers.length === 0) continue;
|
|
25618
|
+
compared++;
|
|
25619
|
+
if ([...writers, ...readers].every((c) => c.keyed)) {
|
|
25620
|
+
keyedTables.push(table);
|
|
25621
|
+
continue;
|
|
25622
|
+
}
|
|
25623
|
+
for (const w of writers) {
|
|
25624
|
+
if (w.keyed) continue;
|
|
25625
|
+
for (const r of readers) {
|
|
25626
|
+
if (r.keyed) continue;
|
|
25627
|
+
const missing = [...r.claims].filter((c) => !w.claims.has(c));
|
|
25628
|
+
if (missing.length > 0)
|
|
25629
|
+
red.push(
|
|
25630
|
+
`${w.tool} (${w.door}, ${w.at}) writes ${table} without ${missing.join(", ")}, which ${r.tool} (${r.door}) forwards to read it`
|
|
25631
|
+
);
|
|
25632
|
+
}
|
|
25633
|
+
}
|
|
25634
|
+
}
|
|
25635
|
+
const decided = red.length > 0 ? {
|
|
25636
|
+
id: ID3,
|
|
25637
|
+
anchor: red[0].slice(red[0].indexOf("(") + 1).split(", ")[1]?.replace(")", "") ?? tree.root,
|
|
25638
|
+
state: "non-conforming",
|
|
25639
|
+
verdict: `${red.length} write/read claim mismatch(es): a row written without a claim its reads forward is stored where those reads cannot return it (${RULE3}): ${red.join("; ")}.`
|
|
25640
|
+
} : {
|
|
25641
|
+
id: ID3,
|
|
25642
|
+
anchor: tree.root,
|
|
25643
|
+
state: "present",
|
|
25644
|
+
verdict: `${compared} table(s) with both a write and a read tool compared: every write forwards the claims its reads forward${keyedTables.length > 0 ? `; resolved by one helper keyed by the door on ${keyedTables.join(", ")}` : ""} (${RULE3}).`
|
|
25645
|
+
};
|
|
25646
|
+
return settle(ID3, decided, unread2);
|
|
25647
|
+
}
|
|
25648
|
+
var s42WriteReadClaims = {
|
|
25649
|
+
id: ID3,
|
|
25650
|
+
rule: RULE3,
|
|
25651
|
+
pin: STANDARD_PIN,
|
|
25652
|
+
run: runStatic3
|
|
25653
|
+
};
|
|
25654
|
+
|
|
25655
|
+
// src/detectors/s44-closed-output.ts
|
|
25656
|
+
var ID4 = "S44 closed-output";
|
|
25657
|
+
var RULE4 = "S-44";
|
|
25658
|
+
function judge(sites, j) {
|
|
25659
|
+
for (const s of sites) {
|
|
25660
|
+
if (s.kind === "unread")
|
|
25661
|
+
j.unread.push({ anchor: s.anchor, reason: `${s.path}: ${s.form} (${RULE4})` });
|
|
25662
|
+
else if (s.exempt) j.exempt.push(s);
|
|
25663
|
+
else j.violations.push(s);
|
|
25664
|
+
}
|
|
25665
|
+
}
|
|
25666
|
+
function verdictOf2(j, scope, anchorFallback) {
|
|
25667
|
+
const ex = j.exempt.length > 0 ? ` Exempted (${j.exempt.length}): ${j.exempt.map((e) => `${e.path} (${e.anchor}) \u2014 "${e.exempt}"`).join("; ")}.` : "";
|
|
25668
|
+
if (j.withOutput === 0 && j.unread.length === 0)
|
|
25669
|
+
return {
|
|
25670
|
+
id: ID4,
|
|
25671
|
+
anchor: anchorFallback,
|
|
25672
|
+
state: "absent",
|
|
25673
|
+
verdict: `${j.toolCount} tool(s) read (${scope}), none declares an output schema \u2014 ${RULE4} n/a`
|
|
25674
|
+
};
|
|
25675
|
+
const decided = j.violations.length > 0 ? {
|
|
25676
|
+
id: ID4,
|
|
25677
|
+
anchor: j.violations[0].anchor,
|
|
25678
|
+
state: "non-conforming",
|
|
25679
|
+
verdict: `${j.violations.length} closed object(s) in the output schemas of ${j.withOutput} tool(s): each refuses a field added later, which breaks every client connected before the release (${RULE4}): ${j.violations.map((v) => `${v.path} (${v.form}, ${v.anchor})`).join(", ")}.${ex}`
|
|
25680
|
+
} : {
|
|
25681
|
+
id: ID4,
|
|
25682
|
+
anchor: anchorFallback,
|
|
25683
|
+
state: "present",
|
|
25684
|
+
verdict: `${j.withOutput} output schema(s) read (${scope}): no object refuses an added field (${RULE4}).${ex}`
|
|
25685
|
+
};
|
|
25686
|
+
return settle(ID4, decided, j.unread);
|
|
25687
|
+
}
|
|
25688
|
+
function s44Controls() {
|
|
25689
|
+
const red = closedServedSites(
|
|
25690
|
+
{ type: "object", properties: { a: { type: "string" } }, additionalProperties: false },
|
|
25691
|
+
"c",
|
|
25692
|
+
"<s44-control>"
|
|
25693
|
+
);
|
|
25694
|
+
const green = closedServedSites(
|
|
25695
|
+
{ type: "object", properties: { a: { type: "object", properties: {} } } },
|
|
25696
|
+
"c",
|
|
25697
|
+
"<s44-control>"
|
|
25698
|
+
);
|
|
25699
|
+
return {
|
|
25700
|
+
sees: red.length === 1 && red[0].kind === "violation" && red[0].path === "c",
|
|
25701
|
+
spares: green.length === 0
|
|
25702
|
+
};
|
|
25703
|
+
}
|
|
25704
|
+
function runStatic4(tree) {
|
|
25705
|
+
const controls = s44Controls();
|
|
25706
|
+
if (!controls.sees || !controls.spares)
|
|
25707
|
+
throw new Error(
|
|
25708
|
+
`S44 positive control FAILED: sees=${controls.sees} spares=${controls.spares} \u2014 reader broken, verdict untrustworthy`
|
|
25709
|
+
);
|
|
25710
|
+
const inProduct = (a) => isProductSource(a.slice(0, a.lastIndexOf(":")));
|
|
25711
|
+
const tools = findRegisteredTools(tree).filter((t) => inProduct(t.anchor));
|
|
25712
|
+
const unresolved = findUnresolvedToolSites(tree).filter(inProduct);
|
|
25713
|
+
if (tools.length === 0) {
|
|
25714
|
+
const surface = toolSurfaceAnchor(tree);
|
|
25715
|
+
if (surface || unresolved.length > 0) {
|
|
25716
|
+
const reason = noToolsLocatedReason(tree, `no output schema could be read (${RULE4})`);
|
|
25717
|
+
return couldNotJudge(
|
|
25718
|
+
ID4,
|
|
25719
|
+
surface ?? unresolved[0],
|
|
25720
|
+
unresolved.length > 0 ? `${reason}; unresolved registration site(s): ${unresolved.join(", ")}` : reason
|
|
25721
|
+
);
|
|
25722
|
+
}
|
|
25723
|
+
return {
|
|
25724
|
+
id: ID4,
|
|
25725
|
+
anchor: tree.root,
|
|
25726
|
+
state: "absent",
|
|
25727
|
+
verdict: `no MCP tool registered in product source \u2014 ${RULE4} n/a`
|
|
25728
|
+
};
|
|
25729
|
+
}
|
|
25730
|
+
const j = {
|
|
25731
|
+
violations: [],
|
|
25732
|
+
exempt: [],
|
|
25733
|
+
unread: [],
|
|
25734
|
+
toolCount: tools.length,
|
|
25735
|
+
withOutput: 0
|
|
25736
|
+
};
|
|
25737
|
+
for (const a of unresolved)
|
|
25738
|
+
j.unread.push({
|
|
25739
|
+
anchor: a,
|
|
25740
|
+
reason: `a tool registered here has a name the scan cannot resolve, so its output schema is unread (${RULE4})`
|
|
25741
|
+
});
|
|
25742
|
+
for (const tool of tools) {
|
|
25743
|
+
const read = closedOutputSites(tree, tool.name, tool.anchor);
|
|
25744
|
+
if (read.kind === "none") continue;
|
|
25745
|
+
j.withOutput++;
|
|
25746
|
+
judge(read.sites, j);
|
|
25747
|
+
}
|
|
25748
|
+
return verdictOf2(j, "static, from source", tools[0].anchor);
|
|
25749
|
+
}
|
|
25750
|
+
function runServedHalf2(runtime) {
|
|
25751
|
+
const anchor = `${runtime.root} (served)`;
|
|
25752
|
+
if (runtime.launchError)
|
|
25753
|
+
return couldNotJudge(
|
|
25754
|
+
ID4,
|
|
25755
|
+
anchor,
|
|
25756
|
+
`the server could not be started/introspected, so no served outputSchema was read: ${runtime.launchError} (${RULE4})`
|
|
25757
|
+
);
|
|
25758
|
+
const j = {
|
|
25759
|
+
violations: [],
|
|
25760
|
+
exempt: [],
|
|
25761
|
+
unread: [],
|
|
25762
|
+
toolCount: runtime.tools.length,
|
|
25763
|
+
withOutput: 0
|
|
25764
|
+
};
|
|
25765
|
+
for (const t of runtime.tools) {
|
|
25766
|
+
if (t.outputSchema === void 0) continue;
|
|
25767
|
+
j.withOutput++;
|
|
25768
|
+
judge(closedServedSites(t.outputSchema, t.name, `${anchor} tools/list ${t.name}`), j);
|
|
25769
|
+
}
|
|
25770
|
+
return verdictOf2(j, "served tools/list outputSchema", anchor);
|
|
25771
|
+
}
|
|
25772
|
+
var s44ClosedOutput = {
|
|
25773
|
+
id: ID4,
|
|
25774
|
+
rule: RULE4,
|
|
25775
|
+
pin: STANDARD_PIN,
|
|
25776
|
+
run: runStatic4,
|
|
25777
|
+
runServed: (runtime) => runServedHalf2(runtime)
|
|
25778
|
+
};
|
|
25779
|
+
|
|
24826
25780
|
// src/detectors/index.ts
|
|
24827
25781
|
var registered = [
|
|
24828
25782
|
d2,
|
|
@@ -24857,6 +25811,7 @@ var registered = [
|
|
|
24857
25811
|
c25BuildIdentity,
|
|
24858
25812
|
c26SubpackageLockfile,
|
|
24859
25813
|
c31PluginInstallable,
|
|
25814
|
+
c36ReadmeNpmLimit,
|
|
24860
25815
|
s5AuthzElements,
|
|
24861
25816
|
s29EventsDeclared,
|
|
24862
25817
|
s30EventDescriptors,
|
|
@@ -24928,7 +25883,9 @@ var registered = [
|
|
|
24928
25883
|
s39UpstreamError,
|
|
24929
25884
|
s40UpstreamRowsNarrowed,
|
|
24930
25885
|
s41LakeReader,
|
|
25886
|
+
s42WriteReadClaims,
|
|
24931
25887
|
s43UnionInput,
|
|
25888
|
+
s44ClosedOutput,
|
|
24932
25889
|
e5ExtensionIsolation,
|
|
24933
25890
|
a3SandboxRespected,
|
|
24934
25891
|
a4WcagGate,
|
|
@@ -24962,7 +25919,9 @@ var READS_CODE = /* @__PURE__ */ new Set([
|
|
|
24962
25919
|
"S-39",
|
|
24963
25920
|
"S-40",
|
|
24964
25921
|
"S-41",
|
|
25922
|
+
"S-42",
|
|
24965
25923
|
"S-43",
|
|
25924
|
+
"S-44",
|
|
24966
25925
|
"E-5",
|
|
24967
25926
|
"A-3"
|
|
24968
25927
|
]);
|
|
@@ -24972,8 +25931,8 @@ var detectors = registered.map(
|
|
|
24972
25931
|
|
|
24973
25932
|
// src/runtime/launch.ts
|
|
24974
25933
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
24975
|
-
import { existsSync as existsSync23, readFileSync as
|
|
24976
|
-
import { dirname as dirname17, isAbsolute, join as
|
|
25934
|
+
import { existsSync as existsSync23, readFileSync as readFileSync18, statSync as statSync21 } from "fs";
|
|
25935
|
+
import { dirname as dirname17, isAbsolute, join as join29, resolve as resolve3 } from "path";
|
|
24977
25936
|
function findPackageDir(target) {
|
|
24978
25937
|
let dir;
|
|
24979
25938
|
try {
|
|
@@ -24982,7 +25941,7 @@ function findPackageDir(target) {
|
|
|
24982
25941
|
return null;
|
|
24983
25942
|
}
|
|
24984
25943
|
for (let depth = 0; depth < 8; depth++) {
|
|
24985
|
-
if (existsSync23(
|
|
25944
|
+
if (existsSync23(join29(dir, "package.json"))) return dir;
|
|
24986
25945
|
const parent = dirname17(dir);
|
|
24987
25946
|
if (parent === dir) break;
|
|
24988
25947
|
dir = parent;
|
|
@@ -25007,13 +25966,13 @@ function deriveLaunchPlan(target) {
|
|
|
25007
25966
|
}
|
|
25008
25967
|
let pkg;
|
|
25009
25968
|
try {
|
|
25010
|
-
if (!statSync21(
|
|
25011
|
-
return { error: `${
|
|
25969
|
+
if (!statSync21(join29(pkgDir, "package.json")).isFile()) {
|
|
25970
|
+
return { error: `${join29(pkgDir, "package.json")} is not a regular file \u2014 not read` };
|
|
25012
25971
|
}
|
|
25013
|
-
pkg = JSON.parse(
|
|
25972
|
+
pkg = JSON.parse(readFileSync18(join29(pkgDir, "package.json"), "utf8"));
|
|
25014
25973
|
} catch (err) {
|
|
25015
25974
|
return {
|
|
25016
|
-
error: `could not parse ${
|
|
25975
|
+
error: `could not parse ${join29(pkgDir, "package.json")}: ${err instanceof Error ? err.message : String(err)}`
|
|
25017
25976
|
};
|
|
25018
25977
|
}
|
|
25019
25978
|
const bin = firstBinEntry(pkg.bin);
|
|
@@ -25333,7 +26292,7 @@ const onMessage = (msg) => {
|
|
|
25333
26292
|
const props = schemaOf(t).properties;
|
|
25334
26293
|
return Boolean(props && typeof props === "object" && Object.prototype.hasOwnProperty.call(props, "cursor"));
|
|
25335
26294
|
};
|
|
25336
|
-
tools = served.map((t) => ({ name: String(t && t.name), description: t && typeof t.description === "string" ? t.description : undefined, cursorArgument: takesCursor(t), inputSchema: t && t.inputSchema && typeof t.inputSchema === "object" && !Array.isArray(t.inputSchema) ? t.inputSchema : undefined }));
|
|
26295
|
+
tools = served.map((t) => ({ name: String(t && t.name), description: t && typeof t.description === "string" ? t.description : undefined, cursorArgument: takesCursor(t), inputSchema: t && t.inputSchema && typeof t.inputSchema === "object" && !Array.isArray(t.inputSchema) ? t.inputSchema : undefined, outputSchema: t && t.outputSchema && typeof t.outputSchema === "object" && !Array.isArray(t.outputSchema) ? t.outputSchema : undefined }));
|
|
25337
26296
|
const methods = ["tools/list"];
|
|
25338
26297
|
if (capabilities.resources) methods.push("resources/list", "resources/templates/list");
|
|
25339
26298
|
if (capabilities.prompts) methods.push("prompts/list");
|
|
@@ -25461,14 +26420,14 @@ function readEvalCounts(target) {
|
|
|
25461
26420
|
if (!pkgDir) return { counts };
|
|
25462
26421
|
let dir = pkgDir;
|
|
25463
26422
|
for (let depth = 0; depth < 8; depth++) {
|
|
25464
|
-
const candidate =
|
|
26423
|
+
const candidate = join29(dir, "evals", "evals.json");
|
|
25465
26424
|
if (existsSync23(candidate)) {
|
|
25466
26425
|
let text;
|
|
25467
26426
|
try {
|
|
25468
26427
|
if (!statSync21(candidate).isFile()) {
|
|
25469
26428
|
return { counts, unreadable: `${candidate} is not a regular file \u2014 not read` };
|
|
25470
26429
|
}
|
|
25471
|
-
text =
|
|
26430
|
+
text = readFileSync18(candidate, "utf8");
|
|
25472
26431
|
} catch (err) {
|
|
25473
26432
|
return {
|
|
25474
26433
|
counts,
|
|
@@ -25638,7 +26597,8 @@ function introspect(plan, root, evalSource, expectedCommit, evalsNote, secrets)
|
|
|
25638
26597
|
const count = evals.counts.get(name);
|
|
25639
26598
|
const base = t.description ? { name, description: t.description } : { name };
|
|
25640
26599
|
const withCursor = t.cursorArgument === true ? { ...base, cursorArgument: true } : base;
|
|
25641
|
-
const
|
|
26600
|
+
const withInput = t.inputSchema ? { ...withCursor, inputSchema: t.inputSchema } : withCursor;
|
|
26601
|
+
const withSchema = t.outputSchema ? { ...withInput, outputSchema: t.outputSchema } : withInput;
|
|
25642
26602
|
return count === void 0 ? withSchema : { ...withSchema, evalCaseCount: count };
|
|
25643
26603
|
});
|
|
25644
26604
|
return {
|
|
@@ -26098,7 +27058,7 @@ var USAGE = [
|
|
|
26098
27058
|
function readVersion() {
|
|
26099
27059
|
try {
|
|
26100
27060
|
const here = dirname18(fileURLToPath2(import.meta.url));
|
|
26101
|
-
const manifest = JSON.parse(
|
|
27061
|
+
const manifest = JSON.parse(readFileSync19(join30(here, "..", "package.json"), "utf8"));
|
|
26102
27062
|
return manifest.version ?? null;
|
|
26103
27063
|
} catch {
|
|
26104
27064
|
return null;
|