@vantageos/mcp-doctor 0.23.0 → 0.24.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 +6 -0
- package/dist/doctor.js +705 -217
- package/package.json +1 -1
package/dist/doctor.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
dotted,
|
|
3
4
|
isJudgeable,
|
|
5
|
+
lineOf,
|
|
4
6
|
parseFile,
|
|
5
|
-
|
|
7
|
+
propRead,
|
|
8
|
+
scanR4FilterPaths,
|
|
9
|
+
sourceOf,
|
|
10
|
+
unwrap,
|
|
11
|
+
walk
|
|
6
12
|
} from "./chunk-OLW7SIJF.js";
|
|
7
13
|
|
|
8
14
|
// src/doctor.ts
|
|
@@ -51,7 +57,7 @@ function isCommentLine(raw) {
|
|
|
51
57
|
}
|
|
52
58
|
var UNSCANNED_RE = /\.(?:m?js|cjs|jsx|mts|cts)$/;
|
|
53
59
|
var NOT_PRODUCT_NAME_RE = /\.d\.[mc]?ts$|\.(?:test|spec)\.[mc]?[jt]sx?$|\.config\.[mc]?[jt]s$|\.min\./;
|
|
54
|
-
function
|
|
60
|
+
function walk2(dir, out, onSkip, unscanned = [], seen = { files: 0 }) {
|
|
55
61
|
let entries;
|
|
56
62
|
try {
|
|
57
63
|
entries = readdirSync(dir);
|
|
@@ -73,7 +79,7 @@ function walk(dir, out, onSkip, unscanned = [], seen = { files: 0 }) {
|
|
|
73
79
|
onSkip(full);
|
|
74
80
|
continue;
|
|
75
81
|
}
|
|
76
|
-
|
|
82
|
+
walk2(full, out, onSkip, unscanned, seen);
|
|
77
83
|
continue;
|
|
78
84
|
}
|
|
79
85
|
if (!st.isFile()) {
|
|
@@ -190,7 +196,7 @@ function loadTree(root, backendRoot) {
|
|
|
190
196
|
throw new SubjectUnreadableError(root, "the directory is empty (0 entries)");
|
|
191
197
|
}
|
|
192
198
|
const seen = { files: 0 };
|
|
193
|
-
|
|
199
|
+
walk2(root, filePaths, (d, reason) => recordSkip(tree, d, root, reason), unscanned, seen);
|
|
194
200
|
for (const p of filePaths) {
|
|
195
201
|
try {
|
|
196
202
|
tree.files.push(loadFile(p, baseDir));
|
|
@@ -654,7 +660,7 @@ function findDiskFiles(tree, pred) {
|
|
|
654
660
|
const out = [];
|
|
655
661
|
const refused = [];
|
|
656
662
|
const base = baseOf(tree);
|
|
657
|
-
const
|
|
663
|
+
const walk4 = (dir) => {
|
|
658
664
|
let entries;
|
|
659
665
|
try {
|
|
660
666
|
entries = readdirSync2(dir);
|
|
@@ -679,7 +685,7 @@ function findDiskFiles(tree, pred) {
|
|
|
679
685
|
recordSkip(tree, full, base);
|
|
680
686
|
continue;
|
|
681
687
|
}
|
|
682
|
-
|
|
688
|
+
walk4(full);
|
|
683
689
|
} else {
|
|
684
690
|
const rel2 = relative2(base, full).split(sep2).join("/");
|
|
685
691
|
if (!pred(name, rel2)) continue;
|
|
@@ -701,7 +707,7 @@ function findDiskFiles(tree, pred) {
|
|
|
701
707
|
}
|
|
702
708
|
}
|
|
703
709
|
};
|
|
704
|
-
|
|
710
|
+
walk4(base);
|
|
705
711
|
return Object.assign(out, { refused });
|
|
706
712
|
}
|
|
707
713
|
function readText(path) {
|
|
@@ -1961,6 +1967,38 @@ function splitArgs(text, open, max = Number.POSITIVE_INFINITY) {
|
|
|
1961
1967
|
}
|
|
1962
1968
|
return null;
|
|
1963
1969
|
}
|
|
1970
|
+
function parameterBehindLocal(body, local, paramNames, nameParam) {
|
|
1971
|
+
const decl = new RegExp(`\\bconst\\s+${local.replace(/\$/g, "\\$")}\\s*(?::[^=\\n]+)?=(?!=)`);
|
|
1972
|
+
const m = body.match(decl);
|
|
1973
|
+
if (!m || m.index === void 0) return -1;
|
|
1974
|
+
const start = m.index + m[0].length;
|
|
1975
|
+
let depth = 0;
|
|
1976
|
+
let end = body.length;
|
|
1977
|
+
for (let i = start; i < body.length; i++) {
|
|
1978
|
+
const c = body[i];
|
|
1979
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
1980
|
+
for (i++; i < body.length && body[i] !== c; i++) if (body[i] === "\\") i++;
|
|
1981
|
+
continue;
|
|
1982
|
+
}
|
|
1983
|
+
if ("([{".includes(c)) depth++;
|
|
1984
|
+
else if (")]}".includes(c)) depth--;
|
|
1985
|
+
else if (c === ";" && depth <= 0) {
|
|
1986
|
+
end = i;
|
|
1987
|
+
break;
|
|
1988
|
+
}
|
|
1989
|
+
if (depth < 0) {
|
|
1990
|
+
end = i;
|
|
1991
|
+
break;
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
const init = body.slice(start, end);
|
|
1995
|
+
const read = [];
|
|
1996
|
+
paramNames.forEach((p, k) => {
|
|
1997
|
+
if (p && p !== nameParam && new RegExp(`(?<![\\w$.])${p.replace(/\$/g, "\\$")}(?![\\w$])`).test(init))
|
|
1998
|
+
read.push(k);
|
|
1999
|
+
});
|
|
2000
|
+
return read.length === 1 ? read[0] : -1;
|
|
2001
|
+
}
|
|
1964
2002
|
function scanWrappers(tree) {
|
|
1965
2003
|
const cached = wrapperScans.get(tree);
|
|
1966
2004
|
if (cached) return cached;
|
|
@@ -1980,7 +2018,7 @@ function scanWrappers(tree) {
|
|
|
1980
2018
|
lineStart.push(off);
|
|
1981
2019
|
off += l.raw.length + 1;
|
|
1982
2020
|
}
|
|
1983
|
-
const
|
|
2021
|
+
const lineOf6 = (idx) => {
|
|
1984
2022
|
let lo = 0;
|
|
1985
2023
|
let hi = lineStart.length - 1;
|
|
1986
2024
|
while (lo < hi) {
|
|
@@ -2031,12 +2069,13 @@ function scanWrappers(tree) {
|
|
|
2031
2069
|
const k = paramNames.indexOf(c[1]);
|
|
2032
2070
|
if (k < 0) continue;
|
|
2033
2071
|
idxs.add(k);
|
|
2034
|
-
scan.internal.add(`${file.rel}:${
|
|
2072
|
+
scan.internal.add(`${file.rel}:${lineOf6(bodyOpen + (c.index ?? 0))}`);
|
|
2035
2073
|
const after = body.slice((c.index ?? 0) + c[0].length, (c.index ?? 0) + c[0].length + 3e3);
|
|
2036
2074
|
const dm = after.match(/(?:^|[\s{,])description\b\s*(?::\s*([A-Za-z_$][\w$]*))?\s*[,}]/);
|
|
2037
2075
|
if (dm) {
|
|
2038
2076
|
const ref = dm[1] ?? "description";
|
|
2039
2077
|
descIdx = paramNames.indexOf(ref);
|
|
2078
|
+
if (descIdx < 0) descIdx = parameterBehindLocal(body, ref, paramNames, c[1]);
|
|
2040
2079
|
}
|
|
2041
2080
|
}
|
|
2042
2081
|
if (idxs.size !== 1) return;
|
|
@@ -2046,7 +2085,7 @@ function scanWrappers(tree) {
|
|
|
2046
2085
|
descIdx,
|
|
2047
2086
|
file,
|
|
2048
2087
|
declLine: line.n,
|
|
2049
|
-
endLine:
|
|
2088
|
+
endLine: lineOf6(bodyEnd)
|
|
2050
2089
|
});
|
|
2051
2090
|
});
|
|
2052
2091
|
}
|
|
@@ -2787,7 +2826,7 @@ function governingWorkflows(tree) {
|
|
|
2787
2826
|
}
|
|
2788
2827
|
return [];
|
|
2789
2828
|
}
|
|
2790
|
-
function
|
|
2829
|
+
function lineOf2(text, re) {
|
|
2791
2830
|
const m = re.exec(text);
|
|
2792
2831
|
if (!m) return 1;
|
|
2793
2832
|
return text.slice(0, m.index).split("\n").length;
|
|
@@ -3148,7 +3187,7 @@ function collect(base) {
|
|
|
3148
3187
|
const out = [];
|
|
3149
3188
|
const unmeasured = [];
|
|
3150
3189
|
const relOf = (full) => relative3(base, full).split(sep3).join("/");
|
|
3151
|
-
const
|
|
3190
|
+
const walk4 = (dir, depth) => {
|
|
3152
3191
|
if (depth > 8) {
|
|
3153
3192
|
unmeasured.push(`${relOf(dir)}/ (deeper than 8 levels, not walked)`);
|
|
3154
3193
|
return;
|
|
@@ -3172,7 +3211,7 @@ function collect(base) {
|
|
|
3172
3211
|
continue;
|
|
3173
3212
|
}
|
|
3174
3213
|
if (st.isDirectory()) {
|
|
3175
|
-
if (!WALK_SKIP.has(name))
|
|
3214
|
+
if (!WALK_SKIP.has(name)) walk4(full, depth + 1);
|
|
3176
3215
|
} else if (candidate) {
|
|
3177
3216
|
if (!st.isFile()) {
|
|
3178
3217
|
unmeasured.push(`${rel2} (not a regular file, not read)`);
|
|
@@ -3190,7 +3229,7 @@ function collect(base) {
|
|
|
3190
3229
|
}
|
|
3191
3230
|
}
|
|
3192
3231
|
};
|
|
3193
|
-
|
|
3232
|
+
walk4(base, 0);
|
|
3194
3233
|
return { bundles: out, unmeasured };
|
|
3195
3234
|
}
|
|
3196
3235
|
var kb = (n) => `${(n / 1024).toFixed(1)} KB gz`;
|
|
@@ -6659,16 +6698,16 @@ function hostToolProblems(tree) {
|
|
|
6659
6698
|
const unresolvedSites = findUnresolvedToolSites(tree);
|
|
6660
6699
|
const named = [];
|
|
6661
6700
|
for (const c of caps) {
|
|
6662
|
-
for (const
|
|
6663
|
-
if (c.key !==
|
|
6701
|
+
for (const ts9 of TOOL_SETTINGS) {
|
|
6702
|
+
if (c.key !== ts9.cap) continue;
|
|
6664
6703
|
const m = c.body.match(
|
|
6665
|
-
new RegExp(`["'\`]?${
|
|
6704
|
+
new RegExp(`["'\`]?${ts9.setting}["'\`]?\\s*:\\s*["'\`]([^"'\`]+)["'\`]`)
|
|
6666
6705
|
);
|
|
6667
6706
|
if (m)
|
|
6668
6707
|
named.push({
|
|
6669
6708
|
name: m[1],
|
|
6670
|
-
kind:
|
|
6671
|
-
from: `${
|
|
6709
|
+
kind: ts9.kind,
|
|
6710
|
+
from: `${ts9.cap}.${ts9.setting}`,
|
|
6672
6711
|
anchor: c.anchor
|
|
6673
6712
|
});
|
|
6674
6713
|
}
|
|
@@ -9173,7 +9212,7 @@ function jsonToS(v, root, seen, depth = 0) {
|
|
|
9173
9212
|
return v.enum !== void 0 || v.const !== void 0 ? SCALAR : { k: "any" };
|
|
9174
9213
|
return parts.length === 1 ? parts[0] : { k: "all", parts };
|
|
9175
9214
|
}
|
|
9176
|
-
function
|
|
9215
|
+
function walk3(s, path, useAt, out, loc) {
|
|
9177
9216
|
const offsetsFor = (...offs) => offs.filter((o) => o !== void 0);
|
|
9178
9217
|
switch (s.k) {
|
|
9179
9218
|
case "union": {
|
|
@@ -9202,18 +9241,18 @@ function walk2(s, path, useAt, out, loc) {
|
|
|
9202
9241
|
anchor: loc(unreadB[0].at ?? s.at ?? useAt).anchor
|
|
9203
9242
|
});
|
|
9204
9243
|
}
|
|
9205
|
-
for (const b of branches2) if (b.k !== "unread")
|
|
9244
|
+
for (const b of branches2) if (b.k !== "unread") walk3(b, path, useAt, out, loc);
|
|
9206
9245
|
return;
|
|
9207
9246
|
}
|
|
9208
9247
|
case "array":
|
|
9209
|
-
if (s.items)
|
|
9210
|
-
s.prefix.forEach((p, i) =>
|
|
9248
|
+
if (s.items) walk3(s.items, `${path}[]`, useAt, out, loc);
|
|
9249
|
+
s.prefix.forEach((p, i) => walk3(p, `${path}[${i}]`, useAt, out, loc));
|
|
9211
9250
|
return;
|
|
9212
9251
|
case "object":
|
|
9213
|
-
for (const p of s.props)
|
|
9252
|
+
for (const p of s.props) walk3(p.schema, `${path}.${p.label}`, p.at ?? useAt, out, loc);
|
|
9214
9253
|
return;
|
|
9215
9254
|
case "all":
|
|
9216
|
-
for (const p of s.parts)
|
|
9255
|
+
for (const p of s.parts) walk3(p, path, useAt, out, loc);
|
|
9217
9256
|
return;
|
|
9218
9257
|
case "unread":
|
|
9219
9258
|
out.push({
|
|
@@ -9541,7 +9580,7 @@ function runStatic(tree) {
|
|
|
9541
9580
|
const finalSchema = located.kind === "json" ? jsonSchemaOf(located.node, ctx) : evalZod(located.node, ctx);
|
|
9542
9581
|
j.argumentCount += countArgs(finalSchema);
|
|
9543
9582
|
const sites = [];
|
|
9544
|
-
|
|
9583
|
+
walk3(finalSchema, tool.name, void 0, sites, loc);
|
|
9545
9584
|
judgeSites(dedupe(sites), false, j);
|
|
9546
9585
|
}
|
|
9547
9586
|
return verdictOf(j, "static, from source", tools[0].anchor);
|
|
@@ -9584,7 +9623,7 @@ function runServedHalf(runtime) {
|
|
|
9584
9623
|
const schema = jsonToS(t.inputSchema, { root: t.inputSchema }, /* @__PURE__ */ new Set());
|
|
9585
9624
|
j.argumentCount += countArgs(schema);
|
|
9586
9625
|
const sites = [];
|
|
9587
|
-
|
|
9626
|
+
walk3(schema, t.name, void 0, sites, () => ({ anchor: `${anchor} tools/list ${t.name}` }));
|
|
9588
9627
|
judgeSites(dedupe(sites), true, j);
|
|
9589
9628
|
}
|
|
9590
9629
|
return verdictOf(j, "served tools/list inputSchema", anchor);
|
|
@@ -9764,7 +9803,7 @@ function controlSites(text) {
|
|
|
9764
9803
|
if (located.kind !== "zod") return [];
|
|
9765
9804
|
const ctx = moduleCtx(file, null);
|
|
9766
9805
|
const sites = [];
|
|
9767
|
-
|
|
9806
|
+
walk3(evalZod(located.node, ctx), "c", void 0, sites, () => ({ anchor: "<s43-control>" }));
|
|
9768
9807
|
return sites;
|
|
9769
9808
|
}
|
|
9770
9809
|
function s43Controls() {
|
|
@@ -10309,7 +10348,7 @@ function ceilingCensus(tree) {
|
|
|
10309
10348
|
continue;
|
|
10310
10349
|
}
|
|
10311
10350
|
if (!isRecord(json) || !("contextCeiling" in json)) continue;
|
|
10312
|
-
const anchor = `${f.rel}:${
|
|
10351
|
+
const anchor = `${f.rel}:${lineOf2(text, /"contextCeiling"/)}`;
|
|
10313
10352
|
const c = json.contextCeiling;
|
|
10314
10353
|
if (!isRecord(c)) {
|
|
10315
10354
|
census.partial.push({
|
|
@@ -11464,11 +11503,67 @@ var BARE_STRING_RE = /^\s*["'`]([^"'`]+)["'`]\s*,?\s*$/;
|
|
|
11464
11503
|
var BACKWARD_LOOKBACK = 10;
|
|
11465
11504
|
var FORWARD_LOOKAHEAD = 6;
|
|
11466
11505
|
var DESCRIPTION_KEY_RE = /\bdescription\s*:/;
|
|
11506
|
+
function templateLength(s) {
|
|
11507
|
+
let i = 1;
|
|
11508
|
+
while (i < s.length) {
|
|
11509
|
+
const c = s[i];
|
|
11510
|
+
if (c === "\\") i += 2;
|
|
11511
|
+
else if (c === "`") return i + 1;
|
|
11512
|
+
else if (c === "$" && s[i + 1] === "{") {
|
|
11513
|
+
let depth = 1;
|
|
11514
|
+
i += 2;
|
|
11515
|
+
while (i < s.length && depth > 0) {
|
|
11516
|
+
const d = s[i];
|
|
11517
|
+
if (d === "`") {
|
|
11518
|
+
const inner = templateLength(s.slice(i));
|
|
11519
|
+
if (inner < 0) return -1;
|
|
11520
|
+
i += inner;
|
|
11521
|
+
continue;
|
|
11522
|
+
}
|
|
11523
|
+
if (d === '"' || d === "'") {
|
|
11524
|
+
for (i++; i < s.length && s[i] !== d; i++) if (s[i] === "\\") i++;
|
|
11525
|
+
} else if (d === "{") depth++;
|
|
11526
|
+
else if (d === "}") depth--;
|
|
11527
|
+
i++;
|
|
11528
|
+
}
|
|
11529
|
+
} else i++;
|
|
11530
|
+
}
|
|
11531
|
+
return -1;
|
|
11532
|
+
}
|
|
11533
|
+
function readDeclaredDescription(text) {
|
|
11534
|
+
let rest = text.replace(/^\s+/, "");
|
|
11535
|
+
let acc = "";
|
|
11536
|
+
let first = true;
|
|
11537
|
+
for (; ; ) {
|
|
11538
|
+
const q = rest[0];
|
|
11539
|
+
let len2 = -1;
|
|
11540
|
+
if (q === "`") len2 = templateLength(rest);
|
|
11541
|
+
else if (q === '"' || q === "'") {
|
|
11542
|
+
let i = 1;
|
|
11543
|
+
while (i < rest.length && rest[i] !== q && rest[i] !== "\n") i += rest[i] === "\\" ? 2 : 1;
|
|
11544
|
+
if (rest[i] === q) len2 = i + 1;
|
|
11545
|
+
}
|
|
11546
|
+
if (len2 < 0) {
|
|
11547
|
+
const expr = rest.split("\n")[0].trim().slice(0, 60);
|
|
11548
|
+
return { kind: "non-literal", expr: first ? expr : `\u2026+ ${expr}` };
|
|
11549
|
+
}
|
|
11550
|
+
first = false;
|
|
11551
|
+
const piece = rest.slice(0, len2);
|
|
11552
|
+
const lit = q === "`" ? readDescriptionValue(piece) : void 0;
|
|
11553
|
+
acc += lit?.kind === "literal" ? lit.text : q === "`" ? piece : piece.slice(1, -1);
|
|
11554
|
+
rest = rest.slice(len2).replace(/^\s+/, "");
|
|
11555
|
+
if (rest.startsWith("+")) {
|
|
11556
|
+
rest = rest.slice(1).replace(/^\s+/, "");
|
|
11557
|
+
continue;
|
|
11558
|
+
}
|
|
11559
|
+
return { kind: "literal", text: acc };
|
|
11560
|
+
}
|
|
11561
|
+
}
|
|
11467
11562
|
function findInlineDescription(tree, siteAnchor, toolName2) {
|
|
11468
11563
|
const forwarded = wrapperDescriptionArg(tree, siteAnchor);
|
|
11469
11564
|
if (forwarded !== void 0) {
|
|
11470
11565
|
const resolved = /^[A-Za-z_$][\w$]*$/.test(forwarded) ? constExpression(tree, forwarded) : null;
|
|
11471
|
-
const v =
|
|
11566
|
+
const v = readDeclaredDescription(resolved ?? forwarded);
|
|
11472
11567
|
if (v.kind === "literal" && v.text.length > 0) return v.text;
|
|
11473
11568
|
if (v.kind === "non-literal") return v;
|
|
11474
11569
|
}
|
|
@@ -11494,7 +11589,7 @@ function findInlineDescription(tree, siteAnchor, toolName2) {
|
|
|
11494
11589
|
if (key && key.index !== void 0) {
|
|
11495
11590
|
const after = line.raw.slice(key.index + key[0].length);
|
|
11496
11591
|
const tail = file.lines.slice(n, n + 8).filter((l) => !l.comment).map((l) => l.raw).join("\n");
|
|
11497
|
-
const v =
|
|
11592
|
+
const v = readDeclaredDescription(`${after}
|
|
11498
11593
|
${tail}`);
|
|
11499
11594
|
if (v.kind === "literal" && v.text.length > 0) return v.text;
|
|
11500
11595
|
if (v.kind === "non-literal") {
|
|
@@ -11508,6 +11603,12 @@ ${tail}`);
|
|
|
11508
11603
|
if (n >= siteLine) {
|
|
11509
11604
|
const bare = line.raw.match(BARE_STRING_RE);
|
|
11510
11605
|
if (bare && bare[1] !== toolName2) return bare[1];
|
|
11606
|
+
if (!bare && /^\s*(["'`]).*\1\s*\+\s*$/.test(line.raw)) {
|
|
11607
|
+
const chain = file.lines.slice(n - 1, n + 8).filter((l) => !l.comment).map((l) => l.raw).join("\n");
|
|
11608
|
+
const v = readDeclaredDescription(chain);
|
|
11609
|
+
if (v.kind === "literal" && v.text.length > 0 && v.text !== toolName2) return v.text;
|
|
11610
|
+
if (v.kind === "non-literal" && !nonLiteral) nonLiteral = v;
|
|
11611
|
+
}
|
|
11511
11612
|
}
|
|
11512
11613
|
}
|
|
11513
11614
|
return nonLiteral;
|
|
@@ -13097,7 +13198,7 @@ function workflowEvidence(text) {
|
|
|
13097
13198
|
if (NOTIFY_RE.test(window)) signal = i + 1;
|
|
13098
13199
|
}
|
|
13099
13200
|
});
|
|
13100
|
-
const identity = IDENTITY_CHECK_RE.test(text) ?
|
|
13201
|
+
const identity = IDENTITY_CHECK_RE.test(text) ? lineOf2(text, IDENTITY_CHECK_RE) : null;
|
|
13101
13202
|
return { signal, identity };
|
|
13102
13203
|
}
|
|
13103
13204
|
var c28DeployFailureSignal = {
|
|
@@ -13146,7 +13247,7 @@ var c28DeployFailureSignal = {
|
|
|
13146
13247
|
for (const w of deploys) {
|
|
13147
13248
|
const ev = workflowEvidence(w.text);
|
|
13148
13249
|
if (ev.signal === null && ev.identity === null) {
|
|
13149
|
-
reds.push(`${w.rel}:${
|
|
13250
|
+
reds.push(`${w.rel}:${lineOf2(w.text, DEPLOY_RE)}`);
|
|
13150
13251
|
} else {
|
|
13151
13252
|
oks.push({
|
|
13152
13253
|
rel: w.rel,
|
|
@@ -13196,7 +13297,7 @@ function pluginPackages(tree) {
|
|
|
13196
13297
|
function filesUnder(dir, unread2, rel2) {
|
|
13197
13298
|
const out = /* @__PURE__ */ new Map();
|
|
13198
13299
|
let incomplete = false;
|
|
13199
|
-
const
|
|
13300
|
+
const walk4 = (d, prefix) => {
|
|
13200
13301
|
let names2;
|
|
13201
13302
|
try {
|
|
13202
13303
|
names2 = readdirSync8(d);
|
|
@@ -13209,7 +13310,7 @@ function filesUnder(dir, unread2, rel2) {
|
|
|
13209
13310
|
const full = join12(d, n);
|
|
13210
13311
|
const r = prefix ? `${prefix}/${n}` : n;
|
|
13211
13312
|
try {
|
|
13212
|
-
if (statSync11(full).isDirectory())
|
|
13313
|
+
if (statSync11(full).isDirectory()) walk4(full, r);
|
|
13213
13314
|
else out.set(r, readFileSync11(full));
|
|
13214
13315
|
} catch (e) {
|
|
13215
13316
|
out.set(r, null);
|
|
@@ -13220,7 +13321,7 @@ function filesUnder(dir, unread2, rel2) {
|
|
|
13220
13321
|
}
|
|
13221
13322
|
}
|
|
13222
13323
|
};
|
|
13223
|
-
|
|
13324
|
+
walk4(dir, "");
|
|
13224
13325
|
return { files: out, incomplete };
|
|
13225
13326
|
}
|
|
13226
13327
|
function absenceOf(base, rel2) {
|
|
@@ -14076,7 +14177,7 @@ function writesFile(text, f) {
|
|
|
14076
14177
|
function testFiles(tree, unread2) {
|
|
14077
14178
|
const base = baseOf(tree);
|
|
14078
14179
|
const out = [];
|
|
14079
|
-
const
|
|
14180
|
+
const walk4 = (dir, rel2) => {
|
|
14080
14181
|
let names2;
|
|
14081
14182
|
try {
|
|
14082
14183
|
names2 = readdirSync10(dir);
|
|
@@ -14093,14 +14194,14 @@ function testFiles(tree, unread2) {
|
|
|
14093
14194
|
} catch {
|
|
14094
14195
|
continue;
|
|
14095
14196
|
}
|
|
14096
|
-
if (st.isDirectory())
|
|
14197
|
+
if (st.isDirectory()) walk4(full, `${rel2}/${name}`);
|
|
14097
14198
|
else if (/\.[cm]?[jt]sx?$/.test(name))
|
|
14098
14199
|
out.push({ rel: `${rel2}/${name}`, text: readText(full) ?? "" });
|
|
14099
14200
|
}
|
|
14100
14201
|
};
|
|
14101
14202
|
for (const d of ["tests", "test", "__tests__"]) {
|
|
14102
14203
|
try {
|
|
14103
|
-
if (statSync13(join14(base, d)).isDirectory())
|
|
14204
|
+
if (statSync13(join14(base, d)).isDirectory()) walk4(join14(base, d), d);
|
|
14104
14205
|
} catch {
|
|
14105
14206
|
}
|
|
14106
14207
|
}
|
|
@@ -15346,7 +15447,7 @@ function walkManifests(tree, dir, out, unread2) {
|
|
|
15346
15447
|
}
|
|
15347
15448
|
}
|
|
15348
15449
|
}
|
|
15349
|
-
function
|
|
15450
|
+
function lineOf3(text, pkg) {
|
|
15350
15451
|
const i = text.split("\n").findIndex((l) => l.includes(`"${pkg}"`));
|
|
15351
15452
|
return i < 0 ? 1 : i + 1;
|
|
15352
15453
|
}
|
|
@@ -15387,7 +15488,7 @@ function c41Collect(tree) {
|
|
|
15387
15488
|
if (alias) {
|
|
15388
15489
|
decls.push({
|
|
15389
15490
|
manifest,
|
|
15390
|
-
line:
|
|
15491
|
+
line: lineOf3(text, pkg),
|
|
15391
15492
|
field: `${field} (alias ${pkg})`,
|
|
15392
15493
|
pkg: alias.pkg,
|
|
15393
15494
|
spec: alias.spec
|
|
@@ -15395,7 +15496,7 @@ function c41Collect(tree) {
|
|
|
15395
15496
|
continue;
|
|
15396
15497
|
}
|
|
15397
15498
|
if (!pkg.startsWith(SCOPE)) continue;
|
|
15398
|
-
decls.push({ manifest, line:
|
|
15499
|
+
decls.push({ manifest, line: lineOf3(text, pkg), field, pkg, spec });
|
|
15399
15500
|
}
|
|
15400
15501
|
}
|
|
15401
15502
|
}
|
|
@@ -16411,10 +16512,137 @@ var d5 = {
|
|
|
16411
16512
|
};
|
|
16412
16513
|
|
|
16413
16514
|
// src/detectors/d6.ts
|
|
16515
|
+
import * as ts from "typescript";
|
|
16414
16516
|
var COMMUNITY_RE = /["'`]io\.modelcontextprotocol\/ui["'`]\s*:|_meta\s*\[\s*["'`]io\.modelcontextprotocol\/ui["'`]\s*\]/;
|
|
16415
16517
|
var FLAT_RE = /["'`]ui\/resourceUri["'`]\s*:|_meta\s*\[\s*["'`]ui\/resourceUri["'`]\s*\]/;
|
|
16416
|
-
var
|
|
16417
|
-
|
|
16518
|
+
var RESOURCE_REGISTRATIONS = /* @__PURE__ */ new Set([
|
|
16519
|
+
"registerResource",
|
|
16520
|
+
"resource",
|
|
16521
|
+
"registerResourceTemplate",
|
|
16522
|
+
"registerAppResource"
|
|
16523
|
+
]);
|
|
16524
|
+
function staticKey(name) {
|
|
16525
|
+
if (ts.isIdentifier(name) || ts.isStringLiteralLike(name) || ts.isNumericLiteral(name))
|
|
16526
|
+
return name.text;
|
|
16527
|
+
if (ts.isComputedPropertyName(name) && ts.isStringLiteralLike(name.expression))
|
|
16528
|
+
return name.expression.text;
|
|
16529
|
+
return void 0;
|
|
16530
|
+
}
|
|
16531
|
+
function scanKind(rel2) {
|
|
16532
|
+
return rel2.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
16533
|
+
}
|
|
16534
|
+
function scanFileForBinding(file, scan) {
|
|
16535
|
+
const text = file.lines.map((l) => l.raw).join("\n");
|
|
16536
|
+
if (!text.includes("_meta") && !text.includes("registerAppTool")) return;
|
|
16537
|
+
const sf = ts.createSourceFile(file.rel, text, ts.ScriptTarget.Latest, true, scanKind(file.rel));
|
|
16538
|
+
const at = (n) => `${file.rel}:${sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1}`;
|
|
16539
|
+
const unread2 = (n, why) => {
|
|
16540
|
+
scan.unread.push({ anchor: at(n), why });
|
|
16541
|
+
};
|
|
16542
|
+
const bind = (n) => {
|
|
16543
|
+
scan.bound ??= { anchor: at(n) };
|
|
16544
|
+
};
|
|
16545
|
+
const readUiObject = (obj) => {
|
|
16546
|
+
let named = false;
|
|
16547
|
+
let opaque = false;
|
|
16548
|
+
for (const p of obj.properties) {
|
|
16549
|
+
if (ts.isSpreadAssignment(p)) {
|
|
16550
|
+
opaque = true;
|
|
16551
|
+
continue;
|
|
16552
|
+
}
|
|
16553
|
+
if (ts.isShorthandPropertyAssignment(p)) {
|
|
16554
|
+
if (p.name.text === "resourceUri") named = true;
|
|
16555
|
+
continue;
|
|
16556
|
+
}
|
|
16557
|
+
if (ts.isPropertyAssignment(p) || ts.isMethodDeclaration(p)) {
|
|
16558
|
+
const k = staticKey(p.name);
|
|
16559
|
+
if (k === void 0) opaque = true;
|
|
16560
|
+
else if (k === "resourceUri") named = true;
|
|
16561
|
+
}
|
|
16562
|
+
}
|
|
16563
|
+
if (named) bind(obj);
|
|
16564
|
+
else if (opaque)
|
|
16565
|
+
unread2(obj, "a `ui` object built from a spread or a computed key that names no resourceUri");
|
|
16566
|
+
else scan.partial ??= { anchor: at(obj) };
|
|
16567
|
+
};
|
|
16568
|
+
const readUiValue = (v, site) => {
|
|
16569
|
+
const e = ts.isParenthesizedExpression(v) ? v.expression : v;
|
|
16570
|
+
if (ts.isObjectLiteralExpression(e)) readUiObject(e);
|
|
16571
|
+
else
|
|
16572
|
+
unread2(
|
|
16573
|
+
site,
|
|
16574
|
+
`\`ui\` is the expression \`${e.getText(sf).slice(0, 40)}\`, not an object literal`
|
|
16575
|
+
);
|
|
16576
|
+
};
|
|
16577
|
+
const readMetaObject = (obj) => {
|
|
16578
|
+
let sawUi = false;
|
|
16579
|
+
let opaque = false;
|
|
16580
|
+
for (const p of obj.properties) {
|
|
16581
|
+
if (ts.isSpreadAssignment(p)) {
|
|
16582
|
+
opaque = true;
|
|
16583
|
+
continue;
|
|
16584
|
+
}
|
|
16585
|
+
if (ts.isShorthandPropertyAssignment(p)) {
|
|
16586
|
+
if (p.name.text === "ui") {
|
|
16587
|
+
sawUi = true;
|
|
16588
|
+
unread2(p, "`ui` is a shorthand variable, not an object literal");
|
|
16589
|
+
}
|
|
16590
|
+
continue;
|
|
16591
|
+
}
|
|
16592
|
+
if (!ts.isPropertyAssignment(p)) continue;
|
|
16593
|
+
const k = staticKey(p.name);
|
|
16594
|
+
if (k === void 0) {
|
|
16595
|
+
opaque = true;
|
|
16596
|
+
continue;
|
|
16597
|
+
}
|
|
16598
|
+
if (k === "ui") {
|
|
16599
|
+
sawUi = true;
|
|
16600
|
+
readUiValue(p.initializer, p);
|
|
16601
|
+
}
|
|
16602
|
+
}
|
|
16603
|
+
if (!sawUi && opaque)
|
|
16604
|
+
unread2(obj, "a `_meta` object built from a spread or a computed key, no `ui` beside it");
|
|
16605
|
+
};
|
|
16606
|
+
const visit = (n) => {
|
|
16607
|
+
if (ts.isCallExpression(n)) {
|
|
16608
|
+
const c = n.expression;
|
|
16609
|
+
const name = ts.isIdentifier(c) ? c.text : ts.isPropertyAccessExpression(c) ? c.name.text : "";
|
|
16610
|
+
if (name === "registerAppTool") bind(n);
|
|
16611
|
+
if (RESOURCE_REGISTRATIONS.has(name)) return;
|
|
16612
|
+
}
|
|
16613
|
+
if (ts.isPropertyAssignment(n) && staticKey(n.name) === "_meta") {
|
|
16614
|
+
const v = ts.isParenthesizedExpression(n.initializer) ? n.initializer.expression : n.initializer;
|
|
16615
|
+
if (ts.isObjectLiteralExpression(v)) readMetaObject(v);
|
|
16616
|
+
else
|
|
16617
|
+
unread2(
|
|
16618
|
+
n,
|
|
16619
|
+
`\`_meta\` is the expression \`${v.getText(sf).slice(0, 40)}\`, not an object literal`
|
|
16620
|
+
);
|
|
16621
|
+
}
|
|
16622
|
+
if (ts.isBinaryExpression(n) && n.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
|
|
16623
|
+
const last = lastSegment2(n.left);
|
|
16624
|
+
if (last?.name === "resourceUri" && lastSegment2(last.obj)?.name === "ui") {
|
|
16625
|
+
const owner = lastSegment2(last.obj);
|
|
16626
|
+
if (owner && lastSegment2(owner.obj)?.name === "_meta") bind(n);
|
|
16627
|
+
} else if (last?.name === "ui" && lastSegment2(last.obj)?.name === "_meta") {
|
|
16628
|
+
readUiValue(n.right, n);
|
|
16629
|
+
}
|
|
16630
|
+
}
|
|
16631
|
+
ts.forEachChild(n, visit);
|
|
16632
|
+
};
|
|
16633
|
+
visit(sf);
|
|
16634
|
+
}
|
|
16635
|
+
function lastSegment2(e) {
|
|
16636
|
+
if (ts.isPropertyAccessExpression(e)) return { obj: e.expression, name: e.name.text };
|
|
16637
|
+
if (ts.isElementAccessExpression(e) && ts.isStringLiteralLike(e.argumentExpression))
|
|
16638
|
+
return { obj: e.expression, name: e.argumentExpression.text };
|
|
16639
|
+
return void 0;
|
|
16640
|
+
}
|
|
16641
|
+
function scanUiBinding(tree) {
|
|
16642
|
+
const scan = { bound: null, partial: null, unread: [] };
|
|
16643
|
+
for (const file of tree.files) scanFileForBinding(file, scan);
|
|
16644
|
+
return scan;
|
|
16645
|
+
}
|
|
16418
16646
|
var d6 = {
|
|
16419
16647
|
id: "D6 mcp-apps ui-key",
|
|
16420
16648
|
rule: "A-6",
|
|
@@ -16422,15 +16650,11 @@ var d6 = {
|
|
|
16422
16650
|
run(tree) {
|
|
16423
16651
|
let community = null;
|
|
16424
16652
|
let flat = null;
|
|
16425
|
-
let nested2 = null;
|
|
16426
|
-
let sawResourceUri = false;
|
|
16427
16653
|
for (const file of tree.files) {
|
|
16428
16654
|
for (const line of file.lines) {
|
|
16429
16655
|
if (line.comment) continue;
|
|
16430
16656
|
if (!community && COMMUNITY_RE.test(line.raw)) community = { file: file.rel, line: line.n };
|
|
16431
16657
|
if (!flat && FLAT_RE.test(line.raw)) flat = { file: file.rel, line: line.n };
|
|
16432
|
-
if (!nested2 && NESTED_UI_RE.test(line.raw)) nested2 = { file: file.rel, line: line.n };
|
|
16433
|
-
if (RESOURCE_URI_RE.test(line.raw)) sawResourceUri = true;
|
|
16434
16658
|
}
|
|
16435
16659
|
}
|
|
16436
16660
|
if (community) {
|
|
@@ -16449,17 +16673,29 @@ var d6 = {
|
|
|
16449
16673
|
verdict: "flat ui/resourceUri key (deprecated) -> _meta.ui.resourceUri"
|
|
16450
16674
|
};
|
|
16451
16675
|
}
|
|
16452
|
-
|
|
16676
|
+
const binding = scanUiBinding(tree);
|
|
16677
|
+
if (binding.bound) {
|
|
16453
16678
|
return {
|
|
16454
16679
|
id: this.id,
|
|
16455
|
-
anchor:
|
|
16680
|
+
anchor: binding.bound.anchor,
|
|
16456
16681
|
state: "present",
|
|
16457
16682
|
verdict: "GA nested _meta.ui.resourceUri"
|
|
16458
16683
|
};
|
|
16459
16684
|
}
|
|
16460
16685
|
const ui = uiResourceSites(tree);
|
|
16461
16686
|
if (ui.length > 0) {
|
|
16462
|
-
|
|
16687
|
+
if (binding.unread.length > 0) {
|
|
16688
|
+
const u = binding.unread[0];
|
|
16689
|
+
const reason = `could not determine binding: the App serves ${ui.length} ui:// resource(s) and no \`_meta.ui.resourceUri\` was read, but ${u.anchor} holds a shape the reader cannot follow (${u.why})${binding.unread.length > 1 ? `; ${binding.unread.length - 1} more` : ""} (A-6)`;
|
|
16690
|
+
return {
|
|
16691
|
+
id: this.id,
|
|
16692
|
+
anchor: u.anchor,
|
|
16693
|
+
state: "could-not-judge",
|
|
16694
|
+
reason,
|
|
16695
|
+
verdict: `could not judge: ${reason}`
|
|
16696
|
+
};
|
|
16697
|
+
}
|
|
16698
|
+
const partial = binding.partial ? ` (a nested _meta.ui at ${binding.partial.anchor} names no resourceUri)` : "";
|
|
16463
16699
|
return {
|
|
16464
16700
|
id: this.id,
|
|
16465
16701
|
anchor: ui[0].anchor,
|
|
@@ -17798,7 +18034,7 @@ function findExtensionManifests(tree) {
|
|
|
17798
18034
|
} catch {
|
|
17799
18035
|
return out;
|
|
17800
18036
|
}
|
|
17801
|
-
const
|
|
18037
|
+
const walk4 = (dir) => {
|
|
17802
18038
|
let entries;
|
|
17803
18039
|
try {
|
|
17804
18040
|
entries = readdirSync13(dir);
|
|
@@ -17820,7 +18056,7 @@ function findExtensionManifests(tree) {
|
|
|
17820
18056
|
recordSkip(tree, full, base);
|
|
17821
18057
|
continue;
|
|
17822
18058
|
}
|
|
17823
|
-
|
|
18059
|
+
walk4(full);
|
|
17824
18060
|
} else if (name === "extension.json") {
|
|
17825
18061
|
if (!st.isFile()) {
|
|
17826
18062
|
recordSkip(tree, full, base, "not a regular file (FIFO, socket or device) \u2014 not read");
|
|
@@ -17830,7 +18066,7 @@ function findExtensionManifests(tree) {
|
|
|
17830
18066
|
}
|
|
17831
18067
|
}
|
|
17832
18068
|
};
|
|
17833
|
-
|
|
18069
|
+
walk4(base);
|
|
17834
18070
|
return out;
|
|
17835
18071
|
}
|
|
17836
18072
|
|
|
@@ -18531,7 +18767,7 @@ function findHooksDirs(tree, unreadable2, gaps) {
|
|
|
18531
18767
|
unreadable2.push({ anchor, reason });
|
|
18532
18768
|
}
|
|
18533
18769
|
};
|
|
18534
|
-
const
|
|
18770
|
+
const walk4 = (dir) => {
|
|
18535
18771
|
let entries;
|
|
18536
18772
|
try {
|
|
18537
18773
|
entries = readdirSync14(dir);
|
|
@@ -18571,10 +18807,10 @@ function findHooksDirs(tree, unreadable2, gaps) {
|
|
|
18571
18807
|
}
|
|
18572
18808
|
out.push({ anchor: `${name}/`, tokens });
|
|
18573
18809
|
}
|
|
18574
|
-
|
|
18810
|
+
walk4(full);
|
|
18575
18811
|
}
|
|
18576
18812
|
};
|
|
18577
|
-
|
|
18813
|
+
walk4(base);
|
|
18578
18814
|
return out;
|
|
18579
18815
|
}
|
|
18580
18816
|
var LIFECYCLE_OBJ_RE = /\blifecycle\s*:\s*\{/;
|
|
@@ -19094,7 +19330,7 @@ function collectHooksDirSources(tree, unreadable2, gaps) {
|
|
|
19094
19330
|
unreadable2.push({ anchor, reason });
|
|
19095
19331
|
}
|
|
19096
19332
|
};
|
|
19097
|
-
const
|
|
19333
|
+
const walk4 = (dir) => {
|
|
19098
19334
|
let entries;
|
|
19099
19335
|
try {
|
|
19100
19336
|
entries = readdirSync15(dir);
|
|
@@ -19149,10 +19385,10 @@ function collectHooksDirSources(tree, unreadable2, gaps) {
|
|
|
19149
19385
|
});
|
|
19150
19386
|
}
|
|
19151
19387
|
}
|
|
19152
|
-
|
|
19388
|
+
walk4(full);
|
|
19153
19389
|
}
|
|
19154
19390
|
};
|
|
19155
|
-
|
|
19391
|
+
walk4(base);
|
|
19156
19392
|
return out;
|
|
19157
19393
|
}
|
|
19158
19394
|
var LIFECYCLE_OBJ_RE2 = /\blifecycle\s*:\s*\{/;
|
|
@@ -19519,6 +19755,194 @@ var dServer2 = guardUnreadablePackageJson(dServer2Inner, {
|
|
|
19519
19755
|
authoritative: false
|
|
19520
19756
|
});
|
|
19521
19757
|
|
|
19758
|
+
// src/detectors/dServer6Flow.ts
|
|
19759
|
+
import * as ts2 from "typescript";
|
|
19760
|
+
var LOG_CALL_RE = /^(?:console|logger|log)\.(?:log|info|warn|error|debug|trace)$/;
|
|
19761
|
+
var STREAM_WRITE_RE = /^process\.(?:stderr|stdout)\.write$/;
|
|
19762
|
+
var ALWAYS_INFRA_PROPS = /* @__PURE__ */ new Set(["hostname"]);
|
|
19763
|
+
var OBJECT_INFRA_PROPS = /* @__PURE__ */ new Set(["host", "url", "origin", "href"]);
|
|
19764
|
+
var SERVERISH_NAME_RE = /server|srv|listener|endpoint|url|uri|origin/i;
|
|
19765
|
+
var INFRA_NAME_RE = /host|url|uri|origin|endpoint|addr/i;
|
|
19766
|
+
var SERVER_FACTORY_RE = /(?:^|\.)(?:serve|createServer|listen)$/;
|
|
19767
|
+
var MAX_DEPTH = 4;
|
|
19768
|
+
function scriptKind(rel2) {
|
|
19769
|
+
if (/\.tsx$/i.test(rel2)) return ts2.ScriptKind.TSX;
|
|
19770
|
+
if (/\.jsx$/i.test(rel2)) return ts2.ScriptKind.JSX;
|
|
19771
|
+
if (/\.(?:js|mjs|cjs)$/i.test(rel2)) return ts2.ScriptKind.JS;
|
|
19772
|
+
return ts2.ScriptKind.TS;
|
|
19773
|
+
}
|
|
19774
|
+
function declsIn(scope2, name) {
|
|
19775
|
+
const out = [];
|
|
19776
|
+
if (ts2.isFunctionLike(scope2)) {
|
|
19777
|
+
for (const p of scope2.parameters) {
|
|
19778
|
+
let found = false;
|
|
19779
|
+
const visitName = (n) => {
|
|
19780
|
+
if (ts2.isIdentifier(n)) found ||= n.text === name;
|
|
19781
|
+
else for (const e of n.elements) if (ts2.isBindingElement(e)) visitName(e.name);
|
|
19782
|
+
};
|
|
19783
|
+
visitName(p.name);
|
|
19784
|
+
if (found) out.push({ kind: "opaque" });
|
|
19785
|
+
}
|
|
19786
|
+
}
|
|
19787
|
+
walk(
|
|
19788
|
+
scope2,
|
|
19789
|
+
(n) => {
|
|
19790
|
+
if (ts2.isVariableDeclaration(n)) {
|
|
19791
|
+
if (ts2.isIdentifier(n.name)) {
|
|
19792
|
+
if (n.name.text === name) out.push({ kind: "var", init: n.initializer, node: n });
|
|
19793
|
+
} else if (ts2.isObjectBindingPattern(n.name)) {
|
|
19794
|
+
for (const el of n.name.elements) {
|
|
19795
|
+
if (!ts2.isIdentifier(el.name) || el.name.text !== name) continue;
|
|
19796
|
+
const prop2 = el.propertyName && ts2.isIdentifier(el.propertyName) ? el.propertyName.text : el.propertyName && ts2.isStringLiteralLike(el.propertyName) ? el.propertyName.text : el.propertyName ? void 0 : el.name.text;
|
|
19797
|
+
if (prop2 && n.initializer && !el.dotDotDotToken)
|
|
19798
|
+
out.push({ kind: "binding", prop: prop2, init: n.initializer, node: el });
|
|
19799
|
+
else out.push({ kind: "opaque" });
|
|
19800
|
+
}
|
|
19801
|
+
} else if (ts2.isArrayBindingPattern(n.name)) {
|
|
19802
|
+
for (const el of n.name.elements)
|
|
19803
|
+
if (ts2.isBindingElement(el) && ts2.isIdentifier(el.name) && el.name.text === name)
|
|
19804
|
+
out.push({ kind: "opaque" });
|
|
19805
|
+
}
|
|
19806
|
+
}
|
|
19807
|
+
},
|
|
19808
|
+
true
|
|
19809
|
+
);
|
|
19810
|
+
return out;
|
|
19811
|
+
}
|
|
19812
|
+
function declOf(id) {
|
|
19813
|
+
for (let s = id.parent; s; s = s.parent) {
|
|
19814
|
+
if (!(ts2.isFunctionLike(s) || ts2.isSourceFile(s))) continue;
|
|
19815
|
+
const ds = declsIn(s, id.text);
|
|
19816
|
+
if (ds.length === 0) continue;
|
|
19817
|
+
return ds.length === 1 ? ds[0] : { kind: "opaque" };
|
|
19818
|
+
}
|
|
19819
|
+
return void 0;
|
|
19820
|
+
}
|
|
19821
|
+
function isServerish(e, depth) {
|
|
19822
|
+
const u = unwrap(e);
|
|
19823
|
+
if (depth > MAX_DEPTH) return false;
|
|
19824
|
+
if (ts2.isNewExpression(u)) return dotted(u.expression) === "URL";
|
|
19825
|
+
if (ts2.isCallExpression(u)) {
|
|
19826
|
+
const c = dotted(u.expression);
|
|
19827
|
+
return c !== void 0 && SERVER_FACTORY_RE.test(c);
|
|
19828
|
+
}
|
|
19829
|
+
const pr = propRead(u);
|
|
19830
|
+
if (pr) return OBJECT_INFRA_PROPS.has(pr.name) && isServerish(pr.obj, depth + 1);
|
|
19831
|
+
if (ts2.isIdentifier(u)) {
|
|
19832
|
+
if (SERVERISH_NAME_RE.test(u.text)) return true;
|
|
19833
|
+
const d = declOf(u);
|
|
19834
|
+
return d?.kind === "var" && d.init !== void 0 && isServerish(d.init, depth + 1);
|
|
19835
|
+
}
|
|
19836
|
+
return false;
|
|
19837
|
+
}
|
|
19838
|
+
function pathOf(obj, name) {
|
|
19839
|
+
const d = dotted(obj);
|
|
19840
|
+
return d === void 0 ? void 0 : `${d}.${name}`;
|
|
19841
|
+
}
|
|
19842
|
+
function infraProp(obj, name) {
|
|
19843
|
+
return ALWAYS_INFRA_PROPS.has(name) || OBJECT_INFRA_PROPS.has(name) && isServerish(obj, 0);
|
|
19844
|
+
}
|
|
19845
|
+
function leaves(e, out = []) {
|
|
19846
|
+
const u = unwrap(e);
|
|
19847
|
+
if (ts2.isTemplateExpression(u)) {
|
|
19848
|
+
for (const s of u.templateSpans) leaves(s.expression, out);
|
|
19849
|
+
} else if (ts2.isBinaryExpression(u) && u.operatorToken.kind === ts2.SyntaxKind.PlusToken) {
|
|
19850
|
+
leaves(u.left, out);
|
|
19851
|
+
leaves(u.right, out);
|
|
19852
|
+
} else if (ts2.isConditionalExpression(u)) {
|
|
19853
|
+
leaves(u.whenTrue, out);
|
|
19854
|
+
leaves(u.whenFalse, out);
|
|
19855
|
+
} else if (ts2.isObjectLiteralExpression(u)) {
|
|
19856
|
+
for (const p of u.properties) {
|
|
19857
|
+
if (ts2.isPropertyAssignment(p)) leaves(p.initializer, out);
|
|
19858
|
+
else if (ts2.isShorthandPropertyAssignment(p)) out.push(p.name);
|
|
19859
|
+
}
|
|
19860
|
+
} else if (ts2.isArrayLiteralExpression(u)) {
|
|
19861
|
+
for (const x of u.elements) if (!ts2.isSpreadElement(x)) leaves(x, out);
|
|
19862
|
+
} else if (ts2.isCallExpression(u)) {
|
|
19863
|
+
const callee = dotted(u.expression);
|
|
19864
|
+
if (callee === "String" || callee === "JSON.stringify") {
|
|
19865
|
+
for (const a of u.arguments) leaves(a, out);
|
|
19866
|
+
} else if (ts2.isPropertyAccessExpression(u.expression) && u.expression.name.text === "toString") {
|
|
19867
|
+
leaves(u.expression.expression, out);
|
|
19868
|
+
} else out.push(u);
|
|
19869
|
+
} else {
|
|
19870
|
+
out.push(u);
|
|
19871
|
+
}
|
|
19872
|
+
return out;
|
|
19873
|
+
}
|
|
19874
|
+
function classify3(e, depth) {
|
|
19875
|
+
if (depth > MAX_DEPTH) return null;
|
|
19876
|
+
const u = unwrap(e);
|
|
19877
|
+
const pr = propRead(u);
|
|
19878
|
+
if (pr) {
|
|
19879
|
+
return infraProp(pr.obj, pr.name) ? {
|
|
19880
|
+
kind: "hit",
|
|
19881
|
+
via: `${u.getText()} (a ${pr.name} read off ${pr.obj.getText()})`,
|
|
19882
|
+
path: pathOf(pr.obj, pr.name)
|
|
19883
|
+
} : null;
|
|
19884
|
+
}
|
|
19885
|
+
if (ts2.isIdentifier(u)) {
|
|
19886
|
+
const d = declOf(u);
|
|
19887
|
+
if (!d) return null;
|
|
19888
|
+
if (d.kind === "binding") {
|
|
19889
|
+
return infraProp(d.init, d.prop) ? {
|
|
19890
|
+
kind: "hit",
|
|
19891
|
+
via: `${u.text} (destructured: ${d.prop} of ${d.init.getText()}${d.prop === u.text ? "" : `, renamed ${u.text}`})`,
|
|
19892
|
+
path: pathOf(d.init, d.prop)
|
|
19893
|
+
} : null;
|
|
19894
|
+
}
|
|
19895
|
+
if (d.kind === "var" && d.init) {
|
|
19896
|
+
const inner = unwrap(d.init);
|
|
19897
|
+
for (const l of leaves(inner)) {
|
|
19898
|
+
const v = classify3(l, depth + 1);
|
|
19899
|
+
if (v?.kind === "hit") return { kind: "hit", via: `${u.text} <- ${v.via}`, path: v.path };
|
|
19900
|
+
if (v?.kind === "unknown") return v;
|
|
19901
|
+
}
|
|
19902
|
+
const flowsFromCall = ts2.isCallExpression(inner) || ts2.isNewExpression(inner);
|
|
19903
|
+
if (flowsFromCall && INFRA_NAME_RE.test(u.text) && depth === 0)
|
|
19904
|
+
return {
|
|
19905
|
+
kind: "unknown",
|
|
19906
|
+
reason: `${u.text} is assigned from ${inner.getText().slice(0, 60)}, a call whose value this reader cannot follow`
|
|
19907
|
+
};
|
|
19908
|
+
return null;
|
|
19909
|
+
}
|
|
19910
|
+
if (d.kind === "opaque" && INFRA_NAME_RE.test(u.text) && depth === 0)
|
|
19911
|
+
return {
|
|
19912
|
+
kind: "unknown",
|
|
19913
|
+
reason: `${u.text} is a parameter or has several declarations, so where its value comes from cannot be followed`
|
|
19914
|
+
};
|
|
19915
|
+
}
|
|
19916
|
+
return null;
|
|
19917
|
+
}
|
|
19918
|
+
function dServer6Flow(file) {
|
|
19919
|
+
const hits = [];
|
|
19920
|
+
const unknown = [];
|
|
19921
|
+
const sf = ts2.createSourceFile(
|
|
19922
|
+
file.rel,
|
|
19923
|
+
sourceOf(file),
|
|
19924
|
+
ts2.ScriptTarget.Latest,
|
|
19925
|
+
true,
|
|
19926
|
+
scriptKind(file.rel)
|
|
19927
|
+
);
|
|
19928
|
+
walk(sf, (n) => {
|
|
19929
|
+
if (!ts2.isCallExpression(n)) return;
|
|
19930
|
+
const callee = dotted(n.expression);
|
|
19931
|
+
if (!callee || !(LOG_CALL_RE.test(callee) || STREAM_WRITE_RE.test(callee))) return;
|
|
19932
|
+
for (const arg of n.arguments) {
|
|
19933
|
+
if (ts2.isSpreadElement(arg)) continue;
|
|
19934
|
+
for (const l of leaves(arg)) {
|
|
19935
|
+
const v = classify3(l, 0);
|
|
19936
|
+
if (v?.kind === "hit")
|
|
19937
|
+
hits.push({ line: lineOf(n), text: l.getText(), via: v.via, path: v.path });
|
|
19938
|
+
else if (v?.kind === "unknown")
|
|
19939
|
+
unknown.push({ line: lineOf(n), text: l.getText(), reason: v.reason });
|
|
19940
|
+
}
|
|
19941
|
+
}
|
|
19942
|
+
});
|
|
19943
|
+
return { hits, unknown };
|
|
19944
|
+
}
|
|
19945
|
+
|
|
19522
19946
|
// src/detectors/dServer6.ts
|
|
19523
19947
|
var LOG_OPENER_RE = /\b(?:console|logger|log)\.(?:log|info|warn|error|debug|trace)\s*\(|\bprocess\.(?:stderr|stdout)\.write\s*\(/;
|
|
19524
19948
|
var SECRET_RE = /\b(?:api[_-]?key|token|secret|passwd|password|authorization|auth[_-]?token|bearer|access[_-]?key|client[_-]?secret|private[_-]?key)\b/i;
|
|
@@ -19786,6 +20210,27 @@ var dServer6 = {
|
|
|
19786
20210
|
}
|
|
19787
20211
|
}
|
|
19788
20212
|
}
|
|
20213
|
+
for (const file of tree.files) {
|
|
20214
|
+
const flow = dServer6Flow(file);
|
|
20215
|
+
const seen = new Set(findings.filter((f) => f.form === "D").map((f) => f.site));
|
|
20216
|
+
for (const h of flow.hits) {
|
|
20217
|
+
const site = `${file.rel}:${h.line}`;
|
|
20218
|
+
if (seen.has(site)) continue;
|
|
20219
|
+
if (h.path && resolvesToLiteral(tree, h.path)) continue;
|
|
20220
|
+
seen.add(site);
|
|
20221
|
+
findings.push({
|
|
20222
|
+
site,
|
|
20223
|
+
form: "D",
|
|
20224
|
+
note: `identifier flow: ${h.via} reaches the log call`
|
|
20225
|
+
});
|
|
20226
|
+
}
|
|
20227
|
+
for (const u of flow.unknown) {
|
|
20228
|
+
unreadable2.push({
|
|
20229
|
+
anchor: `${file.rel}:${u.line}`,
|
|
20230
|
+
reason: `cannot follow the value of ${u.text} logged at ${file.rel}:${u.line}: ${u.reason} \u2014 internal-infrastructure detail unverifiable (C-6)`
|
|
20231
|
+
});
|
|
20232
|
+
}
|
|
20233
|
+
}
|
|
19789
20234
|
for (const file of tree.files) {
|
|
19790
20235
|
for (const line of file.lines) {
|
|
19791
20236
|
if (line.comment) continue;
|
|
@@ -20225,7 +20670,7 @@ function codeText(file) {
|
|
|
20225
20670
|
}
|
|
20226
20671
|
return { file, text: parts.join(""), kind: Uint8Array.from(kinds), lineStart };
|
|
20227
20672
|
}
|
|
20228
|
-
function
|
|
20673
|
+
function lineOf4(ct, off) {
|
|
20229
20674
|
let lo = 0;
|
|
20230
20675
|
let hi = ct.lineStart.length - 1;
|
|
20231
20676
|
while (lo < hi) {
|
|
@@ -20351,8 +20796,8 @@ function on401Path(ct, siteStart, siteEnd) {
|
|
|
20351
20796
|
}
|
|
20352
20797
|
}
|
|
20353
20798
|
}
|
|
20354
|
-
const first = Math.max(1,
|
|
20355
|
-
const last = Math.min(ct.lineStart.length,
|
|
20799
|
+
const first = Math.max(1, lineOf4(ct, siteStart) - PATH_LINES_BEFORE);
|
|
20800
|
+
const last = Math.min(ct.lineStart.length, lineOf4(ct, siteEnd) + PATH_LINES_AFTER);
|
|
20356
20801
|
const from = Math.max(blockStart, ct.lineStart[first - 1]);
|
|
20357
20802
|
const to = Math.min(blockEnd2, last < ct.lineStart.length ? ct.lineStart[last] : t.length);
|
|
20358
20803
|
for (const m of t.slice(from, to).matchAll(/\b401\b/g)) {
|
|
@@ -20370,7 +20815,7 @@ function scanChallengeSites(files) {
|
|
|
20370
20815
|
const open = m.index ?? 0;
|
|
20371
20816
|
const close2 = open + m[0].length - 1;
|
|
20372
20817
|
if (ct.kind[open] !== 1 || ct.kind[close2] !== 1) continue;
|
|
20373
|
-
const anchor = `${file.rel}:${
|
|
20818
|
+
const anchor = `${file.rel}:${lineOf4(ct, open)}`;
|
|
20374
20819
|
const before = t.slice(Math.max(0, open - 200), open);
|
|
20375
20820
|
const after = t.slice(close2 + 1, close2 + 200);
|
|
20376
20821
|
let form = null;
|
|
@@ -20971,7 +21416,7 @@ function configPlaces(tree, reg) {
|
|
|
20971
21416
|
meta: placeOf(tree, config, "_meta")
|
|
20972
21417
|
};
|
|
20973
21418
|
}
|
|
20974
|
-
function
|
|
21419
|
+
function lineOf5(anchor) {
|
|
20975
21420
|
const i = anchor.lastIndexOf(":");
|
|
20976
21421
|
return [anchor.slice(0, i), Number(anchor.slice(i + 1))];
|
|
20977
21422
|
}
|
|
@@ -21077,7 +21522,7 @@ function judgeStatic(tree, id) {
|
|
|
21077
21522
|
to: fn ? lineAt(gate.src.shape, fn.close) : lineAt(gate.src.shape, gate.at) + 1
|
|
21078
21523
|
}));
|
|
21079
21524
|
regUnread = unread2.filter((u) => {
|
|
21080
|
-
const [rel2, n] =
|
|
21525
|
+
const [rel2, n] = lineOf5(u.anchor);
|
|
21081
21526
|
return !spans.some((sp) => sp.rel === rel2 && n >= sp.from && n <= sp.to);
|
|
21082
21527
|
});
|
|
21083
21528
|
for (const { gate, fn } of installers) {
|
|
@@ -21129,7 +21574,7 @@ function judgeStatic(tree, id) {
|
|
|
21129
21574
|
}
|
|
21130
21575
|
const decided = problems.length > 0 ? {
|
|
21131
21576
|
id,
|
|
21132
|
-
anchor:
|
|
21577
|
+
anchor: lineOf5(problems[0].match(/\(([^()\s]+:\d+)\)/)?.[1] ?? "-:0").join(":"),
|
|
21133
21578
|
state: "non-conforming",
|
|
21134
21579
|
verdict: `${problems.join("; ")} -> every tool declares { domain, mode } (mode exactly read | write, read <-> readOnlyHint true), and the shared decision of ${CLOUD_IDENTITY} refuses tools/call and filters tools/list for every registered tool (mcp-server-standard "Agent tool roles", rules 2-4, 7)`
|
|
21135
21580
|
} : {
|
|
@@ -22012,7 +22457,7 @@ function declaredEntries(dir, dep, unread2) {
|
|
|
22012
22457
|
}
|
|
22013
22458
|
function walkPackage(dir, nm, skipFixtures, unread2) {
|
|
22014
22459
|
const files = [];
|
|
22015
|
-
const
|
|
22460
|
+
const walk4 = (d) => {
|
|
22016
22461
|
let names2;
|
|
22017
22462
|
try {
|
|
22018
22463
|
names2 = readdirSync16(d).sort();
|
|
@@ -22036,11 +22481,11 @@ function walkPackage(dir, nm, skipFixtures, unread2) {
|
|
|
22036
22481
|
unread2.push(`${full.slice(nm.length + 1)} (test/example directory: not read)`);
|
|
22037
22482
|
continue;
|
|
22038
22483
|
}
|
|
22039
|
-
|
|
22484
|
+
walk4(full);
|
|
22040
22485
|
} else if (st.isFile() && SOURCE_EXT.test(n)) files.push(full);
|
|
22041
22486
|
}
|
|
22042
22487
|
};
|
|
22043
|
-
|
|
22488
|
+
walk4(dir);
|
|
22044
22489
|
return files;
|
|
22045
22490
|
}
|
|
22046
22491
|
var escapeRe4 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -24151,8 +24596,8 @@ function documentsFootprint(manifestText) {
|
|
|
24151
24596
|
} catch {
|
|
24152
24597
|
return false;
|
|
24153
24598
|
}
|
|
24154
|
-
const
|
|
24155
|
-
if (Array.isArray(v)) return v.some(
|
|
24599
|
+
const walk4 = (v) => {
|
|
24600
|
+
if (Array.isArray(v)) return v.some(walk4);
|
|
24156
24601
|
if (v === null || typeof v !== "object") return false;
|
|
24157
24602
|
for (const [k, val] of Object.entries(v)) {
|
|
24158
24603
|
if (k === "footprint") {
|
|
@@ -24160,11 +24605,11 @@ function documentsFootprint(manifestText) {
|
|
|
24160
24605
|
if (Array.isArray(val) && val.length > 0) return true;
|
|
24161
24606
|
if (val !== null && typeof val === "object" && Object.keys(val).length > 0) return true;
|
|
24162
24607
|
}
|
|
24163
|
-
if (
|
|
24608
|
+
if (walk4(val)) return true;
|
|
24164
24609
|
}
|
|
24165
24610
|
return false;
|
|
24166
24611
|
};
|
|
24167
|
-
return
|
|
24612
|
+
return walk4(json);
|
|
24168
24613
|
}
|
|
24169
24614
|
|
|
24170
24615
|
// src/detectors/s17-forward-auth.ts
|
|
@@ -24958,11 +25403,11 @@ function leavesOf(tree, v, file, depth) {
|
|
|
24958
25403
|
}
|
|
24959
25404
|
function classifyOriginValue(tree, value, file) {
|
|
24960
25405
|
const v = value.trim();
|
|
24961
|
-
const
|
|
24962
|
-
const wild =
|
|
25406
|
+
const leaves2 = leavesOf(tree, v, file, 0);
|
|
25407
|
+
const wild = leaves2.strings.find((x) => x.slice(1, -1).includes("*"));
|
|
24963
25408
|
if (wild) return { kind: "wildcard", detail: wild };
|
|
24964
|
-
if (
|
|
24965
|
-
if (
|
|
25409
|
+
if (leaves2.unresolved) return { kind: "unresolved", detail: leaves2.unresolved };
|
|
25410
|
+
if (leaves2.strings.length === 0)
|
|
24966
25411
|
return { kind: "empty", detail: v.startsWith("[") ? v : `${v} (an empty list)` };
|
|
24967
25412
|
return { kind: "ok", detail: v };
|
|
24968
25413
|
}
|
|
@@ -25148,19 +25593,47 @@ var s24ToolRateLimit = {
|
|
|
25148
25593
|
};
|
|
25149
25594
|
|
|
25150
25595
|
// src/detectors/s25-resource-discipline.ts
|
|
25151
|
-
|
|
25596
|
+
import * as ts3 from "typescript";
|
|
25597
|
+
var SUBJECT_RE2 = /registerResource\s*\(|\.resource\s*\(|\bResourceTemplate\s*\(|resources\/read|ReadResourceRequestSchema|\bresources\s*:\s*\{|type\s*:\s*["'`](?:image|audio)["'`]/;
|
|
25152
25598
|
var HANDLER_RE = /registerResource\s*\(|\.resource\s*\(|ReadResourceRequestSchema/;
|
|
25153
25599
|
var DEREF_RE = /\b(?:readFile|readFileSync|createReadStream|readdir|readdirSync|stat|statSync|open|fetch)\s*\(([^)]*)\)/g;
|
|
25154
25600
|
var CALLER_ARG_RE = /\b(?:uri|url|path|params|href|pathname)\b/;
|
|
25155
25601
|
var VALID_RE2 = /\bresolve\s*\(|\bnormalize\s*\(|\bstartsWith\s*\(|\.includes\(\s*["'`]\.\.|\bnew URL\s*\(|\ballowlist\b|\bisAllowed\w*|\bvalidate\w*\s*\(|\bsanitize\w*\s*\(|\.parse\s*\(|\brealpath\w*\s*\(/i;
|
|
25156
25602
|
var SCHEME_RE = /["'`]([^\s"'`:/]+(?: [^\s"'`:/]+)*):\/\/[^"'`]*["'`]/g;
|
|
25157
25603
|
var RFC3986_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/;
|
|
25604
|
+
function blobAssignments(file) {
|
|
25605
|
+
const text = file.lines.map((l) => l.raw).join("\n");
|
|
25606
|
+
if (!text.includes("blob")) return { sites: [], unparsed: false };
|
|
25607
|
+
const kind = file.rel.endsWith(".tsx") ? ts3.ScriptKind.TSX : ts3.ScriptKind.TS;
|
|
25608
|
+
const sf = ts3.createSourceFile(file.rel, text, ts3.ScriptTarget.Latest, true, kind);
|
|
25609
|
+
const unparsed = (sf.parseDiagnostics ?? []).length > 0;
|
|
25610
|
+
const sites = [];
|
|
25611
|
+
const lineAt4 = (n) => sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1;
|
|
25612
|
+
const visit = (n) => {
|
|
25613
|
+
if (ts3.isPropertyAssignment(n)) {
|
|
25614
|
+
const k = n.name;
|
|
25615
|
+
const key = ts3.isIdentifier(k) || ts3.isStringLiteralLike(k) ? k.text : ts3.isComputedPropertyName(k) && ts3.isStringLiteralLike(k.expression) ? k.expression.text : void 0;
|
|
25616
|
+
if (key === "blob") sites.push({ line: lineAt4(n), value: n.initializer.getText(sf) });
|
|
25617
|
+
} else if (ts3.isBinaryExpression(n) && n.operatorToken.kind === ts3.SyntaxKind.EqualsToken) {
|
|
25618
|
+
const l = n.left;
|
|
25619
|
+
const name = ts3.isPropertyAccessExpression(l) ? l.name.text : ts3.isElementAccessExpression(l) && ts3.isStringLiteralLike(l.argumentExpression) ? l.argumentExpression.text : void 0;
|
|
25620
|
+
if (name === "blob") sites.push({ line: lineAt4(n), value: n.right.getText(sf) });
|
|
25621
|
+
}
|
|
25622
|
+
ts3.forEachChild(n, visit);
|
|
25623
|
+
};
|
|
25624
|
+
visit(sf);
|
|
25625
|
+
return { sites, unparsed };
|
|
25626
|
+
}
|
|
25158
25627
|
function s25Controls() {
|
|
25159
25628
|
return {
|
|
25160
|
-
sees: !RFC3986_SCHEME.test("my_app") && !RFC3986_SCHEME.test("1app") && !RFC3986_SCHEME.test("my app") && SUBJECT_RE2.test("registerResource('a', 'x://y', {}, h)"),
|
|
25161
|
-
spares: RFC3986_SCHEME.test("my-app+v2.x") && RFC3986_SCHEME.test("https") && !SUBJECT_RE2.test("const x = 1")
|
|
25629
|
+
sees: !RFC3986_SCHEME.test("my_app") && !RFC3986_SCHEME.test("1app") && !RFC3986_SCHEME.test("my app") && SUBJECT_RE2.test("registerResource('a', 'x://y', {}, h)") && blobFixture("const a = { blob: raw };") === 1 && blobFixture('const a = { "blob": raw };') === 1 && blobFixture("a.blob = raw;") === 1,
|
|
25630
|
+
spares: RFC3986_SCHEME.test("my-app+v2.x") && RFC3986_SCHEME.test("https") && !SUBJECT_RE2.test("const x = 1") && blobFixture("const S = new Set([\"blob:\", 'blob:', `blob:`]);") === 0
|
|
25162
25631
|
};
|
|
25163
25632
|
}
|
|
25633
|
+
function blobFixture(code) {
|
|
25634
|
+
const lines2 = code.split("\n").map((raw, i) => ({ n: i + 1, raw, comment: false }));
|
|
25635
|
+
return blobAssignments({ path: "control.ts", rel: "control.ts", lines: lines2 }).sites.length;
|
|
25636
|
+
}
|
|
25164
25637
|
var s25ResourceDiscipline = {
|
|
25165
25638
|
id: "S25 resource-discipline",
|
|
25166
25639
|
rule: "S-25",
|
|
@@ -25175,15 +25648,20 @@ var s25ResourceDiscipline = {
|
|
|
25175
25648
|
const reds = [];
|
|
25176
25649
|
let subject = 0;
|
|
25177
25650
|
let first = "";
|
|
25651
|
+
const unread2 = [];
|
|
25178
25652
|
for (const file of tree.files) {
|
|
25179
25653
|
if (!isProductSource(file.rel)) continue;
|
|
25180
25654
|
const rows = uncommentedLines(file);
|
|
25181
25655
|
const text = rows.join("\n");
|
|
25182
|
-
|
|
25656
|
+
const blobs = blobAssignments(file);
|
|
25657
|
+
if (blobs.unparsed) unread2.push(file.rel);
|
|
25658
|
+
const blobAt = /* @__PURE__ */ new Map();
|
|
25659
|
+
if (!blobs.unparsed) for (const b of blobs.sites) blobAt.set(b.line, b.value);
|
|
25660
|
+
if (!SUBJECT_RE2.test(text) && blobAt.size === 0) continue;
|
|
25183
25661
|
subject++;
|
|
25184
25662
|
const at = (i) => `${file.rel}:${i + 1}`;
|
|
25185
25663
|
rows.forEach((row, i) => {
|
|
25186
|
-
if (!first && SUBJECT_RE2.test(row)) first = at(i);
|
|
25664
|
+
if (!first && (SUBJECT_RE2.test(row) || blobAt.has(i + 1))) first = at(i);
|
|
25187
25665
|
for (const m of row.matchAll(SCHEME_RE)) {
|
|
25188
25666
|
const scheme = m[1];
|
|
25189
25667
|
if (scheme.includes("$") || scheme.includes("{")) continue;
|
|
@@ -25193,14 +25671,14 @@ var s25ResourceDiscipline = {
|
|
|
25193
25671
|
);
|
|
25194
25672
|
}
|
|
25195
25673
|
}
|
|
25196
|
-
const blob =
|
|
25197
|
-
if (blob && !/base64|btoa|b64/i.test(blob
|
|
25674
|
+
const blob = blobAt.get(i + 1);
|
|
25675
|
+
if (blob !== void 0 && !/base64|btoa|b64/i.test(blob)) {
|
|
25198
25676
|
reds.push(
|
|
25199
|
-
`${at(i)} sets blob to a value that is not base64-encoded (${blob
|
|
25677
|
+
`${at(i)} sets blob to a value that is not base64-encoded (${blob.trim().replace(/\s+/g, " ").slice(0, 40)}): binary content is base64`
|
|
25200
25678
|
);
|
|
25201
25679
|
}
|
|
25202
25680
|
const near = rows.slice(Math.max(0, i - 3), i + 4).join("\n");
|
|
25203
|
-
if ((/type\s*:\s*["'`](?:image|audio)["'`]/.test(row) || blob) && !/mimeType/.test(near)) {
|
|
25681
|
+
if ((/type\s*:\s*["'`](?:image|audio)["'`]/.test(row) || blob !== void 0) && !/mimeType/.test(near)) {
|
|
25204
25682
|
reds.push(
|
|
25205
25683
|
`${at(i)} carries binary content with no valid MIME type (no mimeType within three lines)`
|
|
25206
25684
|
);
|
|
@@ -25221,6 +25699,16 @@ var s25ResourceDiscipline = {
|
|
|
25221
25699
|
}
|
|
25222
25700
|
});
|
|
25223
25701
|
}
|
|
25702
|
+
if (reds.length === 0 && unread2.length > 0) {
|
|
25703
|
+
const reason = `could not determine blob assignments: ${unread2.join(", ")} did not parse, so a \`blob\` property in it was not read (S-25)`;
|
|
25704
|
+
return {
|
|
25705
|
+
id: this.id,
|
|
25706
|
+
anchor: `${unread2[0]}:1`,
|
|
25707
|
+
state: "could-not-judge",
|
|
25708
|
+
reason,
|
|
25709
|
+
verdict: `could not judge: ${reason}`
|
|
25710
|
+
};
|
|
25711
|
+
}
|
|
25224
25712
|
if (subject === 0) {
|
|
25225
25713
|
return absentResult(
|
|
25226
25714
|
this.id,
|
|
@@ -29195,7 +29683,7 @@ function readDoorAccess(backendRoot, unread2) {
|
|
|
29195
29683
|
const c = o < 0 ? -1 : matchClose2(m, o);
|
|
29196
29684
|
return c < 0 ? void 0 : text.slice(o, c + 1);
|
|
29197
29685
|
};
|
|
29198
|
-
const
|
|
29686
|
+
const walk4 = (body, seen, depth) => {
|
|
29199
29687
|
for (const h of body.matchAll(/\bdb\s*\.\s*insert\s*\(\s*["'`](\w+)["'`]/g))
|
|
29200
29688
|
acc.writes.add(h[1]);
|
|
29201
29689
|
for (const h of body.matchAll(/\bdb\s*\.\s*query\s*\(\s*["'`](\w+)["'`]/g))
|
|
@@ -29209,10 +29697,10 @@ function readDoorAccess(backendRoot, unread2) {
|
|
|
29209
29697
|
if (seen.has(c[1])) continue;
|
|
29210
29698
|
seen.add(c[1]);
|
|
29211
29699
|
const sub = fnBodyRaw(c[1]);
|
|
29212
|
-
if (sub)
|
|
29700
|
+
if (sub) walk4(sub, seen, depth + 1);
|
|
29213
29701
|
}
|
|
29214
29702
|
};
|
|
29215
|
-
|
|
29703
|
+
walk4(raw, /* @__PURE__ */ new Set([hit[1]]), 0);
|
|
29216
29704
|
out.set(`${module}:${hit[1]}`, acc);
|
|
29217
29705
|
}
|
|
29218
29706
|
}
|
|
@@ -33916,7 +34404,7 @@ var s49ServerMetadata = {
|
|
|
33916
34404
|
// src/detectors/s50-served-discovery.ts
|
|
33917
34405
|
var ID16 = "S50 served-discovery";
|
|
33918
34406
|
var RULE17 = "S-50";
|
|
33919
|
-
function
|
|
34407
|
+
function pathOf2(url) {
|
|
33920
34408
|
try {
|
|
33921
34409
|
return new URL(url).pathname;
|
|
33922
34410
|
} catch {
|
|
@@ -33936,23 +34424,23 @@ function judgeCards(cards, v) {
|
|
|
33936
34424
|
const served = cards.filter((c) => c.status === 200 && c.json);
|
|
33937
34425
|
const noAnswer = cards.filter((c) => c.status === void 0);
|
|
33938
34426
|
const good = served.find((c) => cardGaps(c.json).length === 0);
|
|
33939
|
-
if (good) return v.ok.push(`server card at ${
|
|
34427
|
+
if (good) return v.ok.push(`server card at ${pathOf2(good.url)}`);
|
|
33940
34428
|
if (served.length > 0) {
|
|
33941
34429
|
for (const c of served)
|
|
33942
34430
|
v.red.push(
|
|
33943
|
-
`the card at ${
|
|
34431
|
+
`the card at ${pathOf2(c.url)} lacks ${cardGaps(c.json).join(", ")}`
|
|
33944
34432
|
);
|
|
33945
34433
|
return;
|
|
33946
34434
|
}
|
|
33947
|
-
const seen = cards.filter((c) => c.status !== void 0).map((c) => `${
|
|
34435
|
+
const seen = cards.filter((c) => c.status !== void 0).map((c) => `${pathOf2(c.url)} ${c.status}${c.status === 200 ? " (not JSON)" : ""}`);
|
|
33948
34436
|
if (noAnswer.length > 0 && seen.length === 0)
|
|
33949
34437
|
return v.unread.push(
|
|
33950
|
-
`no card candidate answered: ${noAnswer.map((c) => `${
|
|
34438
|
+
`no card candidate answered: ${noAnswer.map((c) => `${pathOf2(c.url)} ${c.detail ?? "no answer"}`).join(", ")}`
|
|
33951
34439
|
);
|
|
33952
34440
|
v.red.push(`no server card served (${seen.join(", ")})`);
|
|
33953
34441
|
if (noAnswer.length > 0)
|
|
33954
34442
|
v.unread.push(
|
|
33955
|
-
`card candidates unanswered: ${noAnswer.map((c) => `${
|
|
34443
|
+
`card candidates unanswered: ${noAnswer.map((c) => `${pathOf2(c.url)} ${c.detail ?? ""}`).join(", ")}`
|
|
33956
34444
|
);
|
|
33957
34445
|
}
|
|
33958
34446
|
function judgeLanding(landing, v) {
|
|
@@ -34045,7 +34533,7 @@ var s50ServedDiscovery = {
|
|
|
34045
34533
|
};
|
|
34046
34534
|
|
|
34047
34535
|
// src/detectors/s51-served-output.ts
|
|
34048
|
-
import * as
|
|
34536
|
+
import * as ts5 from "typescript";
|
|
34049
34537
|
|
|
34050
34538
|
// src/detectors/jsonSchemaCheck.ts
|
|
34051
34539
|
var ANNOTATIONS = /* @__PURE__ */ new Set([
|
|
@@ -34395,15 +34883,15 @@ function schemaCheckControls() {
|
|
|
34395
34883
|
}
|
|
34396
34884
|
|
|
34397
34885
|
// src/detectors/outputContract.ts
|
|
34398
|
-
import * as
|
|
34886
|
+
import * as ts4 from "typescript";
|
|
34399
34887
|
var lineOfPos = (sf, pos) => sf.getLineAndCharacterOfPosition(pos).line + 1;
|
|
34400
34888
|
var startLine = (n) => lineOfPos(n.getSourceFile(), n.getStart(n.getSourceFile()));
|
|
34401
34889
|
function isFunctionLikeExpr(e) {
|
|
34402
|
-
return
|
|
34890
|
+
return ts4.isArrowFunction(e) || ts4.isFunctionExpression(e);
|
|
34403
34891
|
}
|
|
34404
34892
|
var unwrapExpr = (e) => {
|
|
34405
34893
|
let x = e;
|
|
34406
|
-
while (
|
|
34894
|
+
while (ts4.isParenthesizedExpression(x) || ts4.isAsExpression(x) || ts4.isSatisfiesExpression(x) || ts4.isNonNullExpression(x) || ts4.isAwaitExpression(x) || ts4.isTypeAssertionExpression(x))
|
|
34407
34895
|
x = x.expression;
|
|
34408
34896
|
return x;
|
|
34409
34897
|
};
|
|
@@ -34411,10 +34899,10 @@ function sameFileFunction(sf, name) {
|
|
|
34411
34899
|
let found;
|
|
34412
34900
|
const visit = (n) => {
|
|
34413
34901
|
if (found) return;
|
|
34414
|
-
if (
|
|
34415
|
-
else if (
|
|
34902
|
+
if (ts4.isFunctionDeclaration(n) && n.name?.text === name && n.body) found = n;
|
|
34903
|
+
else if (ts4.isVariableDeclaration(n) && ts4.isIdentifier(n.name) && n.name.text === name && n.initializer && isFunctionLikeExpr(unwrapExpr(n.initializer)))
|
|
34416
34904
|
found = unwrapExpr(n.initializer);
|
|
34417
|
-
else
|
|
34905
|
+
else ts4.forEachChild(n, visit);
|
|
34418
34906
|
};
|
|
34419
34907
|
visit(sf);
|
|
34420
34908
|
return found;
|
|
@@ -34424,25 +34912,25 @@ function completes(stmts) {
|
|
|
34424
34912
|
return stmtCompletes(stmts[stmts.length - 1]);
|
|
34425
34913
|
}
|
|
34426
34914
|
function stmtCompletes(s) {
|
|
34427
|
-
if (
|
|
34428
|
-
if (
|
|
34429
|
-
if (
|
|
34915
|
+
if (ts4.isReturnStatement(s) || ts4.isThrowStatement(s)) return false;
|
|
34916
|
+
if (ts4.isBlock(s)) return completes(s.statements);
|
|
34917
|
+
if (ts4.isIfStatement(s))
|
|
34430
34918
|
return !s.elseStatement || stmtCompletes(s.thenStatement) || stmtCompletes(s.elseStatement);
|
|
34431
|
-
if (
|
|
34919
|
+
if (ts4.isTryStatement(s)) {
|
|
34432
34920
|
if (s.finallyBlock && !completes(s.finallyBlock.statements)) return false;
|
|
34433
34921
|
return completes(s.tryBlock.statements) || (s.catchClause ? completes(s.catchClause.block.statements) : false);
|
|
34434
34922
|
}
|
|
34435
|
-
if (
|
|
34923
|
+
if (ts4.isSwitchStatement(s)) {
|
|
34436
34924
|
const clauses = s.caseBlock.clauses;
|
|
34437
|
-
if (!clauses.some((c) =>
|
|
34925
|
+
if (!clauses.some((c) => ts4.isDefaultClause(c))) return true;
|
|
34438
34926
|
return clauses.some((c) => c.statements.length === 0 || completes(c.statements));
|
|
34439
34927
|
}
|
|
34440
34928
|
return true;
|
|
34441
34929
|
}
|
|
34442
34930
|
function collectReturns(body, sf, rel2, out, inCatch = false) {
|
|
34443
34931
|
const visit = (n, catching) => {
|
|
34444
|
-
if (n !== body &&
|
|
34445
|
-
if (
|
|
34932
|
+
if (n !== body && ts4.isFunctionLike(n)) return;
|
|
34933
|
+
if (ts4.isReturnStatement(n)) {
|
|
34446
34934
|
out.push({
|
|
34447
34935
|
anchor: `${rel2}:${startLine(n)}`,
|
|
34448
34936
|
...n.expression ? { expr: n.expression } : {},
|
|
@@ -34451,11 +34939,11 @@ function collectReturns(body, sf, rel2, out, inCatch = false) {
|
|
|
34451
34939
|
});
|
|
34452
34940
|
return;
|
|
34453
34941
|
}
|
|
34454
|
-
if (
|
|
34942
|
+
if (ts4.isCatchClause(n)) {
|
|
34455
34943
|
visit(n.block, true);
|
|
34456
34944
|
return;
|
|
34457
34945
|
}
|
|
34458
|
-
|
|
34946
|
+
ts4.forEachChild(n, (c) => visit(c, catching));
|
|
34459
34947
|
};
|
|
34460
34948
|
visit(body, inCatch);
|
|
34461
34949
|
void sf;
|
|
@@ -34464,7 +34952,7 @@ function functionReturns(fn, sf, rel2) {
|
|
|
34464
34952
|
const out = [];
|
|
34465
34953
|
const body = fn.body;
|
|
34466
34954
|
if (!body) return out;
|
|
34467
|
-
if (!
|
|
34955
|
+
if (!ts4.isBlock(body)) {
|
|
34468
34956
|
out.push({
|
|
34469
34957
|
anchor: `${rel2}:${startLine(body)}`,
|
|
34470
34958
|
expr: body,
|
|
@@ -34488,19 +34976,19 @@ function registrationCall(sf, line, name) {
|
|
|
34488
34976
|
const a = startLine(n);
|
|
34489
34977
|
const b = lineOfPos(sf, n.getEnd());
|
|
34490
34978
|
if (a > line || b < line) return;
|
|
34491
|
-
if (
|
|
34979
|
+
if (ts4.isCallExpression(n)) {
|
|
34492
34980
|
const names2 = n.arguments.some((arg) => {
|
|
34493
34981
|
const u = unwrapExpr(arg);
|
|
34494
|
-
if (
|
|
34495
|
-
return (
|
|
34982
|
+
if (ts4.isStringLiteralLike(u)) return u.text === name;
|
|
34983
|
+
return (ts4.isIdentifier(u) || ts4.isPropertyAccessExpression(u)) && startLine(u) === line;
|
|
34496
34984
|
});
|
|
34497
34985
|
if (names2 && n.arguments.some((arg) => {
|
|
34498
34986
|
const x = unwrapExpr(arg);
|
|
34499
|
-
return isFunctionLikeExpr(x) ||
|
|
34987
|
+
return isFunctionLikeExpr(x) || ts4.isIdentifier(x) || ts4.isCallExpression(x);
|
|
34500
34988
|
}))
|
|
34501
34989
|
best = n;
|
|
34502
34990
|
}
|
|
34503
|
-
|
|
34991
|
+
ts4.forEachChild(n, visit);
|
|
34504
34992
|
};
|
|
34505
34993
|
visit(sf);
|
|
34506
34994
|
return best;
|
|
@@ -34509,9 +34997,9 @@ function caseClause(sf, name) {
|
|
|
34509
34997
|
let found;
|
|
34510
34998
|
const visit = (n) => {
|
|
34511
34999
|
if (found) return;
|
|
34512
|
-
if (
|
|
35000
|
+
if (ts4.isCaseClause(n) && ts4.isStringLiteralLike(n.expression) && n.expression.text === name)
|
|
34513
35001
|
found = n;
|
|
34514
|
-
else
|
|
35002
|
+
else ts4.forEachChild(n, visit);
|
|
34515
35003
|
};
|
|
34516
35004
|
visit(sf);
|
|
34517
35005
|
return found;
|
|
@@ -34541,10 +35029,10 @@ function readHandler(tree, tool) {
|
|
|
34541
35029
|
if (call) {
|
|
34542
35030
|
const last = [...call.arguments].reverse().find((a) => {
|
|
34543
35031
|
const x = unwrapExpr(a);
|
|
34544
|
-
return isFunctionLikeExpr(x) ||
|
|
35032
|
+
return isFunctionLikeExpr(x) || ts4.isIdentifier(x) || ts4.isCallExpression(x) && x.arguments.some((w) => isFunctionLikeExpr(unwrapExpr(w)));
|
|
34545
35033
|
});
|
|
34546
35034
|
let u = last ? unwrapExpr(last) : void 0;
|
|
34547
|
-
if (u &&
|
|
35035
|
+
if (u && ts4.isCallExpression(u))
|
|
34548
35036
|
u = [...u.arguments].map(unwrapExpr).reverse().find(isFunctionLikeExpr);
|
|
34549
35037
|
if (u && isFunctionLikeExpr(u))
|
|
34550
35038
|
return {
|
|
@@ -34554,7 +35042,7 @@ function readHandler(tree, tool) {
|
|
|
34554
35042
|
sf,
|
|
34555
35043
|
file
|
|
34556
35044
|
};
|
|
34557
|
-
if (u &&
|
|
35045
|
+
if (u && ts4.isIdentifier(u)) {
|
|
34558
35046
|
const fn = sameFileFunction(sf, u.text);
|
|
34559
35047
|
if (fn)
|
|
34560
35048
|
return {
|
|
@@ -34612,20 +35100,20 @@ function productRegistrations(tree) {
|
|
|
34612
35100
|
function returnedValues(expr, sf, depth = 0) {
|
|
34613
35101
|
if (expr === void 0) return [{ kind: "nullish", form: "undefined" }];
|
|
34614
35102
|
const e = unwrapExpr(expr);
|
|
34615
|
-
if (e.kind ===
|
|
34616
|
-
if (
|
|
34617
|
-
if (
|
|
34618
|
-
if (
|
|
34619
|
-
if (
|
|
35103
|
+
if (e.kind === ts4.SyntaxKind.NullKeyword) return [{ kind: "nullish", form: "null" }];
|
|
35104
|
+
if (ts4.isIdentifier(e) && e.text === "undefined") return [{ kind: "nullish", form: "undefined" }];
|
|
35105
|
+
if (ts4.isVoidExpression(e)) return [{ kind: "nullish", form: "void" }];
|
|
35106
|
+
if (ts4.isObjectLiteralExpression(e)) return [{ kind: "object", node: e }];
|
|
35107
|
+
if (ts4.isConditionalExpression(e))
|
|
34620
35108
|
return [...returnedValues(e.whenTrue, sf, depth), ...returnedValues(e.whenFalse, sf, depth)];
|
|
34621
35109
|
if (depth >= 4)
|
|
34622
35110
|
return [{ kind: "unread", form: `\`${e.getText(sf).slice(0, 60)}\` (followed too deep)` }];
|
|
34623
|
-
if (
|
|
35111
|
+
if (ts4.isIdentifier(e)) {
|
|
34624
35112
|
const init = constInitOf(e);
|
|
34625
35113
|
if (init) return returnedValues(init, sf, depth + 1).filter((v) => v.kind !== "nullish");
|
|
34626
35114
|
return [{ kind: "unread", form: `identifier \`${e.text}\` not bound to a const in reach` }];
|
|
34627
35115
|
}
|
|
34628
|
-
if (
|
|
35116
|
+
if (ts4.isCallExpression(e) && ts4.isIdentifier(e.expression)) {
|
|
34629
35117
|
const fn = sameFileFunction(sf, e.expression.text);
|
|
34630
35118
|
if (fn) {
|
|
34631
35119
|
const out = [];
|
|
@@ -34641,11 +35129,11 @@ function returnedValues(expr, sf, depth = 0) {
|
|
|
34641
35129
|
}
|
|
34642
35130
|
function constInitOf(id) {
|
|
34643
35131
|
for (let x = id.parent; x; x = x.parent) {
|
|
34644
|
-
if (!(
|
|
35132
|
+
if (!(ts4.isBlock(x) || ts4.isSourceFile(x))) continue;
|
|
34645
35133
|
for (const st of x.statements) {
|
|
34646
|
-
if (!
|
|
35134
|
+
if (!ts4.isVariableStatement(st) || !(st.declarationList.flags & ts4.NodeFlags.Const)) continue;
|
|
34647
35135
|
for (const d of st.declarationList.declarations)
|
|
34648
|
-
if (
|
|
35136
|
+
if (ts4.isIdentifier(d.name) && d.name.text === id.text && d.initializer && d.getStart() < id.getStart())
|
|
34649
35137
|
return d.initializer;
|
|
34650
35138
|
}
|
|
34651
35139
|
}
|
|
@@ -34653,17 +35141,17 @@ function constInitOf(id) {
|
|
|
34653
35141
|
}
|
|
34654
35142
|
function prop(obj, name) {
|
|
34655
35143
|
for (const p of obj.properties) {
|
|
34656
|
-
if (
|
|
35144
|
+
if (ts4.isPropertyAssignment(p) && (ts4.isIdentifier(p.name) || ts4.isStringLiteralLike(p.name)) && p.name.text === name)
|
|
34657
35145
|
return { kind: "value", value: p.initializer };
|
|
34658
|
-
if (
|
|
35146
|
+
if (ts4.isShorthandPropertyAssignment(p) && p.name.text === name)
|
|
34659
35147
|
return { kind: "shorthand", ident: p.name };
|
|
34660
35148
|
}
|
|
34661
|
-
if (obj.properties.some((p) =>
|
|
35149
|
+
if (obj.properties.some((p) => ts4.isSpreadAssignment(p))) return { kind: "spread" };
|
|
34662
35150
|
return { kind: "absent" };
|
|
34663
35151
|
}
|
|
34664
35152
|
function isErrorObject(obj) {
|
|
34665
35153
|
const p = prop(obj, "isError");
|
|
34666
|
-
return p.kind === "value" && p.value.kind ===
|
|
35154
|
+
return p.kind === "value" && p.value.kind === ts4.SyntaxKind.TrueKeyword;
|
|
34667
35155
|
}
|
|
34668
35156
|
function servedToolCalls(id, rule, runtime) {
|
|
34669
35157
|
const anchor = `${runtime.root} (served)`;
|
|
@@ -34720,42 +35208,42 @@ var ID17 = "S51 served-output";
|
|
|
34720
35208
|
var RULE18 = "S-51";
|
|
34721
35209
|
var isNullish = (e) => {
|
|
34722
35210
|
let x = e;
|
|
34723
|
-
while (
|
|
34724
|
-
return x.kind ===
|
|
35211
|
+
while (ts5.isParenthesizedExpression(x) || ts5.isAsExpression(x)) x = x.expression;
|
|
35212
|
+
return x.kind === ts5.SyntaxKind.NullKeyword || ts5.isIdentifier(x) && x.text === "undefined" || ts5.isVoidExpression(x);
|
|
34725
35213
|
};
|
|
34726
35214
|
var strip = (e) => {
|
|
34727
35215
|
let x = e;
|
|
34728
|
-
while (
|
|
35216
|
+
while (ts5.isParenthesizedExpression(x) || ts5.isAsExpression(x) || ts5.isSatisfiesExpression(x))
|
|
34729
35217
|
x = x.expression;
|
|
34730
35218
|
return x;
|
|
34731
35219
|
};
|
|
34732
|
-
var isOutputKey = (n) => (
|
|
35220
|
+
var isOutputKey = (n) => (ts5.isIdentifier(n) || ts5.isStringLiteralLike(n)) && n.text === "outputSchema";
|
|
34733
35221
|
var objectHasOutput = (e) => {
|
|
34734
35222
|
const x = strip(e);
|
|
34735
|
-
return
|
|
34736
|
-
(p) => (
|
|
35223
|
+
return ts5.isObjectLiteralExpression(x) && x.properties.some(
|
|
35224
|
+
(p) => (ts5.isPropertyAssignment(p) || ts5.isShorthandPropertyAssignment(p)) && isOutputKey(p.name)
|
|
34737
35225
|
);
|
|
34738
35226
|
};
|
|
34739
35227
|
var LOGICAL = /* @__PURE__ */ new Set([
|
|
34740
|
-
|
|
34741
|
-
|
|
34742
|
-
|
|
35228
|
+
ts5.SyntaxKind.AmpersandAmpersandToken,
|
|
35229
|
+
ts5.SyntaxKind.BarBarToken,
|
|
35230
|
+
ts5.SyntaxKind.QuestionQuestionToken
|
|
34743
35231
|
]);
|
|
34744
35232
|
function branches(e) {
|
|
34745
35233
|
const x = strip(e);
|
|
34746
|
-
if (
|
|
34747
|
-
if (
|
|
34748
|
-
if (x.operatorToken.kind ===
|
|
34749
|
-
return [
|
|
35234
|
+
if (ts5.isConditionalExpression(x)) return [x.whenTrue, x.whenFalse];
|
|
35235
|
+
if (ts5.isBinaryExpression(x) && LOGICAL.has(x.operatorToken.kind)) {
|
|
35236
|
+
if (x.operatorToken.kind === ts5.SyntaxKind.AmpersandAmpersandToken)
|
|
35237
|
+
return [ts5.factory.createIdentifier("undefined"), x.right];
|
|
34750
35238
|
return [x.left, x.right];
|
|
34751
35239
|
}
|
|
34752
35240
|
return void 0;
|
|
34753
35241
|
}
|
|
34754
|
-
var accessesOutput = (n) =>
|
|
35242
|
+
var accessesOutput = (n) => ts5.isPropertyAccessExpression(n) && n.name.text === "outputSchema" || ts5.isElementAccessExpression(n) && ts5.isStringLiteralLike(n.argumentExpression) && n.argumentExpression.text === "outputSchema";
|
|
34755
35243
|
function underCondition(n) {
|
|
34756
|
-
for (let x = n.parent; x && !
|
|
34757
|
-
if (
|
|
34758
|
-
if (
|
|
35244
|
+
for (let x = n.parent; x && !ts5.isFunctionLike(x) && !ts5.isSourceFile(x); x = x.parent) {
|
|
35245
|
+
if (ts5.isIfStatement(x) || ts5.isConditionalExpression(x)) return true;
|
|
35246
|
+
if (ts5.isBinaryExpression(x) && LOGICAL.has(x.operatorToken.kind)) return true;
|
|
34759
35247
|
}
|
|
34760
35248
|
return false;
|
|
34761
35249
|
}
|
|
@@ -34764,26 +35252,26 @@ function exemptionSites(sf, rel2) {
|
|
|
34764
35252
|
const at = (n) => `${rel2}:${sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1}`;
|
|
34765
35253
|
const text = (n) => n.getText(sf).replace(/\s+/g, " ").slice(0, 120);
|
|
34766
35254
|
const visit = (n) => {
|
|
34767
|
-
if (
|
|
35255
|
+
if (ts5.isSpreadAssignment(n)) {
|
|
34768
35256
|
const b = branches(n.expression);
|
|
34769
35257
|
if (b?.some(objectHasOutput) && !b.every(objectHasOutput))
|
|
34770
35258
|
out.push({ anchor: at(n), form: "X1", text: text(n) });
|
|
34771
|
-
} else if (
|
|
35259
|
+
} else if (ts5.isPropertyAssignment(n) && isOutputKey(n.name)) {
|
|
34772
35260
|
const b = branches(n.initializer);
|
|
34773
35261
|
if (isNullish(n.initializer) || b?.some(isNullish))
|
|
34774
35262
|
out.push({ anchor: at(n), form: "X2", text: text(n) });
|
|
34775
|
-
} else if (
|
|
35263
|
+
} else if (ts5.isBinaryExpression(n) && n.operatorToken.kind === ts5.SyntaxKind.EqualsToken && accessesOutput(n.left) && (underCondition(n) || isNullish(n.right) || branches(n.right)?.some(isNullish))) {
|
|
34776
35264
|
out.push({ anchor: at(n), form: "X3", text: text(n) });
|
|
34777
|
-
} else if (
|
|
35265
|
+
} else if (ts5.isDeleteExpression(n) && accessesOutput(strip(n.expression))) {
|
|
34778
35266
|
out.push({ anchor: at(n), form: "X3", text: text(n) });
|
|
34779
35267
|
}
|
|
34780
|
-
|
|
35268
|
+
ts5.forEachChild(n, visit);
|
|
34781
35269
|
};
|
|
34782
35270
|
visit(sf);
|
|
34783
35271
|
return out;
|
|
34784
35272
|
}
|
|
34785
35273
|
function s51Controls() {
|
|
34786
|
-
const sf = (code) =>
|
|
35274
|
+
const sf = (code) => ts5.createSourceFile("c.ts", code, ts5.ScriptTarget.Latest, true, ts5.ScriptKind.TS);
|
|
34787
35275
|
const red = [
|
|
34788
35276
|
"f({ ...(s !== undefined ? { outputSchema: s } : {}) });",
|
|
34789
35277
|
"f({ outputSchema: skip.has(n) ? undefined : s });",
|
|
@@ -34942,7 +35430,7 @@ var s51ServedOutput = {
|
|
|
34942
35430
|
};
|
|
34943
35431
|
|
|
34944
35432
|
// src/detectors/s52-no-null-success.ts
|
|
34945
|
-
import * as
|
|
35433
|
+
import * as ts6 from "typescript";
|
|
34946
35434
|
var ID18 = "S52 no-null-success";
|
|
34947
35435
|
var RULE19 = "S-52";
|
|
34948
35436
|
function nullReturns(tool, read) {
|
|
@@ -34970,13 +35458,13 @@ function nullReturns(tool, read) {
|
|
|
34970
35458
|
const sc = prop(v.node, "structuredContent");
|
|
34971
35459
|
if (sc.kind === "value") {
|
|
34972
35460
|
const x = sc.value;
|
|
34973
|
-
if (x.kind ===
|
|
35461
|
+
if (x.kind === ts6.SyntaxKind.NullKeyword || ts6.isIdentifier(x) && x.text === "undefined")
|
|
34974
35462
|
red.push({ tool, anchor: r.anchor, form: "N2 `structuredContent: null`" });
|
|
34975
|
-
else if (
|
|
35463
|
+
else if (ts6.isObjectLiteralExpression(x) && x.properties.length === 0)
|
|
34976
35464
|
red.push({ tool, anchor: r.anchor, form: "N4 `structuredContent: {}`" });
|
|
34977
35465
|
}
|
|
34978
35466
|
const content = prop(v.node, "content");
|
|
34979
|
-
if (content.kind === "value" &&
|
|
35467
|
+
if (content.kind === "value" && ts6.isArrayLiteralExpression(content.value) && content.value.elements.length === 0)
|
|
34980
35468
|
red.push({ tool, anchor: r.anchor, form: "N5 `content: []`" });
|
|
34981
35469
|
else if (content.kind === "absent")
|
|
34982
35470
|
red.push({ tool, anchor: r.anchor, form: "N5 a result with no `content`" });
|
|
@@ -35109,24 +35597,24 @@ var s52NoNullSuccess = {
|
|
|
35109
35597
|
};
|
|
35110
35598
|
|
|
35111
35599
|
// src/detectors/s53-structured-not-text.ts
|
|
35112
|
-
import * as
|
|
35600
|
+
import * as ts7 from "typescript";
|
|
35113
35601
|
var ID19 = "S53 structured-not-text";
|
|
35114
35602
|
var RULE20 = "S-53";
|
|
35115
35603
|
function classifyTextExpr(e, sf, depth = 0) {
|
|
35116
35604
|
let x = e;
|
|
35117
|
-
while (
|
|
35118
|
-
if (
|
|
35605
|
+
while (ts7.isParenthesizedExpression(x) || ts7.isAsExpression(x)) x = x.expression;
|
|
35606
|
+
if (ts7.isStringLiteral(x) || ts7.isNoSubstitutionTemplateLiteral(x)) return { kind: "none" };
|
|
35119
35607
|
const t = x.getText(sf);
|
|
35120
|
-
if (
|
|
35608
|
+
if (ts7.isCallExpression(x) && /^JSON\s*\.\s*stringify$/.test(x.expression.getText(sf)))
|
|
35121
35609
|
return { kind: "data", form: "T1 JSON.stringify(...) in the text" };
|
|
35122
|
-
if (
|
|
35610
|
+
if (ts7.isTemplateExpression(x) || ts7.isBinaryExpression(x) && x.operatorToken.kind === ts7.SyntaxKind.PlusToken) {
|
|
35123
35611
|
if (/\bJSON\s*\.\s*stringify\s*\(/.test(t))
|
|
35124
35612
|
return { kind: "data", form: "T2 a serialized value inside the text" };
|
|
35125
35613
|
if (/\.\s*(join|map)\s*\(/.test(t))
|
|
35126
35614
|
return { kind: "data", form: "T2 a list joined into the text" };
|
|
35127
35615
|
if (/\.\s*length\b/.test(t))
|
|
35128
35616
|
return { kind: "data", form: "T2 a count interpolated into the text" };
|
|
35129
|
-
const spans =
|
|
35617
|
+
const spans = ts7.isTemplateExpression(x) ? x.templateSpans.map((sp) => sp.expression) : [x.left, x.right];
|
|
35130
35618
|
const idSpan = spans.find(
|
|
35131
35619
|
(sp) => /(?:^|\.)id$|[a-z0-9](?:Id|Ids|ID)$/.test(sp.getText(sf).trim())
|
|
35132
35620
|
);
|
|
@@ -35135,7 +35623,7 @@ function classifyTextExpr(e, sf, depth = 0) {
|
|
|
35135
35623
|
kind: "data",
|
|
35136
35624
|
form: `T2 an identifier interpolated into the text (${idSpan.getText(sf).trim()})`
|
|
35137
35625
|
};
|
|
35138
|
-
if (
|
|
35626
|
+
if (ts7.isBinaryExpression(x)) {
|
|
35139
35627
|
const parts = [classifyTextExpr(x.left, sf, depth), classifyTextExpr(x.right, sf, depth)];
|
|
35140
35628
|
return parts.find((p) => p.kind === "data") ?? parts.find((p) => p.kind === "unread") ?? { kind: "none" };
|
|
35141
35629
|
}
|
|
@@ -35144,16 +35632,16 @@ function classifyTextExpr(e, sf, depth = 0) {
|
|
|
35144
35632
|
form: `a template with interpolated values \`${t.replace(/\s+/g, " ").slice(0, 60)}\``
|
|
35145
35633
|
};
|
|
35146
35634
|
}
|
|
35147
|
-
if (
|
|
35635
|
+
if (ts7.isCallExpression(x) && /\.\s*join$/.test(x.expression.getText(sf)))
|
|
35148
35636
|
return { kind: "data", form: "T2 a list joined into the text" };
|
|
35149
|
-
if (
|
|
35637
|
+
if (ts7.isConditionalExpression(x)) {
|
|
35150
35638
|
const parts = [
|
|
35151
35639
|
classifyTextExpr(x.whenTrue, sf, depth),
|
|
35152
35640
|
classifyTextExpr(x.whenFalse, sf, depth)
|
|
35153
35641
|
];
|
|
35154
35642
|
return parts.find((p) => p.kind === "data") ?? parts.find((p) => p.kind === "unread") ?? { kind: "none" };
|
|
35155
35643
|
}
|
|
35156
|
-
if (
|
|
35644
|
+
if (ts7.isIdentifier(x) && depth < 2) {
|
|
35157
35645
|
const init = constInit(x);
|
|
35158
35646
|
if (init) return classifyTextExpr(init, sf, depth + 1);
|
|
35159
35647
|
}
|
|
@@ -35161,11 +35649,11 @@ function classifyTextExpr(e, sf, depth = 0) {
|
|
|
35161
35649
|
}
|
|
35162
35650
|
function constInit(id) {
|
|
35163
35651
|
for (let p = id.parent; p; p = p.parent) {
|
|
35164
|
-
if (!(
|
|
35652
|
+
if (!(ts7.isBlock(p) || ts7.isSourceFile(p))) continue;
|
|
35165
35653
|
for (const st of p.statements) {
|
|
35166
|
-
if (!
|
|
35654
|
+
if (!ts7.isVariableStatement(st) || !(st.declarationList.flags & ts7.NodeFlags.Const)) continue;
|
|
35167
35655
|
for (const d of st.declarationList.declarations)
|
|
35168
|
-
if (
|
|
35656
|
+
if (ts7.isIdentifier(d.name) && d.name.text === id.text && d.initializer && d.getStart() < id.getStart())
|
|
35169
35657
|
return d.initializer;
|
|
35170
35658
|
}
|
|
35171
35659
|
}
|
|
@@ -35174,11 +35662,11 @@ function constInit(id) {
|
|
|
35174
35662
|
function textOnlyReturn(obj, sf) {
|
|
35175
35663
|
const content = prop(obj, "content");
|
|
35176
35664
|
if (content.kind === "absent") return { kind: "none" };
|
|
35177
|
-
if (content.kind !== "value" || !
|
|
35665
|
+
if (content.kind !== "value" || !ts7.isArrayLiteralExpression(content.value))
|
|
35178
35666
|
return { kind: "unread", form: "a `content` that is not an array literal" };
|
|
35179
35667
|
const out = [];
|
|
35180
35668
|
for (const el of content.value.elements) {
|
|
35181
|
-
if (!
|
|
35669
|
+
if (!ts7.isObjectLiteralExpression(el)) {
|
|
35182
35670
|
out.push({ kind: "unread", form: "a content block that is not an object literal" });
|
|
35183
35671
|
continue;
|
|
35184
35672
|
}
|
|
@@ -35422,7 +35910,7 @@ var s53StructuredNotText = {
|
|
|
35422
35910
|
// src/detectors/s54-tools-tested.ts
|
|
35423
35911
|
import { readFileSync as readFileSync26, readdirSync as readdirSync18, statSync as statSync24 } from "fs";
|
|
35424
35912
|
import { join as join36, relative as relative17, sep as sep9 } from "path";
|
|
35425
|
-
import * as
|
|
35913
|
+
import * as ts8 from "typescript";
|
|
35426
35914
|
var ID20 = "S54 tools-tested";
|
|
35427
35915
|
var RULE21 = "S-54";
|
|
35428
35916
|
var TEST_DIR = /(^|\/)(test|tests|__tests__|spec|specs|e2e)\//;
|
|
@@ -35438,7 +35926,7 @@ function isTestFile(rel2) {
|
|
|
35438
35926
|
function testFiles2(root) {
|
|
35439
35927
|
const files = [];
|
|
35440
35928
|
const unread2 = [];
|
|
35441
|
-
const
|
|
35929
|
+
const walk4 = (dir) => {
|
|
35442
35930
|
let entries;
|
|
35443
35931
|
try {
|
|
35444
35932
|
entries = readdirSync18(dir);
|
|
@@ -35462,15 +35950,15 @@ function testFiles2(root) {
|
|
|
35462
35950
|
continue;
|
|
35463
35951
|
}
|
|
35464
35952
|
if (st.isDirectory()) {
|
|
35465
|
-
if (!NOT_TESTS.has(name))
|
|
35953
|
+
if (!NOT_TESTS.has(name)) walk4(full);
|
|
35466
35954
|
continue;
|
|
35467
35955
|
}
|
|
35468
35956
|
const rel2 = relative17(root, full).split(sep9).join("/");
|
|
35469
35957
|
if (!st.isFile() || !isTestFile(rel2)) continue;
|
|
35470
35958
|
try {
|
|
35471
35959
|
const text = readFileSync26(full, "utf8");
|
|
35472
|
-
const kind = /x$/.test(rel2) ?
|
|
35473
|
-
files.push({ rel: rel2, sf:
|
|
35960
|
+
const kind = /x$/.test(rel2) ? ts8.ScriptKind.TSX : /\.[cm]?js$/.test(rel2) ? ts8.ScriptKind.JS : ts8.ScriptKind.TS;
|
|
35961
|
+
files.push({ rel: rel2, sf: ts8.createSourceFile(rel2, text, ts8.ScriptTarget.Latest, true, kind) });
|
|
35474
35962
|
} catch (e) {
|
|
35475
35963
|
unread2.push({
|
|
35476
35964
|
anchor: rel2,
|
|
@@ -35479,40 +35967,40 @@ function testFiles2(root) {
|
|
|
35479
35967
|
}
|
|
35480
35968
|
}
|
|
35481
35969
|
};
|
|
35482
|
-
|
|
35970
|
+
walk4(root);
|
|
35483
35971
|
return { files, unread: unread2 };
|
|
35484
35972
|
}
|
|
35485
35973
|
var up = (n) => {
|
|
35486
35974
|
let x = n;
|
|
35487
|
-
while (x.parent && (
|
|
35975
|
+
while (x.parent && (ts8.isParenthesizedExpression(x.parent) || ts8.isAsExpression(x.parent) || ts8.isNonNullExpression(x.parent) || ts8.isAwaitExpression(x.parent) || ts8.isSatisfiesExpression(x.parent)))
|
|
35488
35976
|
x = x.parent;
|
|
35489
35977
|
return x;
|
|
35490
35978
|
};
|
|
35491
35979
|
var calleeName = (c) => {
|
|
35492
35980
|
const e = c.expression;
|
|
35493
|
-
if (
|
|
35494
|
-
if (
|
|
35981
|
+
if (ts8.isIdentifier(e)) return e.text;
|
|
35982
|
+
if (ts8.isPropertyAccessExpression(e)) return e.name.text;
|
|
35495
35983
|
return void 0;
|
|
35496
35984
|
};
|
|
35497
|
-
var propName = (p) => p.name && (
|
|
35985
|
+
var propName = (p) => p.name && (ts8.isIdentifier(p.name) || ts8.isStringLiteralLike(p.name)) ? p.name.text : void 0;
|
|
35498
35986
|
function invoked(access) {
|
|
35499
35987
|
const a = up(access);
|
|
35500
35988
|
const p = a.parent;
|
|
35501
35989
|
if (!p) return false;
|
|
35502
|
-
if (
|
|
35503
|
-
if (
|
|
35990
|
+
if (ts8.isCallExpression(p) && p.expression === a) return true;
|
|
35991
|
+
if (ts8.isPropertyAccessExpression(p) && p.expression === a && ["handler", "callback"].includes(p.name.text)) {
|
|
35504
35992
|
const q = up(p).parent;
|
|
35505
|
-
return !!q &&
|
|
35993
|
+
return !!q && ts8.isCallExpression(q) && up(q.expression) === up(p);
|
|
35506
35994
|
}
|
|
35507
|
-
if (
|
|
35995
|
+
if (ts8.isVariableDeclaration(p) && p.initializer && up(p.initializer) === a && ts8.isIdentifier(p.name)) {
|
|
35508
35996
|
const bound = p.name.text;
|
|
35509
35997
|
let scope2 = p;
|
|
35510
|
-
while (scope2.parent && !
|
|
35998
|
+
while (scope2.parent && !ts8.isBlock(scope2) && !ts8.isSourceFile(scope2)) scope2 = scope2.parent;
|
|
35511
35999
|
let called = false;
|
|
35512
36000
|
const visit = (n) => {
|
|
35513
36001
|
if (called) return;
|
|
35514
|
-
if (
|
|
35515
|
-
else
|
|
36002
|
+
if (ts8.isIdentifier(n) && n.text === bound && n !== p.name && invoked(n)) called = true;
|
|
36003
|
+
else ts8.forEachChild(n, visit);
|
|
35516
36004
|
};
|
|
35517
36005
|
visit(scope2);
|
|
35518
36006
|
return called;
|
|
@@ -35523,27 +36011,27 @@ function callsAt(e, helpers) {
|
|
|
35523
36011
|
const x = up(e);
|
|
35524
36012
|
const p = x.parent;
|
|
35525
36013
|
if (!p) return false;
|
|
35526
|
-
if (
|
|
36014
|
+
if (ts8.isPropertyAssignment(p) && p.initializer === x && propName(p) === "name" || ts8.isShorthandPropertyAssignment(p) && p.name === x && p.name.text === "name") {
|
|
35527
36015
|
const obj = p.parent;
|
|
35528
36016
|
const holder = up(obj).parent;
|
|
35529
|
-
if (holder &&
|
|
36017
|
+
if (holder && ts8.isCallExpression(holder) && holder.arguments.some((a) => up(a) === up(obj)) && calleeName(holder) === "callTool")
|
|
35530
36018
|
return true;
|
|
35531
|
-
if (holder &&
|
|
36019
|
+
if (holder && ts8.isPropertyAssignment(holder) && propName(holder) === "params") {
|
|
35532
36020
|
const req = holder.parent;
|
|
35533
36021
|
return req.properties.some(
|
|
35534
|
-
(q) =>
|
|
36022
|
+
(q) => ts8.isPropertyAssignment(q) && propName(q) === "method" && ts8.isStringLiteralLike(q.initializer) && q.initializer.text === "tools/call"
|
|
35535
36023
|
);
|
|
35536
36024
|
}
|
|
35537
36025
|
return false;
|
|
35538
36026
|
}
|
|
35539
|
-
if (
|
|
36027
|
+
if (ts8.isCallExpression(p) && p.arguments.some((a) => up(a) === x)) {
|
|
35540
36028
|
const i = p.arguments.findIndex((a) => up(a) === x);
|
|
35541
|
-
if (calleeName(p) === "get" && i === 0 &&
|
|
36029
|
+
if (calleeName(p) === "get" && i === 0 && ts8.isPropertyAccessExpression(p.expression))
|
|
35542
36030
|
return invoked(p);
|
|
35543
36031
|
const name = calleeName(p);
|
|
35544
36032
|
return !!name && (helpers.get(name)?.has(i) ?? false);
|
|
35545
36033
|
}
|
|
35546
|
-
if (
|
|
36034
|
+
if (ts8.isElementAccessExpression(p) && up(p.argumentExpression) === x) return invoked(p);
|
|
35547
36035
|
return false;
|
|
35548
36036
|
}
|
|
35549
36037
|
function deriveHelpers(files) {
|
|
@@ -35551,10 +36039,10 @@ function deriveHelpers(files) {
|
|
|
35551
36039
|
const fns = [];
|
|
35552
36040
|
for (const { sf } of files) {
|
|
35553
36041
|
const visit = (n) => {
|
|
35554
|
-
if (
|
|
35555
|
-
else if (
|
|
36042
|
+
if (ts8.isFunctionDeclaration(n) && n.name && n.body) fns.push({ name: n.name.text, fn: n });
|
|
36043
|
+
else if (ts8.isVariableDeclaration(n) && ts8.isIdentifier(n.name) && n.initializer && (ts8.isArrowFunction(n.initializer) || ts8.isFunctionExpression(n.initializer)))
|
|
35556
36044
|
fns.push({ name: n.name.text, fn: n.initializer });
|
|
35557
|
-
|
|
36045
|
+
ts8.forEachChild(n, visit);
|
|
35558
36046
|
};
|
|
35559
36047
|
visit(sf);
|
|
35560
36048
|
}
|
|
@@ -35562,14 +36050,14 @@ function deriveHelpers(files) {
|
|
|
35562
36050
|
let grew = false;
|
|
35563
36051
|
for (const { name, fn } of fns) {
|
|
35564
36052
|
fn.parameters.forEach((param, i) => {
|
|
35565
|
-
if (!
|
|
36053
|
+
if (!ts8.isIdentifier(param.name) || helpers.get(name)?.has(i)) return;
|
|
35566
36054
|
const pname = param.name.text;
|
|
35567
36055
|
let hit = false;
|
|
35568
36056
|
const visit = (n) => {
|
|
35569
36057
|
if (hit) return;
|
|
35570
|
-
if (
|
|
36058
|
+
if (ts8.isIdentifier(n) && n.text === pname && n !== param.name && callsAt(n, helpers))
|
|
35571
36059
|
hit = true;
|
|
35572
|
-
else
|
|
36060
|
+
else ts8.forEachChild(n, visit);
|
|
35573
36061
|
};
|
|
35574
36062
|
if (fn.body) visit(fn.body);
|
|
35575
36063
|
if (hit) {
|
|
@@ -35589,9 +36077,9 @@ function testCalls(files, tools) {
|
|
|
35589
36077
|
const out = new Map(tools.map((t) => [t, []]));
|
|
35590
36078
|
for (const { rel: rel2, sf } of files) {
|
|
35591
36079
|
const visit = (n) => {
|
|
35592
|
-
if ((
|
|
36080
|
+
if ((ts8.isStringLiteral(n) || ts8.isNoSubstitutionTemplateLiteral(n)) && wanted.has(n.text) && callsAt(n, helpers))
|
|
35593
36081
|
out.get(n.text)?.push(`${rel2}:${sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1}`);
|
|
35594
|
-
|
|
36082
|
+
ts8.forEachChild(n, visit);
|
|
35595
36083
|
};
|
|
35596
36084
|
visit(sf);
|
|
35597
36085
|
}
|
|
@@ -35601,7 +36089,7 @@ function s54Controls() {
|
|
|
35601
36089
|
const f = (code) => [
|
|
35602
36090
|
{
|
|
35603
36091
|
rel: "c.test.ts",
|
|
35604
|
-
sf:
|
|
36092
|
+
sf: ts8.createSourceFile("c.test.ts", code, ts8.ScriptTarget.Latest, true, ts8.ScriptKind.TS)
|
|
35605
36093
|
}
|
|
35606
36094
|
];
|
|
35607
36095
|
const k = (code) => (testCalls(f(code), ["t"]).get("t") ?? []).length;
|
|
@@ -36576,10 +37064,10 @@ function v4ToBig(ip) {
|
|
|
36576
37064
|
}
|
|
36577
37065
|
function v6ToBig(ip) {
|
|
36578
37066
|
let s = ip.toLowerCase();
|
|
36579
|
-
const
|
|
36580
|
-
if (
|
|
36581
|
-
const v = v4ToBig(
|
|
36582
|
-
s = `${s.slice(0, -
|
|
37067
|
+
const dotted2 = /(\d+\.\d+\.\d+\.\d+)$/.exec(s);
|
|
37068
|
+
if (dotted2) {
|
|
37069
|
+
const v = v4ToBig(dotted2[1]);
|
|
37070
|
+
s = `${s.slice(0, -dotted2[1].length)}${(v >> 16n).toString(16)}:${(v & 0xffffn).toString(16)}`;
|
|
36583
37071
|
}
|
|
36584
37072
|
const [head, tail] = s.includes("::") ? s.split("::") : [s, void 0];
|
|
36585
37073
|
const h = (head ?? "").split(":").filter((x) => x !== "");
|