@vantageos/mcp-doctor 0.11.1 → 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 +75 -0
- package/dist/doctor.js +1080 -98
- package/package.json +1 -1
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);
|
|
@@ -3412,12 +3412,603 @@ function helperImports(tree, re) {
|
|
|
3412
3412
|
return [...new Set(out)];
|
|
3413
3413
|
}
|
|
3414
3414
|
|
|
3415
|
+
// src/detectors/tsForms.ts
|
|
3416
|
+
function textBefore(file, line, col, max = 600) {
|
|
3417
|
+
const rows = uncommentedLines(file);
|
|
3418
|
+
let s = rows[line - 1].slice(0, col);
|
|
3419
|
+
for (let n = line - 1; n >= 1 && s.length < max; n--) s = `${rows[n - 1]}
|
|
3420
|
+
${s}`;
|
|
3421
|
+
return s;
|
|
3422
|
+
}
|
|
3423
|
+
function nextCode(file, line, col, maxLines = 4) {
|
|
3424
|
+
const rows = uncommentedLines(file);
|
|
3425
|
+
for (let n = line; n <= Math.min(file.lines.length, line + maxLines); n++) {
|
|
3426
|
+
const raw = rows[n - 1];
|
|
3427
|
+
for (let c = n === line ? col : 0; c < raw.length; c++) {
|
|
3428
|
+
if (/\s/.test(raw[c])) continue;
|
|
3429
|
+
return { line: n, col: c };
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
return null;
|
|
3433
|
+
}
|
|
3434
|
+
function charAt(file, p) {
|
|
3435
|
+
return uncommentedLines(file)[p.line - 1][p.col] ?? "";
|
|
3436
|
+
}
|
|
3437
|
+
function restOfLine(file, p) {
|
|
3438
|
+
return uncommentedLines(file)[p.line - 1].slice(p.col);
|
|
3439
|
+
}
|
|
3440
|
+
function enclosingOpener(file, line, col) {
|
|
3441
|
+
const rows = uncommentedLines(file);
|
|
3442
|
+
let depth = 0;
|
|
3443
|
+
for (let n = line; n >= 1; n--) {
|
|
3444
|
+
const raw = rows[n - 1];
|
|
3445
|
+
for (let c = (n === line ? col : raw.length) - 1; c >= 0; c--) {
|
|
3446
|
+
const ch = raw[c];
|
|
3447
|
+
if (!"()[]{}".includes(ch) || !isCodeAt(file, n, c)) continue;
|
|
3448
|
+
if (ch === ")" || ch === "]" || ch === "}") depth++;
|
|
3449
|
+
else if (depth === 0) return { line: n, col: c, ch };
|
|
3450
|
+
else depth--;
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
return null;
|
|
3454
|
+
}
|
|
3455
|
+
function afterClose(file, p, open, close) {
|
|
3456
|
+
const b = balancedBlock(file, p.line, p.col, open, close);
|
|
3457
|
+
if (!b) return null;
|
|
3458
|
+
const endLine = b.endLine;
|
|
3459
|
+
const lastRow = b.text.split("\n").pop() ?? "";
|
|
3460
|
+
const endCol = endLine === p.line ? p.col + lastRow.length : lastRow.length;
|
|
3461
|
+
return { line: endLine, col: endCol };
|
|
3462
|
+
}
|
|
3463
|
+
function colonIsTernary(file, line, col) {
|
|
3464
|
+
const rows = uncommentedLines(file);
|
|
3465
|
+
let depth = 0;
|
|
3466
|
+
let colons = 0;
|
|
3467
|
+
for (let n = line; n >= Math.max(1, line - 12); n--) {
|
|
3468
|
+
const raw = rows[n - 1];
|
|
3469
|
+
for (let c = (n === line ? col : raw.length) - 1; c >= 0; c--) {
|
|
3470
|
+
const ch = raw[c];
|
|
3471
|
+
if (!isCodeAt(file, n, c)) continue;
|
|
3472
|
+
if (ch === ")" || ch === "]" || ch === "}") depth++;
|
|
3473
|
+
else if (ch === "(" || ch === "[" || ch === "{") {
|
|
3474
|
+
if (depth === 0) return false;
|
|
3475
|
+
depth--;
|
|
3476
|
+
} else if (depth === 0) {
|
|
3477
|
+
if (ch === ";") return false;
|
|
3478
|
+
if (ch === ":" && raw[c - 1] !== "?") colons++;
|
|
3479
|
+
if (ch === "?" && raw[c + 1] !== "." && raw[c + 1] !== "?" && raw[c - 1] !== "?") {
|
|
3480
|
+
if (raw.slice(c + 1).trimStart().startsWith(":"))
|
|
3481
|
+
continue;
|
|
3482
|
+
if (colons === 0) return true;
|
|
3483
|
+
colons--;
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
return false;
|
|
3489
|
+
}
|
|
3490
|
+
var DECL_ANNOTATION = /\b(?:const|let|var|using)\s+[\w$]+\s*$/;
|
|
3491
|
+
function colonContext(file, brace, before, depth) {
|
|
3492
|
+
const colon = lastCodeChar(file, brace);
|
|
3493
|
+
if (!colon) return { kind: "unread", form: "a `:` whose position cannot be read" };
|
|
3494
|
+
if (colonIsTernary(file, colon.line, colon.col)) return { kind: "value" };
|
|
3495
|
+
const head = before.slice(0, -1).trimEnd();
|
|
3496
|
+
if (/\bcase\b[^;{}]*$/.test(head) || /\bdefault$/.test(head)) return { kind: "block" };
|
|
3497
|
+
if (head.endsWith(")")) return { kind: "type" };
|
|
3498
|
+
const enc = enclosingOpener(file, colon.line, colon.col);
|
|
3499
|
+
if (!enc) {
|
|
3500
|
+
if (DECL_ANNOTATION.test(head)) return { kind: "type" };
|
|
3501
|
+
return { kind: "unread", form: `the brace after \`${head.slice(-30).trim()}:\`` };
|
|
3502
|
+
}
|
|
3503
|
+
if (enc.ch === "(") {
|
|
3504
|
+
return /(?:\(|,)\s*(?:\.\.\.)?\s*[\w$]+\s*\??\s*$/.test(head) ? { kind: "type" } : { kind: "value" };
|
|
3505
|
+
}
|
|
3506
|
+
if (enc.ch === "[") return { kind: "value" };
|
|
3507
|
+
const parent = braceContext(file, enc.line, enc.col, depth + 1);
|
|
3508
|
+
if (parent.kind === "block") {
|
|
3509
|
+
return DECL_ANNOTATION.test(head) ? { kind: "type" } : { kind: "block" };
|
|
3510
|
+
}
|
|
3511
|
+
return parent;
|
|
3512
|
+
}
|
|
3513
|
+
function lastCodeChar(file, p) {
|
|
3514
|
+
const rows = uncommentedLines(file);
|
|
3515
|
+
for (let n = p.line; n >= 1; n--) {
|
|
3516
|
+
const raw = rows[n - 1];
|
|
3517
|
+
for (let c = (n === p.line ? p.col : raw.length) - 1; c >= 0; c--) {
|
|
3518
|
+
if (/\s/.test(raw[c])) continue;
|
|
3519
|
+
return { line: n, col: c };
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
return null;
|
|
3523
|
+
}
|
|
3524
|
+
function braceContext(file, line, col, depth = 0) {
|
|
3525
|
+
if (depth > 12) return { kind: "unread", form: "a brace nested deeper than 12 levels" };
|
|
3526
|
+
const before = textBefore(file, line, col).replace(/\s+$/, "");
|
|
3527
|
+
if (before === "") return { kind: "block" };
|
|
3528
|
+
if (/\b(?:interface\s+[\w$]+[^{};=()]*|type\s+[\w$]+\s*(?:<[^=]*>)?\s*=|enum\s+[\w$]+|class(?:\s+[\w$]+)?[^{};=()]*|as|satisfies|keyof|typeof|extends|implements\s+[^{};]*)$/.test(
|
|
3529
|
+
before
|
|
3530
|
+
) || /[<|&]$/.test(before)) {
|
|
3531
|
+
return { kind: "type" };
|
|
3532
|
+
}
|
|
3533
|
+
if (/\b(?:const|let|var|using)$/.test(before)) return { kind: "pattern" };
|
|
3534
|
+
const prevValueToken = /(?:^|[^=!<>])=$/.test(before) || /\b(?:return|yield|await|throw|default)$/.test(before) || /(?:[(,[?!+\-*]|\?\?|\|\||&&|\.\.\.)$/.test(before);
|
|
3535
|
+
if (prevValueToken) {
|
|
3536
|
+
const after = afterClose(file, { line, col }, "{", "}");
|
|
3537
|
+
const next = after ? nextCode(file, after.line, after.col) : null;
|
|
3538
|
+
const rest = next ? restOfLine(file, next) : "";
|
|
3539
|
+
if (/^=(?![=>])/.test(rest)) return { kind: "pattern" };
|
|
3540
|
+
if (/[(,]$/.test(before)) {
|
|
3541
|
+
if (rest.startsWith(":")) return { kind: "pattern" };
|
|
3542
|
+
const enc = enclosingOpener(file, line, col);
|
|
3543
|
+
if (enc && enc.ch === "(") {
|
|
3544
|
+
const close = afterClose(file, enc, "(", ")");
|
|
3545
|
+
const n2 = close ? nextCode(file, close.line, close.col) : null;
|
|
3546
|
+
const r2 = n2 ? restOfLine(file, n2) : "";
|
|
3547
|
+
const head = textBefore(file, enc.line, enc.col).trimEnd();
|
|
3548
|
+
const isCall = /[\w$\])]$/.test(head) && !/\b(?:function|async)$/.test(head);
|
|
3549
|
+
if (r2.startsWith("=>") || r2.startsWith("{")) return { kind: "pattern" };
|
|
3550
|
+
if (r2.startsWith(":") && !isCall) return { kind: "pattern" };
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
return { kind: "value" };
|
|
3554
|
+
}
|
|
3555
|
+
if (/(?:\)|=>|[;{}])$/.test(before) || /\b(?:else|try|finally|do)$/.test(before)) {
|
|
3556
|
+
return { kind: "block" };
|
|
3557
|
+
}
|
|
3558
|
+
if (before.endsWith(":")) return colonContext(file, { line, col }, before, depth);
|
|
3559
|
+
return { kind: "unread", form: `the brace after \`${before.slice(-30).trim()}\`` };
|
|
3560
|
+
}
|
|
3561
|
+
function conditionalOfObjects(text) {
|
|
3562
|
+
let depth = 0;
|
|
3563
|
+
let q = -1;
|
|
3564
|
+
let colon = -1;
|
|
3565
|
+
for (let i = 0; i < text.length; i++) {
|
|
3566
|
+
const ch = text[i];
|
|
3567
|
+
if ("([{".includes(ch)) depth++;
|
|
3568
|
+
else if (")]}".includes(ch)) depth--;
|
|
3569
|
+
else if (depth === 0 && ch === "?" && text[i + 1] !== "." && text[i + 1] !== "?" && q < 0)
|
|
3570
|
+
q = i;
|
|
3571
|
+
else if (depth === 0 && ch === ":" && q >= 0 && colon < 0) colon = i;
|
|
3572
|
+
}
|
|
3573
|
+
if (q < 0 || colon < 0) return false;
|
|
3574
|
+
const branch = (b) => /^(?:\{[\s\S]*\}|undefined|null)$/.test(b.trim());
|
|
3575
|
+
return branch(text.slice(q + 1, colon)) && branch(text.slice(colon + 1));
|
|
3576
|
+
}
|
|
3577
|
+
function isTsx(file) {
|
|
3578
|
+
return /\.[jt]sx$/.test(file.path);
|
|
3579
|
+
}
|
|
3580
|
+
function skipType(file, p) {
|
|
3581
|
+
const rows = uncommentedLines(file);
|
|
3582
|
+
let depth = 0;
|
|
3583
|
+
for (let n = p.line; n <= Math.min(file.lines.length, p.line + 20); n++) {
|
|
3584
|
+
const raw = rows[n - 1];
|
|
3585
|
+
for (let c = n === p.line ? p.col : 0; c < raw.length; c++) {
|
|
3586
|
+
const ch = raw[c];
|
|
3587
|
+
if (!isCodeAt(file, n, c)) continue;
|
|
3588
|
+
if (ch === "=" && raw[c + 1] === ">") {
|
|
3589
|
+
c++;
|
|
3590
|
+
continue;
|
|
3591
|
+
}
|
|
3592
|
+
if ("<{([".includes(ch)) depth++;
|
|
3593
|
+
else if (">})]".includes(ch)) {
|
|
3594
|
+
if (depth === 0) return { line: n, col: c };
|
|
3595
|
+
depth--;
|
|
3596
|
+
} else if (depth === 0 && (ch === "," || ch === ";")) return { line: n, col: c };
|
|
3597
|
+
}
|
|
3598
|
+
if (depth === 0) return { line: n, col: raw.length };
|
|
3599
|
+
}
|
|
3600
|
+
return { line: p.line, col: rows[p.line - 1].length };
|
|
3601
|
+
}
|
|
3602
|
+
function readSuffix(file, p, parens) {
|
|
3603
|
+
const wrappers = [];
|
|
3604
|
+
let open = parens;
|
|
3605
|
+
let cur = p;
|
|
3606
|
+
for (let guard = 0; guard < 20; guard++) {
|
|
3607
|
+
cur = cur ? nextCode(file, cur.line, cur.col, 1) : null;
|
|
3608
|
+
if (!cur) return { wrappers };
|
|
3609
|
+
const rest = restOfLine(file, cur);
|
|
3610
|
+
if (rest.startsWith("!") && !rest.startsWith("!=")) {
|
|
3611
|
+
wrappers.push("non-null");
|
|
3612
|
+
cur = { line: cur.line, col: cur.col + 1 };
|
|
3613
|
+
continue;
|
|
3614
|
+
}
|
|
3615
|
+
const kw = rest.match(/^(as|satisfies)\b/);
|
|
3616
|
+
if (kw) {
|
|
3617
|
+
wrappers.push(kw[1]);
|
|
3618
|
+
const t = nextCode(file, cur.line, cur.col + kw[1].length, 1);
|
|
3619
|
+
cur = t ? skipType(file, t) : null;
|
|
3620
|
+
continue;
|
|
3621
|
+
}
|
|
3622
|
+
if (rest.startsWith(")") && open > 0) {
|
|
3623
|
+
open--;
|
|
3624
|
+
cur = { line: cur.line, col: cur.col + 1 };
|
|
3625
|
+
continue;
|
|
3626
|
+
}
|
|
3627
|
+
if (/^(?:[,;})\]]|$)/.test(rest) && open === 0) return { wrappers };
|
|
3628
|
+
if (/^\s*$/.test(rest) && open === 0) return { wrappers };
|
|
3629
|
+
return { foreign: rest.trim().slice(0, 40) };
|
|
3630
|
+
}
|
|
3631
|
+
return { foreign: "an expression the reader stopped following" };
|
|
3632
|
+
}
|
|
3633
|
+
function exprText(file, p) {
|
|
3634
|
+
const raw = restOfLine(file, p);
|
|
3635
|
+
let depth = 0;
|
|
3636
|
+
for (let c = 0; c < raw.length; c++) {
|
|
3637
|
+
const ch = raw[c];
|
|
3638
|
+
if ("([{".includes(ch)) depth++;
|
|
3639
|
+
else if (")]}".includes(ch)) {
|
|
3640
|
+
if (depth === 0) return raw.slice(0, c).trim();
|
|
3641
|
+
depth--;
|
|
3642
|
+
} else if (depth === 0 && (ch === "," || ch === ";")) return raw.slice(0, c).trim();
|
|
3643
|
+
}
|
|
3644
|
+
return raw.trim().slice(0, 60);
|
|
3645
|
+
}
|
|
3646
|
+
function unwrapValue(file, line, col) {
|
|
3647
|
+
const wrappers = [];
|
|
3648
|
+
let parens = 0;
|
|
3649
|
+
let p = nextCode(file, line, col);
|
|
3650
|
+
const firstParen = { line: p?.line ?? line, col: p?.col ?? col };
|
|
3651
|
+
for (let guard = 0; p && guard < 10; guard++) {
|
|
3652
|
+
const ch = charAt(file, p);
|
|
3653
|
+
if (ch === "(") {
|
|
3654
|
+
wrappers.push("parentheses");
|
|
3655
|
+
parens++;
|
|
3656
|
+
p = nextCode(file, p.line, p.col + 1);
|
|
3657
|
+
continue;
|
|
3658
|
+
}
|
|
3659
|
+
if (ch === "<" && !isTsx(file)) {
|
|
3660
|
+
const end = afterClose(file, p, "<", ">");
|
|
3661
|
+
if (!end) return { kind: "other", form: "an unterminated `<T>` type assertion" };
|
|
3662
|
+
wrappers.push("type-assertion");
|
|
3663
|
+
p = nextCode(file, end.line, end.col);
|
|
3664
|
+
continue;
|
|
3665
|
+
}
|
|
3666
|
+
break;
|
|
3667
|
+
}
|
|
3668
|
+
if (!p) return { kind: "other", form: "no value after the key" };
|
|
3669
|
+
const start = p;
|
|
3670
|
+
const rest = restOfLine(file, p);
|
|
3671
|
+
if (charAt(file, p) === "{") {
|
|
3672
|
+
const end = afterClose(file, p, "{", "}");
|
|
3673
|
+
if (!end) return { kind: "other", form: "an object that never closes before end of file" };
|
|
3674
|
+
const suffix2 = readSuffix(file, end, parens);
|
|
3675
|
+
if ("foreign" in suffix2) {
|
|
3676
|
+
return { kind: "other", form: `an object literal followed by \`${suffix2.foreign}\`` };
|
|
3677
|
+
}
|
|
3678
|
+
return {
|
|
3679
|
+
kind: "object",
|
|
3680
|
+
line: start.line,
|
|
3681
|
+
col: start.col,
|
|
3682
|
+
wrappers: [...wrappers, ...suffix2.wrappers]
|
|
3683
|
+
};
|
|
3684
|
+
}
|
|
3685
|
+
if (/^(?:true|false|null|undefined)\b/.test(rest) || /^["'`\d-]/.test(rest)) {
|
|
3686
|
+
return { kind: "literal" };
|
|
3687
|
+
}
|
|
3688
|
+
const id = rest.match(/^[A-Za-z_$][\w$]*/);
|
|
3689
|
+
if (!id) return { kind: "other", form: `\`${exprText(file, p)}\`` };
|
|
3690
|
+
if (/^(?:await|new|typeof|void|yield|delete)$/.test(id[0])) {
|
|
3691
|
+
return { kind: "other", form: `an \`${id[0]}\` expression (\`${exprText(file, start)}\`)` };
|
|
3692
|
+
}
|
|
3693
|
+
const after = { line: p.line, col: p.col + id[0].length };
|
|
3694
|
+
const tail = restOfLine(file, after);
|
|
3695
|
+
if (/^\s*(?:\?\.|\.|\(|\[)/.test(tail) || /^\s*<[^>]*>\s*\(/.test(tail)) {
|
|
3696
|
+
const text = exprText(file, start);
|
|
3697
|
+
if (parens > 0 && conditionalOfObjects(text)) return { kind: "objects-inline", ...firstParen };
|
|
3698
|
+
const kind = /\)\s*$/.test(text.replace(/\s+(?:as|satisfies)\s.*$/, "")) ? "a call" : "a member access";
|
|
3699
|
+
return { kind: "other", form: `${kind} (\`${text}\`)` };
|
|
3700
|
+
}
|
|
3701
|
+
const suffix = readSuffix(file, after, parens);
|
|
3702
|
+
if ("foreign" in suffix) {
|
|
3703
|
+
if (parens > 0 && conditionalOfObjects(exprText(file, start)))
|
|
3704
|
+
return { kind: "objects-inline", ...firstParen };
|
|
3705
|
+
return { kind: "other", form: `\`${id[0]}\` followed by \`${suffix.foreign}\`` };
|
|
3706
|
+
}
|
|
3707
|
+
return { kind: "ident", name: id[0], wrappers: [...wrappers, ...suffix.wrappers] };
|
|
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
|
+
}
|
|
3716
|
+
function prevCodeText(file, line, col) {
|
|
3717
|
+
return textBefore(file, line, col, 200).trimEnd();
|
|
3718
|
+
}
|
|
3719
|
+
function keyInBrace(file, line, col, name, form, out) {
|
|
3720
|
+
const anchor = `${file.rel}:${line}`;
|
|
3721
|
+
const enc = enclosingOpener(file, line, col);
|
|
3722
|
+
if (!enc || enc.ch !== "{") return;
|
|
3723
|
+
const ctx = braceContext(file, enc.line, enc.col);
|
|
3724
|
+
if (ctx.kind === "value") {
|
|
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
|
+
});
|
|
3734
|
+
} else if (ctx.kind === "unread") {
|
|
3735
|
+
out.unread.push({
|
|
3736
|
+
anchor,
|
|
3737
|
+
reason: `\`${name}\` at ${anchor} is a key of a brace whose kind (object value, type, pattern, block) is unread: ${ctx.form}`
|
|
3738
|
+
});
|
|
3739
|
+
}
|
|
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
|
+
}
|
|
3790
|
+
function fieldWrites(tree, names) {
|
|
3791
|
+
const out = { writes: [], unread: [], computed: [] };
|
|
3792
|
+
const alt = names.map((n) => n.replace(/[$]/g, "\\$&")).join("|");
|
|
3793
|
+
const identRe = new RegExp(`(?<![\\w$])(${alt})(?![\\w$])`, "g");
|
|
3794
|
+
const quotedRe = new RegExp(`(["'])(${alt})\\1`, "g");
|
|
3795
|
+
for (const file of tree.files) {
|
|
3796
|
+
for (const line of file.lines) {
|
|
3797
|
+
if (line.comment) continue;
|
|
3798
|
+
for (const m of line.raw.matchAll(identRe)) {
|
|
3799
|
+
const col = m.index ?? 0;
|
|
3800
|
+
if (!isCodeAt(file, line.n, col)) continue;
|
|
3801
|
+
const name = m[1];
|
|
3802
|
+
const prev = prevCodeText(file, line.n, col);
|
|
3803
|
+
const nx = nextCode(file, line.n, col + name.length, 1);
|
|
3804
|
+
const after = nx ? restOfLine(file, nx) : "";
|
|
3805
|
+
if (prev.endsWith(".") && !prev.endsWith("...")) {
|
|
3806
|
+
if (/^=(?![=>])/.test(after)) {
|
|
3807
|
+
const base = prev.match(/([\w$]+)\s*\.$/);
|
|
3808
|
+
out.writes.push({
|
|
3809
|
+
name,
|
|
3810
|
+
form: "member-assign",
|
|
3811
|
+
file,
|
|
3812
|
+
line: line.n,
|
|
3813
|
+
col,
|
|
3814
|
+
anchor: `${file.rel}:${line.n}`,
|
|
3815
|
+
base: base?.[1]
|
|
3816
|
+
});
|
|
3817
|
+
}
|
|
3818
|
+
continue;
|
|
3819
|
+
}
|
|
3820
|
+
const keyPos = /[{,]$/.test(prev);
|
|
3821
|
+
if (!keyPos) continue;
|
|
3822
|
+
if (after.startsWith(":") && !after.startsWith("::")) {
|
|
3823
|
+
keyInBrace(file, line.n, col, name, "key", out);
|
|
3824
|
+
} else if (/^(?:[,}]|$)/.test(after)) {
|
|
3825
|
+
keyInBrace(file, line.n, col, name, "shorthand", out);
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
computedKeys(file, line.n, names, out);
|
|
3829
|
+
for (const m of line.raw.matchAll(quotedRe)) {
|
|
3830
|
+
const col = m.index ?? 0;
|
|
3831
|
+
if (!isCodeAt(file, line.n, col)) continue;
|
|
3832
|
+
const name = m[2];
|
|
3833
|
+
const prev = prevCodeText(file, line.n, col);
|
|
3834
|
+
const nx = nextCode(file, line.n, col + m[0].length, 1);
|
|
3835
|
+
const after = nx ? restOfLine(file, nx) : "";
|
|
3836
|
+
if (prev.endsWith("[") && /^\]\s*=(?![=>])/.test(after)) {
|
|
3837
|
+
const base = prev.match(/([\w$]+)\s*\??\.?\s*\[$/);
|
|
3838
|
+
out.writes.push({
|
|
3839
|
+
name,
|
|
3840
|
+
form: "bracket-assign",
|
|
3841
|
+
file,
|
|
3842
|
+
line: line.n,
|
|
3843
|
+
col,
|
|
3844
|
+
anchor: `${file.rel}:${line.n}`,
|
|
3845
|
+
base: base?.[1]
|
|
3846
|
+
});
|
|
3847
|
+
continue;
|
|
3848
|
+
}
|
|
3849
|
+
if (/[{,]$/.test(prev) && after.startsWith(":")) {
|
|
3850
|
+
keyInBrace(file, line.n, col, name, "quoted-key", out);
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
}
|
|
3855
|
+
return out;
|
|
3856
|
+
}
|
|
3857
|
+
function objectMembers(file, p) {
|
|
3858
|
+
const keys = /* @__PURE__ */ new Set();
|
|
3859
|
+
const spreads = [];
|
|
3860
|
+
const b = balancedBlock(file, p.line, p.col, "{", "}");
|
|
3861
|
+
if (!b) return { keys, spreads };
|
|
3862
|
+
const text = b.text.slice(1, -1);
|
|
3863
|
+
let depth = 0;
|
|
3864
|
+
let quote = "";
|
|
3865
|
+
let seg = "";
|
|
3866
|
+
const flush = () => {
|
|
3867
|
+
const s = seg.trim();
|
|
3868
|
+
seg = "";
|
|
3869
|
+
if (!s) return;
|
|
3870
|
+
const spread = s.match(/^\.\.\.\s*([\s\S]+)$/);
|
|
3871
|
+
if (spread) {
|
|
3872
|
+
spreads.push(spread[1].trim());
|
|
3873
|
+
return;
|
|
3874
|
+
}
|
|
3875
|
+
const k = s.match(/^(?:["'`]([^"'`]+)["'`]|([A-Za-z_$][\w$]*))\s*(?:\??:|\(|$)/);
|
|
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]);
|
|
3879
|
+
};
|
|
3880
|
+
for (let i = 0; i < text.length; i++) {
|
|
3881
|
+
const ch = text[i];
|
|
3882
|
+
if (quote) {
|
|
3883
|
+
seg += ch;
|
|
3884
|
+
if (ch === "\\") {
|
|
3885
|
+
seg += text[++i] ?? "";
|
|
3886
|
+
} else if (ch === quote) quote = "";
|
|
3887
|
+
continue;
|
|
3888
|
+
}
|
|
3889
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
3890
|
+
quote = ch;
|
|
3891
|
+
seg += ch;
|
|
3892
|
+
continue;
|
|
3893
|
+
}
|
|
3894
|
+
if ("([{".includes(ch)) depth++;
|
|
3895
|
+
else if (")]}".includes(ch)) depth--;
|
|
3896
|
+
if (depth === 0 && ch === ",") {
|
|
3897
|
+
flush();
|
|
3898
|
+
continue;
|
|
3899
|
+
}
|
|
3900
|
+
seg += ch;
|
|
3901
|
+
}
|
|
3902
|
+
flush();
|
|
3903
|
+
return { keys, spreads };
|
|
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
|
+
}
|
|
4006
|
+
|
|
3415
4007
|
// src/detectors/metaKeys.ts
|
|
3416
4008
|
var KEY_IN_BLOCK_RE = /(["'`])([A-Za-z0-9_.-]+\/[^"'`\s]*)\1\s*:/g;
|
|
3417
4009
|
var META_OPEN_RE = /\b_meta\??\s*[:=]\s*/g;
|
|
3418
4010
|
var CAP_OPEN_RE = /\b(extensions|experimental)\s*:\s*/g;
|
|
3419
4011
|
var META_BRACKET_RE = /\b_meta\s*\[\s*(["'`])([^"'`]+\/[^"'`]*)\1\s*\]/g;
|
|
3420
|
-
var SPREAD_RE = /\.\.\.\s*([A-Za-z_$][\w$]*)\b(?!\s*[(.[])/g;
|
|
3421
4012
|
function addKeys(block, file, obj, acc) {
|
|
3422
4013
|
obj.texts.push(block.text);
|
|
3423
4014
|
block.text.split("\n").forEach((text, i) => {
|
|
@@ -3432,19 +4023,33 @@ function addKeys(block, file, obj, acc) {
|
|
|
3432
4023
|
}
|
|
3433
4024
|
});
|
|
3434
4025
|
}
|
|
3435
|
-
function
|
|
4026
|
+
function findConstBinding(tree, name) {
|
|
3436
4027
|
const re = new RegExp(
|
|
3437
|
-
`\\b(?:const|let|var)\\s+${name.replace(/[$]/g, "\\$&")}\\b[^=\\n]
|
|
4028
|
+
`\\b(?:const|let|var)\\s+${name.replace(/[$]/g, "\\$&")}\\b[^=\\n]*=(?![=>])\\s*`,
|
|
3438
4029
|
"g"
|
|
3439
4030
|
);
|
|
4031
|
+
const forms = [];
|
|
3440
4032
|
for (const site of codeSites(tree, re)) {
|
|
3441
4033
|
const after = site.col + site.match[0].length;
|
|
3442
|
-
const
|
|
3443
|
-
if (
|
|
3444
|
-
|
|
3445
|
-
|
|
4034
|
+
const core = unwrapValue(site.file, site.line.n, after);
|
|
4035
|
+
if (core.kind === "object") {
|
|
4036
|
+
const block = balancedBlock(site.file, core.line, core.col, "{", "}");
|
|
4037
|
+
if (block) return { found: { file: site.file, block, col: core.col }, forms };
|
|
4038
|
+
forms.push(`an object at ${site.anchor} that never closes`);
|
|
4039
|
+
} else if (core.kind === "ident") {
|
|
4040
|
+
forms.push(`the identifier \`${core.name}\` at ${site.anchor}`);
|
|
4041
|
+
} else if (core.kind === "literal") {
|
|
4042
|
+
forms.push(`a literal at ${site.anchor}`);
|
|
4043
|
+
} else if (core.kind === "objects-inline") {
|
|
4044
|
+
forms.push(`a conditional of object literals at ${site.anchor}`);
|
|
4045
|
+
} else {
|
|
4046
|
+
forms.push(`${core.form} at ${site.anchor}`);
|
|
4047
|
+
}
|
|
3446
4048
|
}
|
|
3447
|
-
return null;
|
|
4049
|
+
return { found: null, forms };
|
|
4050
|
+
}
|
|
4051
|
+
function findConstBlock(tree, name) {
|
|
4052
|
+
return findConstBinding(tree, name).found;
|
|
3448
4053
|
}
|
|
3449
4054
|
function followIdent(tree, name, obj, acc, hops, seen, from) {
|
|
3450
4055
|
if (seen.has(name)) return;
|
|
@@ -3456,29 +4061,47 @@ function followIdent(tree, name, obj, acc, hops, seen, from) {
|
|
|
3456
4061
|
});
|
|
3457
4062
|
return;
|
|
3458
4063
|
}
|
|
3459
|
-
const found =
|
|
4064
|
+
const { found, forms } = findConstBinding(tree, name);
|
|
3460
4065
|
if (!found) {
|
|
4066
|
+
const bound = forms.length > 0 ? ` (bound to ${forms.join("; ")})` : "";
|
|
3461
4067
|
acc.unreadable.push({
|
|
3462
4068
|
anchor: from,
|
|
3463
|
-
reason: `\`${name}\` (reached from ${from}) is not a const object in this tree \u2014 the keys it carries are unread`
|
|
4069
|
+
reason: `\`${name}\` (reached from ${from}) is not a const object in this tree${bound} \u2014 the keys it carries are unread`
|
|
3464
4070
|
});
|
|
3465
4071
|
return;
|
|
3466
4072
|
}
|
|
3467
4073
|
addKeys(found.block, found.file, obj, acc);
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
4074
|
+
followSpreads(tree, found.block, found.col, found.file, obj, acc, hops - 1, seen, from);
|
|
4075
|
+
}
|
|
4076
|
+
var SPREAD_ANY_RE = /\.\.\.\s*/g;
|
|
4077
|
+
function followSpreads(tree, block, startCol, file, obj, acc, hops, seen, from) {
|
|
4078
|
+
const rows = block.text.split("\n");
|
|
4079
|
+
rows.forEach((row, i) => {
|
|
4080
|
+
for (const m of row.matchAll(SPREAD_ANY_RE)) {
|
|
4081
|
+
const lineNo = block.startLine + i;
|
|
4082
|
+
const at = (i === 0 ? startCol : 0) + (m.index ?? 0);
|
|
4083
|
+
if (!isCodeAt(file, lineNo, at)) continue;
|
|
4084
|
+
const core = unwrapValue(file, lineNo, at + m[0].length);
|
|
4085
|
+
if (core.kind === "ident") {
|
|
4086
|
+
followIdent(tree, core.name, obj, acc, hops, seen, from);
|
|
4087
|
+
} else if (core.kind === "other") {
|
|
4088
|
+
acc.unreadable.push({
|
|
4089
|
+
anchor: `${file.rel}:${lineNo}`,
|
|
4090
|
+
reason: `the spread at ${file.rel}:${lineNo} (reached from ${from}) is ${core.form} \u2014 the keys it carries are unread`
|
|
4091
|
+
});
|
|
4092
|
+
}
|
|
4093
|
+
}
|
|
4094
|
+
});
|
|
3471
4095
|
}
|
|
3472
4096
|
function readValue(tree, file, lineNo, col, context, acc) {
|
|
3473
4097
|
const raw = file.lines[lineNo - 1].raw;
|
|
3474
4098
|
const rest = raw.slice(col);
|
|
3475
4099
|
const anchor = `${file.rel}:${lineNo}`;
|
|
3476
4100
|
if (/^z\s*\./.test(rest.trim())) return;
|
|
3477
|
-
const op = nextOpener(file, lineNo, col, "{[(", rest.trim() === "" ? 1 : 0);
|
|
3478
|
-
const identMatch = rest.match(/^([A-Za-z_$][\w$]*)\s*(?:[,;)}]|as\b|$)/);
|
|
3479
4101
|
const obj = { anchor, context, file, texts: [], keys: [] };
|
|
3480
|
-
|
|
3481
|
-
|
|
4102
|
+
const core = unwrapValue(file, lineNo, col);
|
|
4103
|
+
if (core.kind === "object") {
|
|
4104
|
+
const block = balancedBlock(file, core.line, core.col, "{", "}");
|
|
3482
4105
|
if (!block) {
|
|
3483
4106
|
acc.unreadable.push({
|
|
3484
4107
|
anchor,
|
|
@@ -3488,28 +4111,41 @@ function readValue(tree, file, lineNo, col, context, acc) {
|
|
|
3488
4111
|
}
|
|
3489
4112
|
acc.objects.push(obj);
|
|
3490
4113
|
addKeys(block, file, obj, acc);
|
|
3491
|
-
|
|
3492
|
-
for (const sp of block.text.matchAll(SPREAD_RE)) {
|
|
3493
|
-
followIdent(tree, sp[1], obj, acc, 3, seen, anchor);
|
|
3494
|
-
}
|
|
4114
|
+
followSpreads(tree, block, core.col, file, obj, acc, 3, /* @__PURE__ */ new Set(), anchor);
|
|
3495
4115
|
return;
|
|
3496
4116
|
}
|
|
3497
|
-
if (
|
|
3498
|
-
if (
|
|
4117
|
+
if (core.kind === "literal") return;
|
|
4118
|
+
if (core.kind === "objects-inline") {
|
|
4119
|
+
const block = balancedBlock(file, core.line, core.col, "(", ")");
|
|
4120
|
+
if (block) {
|
|
4121
|
+
acc.objects.push(obj);
|
|
4122
|
+
addKeys(block, file, obj, acc);
|
|
4123
|
+
return;
|
|
4124
|
+
}
|
|
4125
|
+
}
|
|
4126
|
+
if (core.kind === "ident") {
|
|
4127
|
+
if (/^(?:undefined)$/.test(core.name)) return;
|
|
3499
4128
|
acc.objects.push(obj);
|
|
3500
|
-
followIdent(tree,
|
|
4129
|
+
followIdent(tree, core.name, obj, acc, 3, /* @__PURE__ */ new Set(), anchor);
|
|
3501
4130
|
return;
|
|
3502
4131
|
}
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
4132
|
+
acc.unreadable.push({
|
|
4133
|
+
anchor,
|
|
4134
|
+
reason: `the ${context} value at ${anchor} is neither an object literal nor a same-tree const (${core.kind === "other" ? core.form : "a conditional whose parentheses never close"}) \u2014 its keys are unread`
|
|
4135
|
+
});
|
|
4136
|
+
}
|
|
4137
|
+
function isTypeMember(file, lineNo, col, matched) {
|
|
4138
|
+
if (/\?\s*:/.test(matched)) return true;
|
|
4139
|
+
if (!/:/.test(matched)) return false;
|
|
4140
|
+
const enc = enclosingOpener(file, lineNo, col);
|
|
4141
|
+
if (!enc || enc.ch !== "{") return false;
|
|
4142
|
+
const ctx = braceContext(file, enc.line, enc.col);
|
|
4143
|
+
return ctx.kind === "type" || ctx.kind === "pattern";
|
|
3509
4144
|
}
|
|
3510
4145
|
function collectNamespacedKeys(tree) {
|
|
3511
4146
|
const acc = { keys: [], objects: [], arrayForms: [], unreadable: [] };
|
|
3512
4147
|
for (const site of codeSites(tree, META_OPEN_RE)) {
|
|
4148
|
+
if (isTypeMember(site.file, site.line.n, site.col, site.match[0])) continue;
|
|
3513
4149
|
readValue(tree, site.file, site.line.n, site.col + site.match[0].length, "_meta", acc);
|
|
3514
4150
|
}
|
|
3515
4151
|
for (const site of codeSites(tree, CAP_OPEN_RE)) {
|
|
@@ -3529,6 +4165,18 @@ function collectNamespacedKeys(tree) {
|
|
|
3529
4165
|
}
|
|
3530
4166
|
if (tail.trimStart().startsWith("{") || tail.trim() === "") {
|
|
3531
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
|
+
});
|
|
3532
4180
|
}
|
|
3533
4181
|
}
|
|
3534
4182
|
for (const site of codeSites(tree, META_BRACKET_RE)) {
|
|
@@ -3639,8 +4287,8 @@ function readSkillsSurface(tree) {
|
|
|
3639
4287
|
function skillsCacheProblems(tree) {
|
|
3640
4288
|
if (!readSkillsSurface(tree).declared) return null;
|
|
3641
4289
|
const sites = methodSites(tree, ["skills/list", "skills/get"]);
|
|
3642
|
-
const ttl =
|
|
3643
|
-
const scope =
|
|
4290
|
+
const ttl = fieldWrites(tree, ["ttlMs"]).writes;
|
|
4291
|
+
const scope = fieldWrites(tree, ["cacheScope"]).writes;
|
|
3644
4292
|
const problems = [];
|
|
3645
4293
|
let first = "";
|
|
3646
4294
|
for (const [method, anchors] of sites) {
|
|
@@ -6332,7 +6980,13 @@ var c10MechanismDeclared = {
|
|
|
6332
6980
|
|
|
6333
6981
|
// src/detectors/c11-pagination.ts
|
|
6334
6982
|
var PIN2 = STANDARD_PIN;
|
|
6335
|
-
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
|
+
}
|
|
6336
6990
|
function c11PositiveControls() {
|
|
6337
6991
|
const field = toolAnnotationFieldControls().pagination;
|
|
6338
6992
|
return { fieldMatcher: field };
|
|
@@ -6359,30 +7013,47 @@ var c11Pagination = {
|
|
|
6359
7013
|
verdict: `could not judge: ${reason}`
|
|
6360
7014
|
};
|
|
6361
7015
|
}
|
|
6362
|
-
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");
|
|
6363
7032
|
if (tools.length === 0) {
|
|
6364
7033
|
return {
|
|
6365
7034
|
id: this.id,
|
|
6366
7035
|
anchor: "-",
|
|
6367
7036
|
state: "absent",
|
|
6368
|
-
verdict: "no list
|
|
7037
|
+
verdict: "no list or search tool registrations found (declared verb, or name prefix without one); pagination declaration check n/a"
|
|
6369
7038
|
};
|
|
6370
7039
|
}
|
|
6371
7040
|
const opaque = opaqueAnnotationsAbstain(this.id, "C-11", tools);
|
|
6372
7041
|
if (opaque) return opaque;
|
|
6373
|
-
|
|
7042
|
+
const failing = tools.flatMap((t) => {
|
|
6374
7043
|
const missing = [];
|
|
6375
7044
|
if (!t.paginationCursorDeclared) missing.push("paginationCursor");
|
|
6376
7045
|
if (t.paginationDefault === void 0) missing.push("paginationDefault");
|
|
6377
7046
|
if (t.paginationMax === void 0) missing.push("paginationMax (finite)");
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
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
|
+
};
|
|
6386
7057
|
}
|
|
6387
7058
|
return {
|
|
6388
7059
|
id: this.id,
|
|
@@ -6408,13 +7079,15 @@ var c11Pagination = {
|
|
|
6408
7079
|
verdict: `could not judge: ${reason}`
|
|
6409
7080
|
};
|
|
6410
7081
|
}
|
|
6411
|
-
const paginable = runtime.tools.filter(
|
|
7082
|
+
const paginable = runtime.tools.filter(
|
|
7083
|
+
(t) => PAGINABLE_NAME_RE.test(t.name) || t.cursorArgument
|
|
7084
|
+
);
|
|
6412
7085
|
if (paginable.length === 0) {
|
|
6413
7086
|
return {
|
|
6414
7087
|
id: this.id,
|
|
6415
7088
|
anchor: `${runtime.root} (runtime tools/list)`,
|
|
6416
7089
|
state: "absent",
|
|
6417
|
-
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"
|
|
6418
7091
|
};
|
|
6419
7092
|
}
|
|
6420
7093
|
const anchor = `${runtime.root} (runtime invalid-cursor probes)`;
|
|
@@ -10249,7 +10922,7 @@ function absentBelowRevision(id, anchor, rule, fields, negotiated, where) {
|
|
|
10249
10922
|
}
|
|
10250
10923
|
|
|
10251
10924
|
// src/detectors/d3.ts
|
|
10252
|
-
var
|
|
10925
|
+
var RESULT_TYPE_FIELD = ["resultType"];
|
|
10253
10926
|
var KIT_RESULT_CALL_RE = /\b(buildToolsListResult|buildListResult|buildToolCallResult)\s*\(/;
|
|
10254
10927
|
var d3 = {
|
|
10255
10928
|
id: "D3 resultType",
|
|
@@ -10257,17 +10930,31 @@ var d3 = {
|
|
|
10257
10930
|
pin: STANDARD_PIN,
|
|
10258
10931
|
run(tree) {
|
|
10259
10932
|
const builders = findListReadBuilders(tree);
|
|
10260
|
-
const rt =
|
|
10933
|
+
const rt = fieldWrites(tree, RESULT_TYPE_FIELD);
|
|
10261
10934
|
const kit = countKeywordInCode(tree, KIT_RESULT_CALL_RE);
|
|
10262
|
-
if (rt.
|
|
10263
|
-
|
|
10935
|
+
if (rt.writes.length > 0) {
|
|
10936
|
+
return {
|
|
10937
|
+
id: this.id,
|
|
10938
|
+
anchor: rt.writes[0].anchor,
|
|
10939
|
+
state: "present",
|
|
10940
|
+
verdict: "resultType present"
|
|
10941
|
+
};
|
|
10942
|
+
}
|
|
10943
|
+
if (kit.count > 0) {
|
|
10264
10944
|
return {
|
|
10265
10945
|
id: this.id,
|
|
10266
|
-
anchor:
|
|
10946
|
+
anchor: kit.firstFile ? `${kit.firstFile.rel}:${kit.firstLine}` : "-",
|
|
10267
10947
|
state: "present",
|
|
10268
|
-
verdict:
|
|
10948
|
+
verdict: "resultType via kit result-builder call"
|
|
10269
10949
|
};
|
|
10270
10950
|
}
|
|
10951
|
+
if (rt.unread.length > 0) {
|
|
10952
|
+
return couldNotJudge(
|
|
10953
|
+
this.id,
|
|
10954
|
+
rt.unread[0].anchor,
|
|
10955
|
+
`${rt.unread.length} resultType site(s) could not be read \u2014 ${rt.unread[0].reason} (S-2)`
|
|
10956
|
+
);
|
|
10957
|
+
}
|
|
10271
10958
|
if (builders.length === 0) {
|
|
10272
10959
|
const sdk = sdkFirstAnchor(tree);
|
|
10273
10960
|
if (sdk) {
|
|
@@ -10382,7 +11069,7 @@ var d3 = {
|
|
|
10382
11069
|
};
|
|
10383
11070
|
|
|
10384
11071
|
// src/detectors/d4.ts
|
|
10385
|
-
var
|
|
11072
|
+
var CACHEABLE_FIELDS = ["ttlMs", "cacheScope"];
|
|
10386
11073
|
var d4 = {
|
|
10387
11074
|
id: "D4 CacheableResult",
|
|
10388
11075
|
rule: "S-3",
|
|
@@ -10398,15 +11085,22 @@ var d4 = {
|
|
|
10398
11085
|
};
|
|
10399
11086
|
}
|
|
10400
11087
|
const builders = findListReadBuilders(tree);
|
|
10401
|
-
const cache2 =
|
|
10402
|
-
if (cache2.
|
|
11088
|
+
const cache2 = fieldWrites(tree, CACHEABLE_FIELDS);
|
|
11089
|
+
if (cache2.writes.length > 0) {
|
|
10403
11090
|
return {
|
|
10404
11091
|
id: this.id,
|
|
10405
|
-
anchor: cache2.
|
|
11092
|
+
anchor: cache2.writes[0].anchor,
|
|
10406
11093
|
state: "present",
|
|
10407
11094
|
verdict: "CacheableResult present (ttlMs/cacheScope)"
|
|
10408
11095
|
};
|
|
10409
11096
|
}
|
|
11097
|
+
if (cache2.unread.length > 0) {
|
|
11098
|
+
return couldNotJudge(
|
|
11099
|
+
this.id,
|
|
11100
|
+
cache2.unread[0].anchor,
|
|
11101
|
+
`${cache2.unread.length} ttlMs/cacheScope site(s) could not be read \u2014 ${cache2.unread[0].reason} (S-3)`
|
|
11102
|
+
);
|
|
11103
|
+
}
|
|
10410
11104
|
if (builders.length === 0) {
|
|
10411
11105
|
const sdk = sdkFirstAnchor(tree);
|
|
10412
11106
|
if (sdk) {
|
|
@@ -10709,34 +11403,94 @@ function sdkV2Dependency(pkgJson) {
|
|
|
10709
11403
|
}
|
|
10710
11404
|
return { kind: "none" };
|
|
10711
11405
|
}
|
|
10712
|
-
var
|
|
11406
|
+
var HANDROLLED_FIELDS = ["resultType", "ttlMs", "cacheScope"];
|
|
11407
|
+
var RESULT_PAYLOAD_KEYS = [
|
|
11408
|
+
"resultType",
|
|
11409
|
+
"content",
|
|
11410
|
+
"structuredContent",
|
|
11411
|
+
"isError",
|
|
11412
|
+
"tools",
|
|
11413
|
+
"resources",
|
|
11414
|
+
"resourceTemplates",
|
|
11415
|
+
"prompts",
|
|
11416
|
+
"contents",
|
|
11417
|
+
"messages",
|
|
11418
|
+
"completion",
|
|
11419
|
+
"nextCursor"
|
|
11420
|
+
];
|
|
11421
|
+
var RESULT_ANCHOR_KEYS = ["content", "structuredContent", "resultType"];
|
|
11422
|
+
function baseIsResult(file, base, tree) {
|
|
11423
|
+
if (!base) return false;
|
|
11424
|
+
const esc4 = base.replace(/[$]/g, "\\$&");
|
|
11425
|
+
const keys = RESULT_PAYLOAD_KEYS.join("|");
|
|
11426
|
+
const assigned = new RegExp(
|
|
11427
|
+
`\\b${esc4}\\s*(?:\\.\\s*(?:${keys})|\\[\\s*["'](?:${keys})["']\\s*\\])\\s*=(?![=>])`
|
|
11428
|
+
);
|
|
11429
|
+
if (file.lines.some((l) => !l.comment && assigned.test(l.raw))) return true;
|
|
11430
|
+
const one = { ...tree, files: [file] };
|
|
11431
|
+
const bound = findConstBinding(one, base).found;
|
|
11432
|
+
if (!bound) return false;
|
|
11433
|
+
const m = objectMembers(bound.file, { line: bound.block.startLine, col: bound.col });
|
|
11434
|
+
return RESULT_PAYLOAD_KEYS.some((k) => m.keys.has(k));
|
|
11435
|
+
}
|
|
10713
11436
|
function handRolledBuilder(tree) {
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
|
|
10721
|
-
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
|
|
11437
|
+
const scan = fieldWrites(tree, HANDROLLED_FIELDS);
|
|
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
|
+
}
|
|
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
|
+
}
|
|
11459
|
+
let result = w.name === "resultType";
|
|
11460
|
+
if (!result && w.object) {
|
|
11461
|
+
const m = objectMembers(w.file, w.object);
|
|
11462
|
+
result = RESULT_PAYLOAD_KEYS.some((k) => m.keys.has(k));
|
|
11463
|
+
if (!result && m.spreads.length > 0) {
|
|
11464
|
+
unread.push({
|
|
11465
|
+
anchor: w.anchor,
|
|
11466
|
+
reason: `\`${w.name}\` is written at ${w.anchor} into an object whose other members come from \`...${m.spreads[0]}\`: whether that object is a protocol result is unread (D7)`
|
|
11467
|
+
});
|
|
11468
|
+
continue;
|
|
10730
11469
|
}
|
|
11470
|
+
} else if (!result) {
|
|
11471
|
+
result = baseIsResult(w.file, w.base, tree);
|
|
11472
|
+
}
|
|
11473
|
+
if (result) {
|
|
11474
|
+
return { hand: { file: w.file.rel, line: w.line, field: w.name, form: w.form }, unread };
|
|
10731
11475
|
}
|
|
10732
11476
|
}
|
|
10733
|
-
return null;
|
|
11477
|
+
return { hand: null, unread };
|
|
11478
|
+
}
|
|
11479
|
+
function controlTree2(text) {
|
|
11480
|
+
const file = {
|
|
11481
|
+
path: "<d7-control>.ts",
|
|
11482
|
+
rel: "<d7-control>",
|
|
11483
|
+
lines: text.split("\n").map((raw, i) => ({ n: i + 1, raw, comment: false }))
|
|
11484
|
+
};
|
|
11485
|
+
return { root: "<d7-control>", files: [file], packageJson: null, skippedDirs: [] };
|
|
10734
11486
|
}
|
|
10735
11487
|
var d7Inner = {
|
|
10736
11488
|
id: "D7 protocol-kit",
|
|
10737
11489
|
run(tree) {
|
|
10738
11490
|
const v2 = (r) => sdkV2Dependency({ dependencies: { [SDK_V2_PKG]: r } }).kind;
|
|
10739
|
-
if (v2("^2.3.1") !== "v2" || v2(">=2 <3") !== "v2" || v2("^1.12.0") !== "below-v2" || v2("latest") !== "unreadable" ||
|
|
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) {
|
|
10740
11494
|
throw new Error(
|
|
10741
11495
|
"D7 control FAILED: SDK v2 range reader / hand-rolled matcher broken \u2014 verdict untrustworthy"
|
|
10742
11496
|
);
|
|
@@ -10782,13 +11536,23 @@ var d7Inner = {
|
|
|
10782
11536
|
};
|
|
10783
11537
|
}
|
|
10784
11538
|
if (sdk.kind === "v2") {
|
|
10785
|
-
const hand = handRolledBuilder(tree);
|
|
11539
|
+
const { hand, unread } = handRolledBuilder(tree);
|
|
10786
11540
|
if (hand) {
|
|
10787
11541
|
return {
|
|
10788
11542
|
id: this.id,
|
|
10789
11543
|
anchor: `${hand.file}:${hand.line}`,
|
|
10790
11544
|
state: "non-conforming",
|
|
10791
|
-
verdict: `hand-rolled result builder (\`${hand.field}
|
|
11545
|
+
verdict: `hand-rolled result builder (\`${hand.field}\` written by hand as a ${hand.form} into a result object at ${hand.file}:${hand.line}) and @vantageos/mcp-protocol-kit not a dependency -> let the SDK emit resultType/ttlMs/cacheScope (cacheHints) or adopt the kit (D7)`
|
|
11546
|
+
};
|
|
11547
|
+
}
|
|
11548
|
+
if (unread.length > 0) {
|
|
11549
|
+
const reason = `${unread.length} protocol-field write(s) could not be judged \u2014 ${unread[0].reason}`;
|
|
11550
|
+
return {
|
|
11551
|
+
id: this.id,
|
|
11552
|
+
anchor: unread[0].anchor,
|
|
11553
|
+
state: "could-not-judge",
|
|
11554
|
+
reason,
|
|
11555
|
+
verdict: `could not judge: ${reason}`
|
|
10792
11556
|
};
|
|
10793
11557
|
}
|
|
10794
11558
|
return {
|
|
@@ -13846,7 +14610,7 @@ var PII_RE = /\b(?:email|e[_-]?mail|ip[_-]?address|full[_-]?name|phone[_-]?numbe
|
|
|
13846
14610
|
var INTERNAL_RE = /\b(?:hostname|host[_-]?name|absolute[_-]?path|internal[_-]?path|infra[_-]?version|server[_-]?version|__dirname|__filename)\b/;
|
|
13847
14611
|
var STACK_RE = /\b(?:error|err|e|ex|exception)\.stack\b/;
|
|
13848
14612
|
var CLIENT_SINK_RE = /\b(?:content|text|message|body)\s*:|(?:\breturn\b|\bthrow\b|JSON\.stringify)/;
|
|
13849
|
-
var
|
|
14613
|
+
var SPREAD_RE = /\.\.\.[A-Za-z_$]/;
|
|
13850
14614
|
var SECRET_POSITIVE = "apiKey";
|
|
13851
14615
|
var SECRET_NEGATIVE = "customerId";
|
|
13852
14616
|
var PII_POSITIVE = "email";
|
|
@@ -14068,7 +14832,7 @@ var dServer6 = {
|
|
|
14068
14832
|
});
|
|
14069
14833
|
}
|
|
14070
14834
|
for (const call of calls) {
|
|
14071
|
-
if (
|
|
14835
|
+
if (SPREAD_RE.test(call.argText)) {
|
|
14072
14836
|
unreadable.push({
|
|
14073
14837
|
anchor: call.anchor,
|
|
14074
14838
|
reason: `cannot inspect the spread argument of the log call at ${call.anchor} \u2014 a spread hides arbitrary content, secret/PII presence unverifiable (C-6)`
|
|
@@ -17726,14 +18490,14 @@ var s22OriginValidation = {
|
|
|
17726
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)`
|
|
17727
18491
|
);
|
|
17728
18492
|
}
|
|
17729
|
-
if (origins.
|
|
18493
|
+
if (origins.unresolved.length > 0) {
|
|
17730
18494
|
return couldNotJudge(
|
|
17731
18495
|
this.id,
|
|
17732
18496
|
origins.unresolved[0].anchor,
|
|
17733
|
-
|
|
18497
|
+
`${unresolvedText(origins.unresolved)}: whether it names concrete origins is unread (S-22)`
|
|
17734
18498
|
);
|
|
17735
18499
|
}
|
|
17736
|
-
if (origins.
|
|
18500
|
+
if (origins.ok.length > 0 && flag.length === 0) {
|
|
17737
18501
|
return couldNotJudge(
|
|
17738
18502
|
this.id,
|
|
17739
18503
|
origins.first,
|
|
@@ -17754,31 +18518,141 @@ var s22OriginValidation = {
|
|
|
17754
18518
|
const rows = uncommentedLines(file);
|
|
17755
18519
|
rows.forEach((row, i) => {
|
|
17756
18520
|
if (!ORIGIN_READ_RE.test(row)) return;
|
|
17757
|
-
const
|
|
18521
|
+
const readCol = ORIGIN_READ_RE.exec(row)?.index ?? 0;
|
|
18522
|
+
const window = rows.slice(i, refusalWindowEnd(file, rows, i, readCol)).join("\n");
|
|
17758
18523
|
(REFUSE_RE.test(window) ? refused : ignored).push(`${file.rel}:${i + 1}`);
|
|
17759
18524
|
});
|
|
17760
18525
|
}
|
|
18526
|
+
const declaredNote = origins.declared.length > 0 ? `; ${origins.declared.map((d) => d.text).join("; ")}` : "";
|
|
17761
18527
|
if (refused.length > 0) {
|
|
17762
18528
|
return presentResult(
|
|
17763
18529
|
this.id,
|
|
17764
18530
|
refused[0],
|
|
17765
|
-
`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)`
|
|
17766
18547
|
);
|
|
17767
18548
|
}
|
|
17768
18549
|
if (ignored.length > 0) {
|
|
17769
18550
|
return redResult(
|
|
17770
18551
|
this.id,
|
|
17771
18552
|
ignored[0],
|
|
17772
|
-
`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)`
|
|
17773
18554
|
);
|
|
17774
18555
|
}
|
|
17775
18556
|
return redResult(
|
|
17776
18557
|
this.id,
|
|
17777
18558
|
transport[0].anchor,
|
|
17778
|
-
`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)`
|
|
17779
18560
|
);
|
|
17780
18561
|
}
|
|
17781
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
|
+
}
|
|
17782
18656
|
function resolveConstLiteral(tree, name, file) {
|
|
17783
18657
|
const re = new RegExp(
|
|
17784
18658
|
`\\b(?:const|let|var)\\s+${name.replace(/[$]/g, "\\$&")}\\b[^=\\n]*=\\s*`,
|
|
@@ -17799,14 +18673,55 @@ function resolveConstLiteral(tree, name, file) {
|
|
|
17799
18673
|
return null;
|
|
17800
18674
|
}
|
|
17801
18675
|
function classifyAllowedOrigins(tree) {
|
|
17802
|
-
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
|
+
};
|
|
17803
18693
|
for (const site of codeSites(tree, ALLOWED_ORIGINS_RE)) {
|
|
17804
18694
|
if (!isProductSource(site.file.rel)) continue;
|
|
17805
18695
|
const after = site.col + site.match[0].length;
|
|
17806
18696
|
const rest = site.line.raw.slice(after);
|
|
17807
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
|
+
}
|
|
17808
18705
|
out.sites++;
|
|
17809
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
|
+
}
|
|
17810
18725
|
let value;
|
|
17811
18726
|
if (rest.startsWith("[")) {
|
|
17812
18727
|
const b = balancedBlock(site.file, site.line.n, after, "[", "]");
|
|
@@ -18211,14 +19126,73 @@ var s26ListChangedParity = {
|
|
|
18211
19126
|
|
|
18212
19127
|
// src/detectors/s27-elicitation-floor.ts
|
|
18213
19128
|
var ELICIT_RE = /\belicitInput\s*\(|["'`]elicitation\/create["'`]|\brequestedSchema\b/;
|
|
18214
|
-
var
|
|
19129
|
+
var MRTR_VALUE = "input_required";
|
|
18215
19130
|
var FALLBACK_RE = /\belicitInput\s*\(|["'`]elicitation\/create["'`]/;
|
|
18216
19131
|
var DECL_RE2 = /\b(?:midCallInput|elicitation|inputRequired)AtFloor["']?\s*:\s*(?:false|["'](?:unsupported|none)["'])/i;
|
|
18217
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
|
+
}
|
|
18218
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" });'));
|
|
18219
19193
|
return {
|
|
18220
|
-
sees: SENSITIVE_KEY_RE.test("apiKey") && SENSITIVE_KEY_RE.test("card_number") && SENSITIVE_KEY_RE.test("medicalHistory") &&
|
|
18221
|
-
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
|
|
18222
19196
|
};
|
|
18223
19197
|
}
|
|
18224
19198
|
var s27ElicitationFloor = {
|
|
@@ -18238,6 +19212,10 @@ var s27ElicitationFloor = {
|
|
|
18238
19212
|
let declared = false;
|
|
18239
19213
|
let first = "";
|
|
18240
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;
|
|
18241
19219
|
for (const file of tree.files) {
|
|
18242
19220
|
if (!isProductSource(file.rel)) continue;
|
|
18243
19221
|
const rows = uncommentedLines(file);
|
|
@@ -18249,10 +19227,6 @@ var s27ElicitationFloor = {
|
|
|
18249
19227
|
elicitation++;
|
|
18250
19228
|
first ||= `${file.rel}:${i + 1}`;
|
|
18251
19229
|
}
|
|
18252
|
-
if (MRTR_RE.test(row)) {
|
|
18253
|
-
mrtr++;
|
|
18254
|
-
first ||= `${file.rel}:${i + 1}`;
|
|
18255
|
-
}
|
|
18256
19230
|
const at = row.indexOf("requestedSchema");
|
|
18257
19231
|
if (at >= 0) {
|
|
18258
19232
|
const op = nextOpener(file, i + 1, at, "{", 2);
|
|
@@ -18269,7 +19243,8 @@ var s27ElicitationFloor = {
|
|
|
18269
19243
|
}
|
|
18270
19244
|
});
|
|
18271
19245
|
}
|
|
18272
|
-
|
|
19246
|
+
first = mrtrScan.rounds[0] ?? first;
|
|
19247
|
+
if (elicitation + mrtr === 0 && unread.length === 0) {
|
|
18273
19248
|
return absentResult(
|
|
18274
19249
|
this.id,
|
|
18275
19250
|
"-",
|
|
@@ -18288,6 +19263,13 @@ var s27ElicitationFloor = {
|
|
|
18288
19263
|
`${reds.join("; ")} (S-27, positive-control OK)`
|
|
18289
19264
|
);
|
|
18290
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
|
+
}
|
|
18291
19273
|
return couldNotJudge(
|
|
18292
19274
|
this.id,
|
|
18293
19275
|
first,
|