@node9/policy-engine 2.50.1 → 2.51.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
@@ -5415,9 +5415,15 @@ function detectDangerousShellExec(command) {
5415
5415
  if (f === PARSE_FAIL) return null;
5416
5416
  let result = null;
5417
5417
  const assigned = assignedNames(f);
5418
- walk(f, (node) => {
5418
+ const known = plainlyNamedPrograms(f);
5419
+ const calledByName = literallyCalledFunctions(f);
5420
+ const bodies = [];
5421
+ const inBody = (pos) => bodies.some(([a, b]) => pos >= a && pos < b);
5422
+ walkWithCalls(f, (node) => {
5419
5423
  if (!node || result === "block") return false;
5420
5424
  const n = node;
5425
+ if (n.kind === "FuncDecl" && n.Body && callDepth === 0 && calledByName.has(n.Name?.Value))
5426
+ bodies.push([n.Body.pos, n.Body.end]);
5421
5427
  if (n.kind === "BinaryCmd" && n.Y && !listOps().has(n.Op)) {
5422
5428
  const call = n.Y.Cmd;
5423
5429
  if (call && call.kind === "CallExpr") {
@@ -5441,7 +5447,8 @@ function detectDangerousShellExec(command) {
5441
5447
  );
5442
5448
  const head = unwrapCommandHead(headWords, false, true);
5443
5449
  const lookup = headWords[0]?.toLowerCase() === "command" && headWords.slice(1).some((w) => w === "-v" || w === "-V");
5444
- if (!lookup && (opaqueExecutable(args[0], assigned) || opaqueExecutable(args[head], assigned)))
5450
+ const unboundBody = callDepth === 0 && inBody(n.pos ?? -1);
5451
+ if (!lookup && !unboundBody && (opaqueExecutable(args[0], assigned, known) || opaqueExecutable(args[head], assigned, known)))
5445
5452
  result = "review";
5446
5453
  const firstParts = args[0].Parts || [];
5447
5454
  if (firstParts.length !== 1 || firstParts[0].kind !== "Lit") return true;
@@ -5485,6 +5492,7 @@ function lookupSubstitution(part) {
5485
5492
  if (words.length === 3 && words[0] === "type" && words[1] === "-p") return words[2];
5486
5493
  return null;
5487
5494
  }
5495
+ var EMPTY_NAMES = /* @__PURE__ */ new Set();
5488
5496
  var VARIABLE_READERS = /* @__PURE__ */ new Set([
5489
5497
  "read",
5490
5498
  "mapfile",
@@ -5514,11 +5522,106 @@ function assignedNames(f) {
5514
5522
  });
5515
5523
  return names;
5516
5524
  }
5517
- function executableParts(word, assigned, quoted = false) {
5525
+ function literallyCalledFunctions(f) {
5526
+ const declared = /* @__PURE__ */ new Set();
5527
+ const called = /* @__PURE__ */ new Set();
5528
+ walk(f, (node) => {
5529
+ if (!node) return false;
5530
+ if (node.kind === "FuncDecl" && node.Name?.Value) declared.add(node.Name.Value);
5531
+ if (node.kind === "CallExpr") {
5532
+ const head = resolveWordLiteral(node.Args?.[0]);
5533
+ if (head) called.add(head);
5534
+ }
5535
+ return true;
5536
+ });
5537
+ return new Set([...declared].filter((name) => called.has(name)));
5538
+ }
5539
+ var PLAIN_PROGRAM_NAME = /^[A-Za-z_][\w.+-]*$/;
5540
+ function plainlyNamedPrograms(f) {
5541
+ const values = /* @__PURE__ */ new Map();
5542
+ const arrays = /* @__PURE__ */ new Set();
5543
+ const give = (name, value) => {
5544
+ if (value === null || !PLAIN_PROGRAM_NAME.test(value)) {
5545
+ values.set(name, null);
5546
+ return;
5547
+ }
5548
+ const cur = values.get(name);
5549
+ if (cur === null) return;
5550
+ if (cur === void 0) values.set(name, /* @__PURE__ */ new Set([value]));
5551
+ else cur.add(value);
5552
+ };
5553
+ const literalOnly = (w) => {
5554
+ const parts = w?.Parts ?? [];
5555
+ if (parts.length !== 1) return null;
5556
+ const p = parts[0];
5557
+ if (p.kind === "Lit") return p.Value ?? null;
5558
+ if (p.kind === "ParamExp" && expansionName(p) === "FUNCNAME") return "FUNCNAME";
5559
+ if (p.kind === "SglQuoted" && !p.Dollar) return p.Value ?? null;
5560
+ if (p.kind === "DblQuoted") {
5561
+ const inner = p.Parts ?? [];
5562
+ return inner.length === 1 && inner[0].kind === "Lit" ? inner[0].Value ?? null : null;
5563
+ }
5564
+ return null;
5565
+ };
5566
+ let ifsTouched = false;
5567
+ walk(f, (node) => {
5568
+ if (!node) return false;
5569
+ const kind = node.kind;
5570
+ if (kind === "FuncDecl" && node.Name?.Value) give(node.Name.Value, node.Name.Value);
5571
+ if (kind === "Assign" && node.Name?.Value) {
5572
+ const name = node.Name.Value;
5573
+ if (name === "IFS") ifsTouched = true;
5574
+ if (node.Append) values.set(name, null);
5575
+ else if (node.Array) {
5576
+ arrays.add(name);
5577
+ for (const el of node.Array.Elems ?? []) give(name, literalOnly(el.Value));
5578
+ } else if (node.Index) {
5579
+ arrays.add(name);
5580
+ give(name, node.Value ? literalOnly(node.Value) : null);
5581
+ } else give(name, node.Value ? literalOnly(node.Value) : null);
5582
+ }
5583
+ if (kind === "ForClause" && node.Loop?.Name?.Value) values.set(node.Loop.Name.Value, null);
5584
+ if (kind === "CallExpr") {
5585
+ const words = (node.Args ?? []).map((a) => resolveWordLiteral(a));
5586
+ if (VARIABLE_READERS.has(words[0] ?? "")) {
5587
+ for (const w of words.slice(1)) if (w && /^[A-Za-z_]\w*$/.test(w)) values.set(w, null);
5588
+ }
5589
+ }
5590
+ return true;
5591
+ });
5592
+ if (ifsTouched) return /* @__PURE__ */ new Set();
5593
+ const functions = /* @__PURE__ */ new Set();
5594
+ walk(f, (node) => {
5595
+ if (node && node.kind === "FuncDecl" && node.Name?.Value) functions.add(node.Name.Value);
5596
+ return true;
5597
+ });
5598
+ const callable = (v) => functions.has(v) || v === "FUNCNAME" || v === "true" || v === "false" || v === ":";
5599
+ for (const [name, vals] of values) {
5600
+ if (vals && ![...vals].every(callable)) values.set(name, null);
5601
+ }
5602
+ const known = /* @__PURE__ */ new Set();
5603
+ for (const [name, vals] of values)
5604
+ if (vals && (vals.size === 1 || arrays.has(name) && vals.size > 0)) known.add(name);
5605
+ return known;
5606
+ }
5607
+ function expansionName(part) {
5608
+ if (part.kind !== "ParamExp") return null;
5609
+ if (part.Excl || part.Length || part.Width || part.Slice || part.Repl || part.Exp) return null;
5610
+ return part.Param?.Value ?? null;
5611
+ }
5612
+ function executableParts(word, assigned, quoted = false, known = EMPTY_NAMES) {
5518
5613
  return (word?.Parts ?? []).flatMap((part) => {
5519
5614
  const kind = part.kind;
5520
- if (kind === "DblQuoted") return executableParts(part, assigned, true);
5615
+ if (kind === "DblQuoted") return executableParts(part, assigned, true, known);
5521
5616
  if (kind === "Lit") return [{ kind: "Lit", value: part.Value ?? "", quoted }];
5617
+ const name = expansionName(part);
5618
+ if (name !== null && (known.has(name) || name === "FUNCNAME"))
5619
+ return [{ kind: "Lit", value: name, quoted }];
5620
+ if (name !== null) {
5621
+ const bound = recordedExpansion(name === "@" || name === "*" ? "1" : name);
5622
+ if (typeof bound === "string" && PLAIN_PROGRAM_NAME.test(bound))
5623
+ return [{ kind: "Lit", value: bound, quoted }];
5624
+ }
5522
5625
  if (kind === "SglQuoted")
5523
5626
  return [{ kind: part.Dollar ? "Dynamic" : "Lit", value: part.Value ?? "", quoted: true }];
5524
5627
  if (kind === "ParamExp" && isDefaultExpansion(part) && !assigned.has(part.Param?.Value)) {
@@ -5526,14 +5629,14 @@ function executableParts(word, assigned, quoted = false) {
5526
5629
  if (fallback !== null) return [{ kind: "Lit", value: fallback, quoted }];
5527
5630
  }
5528
5631
  if (kind === "CmdSubst") {
5529
- const name = lookupSubstitution(part);
5530
- if (name !== null) return [{ kind: "Lit", value: name, quoted }];
5632
+ const name2 = lookupSubstitution(part);
5633
+ if (name2 !== null) return [{ kind: "Lit", value: name2, quoted }];
5531
5634
  }
5532
5635
  return [{ kind: "Dynamic", value: "", quoted }];
5533
5636
  });
5534
5637
  }
5535
- function opaqueExecutable(word, assigned) {
5536
- const parts = executableParts(word, assigned);
5638
+ function opaqueExecutable(word, assigned, known = EMPTY_NAMES) {
5639
+ const parts = executableParts(word, assigned, false, known);
5537
5640
  let lastSlash = -1;
5538
5641
  parts.forEach((p, i) => {
5539
5642
  if (p.kind === "Lit" && p.value.includes("/")) lastSlash = i;
@@ -6343,6 +6446,9 @@ var _listOps = null;
6343
6446
  function isListOp(op) {
6344
6447
  return listOps().has(op);
6345
6448
  }
6449
+ function isPipeOp(op) {
6450
+ return pipeOps().has(op);
6451
+ }
6346
6452
  function listOps() {
6347
6453
  if (_listOps) return _listOps;
6348
6454
  _listOps = new Set(
@@ -6618,6 +6724,33 @@ function isProtectedCodePath(p) {
6618
6724
  if (matchSensitivePath(p) !== null) return true;
6619
6725
  return SYSTEM_AUTH_FILES.includes(p) || SYSTEM_AUTH_DIRS.some((d) => p === d || p.startsWith(d + "/"));
6620
6726
  }
6727
+ function isJailedCodePath(literal, jailPaths) {
6728
+ const value = trimTrailingSlashes(literal.replace(/\\/g, "/"));
6729
+ if (!value) return false;
6730
+ for (const raw of jailPaths) {
6731
+ const jail = trimTrailingSlashes(raw.trim().replace(/\\/g, "/"));
6732
+ if (!jail) continue;
6733
+ const home = homeTail(jail);
6734
+ if (home === null) {
6735
+ if (value === jail || value.startsWith(jail + "/")) return true;
6736
+ continue;
6737
+ }
6738
+ if (!home) continue;
6739
+ const tail = homeTail(value);
6740
+ if (tail !== null && (tail === home || tail.startsWith(home + "/"))) return true;
6741
+ }
6742
+ return false;
6743
+ }
6744
+ function trimTrailingSlashes(s) {
6745
+ let end = s.length;
6746
+ while (end > 0 && s.charCodeAt(end - 1) === 47) end--;
6747
+ return s.slice(0, end);
6748
+ }
6749
+ function homeTail(p) {
6750
+ const m = /^(?:~|\$\{?HOME\}?|\/home\/[^/]+|\/Users\/[^/]+|\/root)(?:\/(.*))?$/.exec(p);
6751
+ if (!m) return null;
6752
+ return m[1] ?? "";
6753
+ }
6621
6754
  function inlineExecDescription(r) {
6622
6755
  const lead = r ? `The AI is running code directly from the command line: ${inlineExecReason(r).replace(/^This/, "this")}.` : "The AI is running code directly from the command line.";
6623
6756
  return `${lead} Review the full script below before allowing it to execute.`;
@@ -6626,7 +6759,8 @@ function inlineExecReason(r) {
6626
6759
  const who = r.interp ? `This inline ${r.interp} code` : "This inline code";
6627
6760
  return r.evidence ? `${who} ${r.what} (${r.evidence})` : `${who} ${r.what}`;
6628
6761
  }
6629
- function inlineExecReview(command) {
6762
+ function inlineExecReview(command, jailPaths = []) {
6763
+ const isProtected = jailPaths.length === 0 ? isProtectedCodePath : (p) => isProtectedCodePath(p) || isJailedCodePath(p, jailPaths);
6630
6764
  const calls = inlineExecCalls(command);
6631
6765
  if (calls === PARSE_FAIL) {
6632
6766
  return INLINE_EXEC_FALLBACK.test(command) ? { outcome: "unreadable", interp: "", what: "could not be parsed" } : null;
@@ -6649,7 +6783,7 @@ function inlineExecReview(command) {
6649
6783
  what: `is ${call.interp} code, which node9 does not read`
6650
6784
  };
6651
6785
  } else {
6652
- const judged = judgeInlineCode(language, code, isProtectedCodePath);
6786
+ const judged = judgeInlineCode(language, code, isProtected);
6653
6787
  if (judged) finding = { ...judged, interp: call.interp };
6654
6788
  }
6655
6789
  if (finding?.outcome === "dangerous") return finding;
@@ -7008,6 +7142,13 @@ function recordTopLevelStmt(stmt) {
7008
7142
  if (t === "DeclClause") return ASSIGNMENT_HEADS.has(stmt.Cmd.Variant?.Value ?? "");
7009
7143
  return (stmt.Cmd.Args || []).length === 0 && (stmt.Cmd.Assigns || []).length > 0;
7010
7144
  }
7145
+ var ARRAY_MARK = "array";
7146
+ var ARRAY_SEP = "";
7147
+ function arrayElements(value) {
7148
+ if (typeof value !== "string" || !value.startsWith(ARRAY_MARK)) return null;
7149
+ const body = value.slice(ARRAY_MARK.length);
7150
+ return body === "" ? [] : body.split(ARRAY_SEP);
7151
+ }
7011
7152
  function recordAssignments(n, at) {
7012
7153
  if (!assignmentTable) return;
7013
7154
  const t = n.kind;
@@ -7021,7 +7162,19 @@ function recordAssignments(n, at) {
7021
7162
  } else return;
7022
7163
  for (const a of assigns) {
7023
7164
  const name = a?.Name?.Value;
7024
- if (!name || !a.Value || a.Append) continue;
7165
+ if (!name) continue;
7166
+ if (a.Array) {
7167
+ const elems = (a.Array.Elems || []).map(
7168
+ (e) => e?.Index ? null : resolveWordLiteral(e?.Value)
7169
+ );
7170
+ const literal = elems.every((v) => v !== null);
7171
+ assignmentTable.set(name, {
7172
+ value: literal && !a.Append ? ARRAY_MARK + elems.join(ARRAY_SEP) : null,
7173
+ at
7174
+ });
7175
+ continue;
7176
+ }
7177
+ if (!a.Value || a.Append) continue;
7025
7178
  assignmentTable.set(name, { value: resolveWordLiteral(a.Value), at });
7026
7179
  }
7027
7180
  }
@@ -7032,7 +7185,33 @@ function resolveTrivialSubst(part) {
7032
7185
  const st = stmts[0];
7033
7186
  if ((st.Redirs || []).length > 0 || st.Negated || st.Background) return void 0;
7034
7187
  const cmd = st.Cmd;
7035
- if (!cmd || cmd.kind !== "CallExpr") return void 0;
7188
+ if (!cmd) return void 0;
7189
+ if (cmd.kind === "BinaryCmd" && pipeOps().has(cmd.Op)) {
7190
+ const left = cmd.X?.Cmd;
7191
+ const right = cmd.Y?.Cmd;
7192
+ if (!left || !right || left.kind !== "CallExpr" || right.kind !== "CallExpr") return void 0;
7193
+ if ((cmd.X.Redirs || []).length > 0 || (cmd.Y.Redirs || []).length > 0) return void 0;
7194
+ const input = trivialCallOutput(left);
7195
+ if (input === void 0) return void 0;
7196
+ const filter = (right.Args || []).map((a) => resolveWordLiteral(a));
7197
+ if (filter.some((w) => w === null)) return void 0;
7198
+ const f = baseWord(filter[0]);
7199
+ const flags = filter.slice(1);
7200
+ if (f === "base64" && flags.length === 1 && /^(-d|-D|--decode)$/.test(flags[0])) {
7201
+ try {
7202
+ const out = Buffer.from(input, "base64").toString("utf8");
7203
+ return /^[\x20-\x7e]*$/.test(out) ? out : void 0;
7204
+ } catch {
7205
+ return void 0;
7206
+ }
7207
+ }
7208
+ if (f === "rev" && flags.length === 0) return [...input].reverse().join("");
7209
+ return void 0;
7210
+ }
7211
+ if (cmd.kind !== "CallExpr") return void 0;
7212
+ return trivialCallOutput(cmd);
7213
+ }
7214
+ function trivialCallOutput(cmd) {
7036
7215
  if ((cmd.Assigns || []).length > 0) return void 0;
7037
7216
  const words = (cmd.Args || []).map((a) => resolveWordLiteral(a));
7038
7217
  if (words.length === 0 || words.some((w) => w === null)) return void 0;
@@ -7044,9 +7223,16 @@ function resolveTrivialSubst(part) {
7044
7223
  return rest.slice(i).join(" ");
7045
7224
  }
7046
7225
  if (head === "printf") {
7226
+ if (rest.length === 1 && /^(?:\\(?:[0-7]{1,3}|x[0-9A-Fa-f]{1,2}))+$/.test(rest[0])) {
7227
+ return rest[0].replace(
7228
+ /\\(?:x([0-9A-Fa-f]{1,2})|([0-7]{1,3}))/g,
7229
+ (_, hex, oct) => String.fromCharCode(hex ? parseInt(hex, 16) : parseInt(oct, 8))
7230
+ );
7231
+ }
7047
7232
  if (rest.length !== 2) return void 0;
7048
- if (!/^%s(\\n)?$/.test(rest[0])) return void 0;
7049
- return rest[1];
7233
+ const m = /^([^%]*)%s([^%]*?)(\\n)?$/.exec(rest[0]);
7234
+ if (!m) return void 0;
7235
+ return m[1] + rest[1] + m[2];
7050
7236
  }
7051
7237
  return void 0;
7052
7238
  }
@@ -7060,11 +7246,28 @@ function isPlainParam(p) {
7060
7246
  if (p.kind !== "ParamExp") return false;
7061
7247
  return !(p.Excl || p.Length || p.Width || p.Index || p.Slice || p.Repl || p.Exp);
7062
7248
  }
7249
+ function indexedParam(p) {
7250
+ if (p.kind !== "ParamExp" || !p.Index) return null;
7251
+ if (p.Excl || p.Length || p.Width || p.Slice || p.Repl || p.Exp) return null;
7252
+ const index = resolveWordLiteral(p.Index);
7253
+ const name = p.Param?.Value;
7254
+ return name && index !== null ? { name, index } : null;
7255
+ }
7063
7256
  function expandPlainParam(p) {
7064
7257
  if (!assignmentTable) return void 0;
7258
+ const indexed = indexedParam(p);
7259
+ if (indexed) {
7260
+ const elems = arrayElements(recordedExpansion(indexed.name));
7261
+ if (elems === null) return void 0;
7262
+ if (indexed.index === "@" || indexed.index === "*") return elems.join(" ");
7263
+ return /^\d+$/.test(indexed.index) ? elems[Number(indexed.index)] ?? null : null;
7264
+ }
7065
7265
  if (!isPlainParam(p)) return void 0;
7066
7266
  const recorded = recordedExpansion(p.Param?.Value);
7067
- if (recorded !== void 0) return recorded;
7267
+ if (recorded !== void 0) {
7268
+ const elems = arrayElements(recorded);
7269
+ return elems === null ? recorded : elems[0] ?? "";
7270
+ }
7068
7271
  return HOME_VARIABLES.has(p.Param?.Value) ? "~" : void 0;
7069
7272
  }
7070
7273
  var MAX_CALL_DEPTH2 = 4;
@@ -13502,7 +13705,22 @@ var GitWalk = class {
13502
13705
  found;
13503
13706
  /** Aliases defined earlier in this command: name -> value (null = dynamic). */
13504
13707
  aliases = /* @__PURE__ */ new Map();
13708
+ /** node9Firewall#385: variables assigned a tree-top word (`scope="$PWD"`,
13709
+ * `root=$(git rev-parse --show-toplevel)`, `DIR=$(pwd)`), so the
13710
+ * variable reads as the top where it is used. */
13711
+ treeTopVars = /* @__PURE__ */ new Set();
13712
+ /** node9Firewall#385 (c): a string a script builds with `+=` from
13713
+ * literals (`mode=--ha; mode+=rd`). The jail's table does not follow an
13714
+ * append (JAIL-14a); the git rules read the built word, since a flag
13715
+ * spelled in two halves is still that flag. name -> value, null once a
13716
+ * half is unknown. */
13717
+ appended = /* @__PURE__ */ new Map();
13505
13718
  payloads = /* @__PURE__ */ new Set();
13719
+ /** node9Firewall#385 (a): the text this command writes to each path
13720
+ * (`cat > /tmp/x.sh <<'SH' ... SH`, `echo '...' > f`, `>>` appends), so
13721
+ * a later statement that runs the path (`bash f`, `sh f`, `./f`) is
13722
+ * judged on what it runs. null once a write to the path is unknown. */
13723
+ written = /* @__PURE__ */ new Map();
13506
13724
  /** `for NAME in a b c`: the literal items, or null when one is dynamic. */
13507
13725
  loopVars = /* @__PURE__ */ new Map();
13508
13726
  /** Walk one command string. Returns false when it did not parse. */
@@ -13521,6 +13739,25 @@ var GitWalk = class {
13521
13739
  const type = n.kind;
13522
13740
  if (type === "Stmt") {
13523
13741
  this.visitHeredocShell(n, depth);
13742
+ this.visitPipeline(n, depth);
13743
+ this.visitHookWrite(n);
13744
+ this.recordScriptWrite(n);
13745
+ this.visitWrittenScript(n, depth);
13746
+ return true;
13747
+ }
13748
+ if (type === "Assign" && n.Name?.Value && n.Value) {
13749
+ const name = n.Name.Value;
13750
+ if (n.Append) {
13751
+ const prev = this.appended.has(name) ? this.appended.get(name) : resolveWordLiteral(n.Value) === null ? null : void 0;
13752
+ const base2 = prev === void 0 ? recordedExpansion(name) : prev;
13753
+ const piece = resolveWordLiteral(n.Value);
13754
+ this.appended.set(name, typeof base2 === "string" && piece !== null ? base2 + piece : null);
13755
+ this.treeTopVars.delete(name);
13756
+ return true;
13757
+ }
13758
+ this.appended.delete(name);
13759
+ if (treeTopWord(n.Value, this.treeTopVars)) this.treeTopVars.add(name);
13760
+ else this.treeTopVars.delete(name);
13524
13761
  return true;
13525
13762
  }
13526
13763
  if (type === "ForClause") {
@@ -13549,13 +13786,13 @@ var GitWalk = class {
13549
13786
  const param = plainParamName(rawArgs[loopArg]);
13550
13787
  for (const item of this.loopVars.get(param.name)) {
13551
13788
  const words2 = rawArgs.flatMap(
13552
- (a, i) => i === loopArg ? param.quoted ? [item] : splitFields(item) : resolveGitWords(a)
13789
+ (a, i) => i === loopArg ? param.quoted ? [item] : splitFields(item) : resolveGitWords(a, this.treeTopVars, this.appended)
13553
13790
  );
13554
13791
  this.visitWords(words2, new Map(prefixEnv), depth, false);
13555
13792
  }
13556
13793
  return true;
13557
13794
  }
13558
- const words = rawArgs.flatMap((a) => resolveGitWords(a));
13795
+ const words = rawArgs.flatMap((a) => resolveGitWords(a, this.treeTopVars, this.appended));
13559
13796
  this.visitWords(words, prefixEnv, depth, false);
13560
13797
  return true;
13561
13798
  }
@@ -13580,6 +13817,23 @@ var GitWalk = class {
13580
13817
  if (f) this.found(f);
13581
13818
  return;
13582
13819
  }
13820
+ if (headWord === "rm" || headWord === "unlink") {
13821
+ if (words.slice(head + 1).some((w) => w !== null && isLiveHookFile(w)))
13822
+ this.found(hooksBypassed(shownOf(words)));
13823
+ return;
13824
+ }
13825
+ if (headWord === "mv") {
13826
+ const operands2 = words.slice(head + 1).filter((w) => w === null || !w.startsWith("-"));
13827
+ const src = operands2[0];
13828
+ if (typeof src === "string" && isLiveHookFile(src)) this.found(hooksBypassed(shownOf(words)));
13829
+ return;
13830
+ }
13831
+ if (headWord === "perl") {
13832
+ const code = words.slice(head + 1).find((w) => w !== null && /\brename\b/.test(w));
13833
+ const m = code ? /rename\s*\(?\s*q[qw]?\s*[(\[{<'"]([^)\]}>'"]+)/.exec(code) : null;
13834
+ if (m && isLiveHookFile(m[1])) this.found(hooksBypassed(shownOf(words)));
13835
+ return;
13836
+ }
13583
13837
  if (depth < MAX_PAYLOAD_DEPTH2) {
13584
13838
  const payload = literalShellPayload(words, baseWord(words[0]));
13585
13839
  if (payload !== null) this.runPayload(payload, depth);
@@ -13590,6 +13844,127 @@ var GitWalk = class {
13590
13844
  this.payloads.add(payload);
13591
13845
  this.run(payload, depth + 1);
13592
13846
  }
13847
+ /**
13848
+ * node9Firewall#385: a pipeline whose last stage reads its pathspec from
13849
+ * stdin (`git add --pathspec-from-file=-`) or runs git over the names it
13850
+ * is fed (`xargs -0 git add --`), with a producer that is one literal
13851
+ * (`git rev-parse --show-toplevel`, `printf '%s\0' .`): the literal is
13852
+ * the operand, and the call is judged with it.
13853
+ */
13854
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13855
+ visitPipeline(stmt, depth) {
13856
+ const cmd = stmt.Cmd;
13857
+ if (!cmd || cmd.kind !== "BinaryCmd" || !isPipeOp(cmd.Op)) return;
13858
+ const stages = [];
13859
+ let cur = cmd;
13860
+ while (cur?.kind === "BinaryCmd" && isPipeOp(cur.Op)) {
13861
+ stages.unshift(cur.Y);
13862
+ const left = cur.X;
13863
+ if (left?.Cmd?.kind === "BinaryCmd" && isPipeOp(left.Cmd.Op)) cur = left.Cmd;
13864
+ else {
13865
+ stages.unshift(left);
13866
+ break;
13867
+ }
13868
+ }
13869
+ if (stages.length < 2) return;
13870
+ const producer = stages[stages.length - 2]?.Cmd;
13871
+ const consumer = stages[stages.length - 1]?.Cmd;
13872
+ if (!producer || !consumer || producer.kind !== "CallExpr" || consumer.kind !== "CallExpr")
13873
+ return;
13874
+ const fed = producedLiteral(producer);
13875
+ if (fed === null) return;
13876
+ const words = (consumer.Args || []).flatMap(
13877
+ (a) => resolveGitWords(a, this.treeTopVars, this.appended)
13878
+ );
13879
+ const head = unwrapCommandHead(words);
13880
+ const viaXargs = words.slice(0, head).some((w) => baseWord(w) === "xargs");
13881
+ const fromFile = words.findIndex(
13882
+ (w) => w === "--pathspec-from-file=-" || w === "--pathspec-from-file"
13883
+ );
13884
+ if (!viaXargs && fromFile < 0) return;
13885
+ let fedWords;
13886
+ if (fromFile >= 0) {
13887
+ fedWords = words.filter(
13888
+ (w, k) => !(k === fromFile || w === "-" && words[k - 1] === "--pathspec-from-file")
13889
+ );
13890
+ fedWords.push(fed);
13891
+ } else fedWords = [...words, fed];
13892
+ this.visitWords(fedWords, /* @__PURE__ */ new Map(), depth, false);
13893
+ }
13894
+ /**
13895
+ * node9Firewall#385 (e): a hook file written with a body that checks
13896
+ * nothing (`cat > .githooks/pre-commit <<'SH' exit 0 SH`, `echo 'exit 0'
13897
+ * > .git/hooks/pre-push`, `: > .githooks/pre-commit`). A real body (a
13898
+ * test, a linter) is ordinary work on the hooks.
13899
+ */
13900
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13901
+ visitHookWrite(stmt) {
13902
+ const cmd = stmt.Cmd;
13903
+ if (!cmd || cmd.kind !== "CallExpr") return;
13904
+ const redirs = stmt.Redirs || [];
13905
+ const target = redirs.find((r) => r?.Word && !r.Hdoc && (r.N == null || r.N.Value === "1"));
13906
+ if (!target) return;
13907
+ const path2 = resolveWordLiteral(target.Word);
13908
+ if (path2 === null || !isLiveHookFile(path2)) return;
13909
+ const hdoc = redirs.find((r) => r?.Hdoc);
13910
+ const words = (cmd.Args || []).map((a) => resolveWordLiteral(a));
13911
+ const head = baseWord(words[0]);
13912
+ let body = null;
13913
+ if (hdoc) body = resolveWordLiteral(hdoc.Hdoc);
13914
+ else if (head === ":" || head === "true" || words.length === 0) body = "";
13915
+ else if (head === "echo" || head === "printf") {
13916
+ const rest = words.slice(1);
13917
+ body = rest.some((w) => w === null) ? null : rest.filter((w) => !/^-[neE]+$/.test(w)).join(" ");
13918
+ if (body !== null) body = body.replace(/\\n/g, "\n");
13919
+ }
13920
+ if (body !== null && hookBodyIsEmpty(body)) this.found(hooksBypassed(shownOf(words)));
13921
+ }
13922
+ /** A statement that writes a literal text to a path, by redirect. */
13923
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13924
+ recordScriptWrite(stmt) {
13925
+ const cmd = stmt.Cmd;
13926
+ if (!cmd || cmd.kind !== "CallExpr") return;
13927
+ const redirs = stmt.Redirs || [];
13928
+ const target = redirs.find((r) => r?.Word && !r.Hdoc && (r.N == null || r.N.Value === "1"));
13929
+ if (!target) return;
13930
+ const path2 = resolveWordLiteral(target.Word);
13931
+ if (path2 === null) return;
13932
+ const append = /^>>/.test(target.Op?.toString() ?? "") || redirOpIsAppend(target);
13933
+ const hdoc = redirs.find((r) => r?.Hdoc);
13934
+ const words = (cmd.Args || []).map((a) => resolveWordLiteral(a));
13935
+ const head = baseWord(words[0]);
13936
+ let text = null;
13937
+ if (hdoc && (head === "cat" || head === "tee")) text = resolveWordLiteral(hdoc.Hdoc);
13938
+ else if (head === "echo" || head === "printf") {
13939
+ const rest = words.slice(1);
13940
+ text = rest.some((w) => w === null) ? null : rest.filter((w) => !/^-[neE]+$/.test(w)).join(" ");
13941
+ if (text !== null && head === "printf") text = text.replace(/\\n/g, "\n");
13942
+ } else return;
13943
+ const prev = this.written.get(path2);
13944
+ if (text === null || append && prev === null) this.written.set(path2, null);
13945
+ else this.written.set(path2, append && typeof prev === "string" ? `${prev}
13946
+ ${text}` : text);
13947
+ }
13948
+ /** A statement that runs a path this command wrote: the text is the script. */
13949
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13950
+ visitWrittenScript(stmt, depth) {
13951
+ const cmd = stmt.Cmd;
13952
+ if (!cmd || cmd.kind !== "CallExpr" || this.written.size === 0 || depth >= MAX_PAYLOAD_DEPTH2)
13953
+ return;
13954
+ const words = (cmd.Args || []).map((a) => resolveWordLiteral(a));
13955
+ const head = unwrapCommandHead(words);
13956
+ const name = baseWord(words[head]);
13957
+ let ran = null;
13958
+ if (PAYLOAD_SHELLS.has(name) && name !== "eval") {
13959
+ const operand = words.slice(head + 1).find((w) => w === null || !w.startsWith("-"));
13960
+ if (typeof operand === "string") ran = operand;
13961
+ } else if (typeof words[head] === "string" && this.written.has(words[head])) {
13962
+ ran = words[head];
13963
+ }
13964
+ if (ran === null) return;
13965
+ const text = this.written.get(ran);
13966
+ if (typeof text === "string") this.runPayload(text, depth);
13967
+ }
13593
13968
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13594
13969
  visitHeredocShell(stmt, depth) {
13595
13970
  const cmd = stmt.Cmd;
@@ -13778,7 +14153,61 @@ function dynamicOptionWord(word) {
13778
14153
  if (/^--[a-z-]+=/.test(prefix) || /^-[cC]/.test(prefix)) return `${prefix}$\u2026`;
13779
14154
  return null;
13780
14155
  }
13781
- function resolveGitWords(word) {
14156
+ var NO_VARS = /* @__PURE__ */ new Set();
14157
+ var NO_APPENDS = /* @__PURE__ */ new Map();
14158
+ function arrayExpansionWords(word) {
14159
+ let parts = word?.Parts || [];
14160
+ if (parts.length === 1 && parts[0].kind === "DblQuoted") parts = parts[0].Parts || [];
14161
+ if (parts.length !== 1 || parts[0].kind !== "ParamExp" || !parts[0].Index) return null;
14162
+ const index = resolveWordLiteral(parts[0].Index);
14163
+ if (index !== "@" && index !== "*") return null;
14164
+ const elems = arrayElements(recordedExpansion(parts[0].Param?.Value));
14165
+ return elems;
14166
+ }
14167
+ function producedLiteral(call) {
14168
+ if ((call.Assigns || []).length > 0) return null;
14169
+ const words = (call.Args || []).map((a) => resolveWordLiteral(a));
14170
+ if (words.length === 0 || words.some((w) => w === null)) return null;
14171
+ const head = baseWord(words[0]);
14172
+ const rest = words.slice(1);
14173
+ if (head === "git" && rest[0] === "rev-parse" && rest[1] === "--show-toplevel" && rest.length === 2)
14174
+ return ":/";
14175
+ if (head === "echo") {
14176
+ let i = 0;
14177
+ while (i < rest.length && /^-[neE]+$/.test(rest[i])) i++;
14178
+ return rest.length - i === 1 ? rest[i] : null;
14179
+ }
14180
+ if (head === "printf" && rest.length === 2 && /^%s(\\[0n])?$/.test(rest[0])) return rest[1];
14181
+ return null;
14182
+ }
14183
+ function treeTopWord(word, treeTopVars = NO_VARS) {
14184
+ let parts = word?.Parts || [];
14185
+ if (parts.length === 1 && parts[0].kind === "DblQuoted") parts = parts[0].Parts || [];
14186
+ if (parts.length !== 1) return false;
14187
+ const p = parts[0];
14188
+ if (p.kind === "ParamExp") {
14189
+ const name = plainParamName(word)?.name;
14190
+ return name === "PWD" || name !== void 0 && treeTopVars.has(name);
14191
+ }
14192
+ if (p.kind !== "CmdSubst") return false;
14193
+ const stmts = p.Stmts || [];
14194
+ if (stmts.length !== 1 || !stmts[0].Cmd || stmts[0].Cmd.kind !== "CallExpr") return false;
14195
+ const words = (stmts[0].Cmd.Args || []).map((a) => resolveWordLiteral(a));
14196
+ if (words.some((w) => w === null)) return false;
14197
+ const head = baseWord(words[0]);
14198
+ if (head === "pwd") return words.length === 1 || words[1] === "-P" || words[1] === "-L";
14199
+ return head === "git" && words[1] === "rev-parse" && words[2] === "--show-toplevel";
14200
+ }
14201
+ function resolveGitWords(word, treeTopVars = NO_VARS, appended = NO_APPENDS) {
14202
+ if (treeTopWord(word, treeTopVars)) return [":/"];
14203
+ const plain = plainParamName(word);
14204
+ if (plain && appended.has(plain.name)) {
14205
+ const v = appended.get(plain.name);
14206
+ if (v === null || v === void 0) return [null];
14207
+ return plain.quoted ? [v] : splitFields(v);
14208
+ }
14209
+ const elems = arrayExpansionWords(word);
14210
+ if (elems !== null) return elems;
13782
14211
  const value = resolveWordLiteral(word);
13783
14212
  if (value === null) {
13784
14213
  if (isPositionalParam(word)) return boundPositionals() ?? [POSITIONAL2];
@@ -13944,6 +14373,8 @@ function classify(inv) {
13944
14373
  if (o.flags.has("-n") || o.flags.has("--dry-run")) break;
13945
14374
  const forced = o.flags.has("-f") || o.flags.has("--force") || o.flags.has("--force-with-lease") || o.flags.has("--force-if-includes") || o.flags.has("--mirror") || o.operands.some((r) => r.startsWith("+"));
13946
14375
  if (forced) found(FORCE_PUSH);
14376
+ const deletes = o.flags.has("-d") || o.flags.has("--delete") || o.operands.some((r) => /^:[^:]/.test(r));
14377
+ if (deletes) found(DESTRUCTIVE);
13947
14378
  break;
13948
14379
  }
13949
14380
  case "reset": {
@@ -13971,11 +14402,74 @@ function classify(inv) {
13971
14402
  if (o.flags.has("-d") || o.flags.has("--delete")) found(DESTRUCTIVE);
13972
14403
  break;
13973
14404
  }
14405
+ // node9Firewall#385: history and work discarded through plumbing. A ref
14406
+ // deleted by hand, a stash dropped, the reflog expired or pruned: the
14407
+ // commits behind them are gone the way `branch -D` loses them.
14408
+ case "update-ref": {
14409
+ const o = parseOptions(inv.args, "m", /* @__PURE__ */ new Set());
14410
+ if (o.flags.has("-d") && (o.dynamic || o.operands.some(isHistoryRef))) found(DESTRUCTIVE);
14411
+ break;
14412
+ }
14413
+ case "reflog": {
14414
+ const o = parseOptions(inv.args, "", /* @__PURE__ */ new Set());
14415
+ if (o.operands[0] === "expire" || o.operands[0] === "delete") found(DESTRUCTIVE);
14416
+ break;
14417
+ }
14418
+ case "gc": {
14419
+ if (inv.config.get("gc.reflogexpire") === "now") found(DESTRUCTIVE);
14420
+ break;
14421
+ }
14422
+ case "stash": {
14423
+ const o = parseOptions(inv.args, "", /* @__PURE__ */ new Set());
14424
+ if (o.operands[0] === "clear" || o.operands[0] === "drop") found(DESTRUCTIVE);
14425
+ break;
14426
+ }
14427
+ case "worktree": {
14428
+ const o = parseOptions(inv.args, "", /* @__PURE__ */ new Set());
14429
+ if (o.operands[0] === "remove" && (o.flags.has("-f") || o.flags.has("--force")))
14430
+ found(DESTRUCTIVE);
14431
+ break;
14432
+ }
14433
+ // The working tree overwritten: `restore` from another ref, a forced
14434
+ // checkout, or `checkout -- .` (every local change dropped). A bare
14435
+ // `restore .` or `checkout .` stays an ordinary undo, as pinned.
14436
+ case "restore": {
14437
+ const o = parseOptions(inv.args, "s", RESTORE_LONG_VALUE);
14438
+ const src = restoreSource(inv.args);
14439
+ const whole = o.dynamic || o.operands.some(wholeTree);
14440
+ if (src !== null && src !== "HEAD" && whole) found(DESTRUCTIVE);
14441
+ break;
14442
+ }
14443
+ case "checkout": {
14444
+ const o = parseOptions(inv.args, "bB", CHECKOUT_LONG_VALUE);
14445
+ const forced = o.flags.has("-f") || o.flags.has("--force");
14446
+ const dropAll = inv.args.includes("--") && o.operands.some(wholeTree);
14447
+ if (forced || dropAll) found(DESTRUCTIVE);
14448
+ break;
14449
+ }
13974
14450
  default:
13975
14451
  break;
13976
14452
  }
13977
14453
  return out;
13978
14454
  }
14455
+ function isExcludePathspec(operand) {
14456
+ return /^:[!^]/.test(operand) || /^:\([^)]*\bexclude\b[^)]*\)/.test(operand);
14457
+ }
14458
+ function restoreSource(args) {
14459
+ for (let i = 0; i < args.length; i++) {
14460
+ const w = args[i];
14461
+ if (w === null) continue;
14462
+ if (w.startsWith("--source=")) return w.slice("--source=".length);
14463
+ if (w === "--source" || w === "-s") return args[i + 1] ?? null;
14464
+ if (/^-s./.test(w)) return w.slice(2);
14465
+ }
14466
+ return null;
14467
+ }
14468
+ function isHistoryRef(ref) {
14469
+ return /^refs\/(heads|stash)(\/|$)/.test(ref);
14470
+ }
14471
+ var RESTORE_LONG_VALUE = /* @__PURE__ */ new Set(["--source", "--pathspec-from-file"]);
14472
+ var CHECKOUT_LONG_VALUE = /* @__PURE__ */ new Set(["--pathspec-from-file", "--orphan", "--conflict"]);
13979
14473
  var HOOKS_BYPASS = {
13980
14474
  checkId: "commands.git-hooks-bypass",
13981
14475
  ruleName: "review-git-hooks-bypass",
@@ -14042,6 +14536,7 @@ function hooksBypass(inv) {
14042
14536
  const o = parseOptions(inv.args, "mFCcut", COMMIT_LONG_VALUE);
14043
14537
  return o.flags.has("-n") || o.flags.has("--no-verify");
14044
14538
  }
14539
+ if (sub === "commit-tree") return true;
14045
14540
  if (sub !== void 0 && NO_VERIFY_SUBS.has(sub)) {
14046
14541
  return inv.args.some((a) => a === "--no-verify");
14047
14542
  }
@@ -14094,7 +14589,20 @@ function configWritesHooksPath(args) {
14094
14589
  return write;
14095
14590
  }
14096
14591
  function isHookPath(word) {
14097
- return /(^|[\\/])(\.git[\\/]hooks|\.husky)([\\/]|$)/.test(word);
14592
+ return /(^|[\\/])(\.git[\\/]hooks|\.husky|\.githooks)([\\/]|$)/.test(word);
14593
+ }
14594
+ function isLiveHookFile(word) {
14595
+ if (!isHookPath(word)) return false;
14596
+ const m = /(^|[\\/])(\.git[\\/]hooks|\.husky|\.githooks)(?:[\\/](.*))?$/.exec(word);
14597
+ if (!m) return false;
14598
+ const rest = m[3] ?? "";
14599
+ if (rest === "" || rest === "_") return true;
14600
+ const leaf = rest.replace(/^_[\\/]/, "");
14601
+ return /^[a-z-]+$/.test(leaf);
14602
+ }
14603
+ function hookBodyIsEmpty(text) {
14604
+ const lines = text.split(/\r?\n/).map((l) => l.trim()).filter((l) => l !== "" && !l.startsWith("#"));
14605
+ return lines.every((l) => /^(exit(\s+0)?|true|:|set\s+-[a-zA-Z]+|set\s+-o\s+\w+)$/.test(l));
14098
14606
  }
14099
14607
  var CHMOD_OPTION_RE = /^-[RvcfHLP]+$/;
14100
14608
  function modeRemovesExecute(mode) {
@@ -14104,6 +14612,23 @@ function modeRemovesExecute(mode) {
14104
14612
  }
14105
14613
  return mode.split(",").some((part) => /^[ugoa]*-[rwst]*x/.test(part));
14106
14614
  }
14615
+ function redirOpIsAppend(redir) {
14616
+ return redir?.Op === appendOp();
14617
+ }
14618
+ var _appendOp = null;
14619
+ function appendOp() {
14620
+ if (_appendOp !== null) return _appendOp;
14621
+ try {
14622
+ const f = parseShared("echo x >> y");
14623
+ _appendOp = typeof f === "symbol" ? -1 : f.Stmts[0].Redirs[0].Op;
14624
+ } catch {
14625
+ _appendOp = -1;
14626
+ }
14627
+ return _appendOp;
14628
+ }
14629
+ function hooksBypassed(shown) {
14630
+ return { ...HOOKS_BYPASS, shown, reason: `${HOOKS_BYPASS.reason}: ${shown}` };
14631
+ }
14107
14632
  function chmodDisarmsHook(args, shown) {
14108
14633
  let i = 0;
14109
14634
  while (i < args.length) {
@@ -14154,6 +14679,7 @@ function stagesEverything(inv) {
14154
14679
  const sub = inv.sub?.toLowerCase();
14155
14680
  const prefix = chdirPrefix(inv);
14156
14681
  const judge = (operands2) => {
14682
+ if (operands2.length > 0 && operands2.every(isExcludePathspec)) return {};
14157
14683
  let conditional = false;
14158
14684
  for (const operand of operands2) {
14159
14685
  if (!wholeTree(operand)) continue;
@@ -14498,7 +15024,7 @@ var PRESCREEN_RE = /\/dev\/(?:tcp|udp)|\b(?:nc|ncat|netcat|telnet|socat|s_client
14498
15024
  var MAX_PAYLOAD_DEPTH3 = 4;
14499
15025
  var CACHE_MAX2 = 1e3;
14500
15026
  var cache2 = /* @__PURE__ */ new Map();
14501
- function isPipeOp(op) {
15027
+ function isPipeOp2(op) {
14502
15028
  return !isListOp(op);
14503
15029
  }
14504
15030
  var dupInOp = null;
@@ -14750,7 +15276,7 @@ var OutboundWalk = class {
14750
15276
  this.visitStmt(n, depth);
14751
15277
  return true;
14752
15278
  }
14753
- if (type === "BinaryCmd" && isPipeOp(n.Op)) {
15279
+ if (type === "BinaryCmd" && isPipeOp2(n.Op)) {
14754
15280
  this.visitPipeline(n);
14755
15281
  return true;
14756
15282
  }
@@ -14851,7 +15377,7 @@ var OutboundWalk = class {
14851
15377
  const stages = [];
14852
15378
  const flatten = (s) => {
14853
15379
  const c = s?.Cmd;
14854
- if (c && c.kind === "BinaryCmd" && isPipeOp(c.Op)) {
15380
+ if (c && c.kind === "BinaryCmd" && isPipeOp2(c.Op)) {
14855
15381
  flatten(c.X);
14856
15382
  flatten(c.Y);
14857
15383
  } else stages.push(s);
@@ -17626,7 +18152,7 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
17626
18152
  if (v?.logged) noteLogged(v);
17627
18153
  else if (v) candidates.push(v);
17628
18154
  };
17629
- const inline = reviewsEveryInline(config.settings.mode) ? detectInlineExec(shellCommand) ? void 0 : null : inlineExecReview(shellCommand);
18155
+ const inline = reviewsEveryInline(config.settings.mode) ? detectInlineExec(shellCommand) ? void 0 : null : inlineExecReview(shellCommand, config.policy.jailPaths);
17630
18156
  if (inline !== null) {
17631
18157
  consider("commands.inline-exec", {
17632
18158
  decision: "review",
@@ -18113,7 +18639,7 @@ function* validCardRuns(text, base2, exemptFractions = true) {
18113
18639
  let m;
18114
18640
  while ((m = re.exec(text)) !== null) {
18115
18641
  const digits = m[0].replace(/\D/g, "");
18116
- const fraction = exemptFractions && isDecimalFraction(text, m.index, digits.length === m[0].length);
18642
+ const fraction = exemptFractions && (isDecimalFraction(text, m.index, digits.length === m[0].length) || isInteriorDotNumber(m[0]));
18117
18643
  if (!fraction && validateLuhn(digits)) {
18118
18644
  yield { index: m.index, length: m[0].length, digits };
18119
18645
  } else {
@@ -18140,6 +18666,12 @@ function replaceValidCards(text, replace, { exemptFractions = true } = {}) {
18140
18666
  }
18141
18667
  return out;
18142
18668
  }
18669
+ function isInteriorDotNumber(run) {
18670
+ const first = run.indexOf(".");
18671
+ if (first <= 0 || first === run.length - 1) return false;
18672
+ if (run.indexOf(".", first + 1) !== -1) return false;
18673
+ return !/[-\s]/.test(run);
18674
+ }
18143
18675
  function isDecimalFraction(text, index, unseparated) {
18144
18676
  if (!unseparated) return false;
18145
18677
  const sep = text[index - 1];
@@ -19465,8 +19997,8 @@ function matchCanaryArgs(args, values) {
19465
19997
 
19466
19998
  // src/scan/canonical.ts
19467
19999
  var LONG_OUTPUT_THRESHOLD_BYTES = 100 * 1024;
19468
- var CANONICAL_EXTRACTOR_VERSION = "canonical-v36";
19469
- var CANONICAL_EXTRACTOR_HASH = "5ed06e803cc1d365";
20000
+ var CANONICAL_EXTRACTOR_VERSION = "canonical-v37";
20001
+ var CANONICAL_EXTRACTOR_HASH = "2c9a0271d9c1dd57";
19470
20002
  var DEDUPE_PREVIEW_LEN = 120;
19471
20003
  function extractCanonicalFindings(call, ctx) {
19472
20004
  const out = [];