@vantageos/mcp-doctor 0.11.2 → 0.12.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 +50 -0
- package/dist/doctor.js +483 -36
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,56 @@
|
|
|
3
3
|
All notable changes to `@vantageos/mcp-doctor` are documented here.
|
|
4
4
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## 0.12.0 — 2026-10-31
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
- **C-11 judges list and search tools only, and names every failing one.** The paginable domain is
|
|
10
|
+
mcp-standard §3 item 4 ("every list and every search"): a tool whose DECLARED verb is `list` or
|
|
11
|
+
`search` (the closed set C-9 reads, `VERB_SET`, now exported); a tool with no declared verb is
|
|
12
|
+
placed by its name prefix (`list`/`search`), so a get-by-id (`get_memory`, `get_activity`) is no
|
|
13
|
+
longer accused, and a search named otherwise (`find_party`, verb `search`) is now judged. A
|
|
14
|
+
declared verb outside the closed set is could-not-judge naming the tool and the verb. The verdict
|
|
15
|
+
names every failing tool with its anchor and missing components (`N of M`), not only the first.
|
|
16
|
+
Rule unchanged: C-11 requires the DECLARATION (cursor, default, finite max) — a tool that pages
|
|
17
|
+
without declaring stays non-conforming. Measured: vantage-memory `mcp-server` @ abe13c35 — 0.11.2
|
|
18
|
+
one site (`get_memory`), now 24 of 24 list/search tools named, no `get_*`; vantageos-crm
|
|
19
|
+
`mcp-server` @ 6ae8b07 — 0.11.2 one site (`get_activity`), now 35 of 35.
|
|
20
|
+
- **S-27 reads the value written into `resultType`, not a text shape.** The MRTR round is a
|
|
21
|
+
`resultType` field written (key, quoted key, shorthand, member or bracket assignment; never a
|
|
22
|
+
type member) whose value is the string `"input_required"` — a literal, or an identifier bound by
|
|
23
|
+
a same-file `const`. A conditional, a call, a member access, a template with a substitution or an
|
|
24
|
+
unbound identifier is could-not-judge naming the site, where it previously read as absent.
|
|
25
|
+
- **`extensions: NAME` is read.** An `extensions` / `experimental` key of an object value whose
|
|
26
|
+
value is an identifier resolves the `const NAME = { ... }` it names and reads its keys; a name
|
|
27
|
+
that does not resolve (an import, a parameter) is unread, naming the identifier and the site.
|
|
28
|
+
It was previously skipped in silence.
|
|
29
|
+
- **D7 binds a hand-rolled result to an object a function RETURNS.** A `resultType` / `ttlMs` /
|
|
30
|
+
`cacheScope` write counts only in an object that is returned (`return {..}`, `=> ({..})`,
|
|
31
|
+
nested in a returned object, or a const whose name is returned). A `{ resultType }` literal
|
|
32
|
+
printed, passed to a call or never returned no longer reads non-conforming; a position the
|
|
33
|
+
reader cannot place (a conditional or logical operand) is could-not-judge. Declared limit: an
|
|
34
|
+
object reaching the return through a call or a second variable reads as not returned, and the
|
|
35
|
+
returning function is not proven to be a registered tool handler.
|
|
36
|
+
- **Computed keys are read, or named unread.** `["resultType"]: v`, `` [`resultType`]: v `` and
|
|
37
|
+
`[NAME]: v` (NAME a same-file `const NAME = "<string>"`) are writes of that field, like the plain
|
|
38
|
+
key, for S-27, D7 and every reader of `fieldWrites`. Any other computed key (`[k]`, `[a.b]`,
|
|
39
|
+
`[a + b]`, a template with a substitution) is decided by the value written, never by the key
|
|
40
|
+
alone: S-27 reads it could-not-judge, naming the site, only when its value is
|
|
41
|
+
`"input_required"`; D7 only inside a returned object that already carries `content`,
|
|
42
|
+
`structuredContent` or `resultType`. A map keyed by data (`{ [entry.env]: raw }`) stays ordinary
|
|
43
|
+
code. D3, D4 and the skills surface do not read these keys (declared at their call sites).
|
|
44
|
+
- **S-22 reads an Origin allow-list declared as configuration.** A server that declares its allow-list
|
|
45
|
+
through the declared-variables mechanism (`defineVariables({ allowedOrigins: { env: "MCP_ALLOWED_ORIGINS",
|
|
46
|
+
type: "originList", default: [] } })`) and refuses an unlisted Origin with 403 read `could-not-judge`
|
|
47
|
+
("allowedOrigins is given by `{`"). The declaration, and a member read of the loaded settings that reaches it
|
|
48
|
+
(`allowedOrigins: settings.allowedOrigins`), are now judged by their `type` and `default`: `originList` with a
|
|
49
|
+
literal default free of `*` conforms (`[]` refuses every browser origin); a `*` in the default is
|
|
50
|
+
`non-conforming` whatever the type; a default that is not a literal, an unknown type, or a type other than
|
|
51
|
+
`originList` is `could-not-judge`, naming it. A direct `process.env.X` read is `could-not-judge`, naming the
|
|
52
|
+
variable. A declared list conforms only with what enforces it (a 403 on the Origin read, or the SDK
|
|
53
|
+
protection); with neither the row stays `non-conforming`. A 403 refusal whose call spans more than six lines
|
|
54
|
+
after the Origin read (the boilerplate's `return c.json({ … }, 403)`) is read to the end of that statement.
|
|
55
|
+
|
|
6
56
|
## 0.11.2 — 2026-10-29
|
|
7
57
|
|
|
8
58
|
Patch: static readers that judged natural TypeScript by an identifier's name or missed a
|
package/dist/doctor.js
CHANGED
|
@@ -1827,9 +1827,9 @@ function resolveNameBindings(tree) {
|
|
|
1827
1827
|
if (braceDepth <= 0) trackingObject = null;
|
|
1828
1828
|
continue;
|
|
1829
1829
|
}
|
|
1830
|
-
const
|
|
1831
|
-
if (
|
|
1832
|
-
bindings.set(
|
|
1830
|
+
const constString2 = raw.match(CONST_STRING_RE);
|
|
1831
|
+
if (constString2) {
|
|
1832
|
+
bindings.set(constString2[1], constString2[2]);
|
|
1833
1833
|
continue;
|
|
1834
1834
|
}
|
|
1835
1835
|
const objOpen = raw.match(CONST_OBJECT_OPEN_RE);
|
|
@@ -3706,6 +3706,13 @@ function unwrapValue(file, line, col) {
|
|
|
3706
3706
|
}
|
|
3707
3707
|
return { kind: "ident", name: id[0], wrappers: [...wrappers, ...suffix.wrappers] };
|
|
3708
3708
|
}
|
|
3709
|
+
function computedValueAt(file, line, col) {
|
|
3710
|
+
const rows = uncommentedLines(file);
|
|
3711
|
+
const end = afterClose(file, { line, col }, "[", "]");
|
|
3712
|
+
const c = end ? nextCode(file, end.line, end.col, 1) : null;
|
|
3713
|
+
if (!c || rows[c.line - 1][c.col] !== ":") return null;
|
|
3714
|
+
return { line: c.line, col: c.col + 1 };
|
|
3715
|
+
}
|
|
3709
3716
|
function prevCodeText(file, line, col) {
|
|
3710
3717
|
return textBefore(file, line, col, 200).trimEnd();
|
|
3711
3718
|
}
|
|
@@ -3715,7 +3722,15 @@ function keyInBrace(file, line, col, name, form, out) {
|
|
|
3715
3722
|
if (!enc || enc.ch !== "{") return;
|
|
3716
3723
|
const ctx = braceContext(file, enc.line, enc.col);
|
|
3717
3724
|
if (ctx.kind === "value") {
|
|
3718
|
-
out.writes.push({
|
|
3725
|
+
out.writes.push({
|
|
3726
|
+
name,
|
|
3727
|
+
form,
|
|
3728
|
+
file,
|
|
3729
|
+
line,
|
|
3730
|
+
col,
|
|
3731
|
+
anchor,
|
|
3732
|
+
object: { line: enc.line, col: enc.col }
|
|
3733
|
+
});
|
|
3719
3734
|
} else if (ctx.kind === "unread") {
|
|
3720
3735
|
out.unread.push({
|
|
3721
3736
|
anchor,
|
|
@@ -3723,8 +3738,57 @@ function keyInBrace(file, line, col, name, form, out) {
|
|
|
3723
3738
|
});
|
|
3724
3739
|
}
|
|
3725
3740
|
}
|
|
3741
|
+
function symbolConst(file, name) {
|
|
3742
|
+
const re = new RegExp(
|
|
3743
|
+
`\\bconst\\s+${name.replace(/[$]/g, "\\$&")}\\b[^=\\n]*=(?![=>])\\s*Symbol\\s*(?:\\.\\s*for\\s*)?\\(`
|
|
3744
|
+
);
|
|
3745
|
+
return uncommentedLines(file).some((row) => re.test(row));
|
|
3746
|
+
}
|
|
3747
|
+
function computedKeys(file, lineNo, names, out) {
|
|
3748
|
+
const raw = file.lines[lineNo - 1].raw;
|
|
3749
|
+
for (let col = raw.indexOf("["); col >= 0; col = raw.indexOf("[", col + 1)) {
|
|
3750
|
+
if (!isCodeAt(file, lineNo, col)) continue;
|
|
3751
|
+
if (!/[{,]$/.test(prevCodeText(file, lineNo, col))) continue;
|
|
3752
|
+
const b = balancedBlock(file, lineNo, col, "[", "]");
|
|
3753
|
+
const end = afterClose(file, { line: lineNo, col }, "[", "]");
|
|
3754
|
+
if (!b || !end) continue;
|
|
3755
|
+
const nx = nextCode(file, end.line, end.col, 1);
|
|
3756
|
+
const after = nx ? restOfLine(file, nx) : "";
|
|
3757
|
+
if (!after.startsWith(":") || after.startsWith("::")) continue;
|
|
3758
|
+
const expr = b.text.slice(1, -1).trim();
|
|
3759
|
+
const lit = expr.match(/^(["'`])((?:\\.|(?!\1)[^\\])*)\1$/);
|
|
3760
|
+
const anchor = `${file.rel}:${lineNo}`;
|
|
3761
|
+
if (lit && !(lit[1] === "`" && lit[2].includes("${"))) {
|
|
3762
|
+
if (names.includes(lit[2])) keyInBrace(file, lineNo, col, lit[2], "computed-key", out);
|
|
3763
|
+
continue;
|
|
3764
|
+
}
|
|
3765
|
+
if (/^[A-Za-z_$][\w$]*$/.test(expr) && symbolConst(file, expr)) continue;
|
|
3766
|
+
if (/^[A-Za-z_$][\w$]*$/.test(expr)) {
|
|
3767
|
+
const bound = constString(file, expr);
|
|
3768
|
+
if (bound.kind === "value") {
|
|
3769
|
+
if (bound.value !== null && names.includes(bound.value)) {
|
|
3770
|
+
keyInBrace(file, lineNo, col, bound.value, "computed-key", out);
|
|
3771
|
+
}
|
|
3772
|
+
continue;
|
|
3773
|
+
}
|
|
3774
|
+
}
|
|
3775
|
+
const enc = enclosingOpener(file, lineNo, col);
|
|
3776
|
+
if (!enc || enc.ch !== "{") continue;
|
|
3777
|
+
const ctx = braceContext(file, enc.line, enc.col);
|
|
3778
|
+
if (ctx.kind === "value" || ctx.kind === "unread") {
|
|
3779
|
+
out.computed.push({
|
|
3780
|
+
expr,
|
|
3781
|
+
file,
|
|
3782
|
+
line: lineNo,
|
|
3783
|
+
col,
|
|
3784
|
+
anchor,
|
|
3785
|
+
object: { line: enc.line, col: enc.col }
|
|
3786
|
+
});
|
|
3787
|
+
}
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3726
3790
|
function fieldWrites(tree, names) {
|
|
3727
|
-
const out = { writes: [], unread: [] };
|
|
3791
|
+
const out = { writes: [], unread: [], computed: [] };
|
|
3728
3792
|
const alt = names.map((n) => n.replace(/[$]/g, "\\$&")).join("|");
|
|
3729
3793
|
const identRe = new RegExp(`(?<![\\w$])(${alt})(?![\\w$])`, "g");
|
|
3730
3794
|
const quotedRe = new RegExp(`(["'])(${alt})\\1`, "g");
|
|
@@ -3746,6 +3810,7 @@ function fieldWrites(tree, names) {
|
|
|
3746
3810
|
form: "member-assign",
|
|
3747
3811
|
file,
|
|
3748
3812
|
line: line.n,
|
|
3813
|
+
col,
|
|
3749
3814
|
anchor: `${file.rel}:${line.n}`,
|
|
3750
3815
|
base: base?.[1]
|
|
3751
3816
|
});
|
|
@@ -3760,6 +3825,7 @@ function fieldWrites(tree, names) {
|
|
|
3760
3825
|
keyInBrace(file, line.n, col, name, "shorthand", out);
|
|
3761
3826
|
}
|
|
3762
3827
|
}
|
|
3828
|
+
computedKeys(file, line.n, names, out);
|
|
3763
3829
|
for (const m of line.raw.matchAll(quotedRe)) {
|
|
3764
3830
|
const col = m.index ?? 0;
|
|
3765
3831
|
if (!isCodeAt(file, line.n, col)) continue;
|
|
@@ -3774,6 +3840,7 @@ function fieldWrites(tree, names) {
|
|
|
3774
3840
|
form: "bracket-assign",
|
|
3775
3841
|
file,
|
|
3776
3842
|
line: line.n,
|
|
3843
|
+
col,
|
|
3777
3844
|
anchor: `${file.rel}:${line.n}`,
|
|
3778
3845
|
base: base?.[1]
|
|
3779
3846
|
});
|
|
@@ -3807,6 +3874,8 @@ function objectMembers(file, p) {
|
|
|
3807
3874
|
}
|
|
3808
3875
|
const k = s.match(/^(?:["'`]([^"'`]+)["'`]|([A-Za-z_$][\w$]*))\s*(?:\??:|\(|$)/);
|
|
3809
3876
|
if (k) keys.add(k[1] ?? k[2]);
|
|
3877
|
+
const c = s.match(/^\[\s*(["'`])([^"'`$]+)\1\s*\]\s*:/);
|
|
3878
|
+
if (c) keys.add(c[2]);
|
|
3810
3879
|
};
|
|
3811
3880
|
for (let i = 0; i < text.length; i++) {
|
|
3812
3881
|
const ch = text[i];
|
|
@@ -3833,6 +3902,107 @@ function objectMembers(file, p) {
|
|
|
3833
3902
|
flush();
|
|
3834
3903
|
return { keys, spreads };
|
|
3835
3904
|
}
|
|
3905
|
+
function fieldValueAt(w) {
|
|
3906
|
+
if (w.form === "shorthand") return null;
|
|
3907
|
+
const rows = uncommentedLines(w.file);
|
|
3908
|
+
if (w.form === "computed-key") return computedValueAt(w.file, w.line, w.col);
|
|
3909
|
+
const delim = w.form === "key" || w.form === "quoted-key" ? ":" : "=";
|
|
3910
|
+
const skip = w.form === "bracket-assign" ? "]" : "";
|
|
3911
|
+
const start = w.form === "quoted-key" || w.form === "bracket-assign" ? 2 : 0;
|
|
3912
|
+
let p = nextCode(w.file, w.line, w.col + w.name.length + start, 1);
|
|
3913
|
+
if (p && skip && charAt(w.file, p) === skip) p = nextCode(w.file, p.line, p.col + 1, 1);
|
|
3914
|
+
if (!p || rows[p.line - 1][p.col] !== delim) return null;
|
|
3915
|
+
return { line: p.line, col: p.col + 1 };
|
|
3916
|
+
}
|
|
3917
|
+
function stringValueAt(file, line, col) {
|
|
3918
|
+
let p = nextCode(file, line, col);
|
|
3919
|
+
let parens = 0;
|
|
3920
|
+
while (p && charAt(file, p) === "(") {
|
|
3921
|
+
parens++;
|
|
3922
|
+
p = nextCode(file, p.line, p.col + 1);
|
|
3923
|
+
}
|
|
3924
|
+
if (!p) return { kind: "other", form: "no value" };
|
|
3925
|
+
const rest = restOfLine(file, p);
|
|
3926
|
+
if (/^(?:true|false|null|undefined)\b/.test(rest) || /^-?\d/.test(rest)) {
|
|
3927
|
+
return { kind: "not-string" };
|
|
3928
|
+
}
|
|
3929
|
+
const m = rest.match(/^(["'`])((?:\\.|(?!\1)[^\\])*)\1/);
|
|
3930
|
+
if (!m || m[1] === "`" && m[2].includes("${")) {
|
|
3931
|
+
return { kind: "other", form: `\`${exprText(file, p)}\`` };
|
|
3932
|
+
}
|
|
3933
|
+
const suffix = readSuffix(file, { line: p.line, col: p.col + m[0].length }, parens);
|
|
3934
|
+
if ("foreign" in suffix) {
|
|
3935
|
+
return { kind: "other", form: `the literal ${m[0]} followed by \`${suffix.foreign}\`` };
|
|
3936
|
+
}
|
|
3937
|
+
return { kind: "string", value: m[2] };
|
|
3938
|
+
}
|
|
3939
|
+
function identReturned(file, name) {
|
|
3940
|
+
const esc4 = name.replace(/[$]/g, "\\$&");
|
|
3941
|
+
const re = new RegExp(
|
|
3942
|
+
`(?:\\breturn|=>)\\s*(?:\\(\\s*)*${esc4}(?![\\w$])(?!\\s*(?:\\?\\.|\\.|\\(|\\[|=))`
|
|
3943
|
+
);
|
|
3944
|
+
return re.test(uncommentedLines(file).join("\n"));
|
|
3945
|
+
}
|
|
3946
|
+
function objectReturned(file, p, depth = 0) {
|
|
3947
|
+
if (depth > 16) return { kind: "unread", form: "an object nested deeper than 16 levels" };
|
|
3948
|
+
const before = textBefore(file, p.line, p.col).trimEnd();
|
|
3949
|
+
if (/\breturn$/.test(before)) return { kind: "returned", how: "return" };
|
|
3950
|
+
if (/=>$/.test(before)) return { kind: "returned", how: "arrow body" };
|
|
3951
|
+
if (/\bexport\s+default$/.test(before)) return { kind: "not-returned", how: "export default" };
|
|
3952
|
+
const decl = before.match(/\b(?:const|let|var)\s+([\w$]+)\s*(?::[^=;]*)?=$/);
|
|
3953
|
+
if (decl) {
|
|
3954
|
+
return identReturned(file, decl[1]) ? { kind: "returned", how: `\`${decl[1]}\` returned` } : { kind: "not-returned", how: `\`${decl[1]}\` never returned` };
|
|
3955
|
+
}
|
|
3956
|
+
if (/(?:^|[^=!<>])=$/.test(before)) return { kind: "not-returned", how: "assigned" };
|
|
3957
|
+
const outward = (why) => {
|
|
3958
|
+
const enc = enclosingOpener(file, p.line, p.col);
|
|
3959
|
+
if (!enc) return { kind: "unread", form: why };
|
|
3960
|
+
if (enc.ch === "(") {
|
|
3961
|
+
const head = textBefore(file, enc.line, enc.col).trimEnd();
|
|
3962
|
+
const isCall = /[\w$\])>]$/.test(head) && !/=>$/.test(head) && !/\b(?:return|yield|await|typeof|void|case|in|of|throw|default)$/.test(head);
|
|
3963
|
+
if (isCall) return { kind: "not-returned", how: "a call argument" };
|
|
3964
|
+
if (!before.endsWith("(")) return { kind: "unread", form: `${why} inside parentheses` };
|
|
3965
|
+
return objectReturned(file, enc, depth + 1);
|
|
3966
|
+
}
|
|
3967
|
+
if (enc.ch === "[") return objectReturned(file, enc, depth + 1);
|
|
3968
|
+
const ctx = braceContext(file, enc.line, enc.col);
|
|
3969
|
+
if (ctx.kind === "value") return objectReturned(file, enc, depth + 1);
|
|
3970
|
+
return { kind: "unread", form: why };
|
|
3971
|
+
};
|
|
3972
|
+
if (before.endsWith("(")) return outward("an object in parentheses");
|
|
3973
|
+
if (before.endsWith("...")) return outward("a spread");
|
|
3974
|
+
if (before.endsWith("[")) return outward("an array element");
|
|
3975
|
+
if (before.endsWith(",")) return outward("an element after a comma");
|
|
3976
|
+
if (before.endsWith(":")) {
|
|
3977
|
+
const colon = lastCodeChar(file, p);
|
|
3978
|
+
if (colon && colonIsTernary(file, colon.line, colon.col)) {
|
|
3979
|
+
return { kind: "unread", form: "a branch of a conditional" };
|
|
3980
|
+
}
|
|
3981
|
+
return outward("a key value");
|
|
3982
|
+
}
|
|
3983
|
+
return {
|
|
3984
|
+
kind: "unread",
|
|
3985
|
+
form: `an object after \`${before.slice(-30).trim()}\``
|
|
3986
|
+
};
|
|
3987
|
+
}
|
|
3988
|
+
function constString(file, name) {
|
|
3989
|
+
const one = { root: file.path, files: [file], packageJson: null, skippedDirs: [] };
|
|
3990
|
+
const re = new RegExp(`\\bconst\\s+${name.replace(/[$]/g, "\\$&")}\\b[^=\\n]*=(?![=>])\\s*`, "g");
|
|
3991
|
+
const site = codeSites(one, re)[0];
|
|
3992
|
+
if (!site) {
|
|
3993
|
+
return {
|
|
3994
|
+
kind: "unread",
|
|
3995
|
+
form: `the identifier \`${name}\`, bound by no same-file const`
|
|
3996
|
+
};
|
|
3997
|
+
}
|
|
3998
|
+
const v = stringValueAt(file, site.line.n, site.col + site.match[0].length);
|
|
3999
|
+
if (v.kind === "string") return { kind: "value", value: v.value };
|
|
4000
|
+
if (v.kind === "not-string") return { kind: "value", value: null };
|
|
4001
|
+
return {
|
|
4002
|
+
kind: "unread",
|
|
4003
|
+
form: `the identifier \`${name}\`, bound at ${site.anchor} to ${v.form}`
|
|
4004
|
+
};
|
|
4005
|
+
}
|
|
3836
4006
|
|
|
3837
4007
|
// src/detectors/metaKeys.ts
|
|
3838
4008
|
var KEY_IN_BLOCK_RE = /(["'`])([A-Za-z0-9_.-]+\/[^"'`\s]*)\1\s*:/g;
|
|
@@ -3995,6 +4165,18 @@ function collectNamespacedKeys(tree) {
|
|
|
3995
4165
|
}
|
|
3996
4166
|
if (tail.trimStart().startsWith("{") || tail.trim() === "") {
|
|
3997
4167
|
readValue(tree, site.file, site.line.n, after, ctx, acc);
|
|
4168
|
+
continue;
|
|
4169
|
+
}
|
|
4170
|
+
const enc = enclosingOpener(site.file, site.line.n, site.col);
|
|
4171
|
+
if (!enc || enc.ch !== "{") continue;
|
|
4172
|
+
const kind = braceContext(site.file, enc.line, enc.col);
|
|
4173
|
+
if (kind.kind === "value") {
|
|
4174
|
+
readValue(tree, site.file, site.line.n, after, ctx, acc);
|
|
4175
|
+
} else if (kind.kind === "unread") {
|
|
4176
|
+
acc.unreadable.push({
|
|
4177
|
+
anchor: site.anchor,
|
|
4178
|
+
reason: `\`${ctx}\` at ${site.anchor} is a key of a brace whose kind (object value, type, pattern, block) is unread: ${kind.form} \u2014 its keys are unread`
|
|
4179
|
+
});
|
|
3998
4180
|
}
|
|
3999
4181
|
}
|
|
4000
4182
|
for (const site of codeSites(tree, META_BRACKET_RE)) {
|
|
@@ -6798,7 +6980,13 @@ var c10MechanismDeclared = {
|
|
|
6798
6980
|
|
|
6799
6981
|
// src/detectors/c11-pagination.ts
|
|
6800
6982
|
var PIN2 = STANDARD_PIN;
|
|
6801
|
-
var
|
|
6983
|
+
var PAGINABLE_VERBS = /* @__PURE__ */ new Set(["list", "search"]);
|
|
6984
|
+
var PAGINABLE_NAME_RE = /^(list|search)/i;
|
|
6985
|
+
function paginability(t) {
|
|
6986
|
+
if (t.verb === void 0) return PAGINABLE_NAME_RE.test(t.name) ? "paginable" : "not-paginable";
|
|
6987
|
+
if (!VERB_SET.has(t.verb)) return { unknownVerb: t.verb };
|
|
6988
|
+
return PAGINABLE_VERBS.has(t.verb) ? "paginable" : "not-paginable";
|
|
6989
|
+
}
|
|
6802
6990
|
function c11PositiveControls() {
|
|
6803
6991
|
const field = toolAnnotationFieldControls().pagination;
|
|
6804
6992
|
return { fieldMatcher: field };
|
|
@@ -6825,30 +7013,47 @@ var c11Pagination = {
|
|
|
6825
7013
|
verdict: `could not judge: ${reason}`
|
|
6826
7014
|
};
|
|
6827
7015
|
}
|
|
6828
|
-
const
|
|
7016
|
+
const located = findToolAnnotations(tree);
|
|
7017
|
+
const undecidable = located.flatMap((t) => {
|
|
7018
|
+
const p = paginability(t);
|
|
7019
|
+
return typeof p === "object" ? [`${t.name} (verb "${p.unknownVerb}" at ${t.anchor})`] : [];
|
|
7020
|
+
});
|
|
7021
|
+
if (undecidable.length > 0) {
|
|
7022
|
+
const reason = `declared verb outside the closed set (C-9) on ${undecidable.length} tool(s): ${undecidable.join(", ")} \u2014 paginability undecidable (C-11)`;
|
|
7023
|
+
return {
|
|
7024
|
+
id: this.id,
|
|
7025
|
+
anchor: located.find((t) => typeof paginability(t) === "object")?.anchor ?? "-",
|
|
7026
|
+
state: "could-not-judge",
|
|
7027
|
+
reason,
|
|
7028
|
+
verdict: `could not judge: ${reason}`
|
|
7029
|
+
};
|
|
7030
|
+
}
|
|
7031
|
+
const tools = located.filter((t) => paginability(t) === "paginable");
|
|
6829
7032
|
if (tools.length === 0) {
|
|
6830
7033
|
return {
|
|
6831
7034
|
id: this.id,
|
|
6832
7035
|
anchor: "-",
|
|
6833
7036
|
state: "absent",
|
|
6834
|
-
verdict: "no list
|
|
7037
|
+
verdict: "no list or search tool registrations found (declared verb, or name prefix without one); pagination declaration check n/a"
|
|
6835
7038
|
};
|
|
6836
7039
|
}
|
|
6837
7040
|
const opaque = opaqueAnnotationsAbstain(this.id, "C-11", tools);
|
|
6838
7041
|
if (opaque) return opaque;
|
|
6839
|
-
|
|
7042
|
+
const failing = tools.flatMap((t) => {
|
|
6840
7043
|
const missing = [];
|
|
6841
7044
|
if (!t.paginationCursorDeclared) missing.push("paginationCursor");
|
|
6842
7045
|
if (t.paginationDefault === void 0) missing.push("paginationDefault");
|
|
6843
7046
|
if (t.paginationMax === void 0) missing.push("paginationMax (finite)");
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
7047
|
+
return missing.length > 0 ? [{ t, missing }] : [];
|
|
7048
|
+
});
|
|
7049
|
+
if (failing.length > 0) {
|
|
7050
|
+
const sites = failing.map(({ t, missing }) => `"${t.name}" at ${t.anchor} (missing ${missing.join(", ")})`).join("; ");
|
|
7051
|
+
return {
|
|
7052
|
+
id: this.id,
|
|
7053
|
+
anchor: failing[0]?.t.anchor ?? "-",
|
|
7054
|
+
state: "non-conforming",
|
|
7055
|
+
verdict: `${failing.length} of ${tools.length} paginable tool(s) miss pagination declaration(s): ${sites} (positive-control OK) -> declare annotations.paginationCursor/paginationDefault/paginationMax with a FINITE max \u2014 an unbounded max never publishes (C-11)`
|
|
7056
|
+
};
|
|
6852
7057
|
}
|
|
6853
7058
|
return {
|
|
6854
7059
|
id: this.id,
|
|
@@ -6874,13 +7079,15 @@ var c11Pagination = {
|
|
|
6874
7079
|
verdict: `could not judge: ${reason}`
|
|
6875
7080
|
};
|
|
6876
7081
|
}
|
|
6877
|
-
const paginable = runtime.tools.filter(
|
|
7082
|
+
const paginable = runtime.tools.filter(
|
|
7083
|
+
(t) => PAGINABLE_NAME_RE.test(t.name) || t.cursorArgument
|
|
7084
|
+
);
|
|
6878
7085
|
if (paginable.length === 0) {
|
|
6879
7086
|
return {
|
|
6880
7087
|
id: this.id,
|
|
6881
7088
|
anchor: `${runtime.root} (runtime tools/list)`,
|
|
6882
7089
|
state: "absent",
|
|
6883
|
-
verdict: "server advertises no list/
|
|
7090
|
+
verdict: "server advertises no list/search tool and no tool taking a cursor at runtime; pagination check n/a"
|
|
6884
7091
|
};
|
|
6885
7092
|
}
|
|
6886
7093
|
const anchor = `${runtime.root} (runtime invalid-cursor probes)`;
|
|
@@ -11211,6 +11418,7 @@ var RESULT_PAYLOAD_KEYS = [
|
|
|
11211
11418
|
"completion",
|
|
11212
11419
|
"nextCursor"
|
|
11213
11420
|
];
|
|
11421
|
+
var RESULT_ANCHOR_KEYS = ["content", "structuredContent", "resultType"];
|
|
11214
11422
|
function baseIsResult(file, base, tree) {
|
|
11215
11423
|
if (!base) return false;
|
|
11216
11424
|
const esc4 = base.replace(/[$]/g, "\\$&");
|
|
@@ -11228,7 +11436,26 @@ function baseIsResult(file, base, tree) {
|
|
|
11228
11436
|
function handRolledBuilder(tree) {
|
|
11229
11437
|
const scan = fieldWrites(tree, HANDROLLED_FIELDS);
|
|
11230
11438
|
const unread = [...scan.unread];
|
|
11439
|
+
for (const k of scan.computed) {
|
|
11440
|
+
if (objectReturned(k.file, k.object).kind !== "returned") continue;
|
|
11441
|
+
const m = objectMembers(k.file, k.object);
|
|
11442
|
+
const member = RESULT_ANCHOR_KEYS.find((key) => m.keys.has(key));
|
|
11443
|
+
if (!member) continue;
|
|
11444
|
+
unread.push({
|
|
11445
|
+
anchor: k.anchor,
|
|
11446
|
+
reason: `the computed key \`[${k.expr.slice(0, 40)}]\` at ${k.anchor} sits in a returned result object (it carries \`${member}\`) and may write resultType / ttlMs / cacheScope: which field it writes is unread (D7)`
|
|
11447
|
+
});
|
|
11448
|
+
}
|
|
11231
11449
|
for (const w of scan.writes) {
|
|
11450
|
+
const bind = w.object ? objectReturned(w.file, w.object) : w.base && identReturned(w.file, w.base) ? { kind: "returned", how: `\`${w.base}\` returned` } : { kind: "not-returned", how: w.base ? `\`${w.base}\` never returned` : "no base" };
|
|
11451
|
+
if (bind.kind === "not-returned") continue;
|
|
11452
|
+
if (bind.kind === "unread") {
|
|
11453
|
+
unread.push({
|
|
11454
|
+
anchor: w.anchor,
|
|
11455
|
+
reason: `\`${w.name}\` is written at ${w.anchor} into an object in ${bind.form}: whether a handler returns it is unread (D7)`
|
|
11456
|
+
});
|
|
11457
|
+
continue;
|
|
11458
|
+
}
|
|
11232
11459
|
let result = w.name === "resultType";
|
|
11233
11460
|
if (!result && w.object) {
|
|
11234
11461
|
const m = objectMembers(w.file, w.object);
|
|
@@ -11261,7 +11488,9 @@ var d7Inner = {
|
|
|
11261
11488
|
id: "D7 protocol-kit",
|
|
11262
11489
|
run(tree) {
|
|
11263
11490
|
const v2 = (r) => sdkV2Dependency({ dependencies: { [SDK_V2_PKG]: r } }).kind;
|
|
11264
|
-
if (v2("^2.3.1") !== "v2" || v2(">=2 <3") !== "v2" || v2("^1.12.0") !== "below-v2" || v2("latest") !== "unreadable" || handRolledBuilder(controlTree2("export const r = () => ({ content: [], ttlMs: 0 });")).hand === null || handRolledBuilder(controlTree2("export const u = (ok: boolean) => (ok ? ttlMs : 0);")).hand !== null
|
|
11491
|
+
if (v2("^2.3.1") !== "v2" || v2(">=2 <3") !== "v2" || v2("^1.12.0") !== "below-v2" || v2("latest") !== "unreadable" || handRolledBuilder(controlTree2("export const r = () => ({ content: [], ttlMs: 0 });")).hand === null || handRolledBuilder(controlTree2("export const u = (ok: boolean) => (ok ? ttlMs : 0);")).hand !== null || handRolledBuilder(
|
|
11492
|
+
controlTree2('export const v = () => { const r = { resultType: "x" }; return r; };')
|
|
11493
|
+
).hand === null || handRolledBuilder(controlTree2('export const w = (log: any) => log({ resultType: "x" });')).hand !== null) {
|
|
11265
11494
|
throw new Error(
|
|
11266
11495
|
"D7 control FAILED: SDK v2 range reader / hand-rolled matcher broken \u2014 verdict untrustworthy"
|
|
11267
11496
|
);
|
|
@@ -18261,14 +18490,14 @@ var s22OriginValidation = {
|
|
|
18261
18490
|
`${flag[0].anchor} turns the DNS rebinding protection on and sets no allowedOrigins: the SDK validates no Origin without a list of origins -> name the expected origins (S-22)`
|
|
18262
18491
|
);
|
|
18263
18492
|
}
|
|
18264
|
-
if (origins.
|
|
18493
|
+
if (origins.unresolved.length > 0) {
|
|
18265
18494
|
return couldNotJudge(
|
|
18266
18495
|
this.id,
|
|
18267
18496
|
origins.unresolved[0].anchor,
|
|
18268
|
-
|
|
18497
|
+
`${unresolvedText(origins.unresolved)}: whether it names concrete origins is unread (S-22)`
|
|
18269
18498
|
);
|
|
18270
18499
|
}
|
|
18271
|
-
if (origins.
|
|
18500
|
+
if (origins.ok.length > 0 && flag.length === 0) {
|
|
18272
18501
|
return couldNotJudge(
|
|
18273
18502
|
this.id,
|
|
18274
18503
|
origins.first,
|
|
@@ -18289,31 +18518,141 @@ var s22OriginValidation = {
|
|
|
18289
18518
|
const rows = uncommentedLines(file);
|
|
18290
18519
|
rows.forEach((row, i) => {
|
|
18291
18520
|
if (!ORIGIN_READ_RE.test(row)) return;
|
|
18292
|
-
const
|
|
18521
|
+
const readCol = ORIGIN_READ_RE.exec(row)?.index ?? 0;
|
|
18522
|
+
const window = rows.slice(i, refusalWindowEnd(file, rows, i, readCol)).join("\n");
|
|
18293
18523
|
(REFUSE_RE.test(window) ? refused : ignored).push(`${file.rel}:${i + 1}`);
|
|
18294
18524
|
});
|
|
18295
18525
|
}
|
|
18526
|
+
const declaredNote = origins.declared.length > 0 ? `; ${origins.declared.map((d) => d.text).join("; ")}` : "";
|
|
18296
18527
|
if (refused.length > 0) {
|
|
18297
18528
|
return presentResult(
|
|
18298
18529
|
this.id,
|
|
18299
18530
|
refused[0],
|
|
18300
|
-
`the Origin header is read and an unlisted origin is refused with 403 (${refused.join(", ")}) (positive-control OK)${wideNote} (S-22)`
|
|
18531
|
+
`the Origin header is read and an unlisted origin is refused with 403 (${refused.join(", ")})${declaredNote} (positive-control OK)${wideNote} (S-22)`
|
|
18532
|
+
);
|
|
18533
|
+
}
|
|
18534
|
+
if (origins.declared.length > 0 && flag.length > 0) {
|
|
18535
|
+
const emptyDefault = origins.declared.find((d) => d.refusesAllByDefault);
|
|
18536
|
+
if (emptyDefault) {
|
|
18537
|
+
return couldNotJudge(
|
|
18538
|
+
this.id,
|
|
18539
|
+
emptyDefault.anchor,
|
|
18540
|
+
`the SDK protection is on (${flag[0].anchor}) and allowedOrigins is ${emptyDefault.text}: the SDK checks no Origin when its list is empty, so with the default the protection validates nothing; whether the deployment sets the variable is unread (S-22)`
|
|
18541
|
+
);
|
|
18542
|
+
}
|
|
18543
|
+
return presentResult(
|
|
18544
|
+
this.id,
|
|
18545
|
+
origins.declared[0].anchor,
|
|
18546
|
+
`the transport's Origin protection is on (${flag[0].anchor})${declaredNote} (positive-control OK)${wideNote} (S-22)`
|
|
18301
18547
|
);
|
|
18302
18548
|
}
|
|
18303
18549
|
if (ignored.length > 0) {
|
|
18304
18550
|
return redResult(
|
|
18305
18551
|
this.id,
|
|
18306
18552
|
ignored[0],
|
|
18307
|
-
`the Origin header is read (${ignored.join(", ")}) and never refused with 403 within six lines: an unlisted origin must be rejected with 403 before the dispatch (S-22)`
|
|
18553
|
+
`the Origin header is read (${ignored.join(", ")}) and never refused with 403 within six lines (or the statement that starts there): an unlisted origin must be rejected with 403 before the dispatch (S-22)`
|
|
18308
18554
|
);
|
|
18309
18555
|
}
|
|
18310
18556
|
return redResult(
|
|
18311
18557
|
this.id,
|
|
18312
18558
|
transport[0].anchor,
|
|
18313
|
-
`a Streamable HTTP transport is served (${transport[0].anchor}) and nothing validates the Origin header (no allowlist, no 403, no SDK protection): DNS rebinding reaches the server${wideNote} -> validate Origin against an allowlist and answer 403 (S-22)`
|
|
18559
|
+
`a Streamable HTTP transport is served (${transport[0].anchor}) and nothing validates the Origin header (no allowlist, no 403, no SDK protection)${declaredNote ? `${declaredNote}, and nothing enforces it` : ""}: DNS rebinding reaches the server${wideNote} -> validate Origin against an allowlist and answer 403 (S-22)`
|
|
18314
18560
|
);
|
|
18315
18561
|
}
|
|
18316
18562
|
};
|
|
18563
|
+
function refusalWindowEnd(file, rows, i, readCol) {
|
|
18564
|
+
const open = [];
|
|
18565
|
+
for (let r = i; r < rows.length && r < i + 40; r++) {
|
|
18566
|
+
const raw = rows[r];
|
|
18567
|
+
for (let c = r === i ? readCol : 0; c < raw.length; c++) {
|
|
18568
|
+
if (!isCodeAt(file, r + 1, c)) continue;
|
|
18569
|
+
if ("([{".includes(raw[c])) open.push(raw[c]);
|
|
18570
|
+
else if (")]}".includes(raw[c])) open.pop();
|
|
18571
|
+
}
|
|
18572
|
+
if (r >= i + 6 && (open.length === 0 || open[0] === "{")) return r + 1;
|
|
18573
|
+
}
|
|
18574
|
+
return Math.min(rows.length, i + 40);
|
|
18575
|
+
}
|
|
18576
|
+
function unresolvedText(list) {
|
|
18577
|
+
const plain = list.filter((u) => u.said === void 0);
|
|
18578
|
+
const parts = plain.length ? [
|
|
18579
|
+
`allowedOrigins is given by ${plain.map((u) => `\`${u.name}\` (${u.anchor})`).join(", ")}, which this tree does not define as a literal list`
|
|
18580
|
+
] : [];
|
|
18581
|
+
for (const u of list) if (u.said !== void 0) parts.push(u.said);
|
|
18582
|
+
return parts.join("; ");
|
|
18583
|
+
}
|
|
18584
|
+
var DECLARED_TYPES = ["string", "integer", "boolean", "url", "originList", "enum", "json"];
|
|
18585
|
+
var ENV_READ_RE = /^process\.env(?:\.([A-Za-z_$][\w$]*)|\[\s*(["'`])([^"'`]+)\2\s*\])/;
|
|
18586
|
+
var MEMBER_READ_RE = /^[A-Za-z_$][\w$]*(?:\??\.[A-Za-z_$][\w$]*)+/;
|
|
18587
|
+
function declaredEntryAt(file, line, col) {
|
|
18588
|
+
const spec = enclosingOpener(file, line, col);
|
|
18589
|
+
if (!spec || spec.ch !== "{") return null;
|
|
18590
|
+
const call = enclosingOpener(file, spec.line, spec.col);
|
|
18591
|
+
if (!call || call.ch !== "(") return null;
|
|
18592
|
+
const before = uncommentedLines(file)[call.line - 1].slice(0, call.col);
|
|
18593
|
+
if (!/\bdefineVariables\s*(?:<[^>]*>)?\s*$/.test(before)) return null;
|
|
18594
|
+
const b = balancedBlock(file, line, col, "{", "}");
|
|
18595
|
+
return b ? b.text : null;
|
|
18596
|
+
}
|
|
18597
|
+
function declarationsOf(tree, key) {
|
|
18598
|
+
const out = [];
|
|
18599
|
+
const re = new RegExp(
|
|
18600
|
+
`(?:\\b${key.replace(/[$]/g, "\\$&")}\\b|["'\`]${key.replace(/[$]/g, "\\$&")}["'\`])\\s*:\\s*\\{`,
|
|
18601
|
+
"g"
|
|
18602
|
+
);
|
|
18603
|
+
for (const site of codeSites(tree, re)) {
|
|
18604
|
+
if (!isProductSource(site.file.rel)) continue;
|
|
18605
|
+
const brace = site.col + site.match[0].length - 1;
|
|
18606
|
+
const text = declaredEntryAt(site.file, site.line.n, brace);
|
|
18607
|
+
if (text !== null) out.push({ anchor: site.anchor, file: site.file, text });
|
|
18608
|
+
}
|
|
18609
|
+
return out;
|
|
18610
|
+
}
|
|
18611
|
+
function judgeDeclared(tree, key, anchor, file, entry) {
|
|
18612
|
+
const members3 = /* @__PURE__ */ new Map();
|
|
18613
|
+
for (const m of splitTopLevel(entry.slice(1, -1))) {
|
|
18614
|
+
const kv = m.match(/^(["'`]?)([A-Za-z_$][\w$]*)\1\s*:\s*([\s\S]*)$/);
|
|
18615
|
+
if (kv) members3.set(kv[2], kv[3].trim());
|
|
18616
|
+
}
|
|
18617
|
+
const envRaw = members3.get("env") ?? "";
|
|
18618
|
+
const env = (envRaw.match(/^(["'`])([^"'`]*)\1$/) ?? [])[2] ?? `env ${envRaw || "absent"}`;
|
|
18619
|
+
const who = `the declared variable \`${key}\` (${env}, ${anchor})`;
|
|
18620
|
+
const typeRaw = members3.get("type");
|
|
18621
|
+
const def = members3.get("default");
|
|
18622
|
+
const defLeaves = def === void 0 ? null : leavesOf(tree, def, file, 0);
|
|
18623
|
+
const wild = defLeaves?.strings.find((x) => x.slice(1, -1).includes("*"));
|
|
18624
|
+
if (wild) return { kind: "wildcard", text: `${who} defaults to a wildcard (${def})` };
|
|
18625
|
+
if (typeRaw === void 0)
|
|
18626
|
+
return { kind: "unresolved", said: `allowedOrigins is ${who}, which declares no type` };
|
|
18627
|
+
const type = (typeRaw.match(/^(["'`])([^"'`]*)\1$/) ?? [])[2];
|
|
18628
|
+
if (type === void 0)
|
|
18629
|
+
return {
|
|
18630
|
+
kind: "unresolved",
|
|
18631
|
+
said: `allowedOrigins is ${who}, whose type \`${typeRaw}\` is not a literal`
|
|
18632
|
+
};
|
|
18633
|
+
if (!DECLARED_TYPES.includes(type))
|
|
18634
|
+
return {
|
|
18635
|
+
kind: "unresolved",
|
|
18636
|
+
said: `allowedOrigins is ${who}, of type \`${typeRaw}\` this reader does not know`
|
|
18637
|
+
};
|
|
18638
|
+
if (type !== "originList")
|
|
18639
|
+
return {
|
|
18640
|
+
kind: "unresolved",
|
|
18641
|
+
said: `allowedOrigins is ${who}, of type \`${typeRaw}\`, which does not validate an origin list at start-up`
|
|
18642
|
+
};
|
|
18643
|
+
if (defLeaves?.unresolved)
|
|
18644
|
+
return {
|
|
18645
|
+
kind: "unresolved",
|
|
18646
|
+
said: `allowedOrigins is ${who}, whose default \`${defLeaves.unresolved}\` is not a literal`
|
|
18647
|
+
};
|
|
18648
|
+
const empty = defLeaves !== null && defLeaves.strings.length === 0;
|
|
18649
|
+
const dflt = defLeaves === null ? "no default (the value is the environment's)" : empty ? "default [] (refuses every browser origin)" : `default ${def}`;
|
|
18650
|
+
return {
|
|
18651
|
+
kind: "ok",
|
|
18652
|
+
text: `allowedOrigins is ${who}, type originList (a "*" or a path refused at start-up), ${dflt}`,
|
|
18653
|
+
refusesAllByDefault: empty
|
|
18654
|
+
};
|
|
18655
|
+
}
|
|
18317
18656
|
function resolveConstLiteral(tree, name, file) {
|
|
18318
18657
|
const re = new RegExp(
|
|
18319
18658
|
`\\b(?:const|let|var)\\s+${name.replace(/[$]/g, "\\$&")}\\b[^=\\n]*=\\s*`,
|
|
@@ -18334,14 +18673,55 @@ function resolveConstLiteral(tree, name, file) {
|
|
|
18334
18673
|
return null;
|
|
18335
18674
|
}
|
|
18336
18675
|
function classifyAllowedOrigins(tree) {
|
|
18337
|
-
const out = { sites: 0, first: "", ok: [], reds: [], unresolved: [] };
|
|
18676
|
+
const out = { sites: 0, first: "", ok: [], reds: [], unresolved: [], declared: [] };
|
|
18677
|
+
const judged = /* @__PURE__ */ new Set();
|
|
18678
|
+
const takeDeclared = (key, decl) => {
|
|
18679
|
+
if (judged.has(decl.anchor)) return;
|
|
18680
|
+
judged.add(decl.anchor);
|
|
18681
|
+
const v = judgeDeclared(tree, key, decl.anchor, decl.file, decl.text);
|
|
18682
|
+
if (v.kind === "wildcard")
|
|
18683
|
+
out.reds.push({ anchor: decl.anchor, text: `${v.text}: a wildcard validates no Origin` });
|
|
18684
|
+
else if (v.kind === "unresolved")
|
|
18685
|
+
out.unresolved.push({ anchor: decl.anchor, name: key, said: v.said });
|
|
18686
|
+
else
|
|
18687
|
+
out.declared.push({
|
|
18688
|
+
anchor: decl.anchor,
|
|
18689
|
+
text: v.text,
|
|
18690
|
+
refusesAllByDefault: v.refusesAllByDefault
|
|
18691
|
+
});
|
|
18692
|
+
};
|
|
18338
18693
|
for (const site of codeSites(tree, ALLOWED_ORIGINS_RE)) {
|
|
18339
18694
|
if (!isProductSource(site.file.rel)) continue;
|
|
18340
18695
|
const after = site.col + site.match[0].length;
|
|
18341
18696
|
const rest = site.line.raw.slice(after);
|
|
18342
18697
|
if (TYPE_ANNOTATION_RE.test(rest)) continue;
|
|
18698
|
+
if (rest.startsWith("{")) {
|
|
18699
|
+
const entry = declaredEntryAt(site.file, site.line.n, after);
|
|
18700
|
+
if (entry !== null) {
|
|
18701
|
+
takeDeclared("allowedOrigins", { anchor: site.anchor, file: site.file, text: entry });
|
|
18702
|
+
continue;
|
|
18703
|
+
}
|
|
18704
|
+
}
|
|
18343
18705
|
out.sites++;
|
|
18344
18706
|
out.first ||= site.anchor;
|
|
18707
|
+
const env = rest.match(ENV_READ_RE);
|
|
18708
|
+
if (env) {
|
|
18709
|
+
out.unresolved.push({
|
|
18710
|
+
anchor: site.anchor,
|
|
18711
|
+
name: env[0],
|
|
18712
|
+
said: `allowedOrigins is read straight from the environment (\`${env[0]}\`, ${site.anchor}) with no declaration (variable ${env[1] ?? env[3]})`
|
|
18713
|
+
});
|
|
18714
|
+
continue;
|
|
18715
|
+
}
|
|
18716
|
+
const member = rest.match(MEMBER_READ_RE);
|
|
18717
|
+
if (member) {
|
|
18718
|
+
const key = member[0].split(".").pop() ?? "";
|
|
18719
|
+
const decls = declarationsOf(tree, key);
|
|
18720
|
+
if (decls.length > 0) {
|
|
18721
|
+
for (const d of decls) takeDeclared(key, d);
|
|
18722
|
+
continue;
|
|
18723
|
+
}
|
|
18724
|
+
}
|
|
18345
18725
|
let value;
|
|
18346
18726
|
if (rest.startsWith("[")) {
|
|
18347
18727
|
const b = balancedBlock(site.file, site.line.n, after, "[", "]");
|
|
@@ -18746,14 +19126,73 @@ var s26ListChangedParity = {
|
|
|
18746
19126
|
|
|
18747
19127
|
// src/detectors/s27-elicitation-floor.ts
|
|
18748
19128
|
var ELICIT_RE = /\belicitInput\s*\(|["'`]elicitation\/create["'`]|\brequestedSchema\b/;
|
|
18749
|
-
var
|
|
19129
|
+
var MRTR_VALUE = "input_required";
|
|
18750
19130
|
var FALLBACK_RE = /\belicitInput\s*\(|["'`]elicitation\/create["'`]/;
|
|
18751
19131
|
var DECL_RE2 = /\b(?:midCallInput|elicitation|inputRequired)AtFloor["']?\s*:\s*(?:false|["'](?:unsupported|none)["'])/i;
|
|
18752
19132
|
var SENSITIVE_KEY_RE = /^(?:password|passwd|pwd|secret\w*|\w*token|api[_-]?key|apikey|private[_-]?key|credential\w*|ssn|social[_-]?security\w*|credit[_-]?card\w*|card[_-]?number|cc[_-]?number|cvv|cvc|iban|account[_-]?number|passport\w*|health\w*|medical\w*|diagnos\w*|salary|income)$/i;
|
|
19133
|
+
function resultTypeValue(w) {
|
|
19134
|
+
if (w.form === "shorthand") return constString(w.file, w.name);
|
|
19135
|
+
const at = fieldValueAt(w);
|
|
19136
|
+
if (!at) return { kind: "unread", form: "a value whose position cannot be read" };
|
|
19137
|
+
const s = stringValueAt(w.file, at.line, at.col);
|
|
19138
|
+
if (s.kind === "string") return { kind: "value", value: s.value };
|
|
19139
|
+
if (s.kind === "not-string") return { kind: "value", value: null };
|
|
19140
|
+
const core = unwrapValue(w.file, at.line, at.col);
|
|
19141
|
+
if (core.kind === "ident") return constString(w.file, core.name);
|
|
19142
|
+
return { kind: "unread", form: core.kind === "other" ? core.form : s.form };
|
|
19143
|
+
}
|
|
19144
|
+
function mrtrRounds(tree) {
|
|
19145
|
+
const scan = fieldWrites(tree, ["resultType"]);
|
|
19146
|
+
const rounds = [];
|
|
19147
|
+
const unread = [...scan.unread];
|
|
19148
|
+
for (const k of scan.computed) {
|
|
19149
|
+
const at = computedValueAt(k.file, k.line, k.col);
|
|
19150
|
+
if (!at) continue;
|
|
19151
|
+
const s = stringValueAt(k.file, at.line, at.col);
|
|
19152
|
+
let value = s.kind === "string" ? s.value : null;
|
|
19153
|
+
if (s.kind === "other") {
|
|
19154
|
+
const core = unwrapValue(k.file, at.line, at.col);
|
|
19155
|
+
if (core.kind === "ident") {
|
|
19156
|
+
const bound = constString(k.file, core.name);
|
|
19157
|
+
if (bound.kind === "value") value = bound.value;
|
|
19158
|
+
}
|
|
19159
|
+
}
|
|
19160
|
+
if (value !== MRTR_VALUE) continue;
|
|
19161
|
+
unread.push({
|
|
19162
|
+
anchor: k.anchor,
|
|
19163
|
+
reason: `the computed key \`[${k.expr.slice(0, 40)}]\` at ${k.anchor} is written "${MRTR_VALUE}": whether that key is \`resultType\` (an MRTR input round) is unread (S-27)`
|
|
19164
|
+
});
|
|
19165
|
+
}
|
|
19166
|
+
for (const w of scan.writes) {
|
|
19167
|
+
const v = resultTypeValue(w);
|
|
19168
|
+
if (v.kind === "unread") {
|
|
19169
|
+
unread.push({
|
|
19170
|
+
anchor: w.anchor,
|
|
19171
|
+
reason: `\`resultType\` at ${w.anchor} is written as ${v.form}: whether it is "${MRTR_VALUE}" (an MRTR input round) is unread (S-27)`
|
|
19172
|
+
});
|
|
19173
|
+
} else if (v.value === MRTR_VALUE) rounds.push(w.anchor);
|
|
19174
|
+
}
|
|
19175
|
+
return { rounds, unread };
|
|
19176
|
+
}
|
|
19177
|
+
function controlTree3(text) {
|
|
19178
|
+
const file = {
|
|
19179
|
+
path: "<s27-control>.ts",
|
|
19180
|
+
rel: "<s27-control>",
|
|
19181
|
+
lines: text.split("\n").map((raw, i) => ({ n: i + 1, raw, comment: false }))
|
|
19182
|
+
};
|
|
19183
|
+
return { root: "<s27-control>", files: [file], packageJson: null, skippedDirs: [] };
|
|
19184
|
+
}
|
|
18753
19185
|
function s27Controls() {
|
|
19186
|
+
const lit = mrtrRounds(controlTree3('export const a = () => ({ resultType: "input_required" });'));
|
|
19187
|
+
const cond = mrtrRounds(
|
|
19188
|
+
controlTree3(
|
|
19189
|
+
'export const b = (c: boolean) => ({ resultType: c ? "input_required" : "complete" });'
|
|
19190
|
+
)
|
|
19191
|
+
);
|
|
19192
|
+
const other = mrtrRounds(controlTree3('export const d = () => ({ resultType: "complete" });'));
|
|
18754
19193
|
return {
|
|
18755
|
-
sees: SENSITIVE_KEY_RE.test("apiKey") && SENSITIVE_KEY_RE.test("card_number") && SENSITIVE_KEY_RE.test("medicalHistory") &&
|
|
18756
|
-
spares: !SENSITIVE_KEY_RE.test("city") && !SENSITIVE_KEY_RE.test("type") && !SENSITIVE_KEY_RE.test("properties")
|
|
19194
|
+
sees: SENSITIVE_KEY_RE.test("apiKey") && SENSITIVE_KEY_RE.test("card_number") && SENSITIVE_KEY_RE.test("medicalHistory") && lit.rounds.length === 1 && cond.unread.length === 1 && DECL_RE2.test("midCallInputAtFloor: false"),
|
|
19195
|
+
spares: !SENSITIVE_KEY_RE.test("city") && !SENSITIVE_KEY_RE.test("type") && !SENSITIVE_KEY_RE.test("properties") && other.rounds.length === 0 && other.unread.length === 0
|
|
18757
19196
|
};
|
|
18758
19197
|
}
|
|
18759
19198
|
var s27ElicitationFloor = {
|
|
@@ -18773,6 +19212,10 @@ var s27ElicitationFloor = {
|
|
|
18773
19212
|
let declared = false;
|
|
18774
19213
|
let first = "";
|
|
18775
19214
|
const reds = [];
|
|
19215
|
+
const product = { ...tree, files: tree.files.filter((f) => isProductSource(f.rel)) };
|
|
19216
|
+
const mrtrScan = mrtrRounds(product);
|
|
19217
|
+
const unread = mrtrScan.unread;
|
|
19218
|
+
mrtr = mrtrScan.rounds.length;
|
|
18776
19219
|
for (const file of tree.files) {
|
|
18777
19220
|
if (!isProductSource(file.rel)) continue;
|
|
18778
19221
|
const rows = uncommentedLines(file);
|
|
@@ -18784,10 +19227,6 @@ var s27ElicitationFloor = {
|
|
|
18784
19227
|
elicitation++;
|
|
18785
19228
|
first ||= `${file.rel}:${i + 1}`;
|
|
18786
19229
|
}
|
|
18787
|
-
if (MRTR_RE.test(row)) {
|
|
18788
|
-
mrtr++;
|
|
18789
|
-
first ||= `${file.rel}:${i + 1}`;
|
|
18790
|
-
}
|
|
18791
19230
|
const at = row.indexOf("requestedSchema");
|
|
18792
19231
|
if (at >= 0) {
|
|
18793
19232
|
const op = nextOpener(file, i + 1, at, "{", 2);
|
|
@@ -18804,7 +19243,8 @@ var s27ElicitationFloor = {
|
|
|
18804
19243
|
}
|
|
18805
19244
|
});
|
|
18806
19245
|
}
|
|
18807
|
-
|
|
19246
|
+
first = mrtrScan.rounds[0] ?? first;
|
|
19247
|
+
if (elicitation + mrtr === 0 && unread.length === 0) {
|
|
18808
19248
|
return absentResult(
|
|
18809
19249
|
this.id,
|
|
18810
19250
|
"-",
|
|
@@ -18823,6 +19263,13 @@ var s27ElicitationFloor = {
|
|
|
18823
19263
|
`${reds.join("; ")} (S-27, positive-control OK)`
|
|
18824
19264
|
);
|
|
18825
19265
|
}
|
|
19266
|
+
if (unread.length > 0) {
|
|
19267
|
+
return couldNotJudge(
|
|
19268
|
+
this.id,
|
|
19269
|
+
unread[0].anchor,
|
|
19270
|
+
`${unread.length} resultType value(s) could not be read \u2014 ${unread.map((u) => u.reason).join("; ")}. ${elicitation} elicitation site(s) and ${mrtr} MRTR round(s) read, no sensitive field requested (S-27)`
|
|
19271
|
+
);
|
|
19272
|
+
}
|
|
18826
19273
|
return couldNotJudge(
|
|
18827
19274
|
this.id,
|
|
18828
19275
|
first,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vantageos/mcp-doctor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Static MCP conformance checker: audits an MCP server source tree against the MCP 2026-07-28 standard and emits a conformance-diff table (file:line | present | absent | non-conforming | verdict).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/doctor.js",
|