@node9/policy-engine 2.46.1 → 2.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,6 +1,3 @@
1
- // src/shell/derived-writes.ts
2
- import mvdanSh3 from "mvdan-sh";
3
-
4
1
  // src/files/protected-access.ts
5
2
  import picomatch from "picomatch";
6
3
 
@@ -3296,7 +3293,121 @@ function resolveCheckMap(settings) {
3296
3293
  import pm from "picomatch";
3297
3294
 
3298
3295
  // src/shell/index.ts
3296
+ import mvdanSh2 from "mvdan-sh";
3297
+
3298
+ // src/shell/plain-tree.ts
3299
3299
  import mvdanSh from "mvdan-sh";
3300
+ var { syntax } = mvdanSh;
3301
+ var KINDS = {
3302
+ File: { nodes: ["Stmts"] },
3303
+ Stmt: { nodes: ["Cmd", "Redirs"], scalars: ["Negated", "Background", "Coprocess"] },
3304
+ CallExpr: { nodes: ["Assigns", "Args"] },
3305
+ Assign: { nodes: ["Name", "Value", "Index", "Array"], scalars: ["Append", "Naked"] },
3306
+ Word: { nodes: ["Parts"] },
3307
+ Lit: { scalars: ["Value"] },
3308
+ SglQuoted: { scalars: ["Value", "Dollar"] },
3309
+ DblQuoted: { nodes: ["Parts"], scalars: ["Dollar"] },
3310
+ ParamExp: {
3311
+ nodes: ["Param", "Index", "Slice", "Repl", "Exp"],
3312
+ scalars: ["Short", "Excl", "Length", "Width"]
3313
+ },
3314
+ CmdSubst: { nodes: ["Stmts"], scalars: ["Backquotes", "TempFile", "ReplyVar"] },
3315
+ ArithmExp: { nodes: ["X"], scalars: ["Bracket", "Unsigned"] },
3316
+ ArithmCmd: { nodes: ["X"], scalars: ["Unsigned"] },
3317
+ ProcSubst: { nodes: ["Stmts"], scalars: ["Op"] },
3318
+ ExtGlob: { nodes: ["Pattern"], scalars: ["Op"] },
3319
+ BraceExp: { nodes: ["Elems"], scalars: ["Sequence"] },
3320
+ // only with SplitBraces, unused here
3321
+ BinaryCmd: { nodes: ["X", "Y"], scalars: ["Op"] },
3322
+ BinaryArithm: { nodes: ["X", "Y"], scalars: ["Op"] },
3323
+ UnaryArithm: { nodes: ["X"], scalars: ["Op", "Post"] },
3324
+ ParenArithm: { nodes: ["X"] },
3325
+ BinaryTest: { nodes: ["X", "Y"], scalars: ["Op"] },
3326
+ UnaryTest: { nodes: ["X"], scalars: ["Op"] },
3327
+ ParenTest: { nodes: ["X"] },
3328
+ Redirect: { nodes: ["N", "Word", "Hdoc"], scalars: ["Op"] },
3329
+ Block: { nodes: ["Stmts"] },
3330
+ Subshell: { nodes: ["Stmts"] },
3331
+ IfClause: { nodes: ["Cond", "Then", "Else"] },
3332
+ WhileClause: { nodes: ["Cond", "Do"], scalars: ["Until"] },
3333
+ ForClause: { nodes: ["Loop", "Do"], scalars: ["Select"] },
3334
+ WordIter: { nodes: ["Name", "Items"] },
3335
+ CStyleLoop: { nodes: ["Init", "Cond", "Post"] },
3336
+ CaseClause: { nodes: ["Word", "Items"] },
3337
+ CaseItem: { nodes: ["Patterns", "Stmts"], scalars: ["Op"] },
3338
+ FuncDecl: { nodes: ["Name", "Body"], scalars: ["RsrvWord"] },
3339
+ DeclClause: { nodes: ["Variant", "Args"], notWalked: ["Variant"] },
3340
+ LetClause: { nodes: ["Exprs"] },
3341
+ TimeClause: { nodes: ["Stmt"], scalars: ["PosixFormat"] },
3342
+ CoprocClause: { nodes: ["Name", "Stmt"] },
3343
+ TestClause: { nodes: ["X"] },
3344
+ TestDecl: { nodes: ["Description", "Body"] },
3345
+ ArrayExpr: { nodes: ["Elems"] },
3346
+ ArrayElem: { nodes: ["Index", "Value"] },
3347
+ Comment: { scalars: ["Text"] }
3348
+ };
3349
+ var STRUCTS = {
3350
+ "ParamExp.Slice": { nodes: ["Offset", "Length"], notWalked: ["Offset", "Length"] },
3351
+ "ParamExp.Repl": { nodes: ["Orig", "With"], scalars: ["All"] },
3352
+ "ParamExp.Exp": { nodes: ["Word"], scalars: ["Op"] }
3353
+ };
3354
+ var unknownKinds = /* @__PURE__ */ new Set();
3355
+ function isGoNode(v) {
3356
+ return v !== null && typeof v === "object" && typeof v.Pos === "function";
3357
+ }
3358
+ function toPlainTree(goNode) {
3359
+ const kind = syntax.NodeType(goNode);
3360
+ const out = { kind, pos: goNode.Pos().Offset(), end: goNode.End().Offset() };
3361
+ const spec = KINDS[kind];
3362
+ if (!spec) {
3363
+ unknownKinds.add(kind);
3364
+ return out;
3365
+ }
3366
+ convertFields(goNode, spec, out, kind);
3367
+ return out;
3368
+ }
3369
+ function convertFields(goNode, spec, out, kind) {
3370
+ for (const f of spec.scalars ?? []) out[f] = goNode[f];
3371
+ for (const f of spec.nodes ?? []) {
3372
+ const v = goNode[f];
3373
+ if (v === void 0 || v === null) {
3374
+ out[f] = null;
3375
+ } else if (Array.isArray(v)) {
3376
+ out[f] = v.map((c) => isGoNode(c) ? toPlainTree(c) : c);
3377
+ } else if (isGoNode(v)) {
3378
+ out[f] = toPlainTree(v);
3379
+ } else if (typeof v === "object" && STRUCTS[`${kind}.${f}`]) {
3380
+ const sub = { struct: `${kind}.${f}` };
3381
+ convertFields(v, STRUCTS[`${kind}.${f}`], sub, `${kind}.${f}`);
3382
+ out[f] = sub;
3383
+ } else {
3384
+ out[f] = v;
3385
+ }
3386
+ }
3387
+ }
3388
+ function childrenOf(n) {
3389
+ const spec = n.kind ? KINDS[n.kind] : STRUCTS[n.struct];
3390
+ if (!spec?.nodes) return [];
3391
+ const out = [];
3392
+ for (const f of spec.nodes) {
3393
+ if (spec.notWalked?.includes(f)) continue;
3394
+ const v = n[f];
3395
+ if (!v) continue;
3396
+ if (Array.isArray(v)) {
3397
+ for (const c of v) if (c) out.push(c);
3398
+ } else if (v.kind) {
3399
+ out.push(v);
3400
+ } else if (v.struct) {
3401
+ out.push(...childrenOf(v));
3402
+ }
3403
+ }
3404
+ return out;
3405
+ }
3406
+ function walk(root, fn) {
3407
+ if (!root) return;
3408
+ if (!fn(root)) return;
3409
+ for (const c of childrenOf(root)) walk(c, fn);
3410
+ }
3300
3411
 
3301
3412
  // src/dlp/normalize.ts
3302
3413
  var INVISIBLE_RE = /[­͏؜᠎​-‏‪-‮⁠-⁤-︀-️]|[\u{E0000}-\u{E007F}]/gu;
@@ -3743,8 +3854,8 @@ function judgeInlineCode(language, code, isProtected) {
3743
3854
  }
3744
3855
 
3745
3856
  // src/shell/index.ts
3746
- var { syntax } = mvdanSh;
3747
- var sharedParser = syntax.NewParser();
3857
+ var { syntax: syntax2 } = mvdanSh2;
3858
+ var sharedParser = syntax2.NewParser();
3748
3859
  var MESSAGE_FLAGS = /* @__PURE__ */ new Set([
3749
3860
  "-m",
3750
3861
  "--message",
@@ -3777,7 +3888,7 @@ var DOWNLOAD_CMDS = /* @__PURE__ */ new Set([
3777
3888
  ]);
3778
3889
  function isCatHeredocOrLit(part) {
3779
3890
  if (!part) return false;
3780
- const t = syntax.NodeType(part);
3891
+ const t = part.kind;
3781
3892
  if (t === "Lit") return true;
3782
3893
  if (t !== "CmdSubst") return false;
3783
3894
  const stmts = part.Stmts || [];
@@ -3787,15 +3898,15 @@ function isCatHeredocOrLit(part) {
3787
3898
  const hasHeredoc = redirs.some((r) => r && r.Hdoc);
3788
3899
  if (!hasHeredoc) return false;
3789
3900
  const cmd = stmt.Cmd;
3790
- if (!cmd || syntax.NodeType(cmd) !== "CallExpr") return false;
3901
+ if (!cmd || cmd.kind !== "CallExpr") return false;
3791
3902
  const firstArg = cmd.Args?.[0]?.Parts || [];
3792
- if (firstArg.length !== 1 || syntax.NodeType(firstArg[0]) !== "Lit") return false;
3903
+ if (firstArg.length !== 1 || firstArg[0].kind !== "Lit") return false;
3793
3904
  return (firstArg[0].Value || "").toLowerCase() === "cat";
3794
3905
  }
3795
3906
  var NORMALIZE_CACHE_MAX = 5e3;
3796
3907
  var normalizeCache = /* @__PURE__ */ new Map();
3797
3908
  var codeBodiesCache = /* @__PURE__ */ new Map();
3798
- var AST_CACHE_MAX = 5e3;
3909
+ var AST_CACHE_MAX = 256;
3799
3910
  var astCache = /* @__PURE__ */ new Map();
3800
3911
  var PARSE_FAIL = /* @__PURE__ */ Symbol("parse-fail");
3801
3912
  function parseShared(command) {
@@ -3807,7 +3918,7 @@ function parseShared(command) {
3807
3918
  }
3808
3919
  let parsed;
3809
3920
  try {
3810
- parsed = sharedParser.Parse(command, "cmd");
3921
+ parsed = toPlainTree(sharedParser.Parse(command, "cmd"));
3811
3922
  } catch {
3812
3923
  parsed = PARSE_FAIL;
3813
3924
  }
@@ -3872,10 +3983,10 @@ function fileAccessViewImpl(command) {
3872
3983
  const at = (byteOffset) => toCharIndex === null ? byteOffset : toCharIndex(byteOffset);
3873
3984
  const edits = [];
3874
3985
  try {
3875
- syntax.Walk(f, (node) => {
3986
+ walk(f, (node) => {
3876
3987
  if (!node) return false;
3877
3988
  const n = node;
3878
- if (syntax.NodeType(n) !== "CallExpr") return true;
3989
+ if (n.kind !== "CallExpr") return true;
3879
3990
  const args = n.Args || [];
3880
3991
  const words = args.map((a) => resolveWordLiteral(a));
3881
3992
  const head = unwrapCommandHead(words);
@@ -3887,8 +3998,8 @@ function fileAccessViewImpl(command) {
3887
3998
  if (!PROGRAM_DIR.test(word)) continue;
3888
3999
  const name = word.split(/[\\/]/).pop() ?? "";
3889
4000
  if (!name) continue;
3890
- const s = at(args[i].Pos().Offset());
3891
- const e = at(args[i].End().Offset());
4001
+ const s = at(args[i].pos);
4002
+ const e = at(args[i].end);
3892
4003
  if (s < 0 || e < 0) continue;
3893
4004
  edits.push([s, e, name]);
3894
4005
  }
@@ -3917,10 +4028,10 @@ function literalPayloadsOf(command, depth) {
3917
4028
  if (f === PARSE_FAIL) return [];
3918
4029
  const out = [];
3919
4030
  try {
3920
- syntax.Walk(f, (node) => {
4031
+ walk(f, (node) => {
3921
4032
  if (!node || out.length >= MAX_READING_PAYLOADS) return false;
3922
4033
  const n = node;
3923
- if (syntax.NodeType(n) !== "CallExpr") return true;
4034
+ if (n.kind !== "CallExpr") return true;
3924
4035
  const words = (n.Args || []).map((a) => resolveWordLiteral(a));
3925
4036
  if (words.length === 0) return true;
3926
4037
  const payload = literalShellPayload(words, baseWord(words[0]));
@@ -3940,23 +4051,23 @@ function foldCommandWords(reading) {
3940
4051
  const at = (byteOffset) => toCharIndex === null ? byteOffset : toCharIndex(byteOffset);
3941
4052
  const edits = [];
3942
4053
  try {
3943
- syntax.Walk(f, (node) => {
4054
+ walk(f, (node) => {
3944
4055
  if (!node) return false;
3945
4056
  const n = node;
3946
- if (syntax.NodeType(n) !== "CallExpr") return true;
4057
+ if (n.kind !== "CallExpr") return true;
3947
4058
  const args = n.Args || [];
3948
4059
  const words = args.map((a) => resolveWordLiteral(a));
3949
4060
  const folded = words.map((w) => w === null ? null : foldHomoglyphs(w));
3950
4061
  const head = unwrapCommandHead(folded);
3951
4062
  for (let i = 0; i <= head && i < args.length; i++) {
3952
4063
  const parts = args[i].Parts || [];
3953
- if (parts.length !== 1 || syntax.NodeType(parts[0]) !== "Lit") continue;
4064
+ if (parts.length !== 1 || parts[0].kind !== "Lit") continue;
3954
4065
  const value = parts[0].Value ?? "";
3955
4066
  const word = folded[i];
3956
4067
  if (word === null || word === value || !/[^\x00-\x7f]/.test(value)) continue;
3957
4068
  if (!/^[A-Za-z0-9._/-]+$/.test(word)) continue;
3958
- const s = at(args[i].Pos().Offset());
3959
- const e = at(args[i].End().Offset());
4069
+ const s = at(args[i].pos);
4070
+ const e = at(args[i].end);
3960
4071
  if (s < 0 || e < 0) continue;
3961
4072
  edits.push([s, e, word]);
3962
4073
  }
@@ -4024,10 +4135,10 @@ function interpreterHeredocSpans(f, at) {
4024
4135
  const stmts = f?.Stmts || [];
4025
4136
  const candidates = [];
4026
4137
  let unsafe = false;
4027
- syntax.Walk(f, (node) => {
4138
+ walk(f, (node) => {
4028
4139
  if (!node || unsafe) return false;
4029
4140
  const n = node;
4030
- const t = syntax.NodeType(n);
4141
+ const t = n.kind;
4031
4142
  if (t === "FuncDecl") {
4032
4143
  unsafe = true;
4033
4144
  return false;
@@ -4047,7 +4158,7 @@ function interpreterHeredocSpans(f, at) {
4047
4158
  });
4048
4159
  if (unsafe) return [];
4049
4160
  for (const st of stmts) {
4050
- if (!st?.Cmd || syntax.NodeType(st.Cmd) !== "CallExpr") continue;
4161
+ if (!st?.Cmd || st.Cmd.kind !== "CallExpr") continue;
4051
4162
  const words = (st.Cmd.Args || []).map((a) => resolveWordLiteral(a));
4052
4163
  const name = (words[0] ?? "").toLowerCase();
4053
4164
  if (!STDIN_CODE_INTERPRETERS.test(name)) continue;
@@ -4062,8 +4173,8 @@ function interpreterHeredocSpans(f, at) {
4062
4173
  if (stdin.length !== 1 || others > 0) continue;
4063
4174
  const r = stdin[0];
4064
4175
  if (heredocText(r.Hdoc) === null) continue;
4065
- const hs = at(r.Hdoc.Pos().Offset());
4066
- const he = at(r.Hdoc.End().Offset());
4176
+ const hs = at(r.Hdoc.pos);
4177
+ const he = at(r.Hdoc.end);
4067
4178
  if (hs < 0 || he < 0 || he <= hs) continue;
4068
4179
  spans.push([hs, he]);
4069
4180
  }
@@ -4083,24 +4194,24 @@ function normalizeCommandForPolicyImpl(command, codeBodies) {
4083
4194
  strips.push([hs, he]);
4084
4195
  msgSpans.add(`${hs}:${he}`);
4085
4196
  }
4086
- syntax.Walk(f, (node) => {
4197
+ walk(f, (node) => {
4087
4198
  if (!node) return false;
4088
4199
  const n = node;
4089
- if (syntax.NodeType(n) !== "CallExpr") return true;
4200
+ if (n.kind !== "CallExpr") return true;
4090
4201
  const args = n.Args || [];
4091
4202
  for (let i = 0; i < args.length - 1; i++) {
4092
4203
  const argParts = args[i].Parts || [];
4093
- if (argParts.length !== 1 || syntax.NodeType(argParts[0]) !== "Lit") continue;
4204
+ if (argParts.length !== 1 || argParts[0].kind !== "Lit") continue;
4094
4205
  const flagVal = argParts[0].Value || "";
4095
4206
  if (!MESSAGE_FLAGS.has(flagVal.toLowerCase())) continue;
4096
4207
  const next = args[i + 1];
4097
4208
  const nextParts = next.Parts || [];
4098
4209
  if (nextParts.length !== 1) continue;
4099
4210
  const quotedNode = nextParts[0];
4100
- const nt = syntax.NodeType(quotedNode);
4211
+ const nt = quotedNode.kind;
4101
4212
  const markStrip = () => {
4102
- const s = at(next.Pos().Offset());
4103
- const e = at(next.End().Offset());
4213
+ const s = at(next.pos);
4214
+ const e = at(next.end);
4104
4215
  if (s < 0 || e < 0) return;
4105
4216
  strips.push([s, e]);
4106
4217
  msgSpans.add(`${s}:${e}`);
@@ -4109,7 +4220,7 @@ function normalizeCommandForPolicyImpl(command, codeBodies) {
4109
4220
  markStrip();
4110
4221
  } else if (nt === "DblQuoted") {
4111
4222
  const innerParts = quotedNode.Parts || [];
4112
- const allLit = innerParts.length === 0 || innerParts.every((p) => syntax.NodeType(p) === "Lit");
4223
+ const allLit = innerParts.length === 0 || innerParts.every((p) => p.kind === "Lit");
4113
4224
  if (allLit) {
4114
4225
  markStrip();
4115
4226
  } else if (innerParts.every((p) => isCatHeredocOrLit(p))) {
@@ -4118,8 +4229,8 @@ function normalizeCommandForPolicyImpl(command, codeBodies) {
4118
4229
  }
4119
4230
  }
4120
4231
  for (const arg of args) {
4121
- const s = at(arg.Pos().Offset());
4122
- const e = at(arg.End().Offset());
4232
+ const s = at(arg.pos);
4233
+ const e = at(arg.end);
4123
4234
  if (s < 0 || e < 0) continue;
4124
4235
  if (msgSpans.has(`${s}:${e}`)) continue;
4125
4236
  const resolved = resolveWordLiteral(arg);
@@ -4159,10 +4270,10 @@ function scanArgsForDynamicExec(args, startIdx) {
4159
4270
  let hasParamExp = false;
4160
4271
  let hasCurl = false;
4161
4272
  for (let i = startIdx; i < args.length; i++) {
4162
- syntax.Walk(args[i], (inner) => {
4273
+ walk(args[i], (inner) => {
4163
4274
  if (!inner) return false;
4164
4275
  const inn = inner;
4165
- const it = syntax.NodeType(inn);
4276
+ const it = inn.kind;
4166
4277
  if (it === "CmdSubst") hasCmdSubst = true;
4167
4278
  if (it === "ParamExp") hasParamExp = true;
4168
4279
  if (it === "Lit" && DOWNLOAD_CMDS.has(inn.Value?.toLowerCase())) hasCurl = true;
@@ -4175,15 +4286,16 @@ function scanArgsForDynamicExec(args, startIdx) {
4175
4286
  }
4176
4287
  function detectDangerousShellExec(command) {
4177
4288
  try {
4178
- const f = sharedParser.Parse(command, "cmd");
4289
+ const f = parseShared(command);
4290
+ if (f === PARSE_FAIL) return null;
4179
4291
  let result = null;
4180
4292
  const assigned = assignedNames(f);
4181
- syntax.Walk(f, (node) => {
4293
+ walk(f, (node) => {
4182
4294
  if (!node || result === "block") return false;
4183
4295
  const n = node;
4184
- if (syntax.NodeType(n) === "BinaryCmd" && n.Y && !listOps().has(n.Op)) {
4296
+ if (n.kind === "BinaryCmd" && n.Y && !listOps().has(n.Op)) {
4185
4297
  const call = n.Y.Cmd;
4186
- if (call && syntax.NodeType(call) === "CallExpr") {
4298
+ if (call && call.kind === "CallExpr") {
4187
4299
  const words = (call.Args || []).map((a) => resolveWordLiteral(a));
4188
4300
  const head2 = unwrapCommandHead(words);
4189
4301
  const name = (words[head2] ?? "").split("/").pop() ?? "";
@@ -4196,7 +4308,7 @@ function detectDangerousShellExec(command) {
4196
4308
  result = "review";
4197
4309
  }
4198
4310
  }
4199
- if (syntax.NodeType(n) !== "CallExpr") return true;
4311
+ if (n.kind !== "CallExpr") return true;
4200
4312
  const args = n.Args || [];
4201
4313
  if (args.length === 0) return true;
4202
4314
  const headWords = args.map(
@@ -4207,7 +4319,7 @@ function detectDangerousShellExec(command) {
4207
4319
  if (!lookup && (opaqueExecutable(args[0], assigned) || opaqueExecutable(args[head], assigned)))
4208
4320
  result = "review";
4209
4321
  const firstParts = args[0].Parts || [];
4210
- if (firstParts.length !== 1 || syntax.NodeType(firstParts[0]) !== "Lit") return true;
4322
+ if (firstParts.length !== 1 || firstParts[0].kind !== "Lit") return true;
4211
4323
  const cmdName = firstParts[0].Value?.toLowerCase() ?? "";
4212
4324
  if (cmdName === "eval") {
4213
4325
  const v = scanArgsForDynamicExec(args, 1);
@@ -4215,7 +4327,7 @@ function detectDangerousShellExec(command) {
4215
4327
  } else if (SHELL_INTERPRETERS.has(cmdName)) {
4216
4328
  for (let i = 1; i < args.length - 1; i++) {
4217
4329
  const flagParts = args[i].Parts || [];
4218
- if (flagParts.length !== 1 || syntax.NodeType(flagParts[0]) !== "Lit" || flagParts[0].Value !== "-c")
4330
+ if (flagParts.length !== 1 || flagParts[0].kind !== "Lit" || flagParts[0].Value !== "-c")
4219
4331
  continue;
4220
4332
  const v = scanArgsForDynamicExec(args, i + 1);
4221
4333
  if (v === "block" || v === "review" && result === null) result = v;
@@ -4240,8 +4352,7 @@ function isDefaultExpansion(part) {
4240
4352
  }
4241
4353
  function lookupSubstitution(part) {
4242
4354
  const stmts = part.Stmts ?? [];
4243
- if (stmts.length !== 1 || !stmts[0].Cmd || syntax.NodeType(stmts[0].Cmd) !== "CallExpr")
4244
- return null;
4355
+ if (stmts.length !== 1 || !stmts[0].Cmd || stmts[0].Cmd.kind !== "CallExpr") return null;
4245
4356
  const words = (stmts[0].Cmd.Args ?? []).map((a) => resolveWordLiteral(a));
4246
4357
  if (words.some((w) => w === null)) return null;
4247
4358
  if (words.length === 2 && words[0] === "which") return words[1];
@@ -4263,9 +4374,9 @@ var VARIABLE_READERS = /* @__PURE__ */ new Set([
4263
4374
  ]);
4264
4375
  function assignedNames(f) {
4265
4376
  const names = /* @__PURE__ */ new Set();
4266
- syntax.Walk(f, (node) => {
4377
+ walk(f, (node) => {
4267
4378
  if (!node) return false;
4268
- const kind = syntax.NodeType(node);
4379
+ const kind = node.kind;
4269
4380
  if (kind === "Assign" && node.Name?.Value) names.add(node.Name.Value);
4270
4381
  if (kind === "ForClause" && node.Loop?.Name?.Value) names.add(node.Loop.Name.Value);
4271
4382
  if (kind === "CallExpr") {
@@ -4280,7 +4391,7 @@ function assignedNames(f) {
4280
4391
  }
4281
4392
  function executableParts(word, assigned, quoted = false) {
4282
4393
  return (word?.Parts ?? []).flatMap((part) => {
4283
- const kind = syntax.NodeType(part);
4394
+ const kind = part.kind;
4284
4395
  if (kind === "DblQuoted") return executableParts(part, assigned, true);
4285
4396
  if (kind === "Lit") return [{ kind: "Lit", value: part.Value ?? "", quoted }];
4286
4397
  if (kind === "SglQuoted")
@@ -5004,10 +5115,10 @@ function chmodHasOpenPermMode(command) {
5004
5115
  if (f === PARSE_FAIL) return false;
5005
5116
  let found = false;
5006
5117
  try {
5007
- syntax.Walk(f, (node) => {
5118
+ walk(f, (node) => {
5008
5119
  if (!node || found) return false;
5009
5120
  const n = node;
5010
- if (syntax.NodeType(n) !== "CallExpr") return true;
5121
+ if (n.kind !== "CallExpr") return true;
5011
5122
  const words = (n.Args || []).map((a) => resolveWordLiteral(a));
5012
5123
  if (words.length === 0) return true;
5013
5124
  const name = (words[0] ?? "").toLowerCase();
@@ -5084,11 +5195,11 @@ function redirStdinOps() {
5084
5195
  }
5085
5196
  function deriveBinaryOp(sample) {
5086
5197
  try {
5087
- const f = sharedParser.Parse(sample, "cmd");
5198
+ const f = toPlainTree(sharedParser.Parse(sample, "cmd"));
5088
5199
  let op = -1;
5089
- syntax.Walk(f, (node) => {
5200
+ walk(f, (node) => {
5090
5201
  const n = node;
5091
- if (n && syntax.NodeType(n) === "BinaryCmd" && op < 0) op = n.Op;
5202
+ if (n && n.kind === "BinaryCmd" && op < 0) op = n.Op;
5092
5203
  return true;
5093
5204
  });
5094
5205
  return op;
@@ -5184,7 +5295,7 @@ function heredocText(word) {
5184
5295
  const parts = word?.Parts ?? [];
5185
5296
  let out = "";
5186
5297
  for (const p of parts) {
5187
- if (syntax.NodeType(p) !== "Lit") return null;
5298
+ if (p.kind !== "Lit") return null;
5188
5299
  out += p.Value ?? "";
5189
5300
  }
5190
5301
  return out;
@@ -5220,7 +5331,7 @@ function attachedCode(interp, flag) {
5220
5331
  }
5221
5332
  function inlineExecCall(stmt, pipeFed) {
5222
5333
  const cmd = stmt?.Cmd;
5223
- if (!cmd || syntax.NodeType(cmd) !== "CallExpr") return null;
5334
+ if (!cmd || cmd.kind !== "CallExpr") return null;
5224
5335
  const words = (cmd.Args || []).map((a) => resolveWordLiteral(a));
5225
5336
  if (words.length === 0) return null;
5226
5337
  const headIdx = unwrapCommandHead(words);
@@ -5303,10 +5414,10 @@ function shellPayloadNeedsReview(payload) {
5303
5414
  let review = false;
5304
5415
  payloadNesting++;
5305
5416
  try {
5306
- syntax.Walk(f, (node) => {
5417
+ walk(f, (node) => {
5307
5418
  if (!node || review) return false;
5308
5419
  const n = node;
5309
- if (syntax.NodeType(n) !== "CallExpr") return true;
5420
+ if (n.kind !== "CallExpr") return true;
5310
5421
  const words = (n.Args || []).map((a) => resolveWordLiteral(a));
5311
5422
  if (words.length === 0) return true;
5312
5423
  const h = unwrapCommandHead(words);
@@ -5341,10 +5452,10 @@ function inlineExecCalls(command) {
5341
5452
  if (f === PARSE_FAIL) return PARSE_FAIL;
5342
5453
  const calls = [];
5343
5454
  try {
5344
- syntax.Walk(f, (node) => {
5455
+ walk(f, (node) => {
5345
5456
  if (!node || calls.length >= MAX_INLINE_CALLS) return false;
5346
5457
  const n = node;
5347
- const t = syntax.NodeType(n);
5458
+ const t = n.kind;
5348
5459
  if (t === "BinaryCmd" && n.Y && !listOps().has(n.Op)) {
5349
5460
  const call = inlineExecCall(n.Y, true);
5350
5461
  if (call) calls.push(call);
@@ -5489,7 +5600,7 @@ function shellScriptOperands(command) {
5489
5600
  walkWithCalls(f, (node) => {
5490
5601
  if (!node) return false;
5491
5602
  const n = node;
5492
- if (syntax.NodeType(n) !== "CallExpr") return true;
5603
+ if (n.kind !== "CallExpr") return true;
5493
5604
  const callArgs = n.Args || [];
5494
5605
  if (callArgs.length === 0) return true;
5495
5606
  const words = callArgs.map((a) => resolveWordLiteral(a));
@@ -5525,7 +5636,7 @@ function shellScriptOperands(command) {
5525
5636
  }
5526
5637
  function windowsDrivePathSpelling(word) {
5527
5638
  const parts = word?.Parts || [];
5528
- if (parts.length === 0 || !parts.every((p) => syntax.NodeType(p) === "Lit")) return null;
5639
+ if (parts.length === 0 || !parts.every((p) => p.kind === "Lit")) return null;
5529
5640
  const raw = parts.map((p) => p.Value ?? "").join("");
5530
5641
  return /^[A-Za-z]:\\[^\s'"$`]*$/.test(raw) ? raw : null;
5531
5642
  }
@@ -5730,8 +5841,8 @@ function recordTopLevelAssignments(f) {
5730
5841
  }
5731
5842
  function probeBinOp(src) {
5732
5843
  try {
5733
- const cmd = syntax.NewParser().Parse(src, "probe")?.Stmts?.[0]?.Cmd;
5734
- if (cmd && syntax.NodeType(cmd) === "BinaryCmd") return cmd.Op;
5844
+ const cmd = toPlainTree(syntax2.NewParser().Parse(src, "probe"))?.Stmts?.[0]?.Cmd;
5845
+ if (cmd && cmd.kind === "BinaryCmd") return cmd.Op;
5735
5846
  } catch {
5736
5847
  }
5737
5848
  return null;
@@ -5741,7 +5852,7 @@ var OR_OP = probeBinOp("a || b");
5741
5852
  var AND_OR_OPS = new Set([AND_OP, OR_OP].filter((o) => o !== null));
5742
5853
  function recordTopLevelStmt(stmt) {
5743
5854
  if (!stmt || !stmt.Cmd) return false;
5744
- const t = syntax.NodeType(stmt.Cmd);
5855
+ const t = stmt.Cmd.kind;
5745
5856
  if (t === "BinaryCmd") {
5746
5857
  if (!AND_OR_OPS.has(stmt.Cmd.Op)) return false;
5747
5858
  if (!recordTopLevelStmt(stmt.Cmd.X)) return false;
@@ -5751,7 +5862,7 @@ function recordTopLevelStmt(stmt) {
5751
5862
  if (t !== "CallExpr" && t !== "DeclClause") return false;
5752
5863
  let at = 0;
5753
5864
  try {
5754
- at = stmt.Pos().Offset();
5865
+ at = stmt.pos;
5755
5866
  } catch {
5756
5867
  at = 0;
5757
5868
  }
@@ -5762,14 +5873,14 @@ function recordTopLevelStmt(stmt) {
5762
5873
  }
5763
5874
  function recordAssignments(n, at) {
5764
5875
  if (!assignmentTable) return;
5765
- const t = syntax.NodeType(n);
5876
+ const t = n.kind;
5766
5877
  let assigns = [];
5767
5878
  if (t === "CallExpr") {
5768
5879
  if ((n.Args || []).length > 0) return;
5769
5880
  assigns = n.Assigns || [];
5770
5881
  } else if (t === "DeclClause") {
5771
5882
  if (!ASSIGNMENT_HEADS.has(n.Variant?.Value ?? "")) return;
5772
- assigns = (n.Args || []).filter((a) => syntax.NodeType(a) === "Assign");
5883
+ assigns = (n.Args || []).filter((a) => a.kind === "Assign");
5773
5884
  } else return;
5774
5885
  for (const a of assigns) {
5775
5886
  const name = a?.Name?.Value;
@@ -5778,13 +5889,13 @@ function recordAssignments(n, at) {
5778
5889
  }
5779
5890
  }
5780
5891
  function resolveTrivialSubst(part) {
5781
- if (syntax.NodeType(part) !== "CmdSubst") return void 0;
5892
+ if (part.kind !== "CmdSubst") return void 0;
5782
5893
  const stmts = part.Stmts || [];
5783
5894
  if (stmts.length !== 1) return void 0;
5784
5895
  const st = stmts[0];
5785
5896
  if ((st.Redirs || []).length > 0 || st.Negated || st.Background) return void 0;
5786
5897
  const cmd = st.Cmd;
5787
- if (!cmd || syntax.NodeType(cmd) !== "CallExpr") return void 0;
5898
+ if (!cmd || cmd.kind !== "CallExpr") return void 0;
5788
5899
  if ((cmd.Assigns || []).length > 0) return void 0;
5789
5900
  const words = (cmd.Args || []).map((a) => resolveWordLiteral(a));
5790
5901
  if (words.length === 0 || words.some((w) => w === null)) return void 0;
@@ -5809,7 +5920,7 @@ function recordedExpansion(name) {
5809
5920
  return rec.value;
5810
5921
  }
5811
5922
  function isPlainParam(p) {
5812
- if (syntax.NodeType(p) !== "ParamExp") return false;
5923
+ if (p.kind !== "ParamExp") return false;
5813
5924
  return !(p.Excl || p.Length || p.Width || p.Index || p.Slice || p.Repl || p.Exp);
5814
5925
  }
5815
5926
  function expandPlainParam(p) {
@@ -5825,9 +5936,9 @@ var callDepth = 0;
5825
5936
  var callWalks = 0;
5826
5937
  function functionBodies(f) {
5827
5938
  const out = /* @__PURE__ */ new Map();
5828
- syntax.Walk(f, (node) => {
5939
+ walk(f, (node) => {
5829
5940
  const n = node;
5830
- if (n && syntax.NodeType(n) === "FuncDecl" && n.Name?.Value && n.Body) {
5941
+ if (n && n.kind === "FuncDecl" && n.Name?.Value && n.Body) {
5831
5942
  const list = out.get(n.Name.Value) ?? [];
5832
5943
  list.push(n.Body);
5833
5944
  out.set(n.Name.Value, list);
@@ -5838,10 +5949,10 @@ function functionBodies(f) {
5838
5949
  }
5839
5950
  function rebindsPositionals(body) {
5840
5951
  let found = false;
5841
- syntax.Walk(body, (node) => {
5952
+ walk(body, (node) => {
5842
5953
  const n = node;
5843
5954
  if (found || !n) return false;
5844
- if (syntax.NodeType(n) === "CallExpr") {
5955
+ if (n.kind === "CallExpr") {
5845
5956
  const words = (n.Args || []).map((a) => resolveWordLiteral(a));
5846
5957
  if (words[0] === "shift") found = true;
5847
5958
  else if (words[0] === "set" && words.slice(1).some((w) => w === null || w === "--" || !/^[-+]/.test(w)))
@@ -5861,7 +5972,7 @@ function tableBindings() {
5861
5972
  function walkWithCalls(f, visit) {
5862
5973
  const bodies = functionBodies(f);
5863
5974
  if (bodies.size === 0) {
5864
- syntax.Walk(f, visit);
5975
+ walk(f, visit);
5865
5976
  return;
5866
5977
  }
5867
5978
  const seenCalls = /* @__PURE__ */ new Set();
@@ -5895,8 +6006,8 @@ function walkWithCalls(f, visit) {
5895
6006
  currentStmtOffset = Number.MAX_SAFE_INTEGER;
5896
6007
  callDepth++;
5897
6008
  try {
5898
- if (body.Cmd && syntax.NodeType(body.Cmd) === "Block") recordTopLevelAssignments(body.Cmd);
5899
- syntax.Walk(body, step);
6009
+ if (body.Cmd && body.Cmd.kind === "Block") recordTopLevelAssignments(body.Cmd);
6010
+ walk(body, step);
5900
6011
  } finally {
5901
6012
  callDepth--;
5902
6013
  assignmentTable = outerTable;
@@ -5907,10 +6018,10 @@ function walkWithCalls(f, visit) {
5907
6018
  const step = (node) => {
5908
6019
  if (!node) return false;
5909
6020
  const go = visit(node);
5910
- if (go !== false && syntax.NodeType(node) === "CallExpr") inline(node);
6021
+ if (go !== false && node.kind === "CallExpr") inline(node);
5911
6022
  return go;
5912
6023
  };
5913
- syntax.Walk(f, step);
6024
+ walk(f, step);
5914
6025
  }
5915
6026
  function withAssignments(f, body) {
5916
6027
  const outerTable = assignmentTable;
@@ -5935,7 +6046,7 @@ function walkCommandScope(command, visit) {
5935
6046
  if (f === PARSE_FAIL) return "parse-fail";
5936
6047
  withAssignments(f, () => {
5937
6048
  walkWithCalls(f, (node) => {
5938
- if (node && syntax.NodeType(node) === "Stmt") trackStatement(node);
6049
+ if (node && node.kind === "Stmt") trackStatement(node);
5939
6050
  return visit(node);
5940
6051
  });
5941
6052
  });
@@ -5943,7 +6054,7 @@ function walkCommandScope(command, visit) {
5943
6054
  }
5944
6055
  function trackStatement(n) {
5945
6056
  try {
5946
- currentStmtOffset = n.Pos().Offset();
6057
+ currentStmtOffset = n.pos;
5947
6058
  } catch {
5948
6059
  currentStmtOffset = Number.MAX_SAFE_INTEGER;
5949
6060
  }
@@ -5959,11 +6070,11 @@ function resolveWordLiteral(w) {
5959
6070
  return s;
5960
6071
  }
5961
6072
  function resolveWordPrefix(w) {
5962
- const walk2 = (parts) => {
6073
+ const walk3 = (parts) => {
5963
6074
  let s = "";
5964
6075
  for (const p of parts) {
5965
6076
  if (p && typeof p === "object" && Array.isArray(p.Parts) && p.Dollar !== void 0) {
5966
- const inner = walk2(p.Parts);
6077
+ const inner = walk3(p.Parts);
5967
6078
  s += inner.prefix;
5968
6079
  if (inner.dynamic) return { prefix: s, dynamic: true };
5969
6080
  continue;
@@ -5974,10 +6085,10 @@ function resolveWordPrefix(w) {
5974
6085
  }
5975
6086
  return { prefix: s, dynamic: false };
5976
6087
  };
5977
- return walk2(w?.Parts || []);
6088
+ return walk3(w?.Parts || []);
5978
6089
  }
5979
6090
  function resolvePart(p, inQuotes) {
5980
- const t = syntax.NodeType(p);
6091
+ const t = p.kind;
5981
6092
  if (t === "Lit") {
5982
6093
  const raw = p.Value ?? "";
5983
6094
  if (!inQuotes) return raw.replace(/\\(.)/g, "$1");
@@ -6073,7 +6184,7 @@ function extractShellDestinations(command) {
6073
6184
  () => walkWithCalls(f, (node) => {
6074
6185
  if (!node) return false;
6075
6186
  const n = node;
6076
- if (syntax.NodeType(n) === "Stmt") {
6187
+ if (n.kind === "Stmt") {
6077
6188
  trackStatement(n);
6078
6189
  for (const raw of redirectWords(n)) {
6079
6190
  const host2 = devNetRedirectHost(raw);
@@ -6085,7 +6196,7 @@ function extractShellDestinations(command) {
6085
6196
  out.push({ host: host2, binary, raw });
6086
6197
  }
6087
6198
  }
6088
- if (syntax.NodeType(n) !== "CallExpr") return true;
6199
+ if (n.kind !== "CallExpr") return true;
6089
6200
  const callArgs = n.Args || [];
6090
6201
  if (callArgs.length === 0) return true;
6091
6202
  const words = callArgs.map((a) => resolveWordLiteral(a));
@@ -6120,7 +6231,7 @@ function extractShellDestTokens(command) {
6120
6231
  () => walkWithCalls(f, (node) => {
6121
6232
  if (!node) return false;
6122
6233
  const n = node;
6123
- if (syntax.NodeType(n) === "Stmt") {
6234
+ if (n.kind === "Stmt") {
6124
6235
  trackStatement(n);
6125
6236
  for (const raw of redirectWords(n)) {
6126
6237
  const host2 = devNetRedirectHost(raw);
@@ -6132,7 +6243,7 @@ function extractShellDestTokens(command) {
6132
6243
  out.push({ token: host2, binary });
6133
6244
  }
6134
6245
  }
6135
- if (syntax.NodeType(n) !== "CallExpr") return true;
6246
+ if (n.kind !== "CallExpr") return true;
6136
6247
  const callArgs = n.Args || [];
6137
6248
  if (callArgs.length === 0) return true;
6138
6249
  const words = callArgs.map((a) => resolveWordLiteral(a));
@@ -6203,11 +6314,11 @@ function isWaivableCleanupTarget(p) {
6203
6314
  }
6204
6315
  function deriveRedirOp(sample) {
6205
6316
  try {
6206
- const f = sharedParser.Parse(sample, "cmd");
6317
+ const f = toPlainTree(sharedParser.Parse(sample, "cmd"));
6207
6318
  let op = -1;
6208
- syntax.Walk(f, (node) => {
6319
+ walk(f, (node) => {
6209
6320
  const n = node;
6210
- if (n && syntax.NodeType(n) === "Redirect" && op < 0) op = n.Op;
6321
+ if (n && n.kind === "Redirect" && op < 0) op = n.Op;
6211
6322
  return true;
6212
6323
  });
6213
6324
  return op;
@@ -6228,7 +6339,7 @@ function collectSameCommandCreations(f) {
6228
6339
  try {
6229
6340
  const stmts = Array.isArray(f?.Stmts) ? f.Stmts : [];
6230
6341
  for (const stmt of stmts) {
6231
- if (!stmt || !stmt.Cmd || syntax.NodeType(stmt.Cmd) !== "CallExpr") continue;
6342
+ if (!stmt || !stmt.Cmd || stmt.Cmd.kind !== "CallExpr") continue;
6232
6343
  const redirs = stmt.Redirs || [];
6233
6344
  if (!redirs.some((r) => r && REDIR_HEREDOC_OPS.has(r.Op))) continue;
6234
6345
  for (const r of redirs) {
@@ -6252,10 +6363,10 @@ function isRmCreatedInCommandCleanup(command) {
6252
6363
  let sawRm = false;
6253
6364
  let ok = true;
6254
6365
  try {
6255
- syntax.Walk(f, (node) => {
6366
+ walk(f, (node) => {
6256
6367
  if (!node || !ok) return false;
6257
6368
  const n = node;
6258
- if (syntax.NodeType(n) !== "CallExpr") return true;
6369
+ if (n.kind !== "CallExpr") return true;
6259
6370
  const args = n.Args || [];
6260
6371
  const name = (resolveWordLiteral(args[0]) ?? "").toLowerCase();
6261
6372
  if (name !== "rm") return true;
@@ -6305,10 +6416,10 @@ function analyzeFsOperationImpl(command, depth = 0) {
6305
6416
  walkWithCalls(f, (node) => {
6306
6417
  if (!node || result?.verdict === "block") return false;
6307
6418
  const n = node;
6308
- const nodeType = syntax.NodeType(n);
6419
+ const nodeType = n.kind;
6309
6420
  if (nodeType === "Stmt") {
6310
6421
  try {
6311
- currentStmtOffset = n.Pos().Offset();
6422
+ currentStmtOffset = n.pos;
6312
6423
  } catch {
6313
6424
  currentStmtOffset = Number.MAX_SAFE_INTEGER;
6314
6425
  }
@@ -6851,11 +6962,12 @@ function analyzeShellCommand(command) {
6851
6962
  if (lower2.startsWith("-")) allTokens.push(lower2.replace(/^-+/, ""));
6852
6963
  };
6853
6964
  try {
6854
- const f = sharedParser.Parse(command, "cmd");
6855
- syntax.Walk(f, (node) => {
6965
+ const f = parseShared(command);
6966
+ if (f === PARSE_FAIL) throw new Error("parse failed");
6967
+ walk(f, (node) => {
6856
6968
  if (!node) return false;
6857
6969
  const n = node;
6858
- if (syntax.NodeType(n) !== "CallExpr") return true;
6970
+ if (n.kind !== "CallExpr") return true;
6859
6971
  const wordValues2 = (n.Args || []).map((arg) => {
6860
6972
  return (arg.Parts || []).map((p) => (p.Value ?? "").replace(/\\(.)/g, "$1")).join("");
6861
6973
  }).filter((s) => s.length > 0);
@@ -7154,8 +7266,8 @@ function shellRuleArgs(tool, args, ruleTool, inspection = {}) {
7154
7266
  }
7155
7267
 
7156
7268
  // src/shell/file-access.ts
7157
- import mvdanSh2 from "mvdan-sh";
7158
- var { syntax: syntax2 } = mvdanSh2;
7269
+ import mvdanSh3 from "mvdan-sh";
7270
+ var { syntax: syntax3 } = mvdanSh3;
7159
7271
  var MAX_ALTERNATIVES = 64;
7160
7272
  var MAX_CALL_DEPTH2 = 4;
7161
7273
  var MAX_CALL_WALKS2 = 256;
@@ -7172,7 +7284,7 @@ function runnablePrefix(command) {
7172
7284
  let text = command;
7173
7285
  for (let attempt = 0; attempt < 32; attempt++) {
7174
7286
  try {
7175
- return syntax2.NewParser().Parse(text, "");
7287
+ return toPlainTree(syntax3.NewParser().Parse(text, ""));
7176
7288
  } catch (error) {
7177
7289
  const message = String(typeof error?.Error === "function" ? error.Error() : error?.message);
7178
7290
  const line = Number(/^(\d+):/.exec(message)?.[1]);
@@ -7317,7 +7429,7 @@ function wordValues(word, state) {
7317
7429
  out2 = next.slice(0, MAX_ALTERNATIVES);
7318
7430
  };
7319
7431
  for (const node of nodes) {
7320
- const kind = syntax2.NodeType(node);
7432
+ const kind = node.kind;
7321
7433
  let pieces;
7322
7434
  if (kind === "ParamExp") pieces = paramValues(node, quoted);
7323
7435
  else if (kind === "DblQuoted") {
@@ -7385,9 +7497,9 @@ function collectShellFileAccesses(command, context = {}) {
7385
7497
  }
7386
7498
  function substitutions(word, state, depth) {
7387
7499
  if (!word) return;
7388
- syntax2.Walk(word, (node) => {
7500
+ walk(word, (node) => {
7389
7501
  if (!node) return false;
7390
- if (["CmdSubst", "ProcSubst"].includes(syntax2.NodeType(node))) {
7502
+ if (["CmdSubst", "ProcSubst"].includes(node.kind)) {
7391
7503
  statements(node.Stmts ?? [], clone(state), depth + 1);
7392
7504
  return false;
7393
7505
  }
@@ -7811,7 +7923,7 @@ function collectShellFileAccesses(command, context = {}) {
7811
7923
  }
7812
7924
  function readsScriptFromStdin(stmt) {
7813
7925
  const cmd = stmt?.Cmd;
7814
- if (!cmd || syntax2.NodeType(cmd) !== "CallExpr") return false;
7926
+ if (!cmd || cmd.kind !== "CallExpr") return false;
7815
7927
  const words = (cmd.Args ?? []).map((a) => resolveWordLiteral(a));
7816
7928
  const head = unwrapCommandHead(words);
7817
7929
  return SHELL_INTERPRETERS.has(base(words[head])) && shellConsumesPipe(words.slice(head + 1));
@@ -7825,7 +7937,7 @@ function collectShellFileAccesses(command, context = {}) {
7825
7937
  }
7826
7938
  function producedText(stmt) {
7827
7939
  const cmd = stmt?.Cmd;
7828
- if (!cmd || syntax2.NodeType(cmd) !== "CallExpr") return null;
7940
+ if (!cmd || cmd.kind !== "CallExpr") return null;
7829
7941
  const words = (cmd.Args ?? []).map((a) => resolveWordLiteral(a));
7830
7942
  if (words.some((w) => w === null)) return null;
7831
7943
  const head = unwrapCommandHead(words);
@@ -7844,7 +7956,7 @@ function collectShellFileAccesses(command, context = {}) {
7844
7956
  if (!stmt || depth > MAX_DEPTH) return;
7845
7957
  state.onSuccess = void 0;
7846
7958
  if (stmt.Background) state = clone(state);
7847
- const headWord = stmt.Cmd && syntax2.NodeType(stmt.Cmd) === "CallExpr" ? base(resolveWordLiteral(stmt.Cmd.Args?.[0])) : "";
7959
+ const headWord = stmt.Cmd && stmt.Cmd.kind === "CallExpr" ? base(resolveWordLiteral(stmt.Cmd.Args?.[0])) : "";
7848
7960
  const sends = SENDING_STDIN.has(headWord);
7849
7961
  for (const redir of stmt.Redirs ?? []) {
7850
7962
  substitutions(redir.Word, state, depth);
@@ -7860,7 +7972,7 @@ function collectShellFileAccesses(command, context = {}) {
7860
7972
  const cmd = stmt.Cmd;
7861
7973
  if (!cmd) return;
7862
7974
  stdinScript(stmt, state, depth);
7863
- switch (syntax2.NodeType(cmd)) {
7975
+ switch (cmd.kind) {
7864
7976
  case "CallExpr":
7865
7977
  call(cmd, state, depth);
7866
7978
  break;
@@ -7874,7 +7986,7 @@ function collectShellFileAccesses(command, context = {}) {
7874
7986
  for (; ; ) {
7875
7987
  segments2.unshift({ op: node.Op, part: node.Y });
7876
7988
  const left = node.X;
7877
- if (left?.Cmd && syntax2.NodeType(left.Cmd) === "BinaryCmd" && !left.Redirs?.length && !left.Negated && !left.Background)
7989
+ if (left?.Cmd && left.Cmd.kind === "BinaryCmd" && !left.Redirs?.length && !left.Negated && !left.Background)
7878
7990
  node = left.Cmd;
7879
7991
  else {
7880
7992
  segments2.unshift({ op: node.Op, part: left });
@@ -8149,7 +8261,6 @@ function evaluateProtectedFileAccess(accesses, context, settings) {
8149
8261
  }
8150
8262
 
8151
8263
  // src/shell/derived-writes.ts
8152
- var { syntax: syntax3 } = mvdanSh3;
8153
8264
  var SEQUENCE_OPS = (() => {
8154
8265
  const ops = /* @__PURE__ */ new Set();
8155
8266
  for (const text of ["x && y", "x || y"]) {
@@ -8188,13 +8299,13 @@ function pipelineTexts(command) {
8188
8299
  const visit = (stmt, depth) => {
8189
8300
  if (!stmt || depth > 64) return;
8190
8301
  const cmd = stmt.Cmd;
8191
- if (cmd && syntax3.NodeType(cmd) === "BinaryCmd" && SEQUENCE_OPS.has(cmd.Op)) {
8302
+ if (cmd && cmd.kind === "BinaryCmd" && SEQUENCE_OPS.has(cmd.Op)) {
8192
8303
  visit(cmd.X, depth + 1);
8193
8304
  visit(cmd.Y, depth + 1);
8194
8305
  return;
8195
8306
  }
8196
- const s = at(stmt.Pos().Offset());
8197
- const e = at(stmt.End().Offset());
8307
+ const s = at(stmt.pos);
8308
+ const e = at(stmt.end);
8198
8309
  const text = s >= 0 && e > s ? command.slice(s, e).replace(/[\s;&]+$/, "") : "";
8199
8310
  if (text) out.push(text);
8200
8311
  };
@@ -12534,8 +12645,6 @@ function writtenTexts(args) {
12534
12645
  }
12535
12646
 
12536
12647
  // src/shell/write-source.ts
12537
- import mvdanSh4 from "mvdan-sh";
12538
- var { syntax: syntax4 } = mvdanSh4;
12539
12648
  var RDR_IN = (() => {
12540
12649
  try {
12541
12650
  return parseShared("x <y").Stmts[0].Redirs[0].Op;
@@ -12570,11 +12679,10 @@ function shellWriteUnseen(command, target) {
12570
12679
  let unseen = false;
12571
12680
  let seen = false;
12572
12681
  try {
12573
- syntax4.Walk(f, (node) => {
12682
+ walk(f, (node) => {
12574
12683
  if (!node || unseen) return false;
12575
12684
  const n = node;
12576
- if (syntax4.NodeType(n) !== "Stmt" || !n.Cmd || syntax4.NodeType(n.Cmd) !== "CallExpr")
12577
- return true;
12685
+ if (n.kind !== "Stmt" || !n.Cmd || n.Cmd.kind !== "CallExpr") return true;
12578
12686
  const words = (n.Cmd.Args || []).map(
12579
12687
  (a) => resolveWordLiteral(a)
12580
12688
  );
@@ -12604,8 +12712,6 @@ function shellWriteUnseen(command, target) {
12604
12712
  }
12605
12713
 
12606
12714
  // src/shell/git.ts
12607
- import mvdanSh5 from "mvdan-sh";
12608
- var { syntax: syntax5 } = mvdanSh5;
12609
12715
  var GIT_PRESCREEN_RE = /git|husky/i;
12610
12716
  var MAX_PAYLOAD_DEPTH2 = 8;
12611
12717
  var MAX_ALIAS_DEPTH = 5;
@@ -12631,11 +12737,11 @@ function analyzeGit(command) {
12631
12737
  }
12632
12738
  function gitInvocations(command) {
12633
12739
  const out = [];
12634
- const walk2 = new GitWalk(
12740
+ const walk3 = new GitWalk(
12635
12741
  (inv) => out.push(inv),
12636
12742
  () => void 0
12637
12743
  );
12638
- walk2.run(command, 0);
12744
+ walk3.run(command, 0);
12639
12745
  return out;
12640
12746
  }
12641
12747
  function analyzeGitImpl(command) {
@@ -12647,8 +12753,8 @@ function analyzeGitImpl(command) {
12647
12753
  seen.add(key);
12648
12754
  findings.push(f);
12649
12755
  };
12650
- const walk2 = new GitWalk((inv) => classify(inv).forEach(found), found);
12651
- const parsed = walk2.run(command, 0);
12756
+ const walk3 = new GitWalk((inv) => classify(inv).forEach(found), found);
12757
+ const parsed = walk3.run(command, 0);
12652
12758
  return { parsed, findings };
12653
12759
  }
12654
12760
  var PAYLOAD_SHELLS = /* @__PURE__ */ new Set(["sh", "bash", "zsh", "dash", "ksh", "eval"]);
@@ -12714,7 +12820,7 @@ var GitWalk = class {
12714
12820
  visit(node, depth) {
12715
12821
  if (!node) return false;
12716
12822
  const n = node;
12717
- const type = syntax5.NodeType(n);
12823
+ const type = n.kind;
12718
12824
  if (type === "Stmt") {
12719
12825
  this.visitHeredocShell(n, depth);
12720
12826
  return true;
@@ -12722,7 +12828,7 @@ var GitWalk = class {
12722
12828
  if (type === "ForClause") {
12723
12829
  const loop = n.Loop;
12724
12830
  const name = loop?.Name?.Value;
12725
- if (name && syntax5.NodeType(loop) === "WordIter") {
12831
+ if (name && loop.kind === "WordIter") {
12726
12832
  const items = (loop.Items || []).map((w) => resolveWordLiteral(w));
12727
12833
  const literal = items.length > 0 && items.every((v) => v !== null);
12728
12834
  this.loopVars.set(name, literal ? items.slice(0, MAX_LOOP_ITEMS) : null);
@@ -12789,7 +12895,7 @@ var GitWalk = class {
12789
12895
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12790
12896
  visitHeredocShell(stmt, depth) {
12791
12897
  const cmd = stmt.Cmd;
12792
- if (!cmd || syntax5.NodeType(cmd) !== "CallExpr" || depth >= MAX_PAYLOAD_DEPTH2) return;
12898
+ if (!cmd || cmd.kind !== "CallExpr" || depth >= MAX_PAYLOAD_DEPTH2) return;
12793
12899
  const redirs = stmt.Redirs || [];
12794
12900
  const hdoc = redirs.find((r) => r?.Hdoc && (r.N == null || r.N.Value === "0"));
12795
12901
  if (!hdoc) return;
@@ -12939,8 +13045,8 @@ var GitWalk = class {
12939
13045
  var POSITIONAL2 = "\0positional";
12940
13046
  function isPositionalParam(word) {
12941
13047
  let parts = word?.Parts || [];
12942
- if (parts.length === 1 && syntax5.NodeType(parts[0]) === "DblQuoted") parts = parts[0].Parts || [];
12943
- if (parts.length !== 1 || syntax5.NodeType(parts[0]) !== "ParamExp") return false;
13048
+ if (parts.length === 1 && parts[0].kind === "DblQuoted") parts = parts[0].Parts || [];
13049
+ if (parts.length !== 1 || parts[0].kind !== "ParamExp") return false;
12944
13050
  return /^(\d+|@|\*)$/.test(parts[0].Param?.Value ?? "");
12945
13051
  }
12946
13052
  function boundPositionals() {
@@ -12954,11 +13060,11 @@ function boundPositionals() {
12954
13060
  function plainParamName(word) {
12955
13061
  let parts = word?.Parts || [];
12956
13062
  let quoted = false;
12957
- if (parts.length === 1 && syntax5.NodeType(parts[0]) === "DblQuoted") {
13063
+ if (parts.length === 1 && parts[0].kind === "DblQuoted") {
12958
13064
  parts = parts[0].Parts || [];
12959
13065
  quoted = true;
12960
13066
  }
12961
- if (parts.length !== 1 || syntax5.NodeType(parts[0]) !== "ParamExp") return null;
13067
+ if (parts.length !== 1 || parts[0].kind !== "ParamExp") return null;
12962
13068
  const p = parts[0];
12963
13069
  if (p.Excl || p.Length || p.Width || p.Index || p.Slice || p.Repl || p.Exp) return null;
12964
13070
  const name = p.Param?.Value;
@@ -12983,7 +13089,7 @@ function resolveGitWords(word) {
12983
13089
  }
12984
13090
  const parts = word?.Parts || [];
12985
13091
  const expansion = parts.some((p) => {
12986
- const t = syntax5.NodeType(p);
13092
+ const t = p.kind;
12987
13093
  return t === "ParamExp" || t === "CmdSubst";
12988
13094
  });
12989
13095
  return expansion ? splitFields(value) : [value];
@@ -13494,14 +13600,14 @@ function hookCommands(text) {
13494
13600
  const root = parsed?.hooks;
13495
13601
  if (!root || typeof root !== "object") return null;
13496
13602
  const out = [];
13497
- const walk2 = (v, depth) => {
13603
+ const walk3 = (v, depth) => {
13498
13604
  if (depth > 8 || !v || typeof v !== "object") return;
13499
13605
  for (const [k, x] of Object.entries(v)) {
13500
13606
  if (k === "command" && typeof x === "string") out.push(x);
13501
- else walk2(x, depth + 1);
13607
+ else walk3(x, depth + 1);
13502
13608
  }
13503
13609
  };
13504
- walk2(root, 0);
13610
+ walk3(root, 0);
13505
13611
  return out;
13506
13612
  }
13507
13613
  function hooksDisarmed(text) {
@@ -13663,8 +13769,6 @@ function evaluateAgentFileWrite(args, accesses, context, settings, shell, hooks
13663
13769
  }
13664
13770
 
13665
13771
  // src/shell/outbound.ts
13666
- import mvdanSh6 from "mvdan-sh";
13667
- var { syntax: syntax6 } = mvdanSh6;
13668
13772
  var SHELLS = /* @__PURE__ */ new Set([...SHELL_INTERPRETERS, "mksh", "ash", "csh", "tcsh"]);
13669
13773
  var NETCATS = /* @__PURE__ */ new Set(["nc", "ncat", "netcat", "nc.traditional", "nc.openbsd"]);
13670
13774
  var NET_CLIENTS = /* @__PURE__ */ new Set([...NETCATS, "telnet", "socat"]);
@@ -13704,9 +13808,9 @@ function isDupInOp(op) {
13704
13808
  if (dupInOp === null) {
13705
13809
  let found = -1;
13706
13810
  try {
13707
- syntax6.Walk(parseShared("cat <&3"), (node) => {
13811
+ walk(parseShared("cat <&3"), (node) => {
13708
13812
  const n = node;
13709
- if (found === -1 && n && syntax6.NodeType(n) === "Stmt" && n.Redirs?.[0]) {
13813
+ if (found === -1 && n && n.kind === "Stmt" && n.Redirs?.[0]) {
13710
13814
  found = n.Redirs[0].Op;
13711
13815
  }
13712
13816
  return true;
@@ -13727,10 +13831,10 @@ function analyzeOutbound(command) {
13727
13831
  return hit;
13728
13832
  }
13729
13833
  const findings = [];
13730
- const walk2 = new OutboundWalk(findings);
13731
- const parsed = walk2.run(command, 0);
13834
+ const walk3 = new OutboundWalk(findings);
13835
+ const parsed = walk3.run(command, 0);
13732
13836
  const envOut = findings.find((f) => f.checkId === "data.env-exfil");
13733
- if (envOut) envOut.destinations = walk2.envDestinations();
13837
+ if (envOut) envOut.destinations = walk3.envDestinations();
13734
13838
  const computed = { parsed, findings };
13735
13839
  if (cache2.size >= CACHE_MAX2) {
13736
13840
  const oldest = cache2.keys().next().value;
@@ -13748,7 +13852,7 @@ function wordShape(word) {
13748
13852
  const parts = word?.Parts || [];
13749
13853
  let out = "";
13750
13854
  for (const p of parts) {
13751
- const t = syntax6.NodeType(p);
13855
+ const t = p.kind;
13752
13856
  if (t === "Lit" || t === "SglQuoted") out += p.Value ?? "";
13753
13857
  else if (t === "DblQuoted") out += wordShape(p);
13754
13858
  else out += "X";
@@ -13904,7 +14008,7 @@ var OutboundWalk = class {
13904
14008
  const f = parseShared(command);
13905
14009
  if (!f || typeof f !== "object" || !f.Stmts) return false;
13906
14010
  try {
13907
- syntax6.Walk(f, (node) => this.visit(node, depth));
14011
+ walk(f, (node) => this.visit(node, depth));
13908
14012
  } catch {
13909
14013
  return false;
13910
14014
  }
@@ -13943,7 +14047,7 @@ var OutboundWalk = class {
13943
14047
  }
13944
14048
  visit(n, depth) {
13945
14049
  if (!n) return false;
13946
- const type = syntax6.NodeType(n);
14050
+ const type = n.kind;
13947
14051
  if (type === "Stmt") {
13948
14052
  this.visitStmt(n, depth);
13949
14053
  return true;
@@ -13963,7 +14067,7 @@ var OutboundWalk = class {
13963
14067
  const redirs = redirectWords(stmt);
13964
14068
  const toSocket = redirs.some((w) => w !== null && DEV_NET_RE.test(w));
13965
14069
  if (!cmd) return;
13966
- const type = syntax6.NodeType(cmd);
14070
+ const type = cmd.kind;
13967
14071
  if (type !== "CallExpr" || wordsOf(cmd).length > 0) {
13968
14072
  if (this.readsNetFd(stmt) && runsCommandsIn(stmt)) {
13969
14073
  this.reverseShell("commands are read from a network socket opened with exec");
@@ -14049,7 +14153,7 @@ var OutboundWalk = class {
14049
14153
  const stages = [];
14050
14154
  const flatten = (s) => {
14051
14155
  const c = s?.Cmd;
14052
- if (c && syntax6.NodeType(c) === "BinaryCmd" && isPipeOp(c.Op)) {
14156
+ if (c && c.kind === "BinaryCmd" && isPipeOp(c.Op)) {
14053
14157
  flatten(c.X);
14054
14158
  flatten(c.Y);
14055
14159
  } else stages.push(s);
@@ -14071,8 +14175,8 @@ var OutboundWalk = class {
14071
14175
  sinks.set(i, socketHosts(st));
14072
14176
  }
14073
14177
  if (!c) return;
14074
- if (syntax6.NodeType(c) === "DeclClause" && declDumpsEnv(c) && dump < 0) dump = i;
14075
- if (syntax6.NodeType(c) !== "CallExpr") {
14178
+ if (c.kind === "DeclClause" && declDumpsEnv(c) && dump < 0) dump = i;
14179
+ if (c.kind !== "CallExpr") {
14076
14180
  if (runsCommandsIn(st)) shell = i;
14077
14181
  return;
14078
14182
  }
@@ -14113,10 +14217,10 @@ var OutboundWalk = class {
14113
14217
  /** A word (or assignment value) whose text includes an env dump's output. */
14114
14218
  carriesEnv(word) {
14115
14219
  let hit = false;
14116
- syntax6.Walk(word, (node) => {
14220
+ walk(word, (node) => {
14117
14221
  if (hit || !node) return false;
14118
14222
  const n = node;
14119
- const t = syntax6.NodeType(n);
14223
+ const t = n.kind;
14120
14224
  if (t === "ParamExp" && n.Param?.Value && this.envVars.has(n.Param.Value)) {
14121
14225
  hit = true;
14122
14226
  return false;
@@ -14133,11 +14237,11 @@ var OutboundWalk = class {
14133
14237
  stmtsDumpEnv(stmts) {
14134
14238
  let hit = false;
14135
14239
  for (const s of stmts) {
14136
- syntax6.Walk(s, (node) => {
14240
+ walk(s, (node) => {
14137
14241
  if (hit || !node) return false;
14138
14242
  const n = node;
14139
- const t = syntax6.NodeType(n);
14140
- if (t === "Stmt" && n.Cmd && syntax6.NodeType(n.Cmd) === "CallExpr") {
14243
+ const t = n.kind;
14244
+ if (t === "Stmt" && n.Cmd && n.Cmd.kind === "CallExpr") {
14141
14245
  const words = wordsOf(n.Cmd);
14142
14246
  if (words.length > 0 && dumpsEnv(words, n)) hit = true;
14143
14247
  }
@@ -14156,16 +14260,16 @@ var OutboundWalk = class {
14156
14260
  };
14157
14261
  function paramName(word) {
14158
14262
  let parts = word?.Parts || [];
14159
- if (parts.length === 1 && syntax6.NodeType(parts[0]) === "DblQuoted") parts = parts[0].Parts || [];
14160
- if (parts.length !== 1 || syntax6.NodeType(parts[0]) !== "ParamExp") return null;
14263
+ if (parts.length === 1 && parts[0].kind === "DblQuoted") parts = parts[0].Parts || [];
14264
+ if (parts.length !== 1 || parts[0].kind !== "ParamExp") return null;
14161
14265
  return parts[0].Param?.Value ?? null;
14162
14266
  }
14163
14267
  function refersTo(word, names) {
14164
14268
  let hit = false;
14165
- syntax6.Walk(word, (node) => {
14269
+ walk(word, (node) => {
14166
14270
  if (hit || !node) return false;
14167
14271
  const n = node;
14168
- if (syntax6.NodeType(n) === "ParamExp" && names.has(n.Param?.Value)) hit = true;
14272
+ if (n.kind === "ParamExp" && names.has(n.Param?.Value)) hit = true;
14169
14273
  return !hit;
14170
14274
  });
14171
14275
  return hit;
@@ -14173,10 +14277,10 @@ function refersTo(word, names) {
14173
14277
  function runsCommandsIn(stmt) {
14174
14278
  const readVars = /* @__PURE__ */ new Set();
14175
14279
  let hit = false;
14176
- syntax6.Walk(stmt, (node) => {
14280
+ walk(stmt, (node) => {
14177
14281
  if (hit || !node) return false;
14178
14282
  const n = node;
14179
- if (syntax6.NodeType(n) !== "CallExpr") return true;
14283
+ if (n.kind !== "CallExpr") return true;
14180
14284
  const words = wordsOf(n);
14181
14285
  if (words.length === 0) return true;
14182
14286
  const { head, at } = headOf(words);
@@ -14197,12 +14301,7 @@ function runsCommandsIn(stmt) {
14197
14301
  return hit;
14198
14302
  }
14199
14303
 
14200
- // src/shell/package-registry.ts
14201
- import mvdanSh8 from "mvdan-sh";
14202
-
14203
14304
  // src/shell/package-install.ts
14204
- import mvdanSh7 from "mvdan-sh";
14205
- var { syntax: syntax7 } = mvdanSh7;
14206
14305
  var NPM_INSTALL_VERBS = /* @__PURE__ */ new Set([
14207
14306
  "install",
14208
14307
  "i",
@@ -15141,7 +15240,7 @@ function localContexts(file) {
15141
15240
  if (depth > 64) return null;
15142
15241
  if (!stmt || stmt.Background || stmt.Negated || stmt.Redirs?.length) return null;
15143
15242
  const cmd = stmt.Cmd;
15144
- const kind = syntax7.NodeType(cmd);
15243
+ const kind = cmd.kind;
15145
15244
  if (kind === "BinaryCmd" && cmd.Op === andOp) {
15146
15245
  const next = visit(cmd.X, steps, depth + 1);
15147
15246
  return next === null ? null : visit(cmd.Y, next, depth + 1);
@@ -15157,7 +15256,7 @@ function localContexts(file) {
15157
15256
  )
15158
15257
  ))
15159
15258
  return null;
15160
- contexts.set(cmd.Pos().Offset(), steps);
15259
+ contexts.set(cmd.pos, steps);
15161
15260
  return null;
15162
15261
  }
15163
15262
  if (file.Stmts?.length === 1) visit(file.Stmts[0], []);
@@ -15168,12 +15267,12 @@ function collect(command, out, depth) {
15168
15267
  const f = parseShared(command);
15169
15268
  if (typeof f === "symbol") return;
15170
15269
  const contexts = depth === 0 ? localContexts(f) : /* @__PURE__ */ new Map();
15171
- syntax7.Walk(f, (node) => {
15172
- if (node && syntax7.NodeType(node) === "CallExpr") {
15270
+ walk(f, (node) => {
15271
+ if (node && node.kind === "CallExpr") {
15173
15272
  const words = (node.Args || []).map((a) => resolveWordLiteral(a));
15174
15273
  const start = out.length;
15175
15274
  if (words.length > 0) fromCall(words, out, depth);
15176
- const steps = contexts.get(node.Pos().Offset());
15275
+ const steps = contexts.get(node.pos);
15177
15276
  for (let i = start; i < out.length; i++) {
15178
15277
  if (["npx", "bunx", "npm exec"].includes(out[i].manager)) {
15179
15278
  if (!steps) out[i].localCwd = null;
@@ -15197,7 +15296,6 @@ function extractPackageInstalls(command) {
15197
15296
  }
15198
15297
 
15199
15298
  // src/shell/package-registry.ts
15200
- var { syntax: syntax8 } = mvdanSh8;
15201
15299
  var NPM_FAMILY = /* @__PURE__ */ new Set(["npm", "pnpm", "yarn", "bun", "npx", "pnpx", "bunx"]);
15202
15300
  var PIP_FAMILY = /* @__PURE__ */ new Set(["pip", "pip3", "uv", "uvx", "pipx", "pipenv"]);
15203
15301
  var NPM_FETCH_VERBS = /* @__PURE__ */ new Set([
@@ -15288,7 +15386,7 @@ function collect2(command, out, depth) {
15288
15386
  try {
15289
15387
  walkCommandScope(command, (node) => {
15290
15388
  const n = node;
15291
- if (!n || syntax8.NodeType(n) !== "CallExpr") return true;
15389
+ if (!n || n.kind !== "CallExpr") return true;
15292
15390
  const words = (n.Args || []).map((a) => resolveWordLiteral(a));
15293
15391
  if (words.length === 0) return true;
15294
15392
  const prefix = (n.Assigns || []).filter((a) => a?.Name?.Value).map(
@@ -17075,12 +17173,12 @@ function extractContentDestinations(text) {
17075
17173
  function extractArgDestinations(args) {
17076
17174
  const out = /* @__PURE__ */ new Set();
17077
17175
  try {
17078
- walk(args, void 0, out, 0);
17176
+ walk2(args, void 0, out, 0);
17079
17177
  } catch {
17080
17178
  }
17081
17179
  return [...out];
17082
17180
  }
17083
- function walk(value, key, out, depth) {
17181
+ function walk2(value, key, out, depth) {
17084
17182
  if (out.size >= MAX_DESTINATIONS || depth > 12) return;
17085
17183
  if (typeof value === "string") {
17086
17184
  const s = value.length > MAX_SCAN_CHARS ? value.slice(0, MAX_SCAN_CHARS) : value;
@@ -17099,12 +17197,12 @@ function walk(value, key, out, depth) {
17099
17197
  return;
17100
17198
  }
17101
17199
  if (Array.isArray(value)) {
17102
- for (const v of value) walk(v, key, out, depth + 1);
17200
+ for (const v of value) walk2(v, key, out, depth + 1);
17103
17201
  return;
17104
17202
  }
17105
17203
  if (value && typeof value === "object") {
17106
17204
  for (const [k, v] of Object.entries(value))
17107
- walk(v, k, out, depth + 1);
17205
+ walk2(v, k, out, depth + 1);
17108
17206
  }
17109
17207
  }
17110
17208
  function destinationDomain(dest) {
@@ -17615,8 +17713,6 @@ function maskLeaf(value, key, depth) {
17615
17713
  }
17616
17714
 
17617
17715
  // src/exposure/shell.ts
17618
- import mvdanSh9 from "mvdan-sh";
17619
- var { syntax: syntax9 } = mvdanSh9;
17620
17716
  var EMPTY = {
17621
17717
  fetches: false,
17622
17718
  sends: false,
@@ -18030,9 +18126,9 @@ function classifyCall(head, args, prefixes, env, state, out) {
18030
18126
  function walkCalls(command, out, depth, state) {
18031
18127
  const f = parseShared(command);
18032
18128
  if (typeof f === "symbol" || !f) return;
18033
- syntax9.Walk(f, (node) => {
18129
+ walk(f, (node) => {
18034
18130
  if (!node) return false;
18035
- const type = syntax9.NodeType(node);
18131
+ const type = node.kind;
18036
18132
  if (type === "DeclClause") {
18037
18133
  for (const a of node.Args || []) if (a?.Name?.Value) state.env.add(a.Name.Value);
18038
18134
  return true;
@@ -18610,7 +18706,7 @@ function matchCanaryArgs(args, values) {
18610
18706
  if (values.length === 0) return null;
18611
18707
  const needles = prepare(values);
18612
18708
  if (needles.length === 0) return null;
18613
- const walk2 = (v, depth, fieldPath) => {
18709
+ const walk3 = (v, depth, fieldPath) => {
18614
18710
  if (depth > MAX_DEPTH4) return null;
18615
18711
  if (typeof v === "string") {
18616
18712
  const hit = matchPrepared(v, needles);
@@ -18619,31 +18715,31 @@ function matchCanaryArgs(args, values) {
18619
18715
  const trimmed = v.trim();
18620
18716
  if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
18621
18717
  try {
18622
- return walk2(JSON.parse(v), depth + 1, fieldPath);
18718
+ return walk3(JSON.parse(v), depth + 1, fieldPath);
18623
18719
  } catch {
18624
18720
  }
18625
18721
  }
18626
18722
  }
18627
18723
  return null;
18628
18724
  }
18629
- if (typeof v === "number" && Number.isFinite(v)) return walk2(String(v), depth, fieldPath);
18725
+ if (typeof v === "number" && Number.isFinite(v)) return walk3(String(v), depth, fieldPath);
18630
18726
  if (Array.isArray(v)) {
18631
18727
  for (let i = 0; i < v.length; i++) {
18632
- const h = walk2(v[i], depth + 1, `${fieldPath}[${i}]`);
18728
+ const h = walk3(v[i], depth + 1, `${fieldPath}[${i}]`);
18633
18729
  if (h) return h;
18634
18730
  }
18635
18731
  return null;
18636
18732
  }
18637
18733
  if (v && typeof v === "object") {
18638
18734
  for (const [k, child] of Object.entries(v)) {
18639
- const h = walk2(child, depth + 1, fieldPath ? `${fieldPath}.${k}` : k);
18735
+ const h = walk3(child, depth + 1, fieldPath ? `${fieldPath}.${k}` : k);
18640
18736
  if (h) return h;
18641
18737
  }
18642
18738
  }
18643
18739
  return null;
18644
18740
  };
18645
18741
  try {
18646
- return walk2(args, 0, "");
18742
+ return walk3(args, 0, "");
18647
18743
  } catch (e) {
18648
18744
  console.error(
18649
18745
  "[node9 engine] canary args walk failed:",
@@ -18656,7 +18752,7 @@ function matchCanaryArgs(args, values) {
18656
18752
  // src/scan/canonical.ts
18657
18753
  var LONG_OUTPUT_THRESHOLD_BYTES = 100 * 1024;
18658
18754
  var CANONICAL_EXTRACTOR_VERSION = "canonical-v35";
18659
- var CANONICAL_EXTRACTOR_HASH = "3b56e19906016767";
18755
+ var CANONICAL_EXTRACTOR_HASH = "dfb2d85278a146ad";
18660
18756
  var DEDUPE_PREVIEW_LEN = 120;
18661
18757
  function extractCanonicalFindings(call, ctx) {
18662
18758
  const out = [];