@node9/policy-engine 2.65.6 → 2.65.8

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.js CHANGED
@@ -79,12 +79,14 @@ __export(src_exports, {
79
79
  PATTERN_VERB_NAMES: () => PATTERN_VERB_NAMES,
80
80
  POSTURE_CATEGORY_OWASP: () => POSTURE_CATEGORY_OWASP,
81
81
  PRIVILEGE_ESCALATION_RE: () => PRIVILEGE_ESCALATION_RE,
82
+ PUBLIC_SSH_NAME_SOURCE: () => PUBLIC_SSH_NAME_SOURCE,
82
83
  REALTIME_PII_PATTERNS: () => REALTIME_PII_PATTERNS,
83
84
  REPLACED_SHIELDS: () => REPLACED_SHIELDS,
84
85
  SCAN_REPO_RULES_WITHOUT_RISK: () => SCAN_REPO_RULES_WITHOUT_RISK,
85
86
  SCAN_SIGNAL_WEIGHTS: () => SCAN_SIGNAL_WEIGHTS,
86
87
  SENSITIVE_PATH_RE: () => SENSITIVE_PATH_RE,
87
88
  SENSITIVE_PATH_REGEXES: () => SENSITIVE_PATH_REGEXES,
89
+ SHELL_INTERPRETERS: () => SHELL_INTERPRETERS,
88
90
  SSRF_MAX_HOST: () => SSRF_MAX_HOST,
89
91
  STARTUP_NAMES: () => STARTUP_NAMES,
90
92
  SYSTEM_AUTH_DIRS: () => SYSTEM_AUTH_DIRS,
@@ -185,6 +187,7 @@ __export(src_exports, {
185
187
  isPrivateHost: () => isPrivateHost,
186
188
  isProtectedHomePath: () => isProtectedHomePath,
187
189
  isPublicRegistryHost: () => isPublicRegistryHost,
190
+ isPublicSshMaterial: () => isPublicSshMaterial,
188
191
  isRecordOnly: () => isRecordOnly,
189
192
  isShellShapedTool: () => isShellShapedTool,
190
193
  isShieldVerdict: () => isShieldVerdict,
@@ -942,13 +945,27 @@ var project_jail_default = {
942
945
  {
943
946
  field: "file_path",
944
947
  op: "matches",
945
- value: "([\\/\\\\]\\.ssh([\\/\\\\]|$)|^\\.ssh[\\/\\\\])",
948
+ value: "([\\/\\\\]\\.ssh(?:$|[\\/\\\\](?!(?:known_hosts(?:\\.old)?|authorized_keys2?|[^\\\\/]+\\.pub)$))|^\\.ssh[\\/\\\\](?!(?:known_hosts(?:\\.old)?|authorized_keys2?|[^\\\\/]+\\.pub)$))",
946
949
  flags: "i"
947
950
  }
948
951
  ],
949
952
  verdict: "block",
950
953
  reason: "Reading SSH private keys is blocked by project-jail shield"
951
954
  },
955
+ {
956
+ name: "shield:project-jail:block-write-ssh-trust-files",
957
+ tool: "!(read|read_file|grep|grep_search)",
958
+ conditions: [
959
+ {
960
+ field: "file_path",
961
+ op: "matches",
962
+ value: "(?:^|[\\/\\\\])\\.ssh[\\/\\\\](?:known_hosts(?:\\.old)?|authorized_keys2?|[^\\\\/]+\\.pub)$",
963
+ flags: "i"
964
+ }
965
+ ],
966
+ verdict: "block",
967
+ reason: "Changing SSH keys and trusted hosts is blocked by project-jail shield"
968
+ },
952
969
  {
953
970
  name: "shield:project-jail:block-read-aws-any-tool",
954
971
  tool: "*",
@@ -2389,15 +2406,15 @@ function ssrfExemptMatches(entries, normalized) {
2389
2406
  continue;
2390
2407
  }
2391
2408
  if (!target) continue;
2392
- const base3 = bitsOf(normalizeIpLiteral(entry.slice(0, slash)) ?? "");
2409
+ const base4 = bitsOf(normalizeIpLiteral(entry.slice(0, slash)) ?? "");
2393
2410
  const prefixText = entry.slice(slash + 1);
2394
2411
  const prefix = /^\d+$/.test(prefixText) ? Number(prefixText) : NaN;
2395
- if (!base3 || !Number.isInteger(prefix) || prefix < 0 || // A v4 range never matches a v6 address, and the reverse: the widths
2412
+ if (!base4 || !Number.isInteger(prefix) || prefix < 0 || // A v4 range never matches a v6 address, and the reverse: the widths
2396
2413
  // differ, so `0.0.0.0/0` does not release `::1`.
2397
- base3.length !== target.length || prefix > base3.length) {
2414
+ base4.length !== target.length || prefix > base4.length) {
2398
2415
  continue;
2399
2416
  }
2400
- if (base3.slice(0, prefix) === target.slice(0, prefix)) return true;
2417
+ if (base4.slice(0, prefix) === target.slice(0, prefix)) return true;
2401
2418
  }
2402
2419
  return false;
2403
2420
  }
@@ -3678,7 +3695,7 @@ var LEGACY_TO_ID = new Map(
3678
3695
  function ssrfCheckId(tier) {
3679
3696
  return isStrictGatedTier(tier) ? "network.internal-addresses" : "network.metadata";
3680
3697
  }
3681
- var PROJECT_JAIL_BLOCK_READ = /^shield:project-jail:block-read-(ssh|aws|env)(-any-tool)?$/;
3698
+ var PROJECT_JAIL_BLOCK_READ = /^shield:project-jail:(?:block-read-(ssh|aws|env)(-any-tool)?|block-write-ssh-trust-files)$/;
3682
3699
  var OVERRIDE_PREFIX = "Override block rule:";
3683
3700
  var LABEL_WRAPPERS = ["Smart Rule:", "Node9 (AST):", "project-jail (AST):"];
3684
3701
  function ruleNameInLabel(s) {
@@ -4196,6 +4213,14 @@ function normalizeFilePath(p, cwd = "", home = "~") {
4196
4213
  }
4197
4214
  return (rooted ? "/" : "") + parts.join("/");
4198
4215
  }
4216
+ var PUBLIC_SSH_NAME_SOURCE = String.raw`(?:known_hosts(?:\.old)?|authorized_keys2?|[^\\/]+\.pub)`;
4217
+ var PUBLIC_SSH_PATH_RE = new RegExp(
4218
+ String.raw`(?:^|[\\/])\.ssh[\\/]${PUBLIC_SSH_NAME_SOURCE}$`,
4219
+ "i"
4220
+ );
4221
+ function isPublicSshMaterial(p) {
4222
+ return PUBLIC_SSH_PATH_RE.test(p);
4223
+ }
4199
4224
 
4200
4225
  // src/shell/index.ts
4201
4226
  var import_picomatch = __toESM(require("picomatch"));
@@ -4430,7 +4455,7 @@ function sedSubstitutions(script) {
4430
4455
  }
4431
4456
  return out.length > 0 ? out : null;
4432
4457
  }
4433
- function collectShellFileAccesses(command, context = {}) {
4458
+ function collectShellFileAccesses(command, context = {}, report) {
4434
4459
  const out = [];
4435
4460
  let payloads = 256;
4436
4461
  const functions = /* @__PURE__ */ new Map();
@@ -4456,7 +4481,11 @@ function collectShellFileAccesses(command, context = {}) {
4456
4481
  });
4457
4482
  }
4458
4483
  function nestedPayload(payload, state, depth) {
4459
- if (payload === null || depth >= MAX_PAYLOAD_DEPTH || payloads-- <= 0) return;
4484
+ if (payload === null) return;
4485
+ if (depth >= MAX_PAYLOAD_DEPTH || payloads-- <= 0) {
4486
+ if (report) report.exhausted = true;
4487
+ return;
4488
+ }
4460
4489
  const f = parseShared(payload);
4461
4490
  if (typeof f !== "symbol") statements(f.Stmts ?? [], state, depth + 1);
4462
4491
  }
@@ -5035,8 +5064,107 @@ function collectShellFileAccesses(command, context = {}) {
5035
5064
  }
5036
5065
  return null;
5037
5066
  }
5067
+ function heredocScript(word) {
5068
+ let text = "";
5069
+ for (const part of word?.Parts ?? []) {
5070
+ if (part?.kind === "Lit") {
5071
+ text += part.Value ?? "";
5072
+ continue;
5073
+ }
5074
+ text += resolveWordLiteral({ Parts: [part] }) ?? "$N9_UNRESOLVED";
5075
+ }
5076
+ return text;
5077
+ }
5078
+ function stdinScriptText(stmt) {
5079
+ for (const redir of stmt?.Redirs ?? []) {
5080
+ if (redir.Hdoc) return heredocScript(redir.Hdoc);
5081
+ if (redir.Op === ops().HERE_STRING) return resolveWordLiteral(redir.Word);
5082
+ }
5083
+ return null;
5084
+ }
5085
+ function printfText(stmt) {
5086
+ const cmd = stmt?.Cmd;
5087
+ if (!cmd || cmd.kind !== "CallExpr") return null;
5088
+ const words = (cmd.Args ?? []).map((a) => resolveWordLiteral(a));
5089
+ if (words.some((w) => w === null)) return null;
5090
+ const head = unwrapCommandHead(words);
5091
+ if (base(words[head]) !== "printf") return null;
5092
+ const rest = words.slice(head + 1);
5093
+ if (rest[0] === "--") rest.shift();
5094
+ if (rest.length === 0 || rest[0].startsWith("-")) return null;
5095
+ const [format, ...args] = rest;
5096
+ const directive = /%(?:%|[-+ #0]*(?:\d+|\*)?(?:\.(?:\d+|\*))?[a-zA-Z])/g;
5097
+ let text = "";
5098
+ let next = 0;
5099
+ for (let round = 0; round < 64; round++) {
5100
+ let used = false;
5101
+ text += format.replace(directive, (d) => {
5102
+ if (d === "%%") return "%";
5103
+ used = true;
5104
+ return args[next++] ?? "";
5105
+ });
5106
+ if (!used || next >= args.length) break;
5107
+ }
5108
+ return text;
5109
+ }
5110
+ function soleStatement(stmt) {
5111
+ let cur = stmt;
5112
+ for (let i = 0; i < 8; i++) {
5113
+ const cmd = cur?.Cmd;
5114
+ if (!cmd || cmd.kind !== "Subshell" && cmd.kind !== "Block") break;
5115
+ if ((cur.Redirs ?? []).length > 0 || (cmd.Stmts ?? []).length !== 1) break;
5116
+ cur = cmd.Stmts[0];
5117
+ }
5118
+ return cur;
5119
+ }
5120
+ function passesStdinThrough(stmt, depth = 0) {
5121
+ const cmd = stmt?.Cmd;
5122
+ if (cmd && (cmd.kind === "Subshell" || cmd.kind === "Block"))
5123
+ return depth <= 4 && (stmt.Redirs ?? []).length === 0 && (cmd.Stmts ?? []).some((inner) => passesStdinThrough(inner, depth + 1));
5124
+ if (!cmd || cmd.kind !== "CallExpr") return false;
5125
+ const words = (cmd.Args ?? []).map((a) => resolveWordLiteral(a));
5126
+ const head = unwrapCommandHead(words);
5127
+ const name = base(words[head]);
5128
+ const rest = words.slice(head + 1);
5129
+ if (name === "tee") return true;
5130
+ return name === "cat" && rest.every((w) => w === "-" || w !== null && /^-[A-Za-z]+$/.test(w));
5131
+ }
5132
+ function producedScripts(stmt, depth = 0) {
5133
+ const cmd = stmt?.Cmd;
5134
+ if (!cmd) return [];
5135
+ if (cmd.kind === "Subshell" || cmd.kind === "Block") {
5136
+ if (depth > 4 || (stmt.Redirs ?? []).length > 0) return [];
5137
+ const first = [];
5138
+ const last = [];
5139
+ for (const inner of cmd.Stmts ?? []) {
5140
+ const readings = producedScripts(inner, depth + 1);
5141
+ if (readings.length === 0) continue;
5142
+ first.push(readings[0]);
5143
+ last.push(readings[readings.length - 1]);
5144
+ }
5145
+ if (first.length === 0) return [];
5146
+ const a = first.join("\n");
5147
+ const b = last.join("\n");
5148
+ return a === b ? [a] : [a, b];
5149
+ }
5150
+ if (cmd.kind !== "CallExpr") return [];
5151
+ const words = (cmd.Args ?? []).map((w) => resolveWordLiteral(w));
5152
+ if (words.length === 1 && base(words[0]) === "cat") {
5153
+ const text2 = stdinScriptText(stmt);
5154
+ return text2 === null ? [] : [text2];
5155
+ }
5156
+ const formatted = printfText(stmt);
5157
+ if (formatted !== null) return [decodeAnsiC(formatted)];
5158
+ const text = producedText(stmt);
5159
+ if (text === null) return [];
5160
+ if (!text.includes("\\")) return [text];
5161
+ const head = unwrapCommandHead(words);
5162
+ const decodes = words.slice(head + 1).some((w) => w !== null && /^-[neE]+$/.test(w) && w.includes("e"));
5163
+ const decoded = decodeAnsiC(text);
5164
+ return decodes || decoded === text ? [decoded] : [text, decoded];
5165
+ }
5038
5166
  function stdinScript(stmt, state, depth) {
5039
- if (readsScriptFromStdin(stmt)) nestedPayload(stdinText(stmt), clone(state), depth);
5167
+ if (readsScriptFromStdin(stmt)) nestedPayload(stdinScriptText(stmt), clone(state), depth);
5040
5168
  }
5041
5169
  function statement(stmt, state, depth) {
5042
5170
  if (!stmt || depth > MAX_DEPTH) return;
@@ -5091,18 +5219,23 @@ function collectShellFileAccesses(command, context = {}) {
5091
5219
  }
5092
5220
  const seen = clone(state);
5093
5221
  let pureAnd = true;
5222
+ let flowing = [];
5094
5223
  segments2.forEach(({ op, part }, i) => {
5095
5224
  if (op === ops().AND || op === ops().OR) {
5096
5225
  if (i > 0 && op === ops().AND && pureAnd && state.onSuccess)
5097
5226
  state.cwd = state.onSuccess;
5098
5227
  if (i > 0 && op === ops().OR) merge(state, seen);
5228
+ flowing = [];
5099
5229
  statement(part, state, depth + 1);
5100
5230
  } else {
5101
5231
  const fed = i > 0 ? producedText(segments2[i - 1].part) : null;
5102
5232
  if (fed !== null) pipedStdin.set(part, fed);
5103
5233
  statement(part, clone(state), depth + 1);
5104
- if (i > 0 && readsScriptFromStdin(part))
5105
- nestedPayload(producedText(segments2[i - 1].part), clone(state), depth);
5234
+ const incoming = i > 0 ? flowing : [];
5235
+ if (i > 0 && readsScriptFromStdin(soleStatement(part)))
5236
+ for (const script of incoming) nestedPayload(script, clone(state), depth);
5237
+ const own = producedScripts(part);
5238
+ flowing = [...passesStdinThrough(part) ? incoming : [], ...own].slice(0, 4);
5106
5239
  if (fed !== null) nestedPayload(xargsPayload(part, fed), clone(state), depth);
5107
5240
  }
5108
5241
  if (i > 0 && op !== ops().AND) pureAnd = false;
@@ -5182,6 +5315,140 @@ function collectShellFileAccesses(command, context = {}) {
5182
5315
  return out;
5183
5316
  }
5184
5317
 
5318
+ // src/shell/dotenv-cli.ts
5319
+ var base2 = (w) => (w ?? "").split(/[\\/]/).pop()?.toLowerCase() ?? "";
5320
+ var FILE_FLAGS = /* @__PURE__ */ new Set(["-f", "--file", "-e", "--env-file"]);
5321
+ var VALUE_FLAGS = /* @__PURE__ */ new Set([
5322
+ "-q",
5323
+ "--quote",
5324
+ "-v",
5325
+ "--env",
5326
+ "-fk",
5327
+ "--env-keys-file",
5328
+ "--convention",
5329
+ "--log-level"
5330
+ ]);
5331
+ var QUIET_SUBCOMMANDS = /* @__PURE__ */ new Set([
5332
+ "set",
5333
+ "unset",
5334
+ "encrypt",
5335
+ "ls",
5336
+ "help",
5337
+ "version",
5338
+ "rotate",
5339
+ "genexample",
5340
+ "gitignore",
5341
+ "prebuild",
5342
+ "precommit",
5343
+ "keypair",
5344
+ "ext"
5345
+ ]);
5346
+ function filesAfter(words, from, files) {
5347
+ for (let j = from; j < words.length; j++) {
5348
+ const w = words[j];
5349
+ if (w === null) continue;
5350
+ if (FILE_FLAGS.has(w)) {
5351
+ if (words[j + 1] !== void 0) files.push(words[j + 1]);
5352
+ j++;
5353
+ continue;
5354
+ }
5355
+ const joined = /^(?:--file|--env-file)=(.*)$/.exec(w);
5356
+ if (joined) files.push(joined[1]);
5357
+ }
5358
+ }
5359
+ function dotenvArgsStart(words, head) {
5360
+ const name = base2(words[head]);
5361
+ if (name === "dotenv" || name === "dotenv-cli" || name === "dotenvx") return head + 1;
5362
+ if (name === "bundle" && words[head + 1] === "exec" && base2(words[head + 2]) === "dotenv")
5363
+ return head + 3;
5364
+ if (/^(?:python[\d.]*|py)$/.test(name)) {
5365
+ for (let i = head + 1; i < words.length; i++) {
5366
+ const w = words[i];
5367
+ if (w === null || !w.startsWith("-")) return -1;
5368
+ if (w === "-m") return words[i + 1] === "dotenv" ? i + 2 : -1;
5369
+ if (w === "-c") return -1;
5370
+ }
5371
+ }
5372
+ return -1;
5373
+ }
5374
+ function readDotenvCli(words, head) {
5375
+ const start = dotenvArgsStart(words, head);
5376
+ if (start < 0) return null;
5377
+ const files = [];
5378
+ let print = false;
5379
+ let sawRun = false;
5380
+ let inner = -1;
5381
+ let i = start;
5382
+ while (i < words.length) {
5383
+ const w = words[i];
5384
+ if (w === null) {
5385
+ inner = i;
5386
+ break;
5387
+ }
5388
+ if (w === "--") {
5389
+ inner = i + 1;
5390
+ break;
5391
+ }
5392
+ if (FILE_FLAGS.has(w)) {
5393
+ const value = words[i + 1];
5394
+ if (!(w === "-e" && (value === "true" || value === "false")) && value !== void 0)
5395
+ files.push(value);
5396
+ i += 2;
5397
+ continue;
5398
+ }
5399
+ const joined = /^(?:--file|--env-file)=(.*)$/.exec(w);
5400
+ if (joined) {
5401
+ files.push(joined[1]);
5402
+ i++;
5403
+ continue;
5404
+ }
5405
+ if (w === "-p" || w === "--print") {
5406
+ print = true;
5407
+ i += 2;
5408
+ continue;
5409
+ }
5410
+ if (VALUE_FLAGS.has(w)) {
5411
+ i += 2;
5412
+ continue;
5413
+ }
5414
+ if (w === "-c" || w === "--cascade") {
5415
+ const value = words[i + 1];
5416
+ const after = words[i + 2];
5417
+ const takes = typeof value === "string" && !value.startsWith("-") && typeof after === "string" && after.startsWith("-");
5418
+ i += takes ? 2 : 1;
5419
+ continue;
5420
+ }
5421
+ if (w.startsWith("-")) {
5422
+ i++;
5423
+ continue;
5424
+ }
5425
+ if (!sawRun) {
5426
+ if (w === "list" || w === "get") {
5427
+ print = true;
5428
+ filesAfter(words, i + 1, files);
5429
+ break;
5430
+ }
5431
+ if (w === "run") {
5432
+ sawRun = true;
5433
+ i++;
5434
+ continue;
5435
+ }
5436
+ if (w === "decrypt") {
5437
+ print = words.slice(i + 1).some((x) => x === "--stdout");
5438
+ filesAfter(words, i + 1, files);
5439
+ break;
5440
+ }
5441
+ if (QUIET_SUBCOMMANDS.has(w)) return null;
5442
+ }
5443
+ inner = i;
5444
+ break;
5445
+ }
5446
+ const loaded = files.length > 0 ? files : [".env"];
5447
+ if (print) return { files: loaded, mode: "print", inner: -1 };
5448
+ if (inner >= 0 && inner < words.length) return { files: loaded, mode: "run", inner };
5449
+ return null;
5450
+ }
5451
+
5185
5452
  // src/shell/services.ts
5186
5453
  var INFRASTRUCTURE_SERVICES = [
5187
5454
  "init",
@@ -5541,8 +5808,19 @@ var DOTENV = {
5541
5808
  values: /\b(?:dotenv_values|get_key)\s*\(/,
5542
5809
  env: /\b(?:environ|getenv)\b/,
5543
5810
  literalPath: /\b(?:load_dotenv|dotenv_values)\s*\(\s*(?:dotenv_path\s*=\s*)?[rRbBuU]?['"]/
5811
+ },
5812
+ // Ruby's dotenv gem (node9Firewall#443): `require "dotenv/load"` loads on
5813
+ // require; `require "dotenv"` alone does not, it needs Dotenv.load.
5814
+ ruby: {
5815
+ load: /\brequire\s*\(?\s*['"]dotenv\/load['"]|\bDotenv\s*\.\s*(?:load|overload|parse)\b/,
5816
+ values: /\bDotenv\s*\.\s*parse\b/,
5817
+ env: /\bENV\b/,
5818
+ literalPath: /\bDotenv\s*\.\s*(?:load|overload|parse)\s*\(?\s*['"]/
5544
5819
  }
5545
5820
  };
5821
+ function inlineReadsEnvironment(language, code) {
5822
+ return language === "python" || language === "node" || language === "ruby" ? DOTENV[language].env.test(code) : false;
5823
+ }
5546
5824
  var DOTENV_PATH_OPTION = /\bconfig\s*\(\s*\{[^)]*\bpath\s*:\s*$/;
5547
5825
  function inlineReadPaths(language, code, preload = {}) {
5548
5826
  const out = [];
@@ -5568,7 +5846,7 @@ function inlineReadPaths(language, code, preload = {}) {
5568
5846
  for (const m of code.matchAll(OPENED_NAME[language])) opened.add(m[1] ?? m[2]);
5569
5847
  for (const [name, values] of assigned) if (opened.has(name)) out.push(...values);
5570
5848
  }
5571
- if (language === "python" || language === "node") {
5849
+ if (language === "python" || language === "node" || language === "ruby") {
5572
5850
  const d = DOTENV[language];
5573
5851
  const readsEnv = d.env.test(code);
5574
5852
  const loads = /dotenv/.test(code) && d.load.test(code) && !d.literalPath.test(code);
@@ -6847,7 +7125,12 @@ var SENSITIVE_PATH_RULES = [
6847
7125
  {
6848
7126
  rule: "shield:project-jail:block-read-ssh",
6849
7127
  reason: "Reading SSH private keys is blocked by project-jail shield",
6850
- match: (p) => /([\\/]\.ssh[\\/]|^\.ssh[\\/]|^(?:[~/]|[A-Za-z]:).*[\\/]\.ssh$)/i.test(p)
7128
+ // Public material is not a key (JAIL-16): `known_hosts`, `authorized_keys`
7129
+ // and `*.pub` are readable. Because the exemption lives in the rule itself,
7130
+ // the copy tier sees `x.pub` as a destination OUTSIDE the jail, so
7131
+ // `cp ~/.ssh/id_rsa ~/.ssh/x.pub` is a reviewed copy, not a quiet rename
7132
+ // followed by an allowed read.
7133
+ match: (p) => /([\\/]\.ssh[\\/]|^\.ssh[\\/]|^(?:[~/]|[A-Za-z]:).*[\\/]\.ssh$)/i.test(p) && !isPublicSshMaterial(p)
6851
7134
  },
6852
7135
  {
6853
7136
  rule: "shield:project-jail:block-read-aws",
@@ -7216,6 +7499,7 @@ function attachedCode(interp, flag) {
7216
7499
  return rest === "" ? null : rest;
7217
7500
  }
7218
7501
  var NODE_VALUE_FLAG = /^(-r|--require|--import|--loader|--experimental-loader|--env-file|--env-file-if-exists|--input-type|-C|--conditions)(?:=(.*))?$/;
7502
+ var RUBY_VALUE_FLAG = /^-([rI])(.*)$/;
7219
7503
  function inlineExecCall(stmt, pipeFed) {
7220
7504
  const cmd = stmt?.Cmd;
7221
7505
  if (!cmd || cmd.kind !== "CallExpr") return null;
@@ -7249,6 +7533,7 @@ function inlineExecCall(stmt, pipeFed) {
7249
7533
  const codes = [];
7250
7534
  const preload = {};
7251
7535
  const nodeFamily = inlineLanguageOf(interp) === "node";
7536
+ const rubyFamily = inlineLanguageOf(interp) === "ruby";
7252
7537
  for (let i = 0; i < args.length; i++) {
7253
7538
  const a = args[i];
7254
7539
  if (nodeFamily && !selectedProgram && codes.length === 0 && a != null) {
@@ -7258,10 +7543,21 @@ function inlineExecCall(stmt, pipeFed) {
7258
7543
  if (value != null) {
7259
7544
  if (/^--env-file/.test(flag[1])) (preload.envFiles ??= []).push(value);
7260
7545
  else if (/^dotenv\/config(?:\.js)?$/.test(value)) preload.dotenv = true;
7546
+ } else if (/^--env-file/.test(flag[1])) {
7547
+ preload.unknownEnvFile = true;
7261
7548
  }
7262
7549
  continue;
7263
7550
  }
7264
7551
  }
7552
+ if (rubyFamily && !selectedProgram && codes.length === 0 && a != null) {
7553
+ const flag = RUBY_VALUE_FLAG.exec(a);
7554
+ if (flag) {
7555
+ const value = flag[2] !== "" ? flag[2] : args[++i];
7556
+ if (flag[1] === "r" && value != null && /^dotenv\/load(?:\.rb)?$/.test(value))
7557
+ preload.dotenv = true;
7558
+ continue;
7559
+ }
7560
+ }
7265
7561
  if (a == null) {
7266
7562
  if (codes.length > 0) break;
7267
7563
  positionals2++;
@@ -7600,7 +7896,7 @@ var NET_BINARIES = /* @__PURE__ */ new Set([
7600
7896
  "netcat",
7601
7897
  "rsync"
7602
7898
  ]);
7603
- var VALUE_FLAGS = {
7899
+ var VALUE_FLAGS2 = {
7604
7900
  // rsync 3.2.7, its own --help: every flag whose operand could be mistaken for
7605
7901
  // a host. `-e ssh` is the one that matters most (`ssh` is not the destination).
7606
7902
  rsync: /* @__PURE__ */ new Set([
@@ -8170,7 +8466,7 @@ function parseDestHost(token) {
8170
8466
  return null;
8171
8467
  }
8172
8468
  function destTokensForBinary(binary, args) {
8173
- const valueFlags = VALUE_FLAGS[binary] ?? /* @__PURE__ */ new Set();
8469
+ const valueFlags = VALUE_FLAGS2[binary] ?? /* @__PURE__ */ new Set();
8174
8470
  const positionals2 = [];
8175
8471
  const urlFlagValues = [];
8176
8472
  for (let i = 0; i < args.length; i++) {
@@ -8322,7 +8618,9 @@ var FS_OP_CACHE_MAX = 5e3;
8322
8618
  var fsOpCache = /* @__PURE__ */ new Map();
8323
8619
  function analyzeFsOperation(command) {
8324
8620
  const normalized = normalizeCommandForPolicy(command);
8325
- if (!FS_OP_PRESCREEN_RE.test(normalized) && !FS_OP_PRESCREEN_RE.test(command) && !SOURCES_FILE_RE.test(command) && !runsInlineInterpreter(command, normalized))
8621
+ const stdinShell = feedsShellStdin(command) || feedsShellStdin(normalized);
8622
+ const dotenvCli = DOTENV_CLI_PRESCREEN_RE.test(command) || DOTENV_CLI_PRESCREEN_RE.test(normalized);
8623
+ if (!FS_OP_PRESCREEN_RE.test(normalized) && !FS_OP_PRESCREEN_RE.test(command) && !SOURCES_FILE_RE.test(command) && !runsInlineInterpreter(command, normalized) && !stdinShell && !dotenvCli)
8326
8624
  return null;
8327
8625
  if (fsOpCache.has(command)) {
8328
8626
  const hit = fsOpCache.get(command) ?? null;
@@ -8330,8 +8628,10 @@ function analyzeFsOperation(command) {
8330
8628
  fsOpCache.set(command, hit);
8331
8629
  return hit;
8332
8630
  }
8333
- const direct = analyzeFsOperationImpl(command) ?? (INDIRECT_SHAPE_RE.test(command) ? structuralJailRead(command) : null);
8334
- const computed = direct?.verdict === "block" || !runsInlineInterpreter(command, normalized) ? direct : stricter(direct, inlineCodeJailRead(command));
8631
+ const own = analyzeFsOperationImpl(command);
8632
+ const direct = stdinShell && own?.verdict !== "block" ? stricter(own, structuralJailRead(command)) : own ?? (INDIRECT_SHAPE_RE.test(command) ? structuralJailRead(command) : null);
8633
+ const withInline = direct?.verdict === "block" || !runsInlineInterpreter(command, normalized) ? direct : stricter(direct, inlineCodeJailRead(command));
8634
+ const computed = withInline?.verdict === "block" || !dotenvCli ? withInline : stricter(withInline, dotenvCliJailRead(command));
8335
8635
  if (fsOpCache.size >= FS_OP_CACHE_MAX) {
8336
8636
  const oldest = fsOpCache.keys().next().value;
8337
8637
  if (oldest !== void 0) fsOpCache.delete(oldest);
@@ -8341,8 +8641,8 @@ function analyzeFsOperation(command) {
8341
8641
  }
8342
8642
  var stripDotSlash = (p) => p.replace(/^\.\//, "");
8343
8643
  function isSensitiveCleanupName(p) {
8344
- const base3 = p.replace(/^.*[\\/]/, "");
8345
- return /^\.env(\.|$)/i.test(base3) || /(?:^|[\\/])\.(?:ssh|aws|gnupg|git)(?:[\\/]|$)/i.test(p) || /\.(?:pem|key|p12|pfx|crt)$/i.test(base3) || /^\.?(?:netrc|npmrc|pgpass|htpasswd)$/i.test(base3) || /^id_(?:rsa|dsa|ecdsa|ed25519)/i.test(base3) || /credential/i.test(p) || /secret/i.test(base3);
8644
+ const base4 = p.replace(/^.*[\\/]/, "");
8645
+ return /^\.env(\.|$)/i.test(base4) || /(?:^|[\\/])\.(?:ssh|aws|gnupg|git)(?:[\\/]|$)/i.test(p) || /\.(?:pem|key|p12|pfx|crt)$/i.test(base4) || /^\.?(?:netrc|npmrc|pgpass|htpasswd)$/i.test(base4) || /^id_(?:rsa|dsa|ecdsa|ed25519)/i.test(base4) || /credential/i.test(p) || /secret/i.test(base4);
8346
8646
  }
8347
8647
  function isWaivableCleanupTarget(p) {
8348
8648
  if (/^[/~]/.test(p) || /^\$/.test(p)) return false;
@@ -8797,6 +9097,11 @@ function matchSensitivePath(p) {
8797
9097
  return null;
8798
9098
  }
8799
9099
  var INDIRECT_SHAPE_RE = /\b(?:for|while|until|find|xargs|set|source)\b|\$\{?PWD\b|[*?[]|(?:^|[;&|(\s])\.\s/;
9100
+ var STDIN_SHELL_WORD_RE = new RegExp(
9101
+ `(?:^|[\\s;&|(/\\\\])(?:${[...SHELL_INTERPRETERS].map((name) => name.replace(/[.*+?^\${}()|[\]\\]/g, "\\$&")).join("|")})(?=$|[\\s;&|)<])`,
9102
+ "i"
9103
+ );
9104
+ var feedsShellStdin = (command) => /\||<</.test(command) && STDIN_SHELL_WORD_RE.test(command);
8800
9105
  var SOURCES_FILE_RE = /(?:^|[;&|(\s])(?:source|\.)\s/;
8801
9106
  function printsEnvironment(words) {
8802
9107
  const [name, ...rest] = words;
@@ -9069,8 +9374,17 @@ function analyzeUnknownCredentialReads(command) {
9069
9374
  }
9070
9375
  return !hit;
9071
9376
  });
9072
- return hit ? {
9073
- reason: "Files are read by names a listing produces when the command runs, and the listing can include credential files"
9377
+ if (hit)
9378
+ return {
9379
+ reason: "Files are read by names a listing produces when the command runs, and the listing can include credential files"
9380
+ };
9381
+ let unknownEnvFile = false;
9382
+ try {
9383
+ unknownEnvFile = readsUnknownEnvFile(command) || dotenvCliReads(command).unknown;
9384
+ } catch {
9385
+ }
9386
+ return unknownEnvFile ? {
9387
+ reason: "An environment file is loaded and its values are shown, and its name is not known until the command runs: it can be a credential file"
9074
9388
  } : null;
9075
9389
  }
9076
9390
  var JAILED_GLOB_NAMES = [
@@ -9096,6 +9410,7 @@ function matchSensitiveGlob(glob, dotGlob) {
9096
9410
  }
9097
9411
  });
9098
9412
  glob = parts.join("/");
9413
+ if (isPublicSshMaterial(glob)) return null;
9099
9414
  const first = parts.findIndex((seg) => GLOB_META.test(seg));
9100
9415
  if (first < 0) return matchSensitivePath(glob);
9101
9416
  const prefix = parts.slice(0, first).join("/");
@@ -9122,8 +9437,9 @@ function matchSensitiveGlob(glob, dotGlob) {
9122
9437
  }
9123
9438
  function structuralJailRead(command) {
9124
9439
  let accesses;
9440
+ const report = { exhausted: false };
9125
9441
  try {
9126
- accesses = collectShellFileAccesses(command);
9442
+ accesses = collectShellFileAccesses(command, {}, report);
9127
9443
  } catch {
9128
9444
  return null;
9129
9445
  }
@@ -9139,7 +9455,7 @@ function structuralJailRead(command) {
9139
9455
  if (hit?.verdict === "block") return hit;
9140
9456
  review ??= hit;
9141
9457
  }
9142
- return review;
9458
+ return report.exhausted ? stricter(review, UNANALYSABLE_NESTING) : review;
9143
9459
  }
9144
9460
  var INLINE_INTERP_PRESCREEN_RE = /(?:^|[^\w-])(?:python|node|tsx|ts-node|deno|bun|perl|ruby|irb|php)(?![A-Za-z_])/i;
9145
9461
  var runsInlineInterpreter = (command, normalized) => INLINE_INTERP_PRESCREEN_RE.test(command) || INLINE_INTERP_PRESCREEN_RE.test(normalized);
@@ -9161,6 +9477,77 @@ function inlineCodeJailRead(command) {
9161
9477
  }
9162
9478
  return review;
9163
9479
  }
9480
+ var DOTENV_CLI_PRESCREEN_RE = /\bdotenvx?\b/i;
9481
+ var MAX_DOTENV_PAYLOAD_DEPTH = 3;
9482
+ function dotenvCliReads(command, depth = 0) {
9483
+ const out = { paths: [], unknown: false };
9484
+ if (depth > MAX_DOTENV_PAYLOAD_DEPTH || !DOTENV_CLI_PRESCREEN_RE.test(command)) return out;
9485
+ const bytes = new TextEncoder().encode(command);
9486
+ const sourceOf = (from, to) => typeof from === "number" && typeof to === "number" && from >= 0 && to > from ? new TextDecoder().decode(bytes.subarray(from, to)) : "";
9487
+ walkCommandScope(command, (node) => {
9488
+ const n = node;
9489
+ if (!n || n.kind !== "CallExpr") return true;
9490
+ const args = n.Args || [];
9491
+ const words = args.map((a) => resolveWordLiteral(a));
9492
+ if (words.length === 0) return true;
9493
+ const call = readDotenvCli(words, unwrapCommandHead(words));
9494
+ if (!call) {
9495
+ const payload = literalShellPayload(words, baseWord(words[0]));
9496
+ if (payload !== null) {
9497
+ const inner = dotenvCliReads(payload, depth + 1);
9498
+ out.paths.push(...inner.paths);
9499
+ out.unknown ||= inner.unknown;
9500
+ }
9501
+ return true;
9502
+ }
9503
+ let shown = call.mode === "print";
9504
+ if (!shown) {
9505
+ const inner = words.slice(call.inner);
9506
+ const literal = (ws) => ws.length > 0 && ws.every((w) => w !== null);
9507
+ const plain = inner.slice(unwrapCommandHead(inner));
9508
+ shown = literal(inner) && printsEnvironment(inner) || literal(plain) && printsEnvironment(plain);
9509
+ const payload = shown ? null : literalShellPayload(inner, baseWord(inner[0]));
9510
+ if (payload !== null && sourcedAndPrinted(`. .env
9511
+ ${payload}`) !== null) shown = true;
9512
+ if (!shown) {
9513
+ const text = sourceOf(args[call.inner]?.pos, args[args.length - 1]?.end);
9514
+ const calls = text ? inlineExecCalls(text) : [];
9515
+ if (calls !== PARSE_FAIL)
9516
+ shown = calls.some((c) => {
9517
+ const language = inlineLanguageOf(c.interp);
9518
+ return language !== null && c.code.some((code) => code !== null && inlineReadsEnvironment(language, code));
9519
+ });
9520
+ }
9521
+ }
9522
+ if (!shown) return true;
9523
+ for (const file of call.files) {
9524
+ if (file === null) out.unknown = true;
9525
+ else out.paths.push(file);
9526
+ }
9527
+ return true;
9528
+ });
9529
+ return out;
9530
+ }
9531
+ function dotenvCliJailRead(command) {
9532
+ let result = null;
9533
+ try {
9534
+ for (const p of dotenvCliReads(command).paths) {
9535
+ result = stricter(result, matchSensitivePath(p));
9536
+ if (result?.verdict === "block") break;
9537
+ }
9538
+ } catch {
9539
+ }
9540
+ return result;
9541
+ }
9542
+ function readsUnknownEnvFile(command) {
9543
+ if (!/--env-file/.test(command)) return false;
9544
+ const calls = inlineExecCalls(command);
9545
+ if (calls === PARSE_FAIL) return false;
9546
+ return calls.some((c) => {
9547
+ const language = inlineLanguageOf(c.interp);
9548
+ return c.preload?.unknownEnvFile === true && language !== null && c.code.some((code) => code !== null && inlineReadsEnvironment(language, code));
9549
+ });
9550
+ }
9164
9551
  function baseWord(w) {
9165
9552
  return (w ?? "").split("/").pop()?.toLowerCase() ?? "";
9166
9553
  }
@@ -12300,6 +12687,120 @@ function secretViews(text, budget) {
12300
12687
  return out;
12301
12688
  }
12302
12689
 
12690
+ // src/dlp/placeholder.ts
12691
+ var TEMPLATE_RE = /\$\{|\{\{|%\{|<[^<>\s]{1,80}>/;
12692
+ var RUN_RE = /(.)\1{7}/;
12693
+ var DOMINANT_SHARE = 0.6;
12694
+ var DOC_WORDS = ["example", "sample", "fake", "dummy", "placeholder", "changeme", "redacted"];
12695
+ var STANDALONE_WORDS = /* @__PURE__ */ new Set([...DOC_WORDS, "your", "here", "insert", "replace"]);
12696
+ var DOC_EDGE_RE = new RegExp(
12697
+ `^(?:${DOC_WORDS.join("|")})|(?:${DOC_WORDS.join("|")})(?:[_-]?(?:key|token|secret))?$`
12698
+ );
12699
+ var VOCABULARY = [
12700
+ ...DOC_WORDS,
12701
+ "your",
12702
+ "here",
12703
+ "insert",
12704
+ "replace",
12705
+ "put",
12706
+ "change",
12707
+ "goes",
12708
+ "with",
12709
+ "this",
12710
+ "please",
12711
+ "real",
12712
+ "actual",
12713
+ "me",
12714
+ "my",
12715
+ "the",
12716
+ "an",
12717
+ "key",
12718
+ "token",
12719
+ "secret",
12720
+ "password",
12721
+ "passwd",
12722
+ "api",
12723
+ "apikey",
12724
+ "access",
12725
+ "auth",
12726
+ "test",
12727
+ "value",
12728
+ "xxx"
12729
+ ];
12730
+ var VOCABULARY_SET = new Set(VOCABULARY);
12731
+ var MAX_COMPOSED_SEGMENT = 48;
12732
+ function madeOfVocabulary(segment) {
12733
+ if (VOCABULARY_SET.has(segment)) return true;
12734
+ if (segment.length > MAX_COMPOSED_SEGMENT) return false;
12735
+ const reachable = new Array(segment.length + 1).fill(false);
12736
+ reachable[0] = true;
12737
+ for (let i = 0; i < segment.length; i++) {
12738
+ if (!reachable[i]) continue;
12739
+ for (const word of VOCABULARY) {
12740
+ if (segment.startsWith(word, i)) reachable[i + word.length] = true;
12741
+ }
12742
+ }
12743
+ return reachable[segment.length];
12744
+ }
12745
+ var isUpper = (c) => c >= 65 && c <= 90;
12746
+ var isLower = (c) => c >= 97 && c <= 122;
12747
+ function alphabeticSegments(token) {
12748
+ const segments2 = [];
12749
+ let start = -1;
12750
+ const close = (end) => {
12751
+ if (start >= 0) segments2.push(token.slice(start, end).toLowerCase());
12752
+ start = -1;
12753
+ };
12754
+ for (let i = 0; i < token.length; i++) {
12755
+ const c = token.charCodeAt(i);
12756
+ if (!isUpper(c) && !isLower(c)) {
12757
+ close(i);
12758
+ continue;
12759
+ }
12760
+ if (start >= 0 && isUpper(c)) {
12761
+ const prev = token.charCodeAt(i - 1);
12762
+ const next = i + 1 < token.length ? token.charCodeAt(i + 1) : 0;
12763
+ if (isLower(prev) || isUpper(prev) && isLower(next)) close(i);
12764
+ }
12765
+ if (start < 0) start = i;
12766
+ }
12767
+ close(token.length);
12768
+ return segments2;
12769
+ }
12770
+ function dominatedByOneChar(s) {
12771
+ if (s.length < 4) return false;
12772
+ const counts = /* @__PURE__ */ new Map();
12773
+ let top = 0;
12774
+ for (const ch of s) {
12775
+ const n = (counts.get(ch) ?? 0) + 1;
12776
+ counts.set(ch, n);
12777
+ if (n > top) top = n;
12778
+ }
12779
+ return top / s.length >= DOMINANT_SHARE;
12780
+ }
12781
+ var MAX_PHRASE_LENGTH = 160;
12782
+ function builtFromVocabulary(token) {
12783
+ if (token.length > MAX_PHRASE_LENGTH) return false;
12784
+ const segments2 = alphabeticSegments(token);
12785
+ if (segments2.length === 0 || !segments2.every(madeOfVocabulary)) return false;
12786
+ const letters = token.replace(/[^A-Za-z]/g, "").length;
12787
+ const alphanumerics = token.replace(/[^A-Za-z0-9]/g, "").length;
12788
+ return letters * 2 >= alphanumerics;
12789
+ }
12790
+ var PHRASE_RE = /^[a-z]{1,20}(?:[-_.][a-z]{1,20}){2,}$/;
12791
+ function isPhrase(secret) {
12792
+ return PHRASE_RE.test(secret);
12793
+ }
12794
+ function isPlaceholder(secret) {
12795
+ if (secret.length === 0) return false;
12796
+ if (TEMPLATE_RE.test(secret)) return true;
12797
+ if (RUN_RE.test(secret) || dominatedByOneChar(secret)) return true;
12798
+ const lower2 = secret.toLowerCase();
12799
+ if (lower2.split(/[^a-z0-9]+/).some((part) => STANDALONE_WORDS.has(part))) return true;
12800
+ if (DOC_EDGE_RE.test(lower2)) return true;
12801
+ return builtFromVocabulary(secret);
12802
+ }
12803
+
12303
12804
  // src/scan/checksums.ts
12304
12805
  var import_crypto = require("crypto");
12305
12806
  function validateLuhn(digits) {
@@ -12422,12 +12923,19 @@ var IBAN_LENGTH = {
12422
12923
  YE: 30
12423
12924
  };
12424
12925
  var IBAN_BBAN_SHAPE = {
12926
+ // AD, AE, BA, EE: the registered countries whose code is two hex letters
12927
+ // and that had no shape here, so a hex id with that prefix and a lucky
12928
+ // mod-97 read as an IBAN (node9Firewall#369).
12929
+ AD: /^\d{8}[A-Z0-9]{12}$/,
12930
+ AE: /^\d{19}$/,
12425
12931
  AT: /^\d{16}$/,
12932
+ BA: /^\d{16}$/,
12426
12933
  BE: /^\d{12}$/,
12427
12934
  CH: /^\d{5}[A-Z0-9]{12}$/,
12428
12935
  CZ: /^\d{20}$/,
12429
12936
  DE: /^\d{18}$/,
12430
12937
  DK: /^\d{14}$/,
12938
+ EE: /^\d{16}$/,
12431
12939
  ES: /^\d{20}$/,
12432
12940
  FI: /^\d{14}$/,
12433
12941
  FR: /^\d{10}[A-Z0-9]{11}\d{2}$/,
@@ -12847,9 +13355,9 @@ function validateBelgianNationalNumber(raw) {
12847
13355
  if (!/^\d{11}$/.test(d)) return false;
12848
13356
  const month = Number(d.slice(2, 4)) % 20;
12849
13357
  if (month !== 0 && !plausibleDate(String(month).padStart(2, "0"), d.slice(4, 6))) return false;
12850
- const base3 = Number(d.slice(0, 9));
13358
+ const base4 = Number(d.slice(0, 9));
12851
13359
  const check = Number(d.slice(9, 11));
12852
- return 97 - base3 % 97 === check || 97 - (2e9 + base3) % 97 === check;
13360
+ return 97 - base4 % 97 === check || 97 - (2e9 + base4) % 97 === check;
12853
13361
  }
12854
13362
  function validateCuit(raw) {
12855
13363
  const d = raw.replace(/-/g, "");
@@ -12976,32 +13484,6 @@ function shannonEntropy(s) {
12976
13484
  }
12977
13485
  return h;
12978
13486
  }
12979
- var DLP_STOPWORDS = [
12980
- "example",
12981
- "placeholder",
12982
- "changeme",
12983
- "your_key",
12984
- "your_token",
12985
- "your_secret",
12986
- "replace_me",
12987
- "insert_key",
12988
- "put_your",
12989
- "fake",
12990
- "dummy",
12991
- "sample",
12992
- "xxxxxxxx",
12993
- "aaaaaa",
12994
- "bbbbbb",
12995
- "00000000",
12996
- "${",
12997
- "{{",
12998
- "%{",
12999
- "<your",
13000
- "test_key",
13001
- "test_token",
13002
- "your",
13003
- "here"
13004
- ];
13005
13487
  function capturedValue(raw, pattern) {
13006
13488
  const m = raw.match(pattern);
13007
13489
  return m?.[1] ?? null;
@@ -13034,8 +13516,7 @@ function rejectedByStructuredValidator(value) {
13034
13516
  }
13035
13517
  function looksGenerated(value, minLength, minEntropy, lettersOnlyAllowed = false) {
13036
13518
  if (value.length < minLength) return false;
13037
- const lower2 = value.toLowerCase();
13038
- if (DLP_STOPWORDS.some((sw) => lower2.includes(sw))) return false;
13519
+ if (isPlaceholder(value)) return false;
13039
13520
  if (REFERENCE_VALUE_RE.test(value)) return false;
13040
13521
  if (!lettersOnlyAllowed && IDENTIFIER_VALUE_RE.test(value)) return false;
13041
13522
  if (EMAIL_VALUE_RE.test(value)) return false;
@@ -13186,9 +13667,7 @@ var SQL_PASSWORD_VALUE_RE = /['"]([^'"\s]{8,128})['"]$/;
13186
13667
  function validateSqlPassword(raw) {
13187
13668
  const value = capturedValue(raw, SQL_PASSWORD_VALUE_RE);
13188
13669
  if (value === null) return false;
13189
- const lower2 = value.toLowerCase();
13190
- if (DLP_STOPWORDS.some((sw) => lower2.includes(sw)) || REFERENCE_VALUE_RE.test(value))
13191
- return false;
13670
+ if (isPlaceholder(value) || REFERENCE_VALUE_RE.test(value)) return false;
13192
13671
  if (/^[a-z]+$/i.test(value) && value.length < 12) return false;
13193
13672
  return shannonEntropy(value) >= 2.5 && !hasSequentialRun(value);
13194
13673
  }
@@ -13223,8 +13702,7 @@ function validateBasicCredential(raw, before = "") {
13223
13702
  if (!pair) return false;
13224
13703
  const password = pair[2];
13225
13704
  if (!/[0-9]/.test(password) || !/[A-Za-z]/.test(password)) return false;
13226
- const lower2 = password.toLowerCase();
13227
- if (DLP_STOPWORDS.some((sw) => lower2.includes(sw)) || hasSequentialRun(password)) return false;
13705
+ if (isPlaceholder(password) || hasSequentialRun(password)) return false;
13228
13706
  return shannonEntropy(password) >= 3;
13229
13707
  }
13230
13708
  function headerPairIsCredential(text) {
@@ -13242,7 +13720,7 @@ function validateDropboxSecret(raw) {
13242
13720
  const value = capturedValue(raw, DROPBOX_SECRET_RE);
13243
13721
  if (value === null || value !== value.toLowerCase()) return false;
13244
13722
  if (!/[0-9]/.test(value) || !/[a-z]/.test(value)) return false;
13245
- if (DLP_STOPWORDS.some((sw) => value.includes(sw)) || hasSequentialRun(value)) return false;
13723
+ if (isPlaceholder(value) || hasSequentialRun(value)) return false;
13246
13724
  return shannonEntropy(value) >= 3;
13247
13725
  }
13248
13726
  var OTP_CAPTURE_RE = /["']([A-Z2-7]{16,128}=*)["']$/i;
@@ -13250,8 +13728,7 @@ var DB_URL_PASSWORD_RE = /:\/\/[^:/\s@]*:([^@\s]{4,})@/;
13250
13728
  function validateDbConnectionString(raw) {
13251
13729
  const password = capturedValue(raw, DB_URL_PASSWORD_RE);
13252
13730
  if (password === null) return false;
13253
- const lower2 = password.toLowerCase();
13254
- if (DLP_STOPWORDS.some((sw) => lower2.includes(sw))) return false;
13731
+ if (isPlaceholder(password)) return false;
13255
13732
  return shannonEntropy(raw) >= 3;
13256
13733
  }
13257
13734
  function validateOtpSecret(raw) {
@@ -13464,8 +13941,9 @@ var DLP_PATTERNS = [
13464
13941
  // ── NPM ───────────────────────────────────────────────────────────────────
13465
13942
  {
13466
13943
  name: "NPM Auth Token",
13467
- regex: /_authToken\s*=\s*[A-Za-z0-9_-]{20,}/,
13944
+ regex: /_authToken\s*=\s*([A-Za-z0-9_-]{20,})/,
13468
13945
  severity: "block",
13946
+ secretGroup: 1,
13469
13947
  keywords: ["_authtoken"]
13470
13948
  },
13471
13949
  // ── JWT ───────────────────────────────────────────────────────────────────
@@ -13582,7 +14060,11 @@ var DLP_PATTERNS = [
13582
14060
  // ── PyPI ──────────────────────────────────────────────────────────────────
13583
14061
  {
13584
14062
  name: "PyPI Upload Token",
13585
- regex: /\bpypi-[A-Za-z0-9_-]{50,}\b/,
14063
+ // A PyPI token is a macaroon whose base64 body always starts with the
14064
+ // same bytes: `pypi-AgEIcHlwaS5vcmc` (pypi.org), `pypi-AgENdGVzdC5weXBp`
14065
+ // (test.pypi.org). Without the `AgE` anchor any `pypi-<long-slug>` in a
14066
+ // URL matched (node9Firewall#374).
14067
+ regex: /\bpypi-AgE[A-Za-z0-9_-]{50,}\b/,
13586
14068
  severity: "block",
13587
14069
  keywords: ["pypi-"],
13588
14070
  minEntropy: 3
@@ -13591,11 +14073,12 @@ var DLP_PATTERNS = [
13591
14073
  // contextBoost: promoted to block when assigned (e.g. AUTH_TOKEN=Bearer eyJ...)
13592
14074
  {
13593
14075
  name: "Bearer Token",
13594
- regex: /Bearer\s+[a-zA-Z0-9\-._~+/]{20,}=*/i,
14076
+ regex: /Bearer\s+([a-zA-Z0-9\-._~+/]{20,})=*/i,
13595
14077
  severity: "review",
13596
14078
  keywords: ["bearer"],
13597
14079
  contextBoost: true,
13598
- minEntropy: 3
14080
+ minEntropy: 3,
14081
+ secretGroup: 1
13599
14082
  },
13600
14083
  // ── HTTP Basic credential ─────────────────────────────────────────────────
13601
14084
  // `Authorization: Basic <base64 of user:password>`, or the bare scheme in a
@@ -13665,8 +14148,9 @@ var DLP_PATTERNS = [
13665
14148
  // ── Cloudinary ────────────────────────────────────────────────────────────
13666
14149
  {
13667
14150
  name: "Cloudinary URL",
13668
- regex: /\bcloudinary:\/\/[0-9]+:[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+/,
14151
+ regex: /\bcloudinary:\/\/[0-9]+:([a-zA-Z0-9_-]+)@[a-zA-Z0-9_-]+/,
13669
14152
  severity: "block",
14153
+ secretGroup: 1,
13670
14154
  keywords: ["cloudinary://"]
13671
14155
  },
13672
14156
  // ── Airtable ──────────────────────────────────────────────────────────────
@@ -13930,6 +14414,7 @@ var SENSITIVE_PATH_PATTERNS = [
13930
14414
  ];
13931
14415
  function matchSensitivePath2(resolvedPath, originalPath, options = {}) {
13932
14416
  const normalised = resolvedPath.replace(/\\/g, "/");
14417
+ if (options.readOnly && isPublicSshMaterial(normalised)) return null;
13933
14418
  if (!options.systemAccessHandled && isLegacySystemPath(normalised))
13934
14419
  return sensitivePathMatch(originalPath);
13935
14420
  for (const pattern of SENSITIVE_PATH_PATTERNS) {
@@ -13964,6 +14449,16 @@ function assertBuiltinPatternsAreSafe() {
13964
14449
  );
13965
14450
  }
13966
14451
  }
14452
+ for (const p of DLP_PATTERNS) {
14453
+ const groups = (new RegExp(`${p.regex.source}|`).exec("")?.length ?? 1) - 1;
14454
+ for (const index of [p.secretGroup, p.redactGroup]) {
14455
+ if (index !== void 0 && (index < 1 || index > groups)) {
14456
+ throw new Error(
14457
+ `[node9 engine] Builtin DLP pattern '${p.name}' names group ${index} of ${groups}`
14458
+ );
14459
+ }
14460
+ }
14461
+ }
13967
14462
  for (const re of SENSITIVE_PATH_PATTERNS) {
13968
14463
  if (!(0, import_safe_regex22.default)(re.source)) {
13969
14464
  throw new Error(
@@ -13995,7 +14490,8 @@ var DLP_SCAN_LIMITS = {
13995
14490
  /** Max nesting depth walked; anything deeper is NOT scanned. */
13996
14491
  maxDepth: MAX_DEPTH2
13997
14492
  };
13998
- function suppressed(pattern, raw, before = "") {
14493
+ function suppressed(pattern, m, before = "") {
14494
+ const raw = m[0];
13999
14495
  if (pattern.validate) {
14000
14496
  let ok;
14001
14497
  try {
@@ -14005,8 +14501,14 @@ function suppressed(pattern, raw, before = "") {
14005
14501
  }
14006
14502
  return !ok;
14007
14503
  }
14008
- if (DLP_STOPWORDS.some((sw) => raw.toLowerCase().includes(sw))) return true;
14009
- if (pattern.minEntropy !== void 0 && shannonEntropy(raw) < pattern.minEntropy) return true;
14504
+ const group = pattern.secretGroup !== void 0 ? m[pattern.secretGroup] : void 0;
14505
+ const secret = typeof group === "string" && group.length > 0 ? group : raw;
14506
+ if (isPlaceholder(secret) || isPhrase(secret)) return true;
14507
+ const lower2 = secret.toLowerCase();
14508
+ const prefix = pattern.keywords?.find((kw) => lower2.startsWith(kw.toLowerCase()));
14509
+ const body = prefix ? secret.slice(prefix.length) : "";
14510
+ if (prefix && (isPlaceholder(body) || isPhrase(body))) return true;
14511
+ if (pattern.minEntropy !== void 0 && shannonEntropy(secret) < pattern.minEntropy) return true;
14010
14512
  return false;
14011
14513
  }
14012
14514
  function firstAcceptedMatch(pattern, text) {
@@ -14018,7 +14520,7 @@ function firstAcceptedMatch(pattern, text) {
14018
14520
  re.lastIndex = m.index + 1;
14019
14521
  continue;
14020
14522
  }
14021
- if (!suppressed(pattern, m[0], text.slice(Math.max(0, m.index - 64), m.index))) return m[0];
14523
+ if (!suppressed(pattern, m, text.slice(Math.max(0, m.index - 64), m.index))) return m[0];
14022
14524
  }
14023
14525
  return null;
14024
14526
  }
@@ -14184,7 +14686,7 @@ function redactText(text) {
14184
14686
  continue;
14185
14687
  }
14186
14688
  result = result.replace(globalRegex, (match, ...rest) => {
14187
- if (suppressed(pattern, match)) return match;
14689
+ if (suppressed(pattern, [match, ...rest])) return match;
14188
14690
  if (!found.includes(pattern.name)) found.push(pattern.name);
14189
14691
  const marker = `[node9-redacted:${pattern.name}]`;
14190
14692
  const group = pattern.redactGroup !== void 0 && typeof rest[pattern.redactGroup - 1] === "string" ? rest[pattern.redactGroup - 1] : void 0;
@@ -14535,9 +15037,9 @@ var GitWalk = class {
14535
15037
  const name = n.Name.Value;
14536
15038
  if (n.Append) {
14537
15039
  const prev = this.appended.has(name) ? this.appended.get(name) : resolveWordLiteral(n.Value) === null ? null : void 0;
14538
- const base3 = prev === void 0 ? recordedExpansion(name) : prev;
15040
+ const base4 = prev === void 0 ? recordedExpansion(name) : prev;
14539
15041
  const piece = resolveWordLiteral(n.Value);
14540
- this.appended.set(name, typeof base3 === "string" && piece !== null ? base3 + piece : null);
15042
+ this.appended.set(name, typeof base4 === "string" && piece !== null ? base4 + piece : null);
14541
15043
  this.treeTopVars.delete(name);
14542
15044
  return true;
14543
15045
  }
@@ -15577,9 +16079,9 @@ var INSTRUCTION_NAMES = /* @__PURE__ */ new Set([
15577
16079
  var SETTINGS_RE = /\/(?:\.claude\/settings(?:\.local)?\.json|\.gemini\/settings\.json|\.codex\/hooks\.json|\.cursor\/hooks\.json)$/i;
15578
16080
  function agentFileKind(p) {
15579
16081
  const lower2 = p.toLowerCase();
15580
- const base3 = lower2.slice(lower2.lastIndexOf("/") + 1);
15581
- if (INSTRUCTION_NAMES.has(base3)) return "instructions";
15582
- if (base3 === "copilot-instructions.md" && lower2.endsWith("/.github/" + base3))
16082
+ const base4 = lower2.slice(lower2.lastIndexOf("/") + 1);
16083
+ if (INSTRUCTION_NAMES.has(base4)) return "instructions";
16084
+ if (base4 === "copilot-instructions.md" && lower2.endsWith("/.github/" + base4))
15583
16085
  return "instructions";
15584
16086
  if (/\/\.cursor\/rules(?:\/|$)/.test(lower2)) return "instructions";
15585
16087
  if (/\/\.claude\/projects\/[^/]+\/memory(?:\/|$)/.test(lower2)) return "memory";
@@ -15749,7 +16251,7 @@ function evaluateAgentFileWrite(args, accesses, context, settings, shell, hooks
15749
16251
  skills: "agent skill",
15750
16252
  settings: "agent settings"
15751
16253
  };
15752
- const base3 = `${kindLabel[kind]} written: ${access.path}`;
16254
+ const base4 = `${kindLabel[kind]} written: ${access.path}`;
15753
16255
  if (!signal && !every) {
15754
16256
  return {
15755
16257
  decision: "allow",
@@ -15759,14 +16261,14 @@ function evaluateAgentFileWrite(args, accesses, context, settings, shell, hooks
15759
16261
  path: access.path,
15760
16262
  operation: access.operation,
15761
16263
  kind,
15762
- reason: base3,
16264
+ reason: base4,
15763
16265
  ruleDescription: "The AI writes to a file every later agent session loads as instructions.",
15764
- blockedByLabel: `Node9 Files: ${base3}`,
16266
+ blockedByLabel: `Node9 Files: ${base4}`,
15765
16267
  tier: 2
15766
16268
  };
15767
16269
  }
15768
16270
  const ruleName = signal === "content" ? "review-agent-file-content" : signal === "hooks" ? "review-agent-hooks-change" : "review-agent-file-write";
15769
- const reason = signal ? `${base3} (${detail})` : base3;
16271
+ const reason = signal ? `${base4} (${detail})` : base4;
15770
16272
  const description = signal === "content" ? "The AI writes an instruction into a file every later agent session loads: to hide something from you, to skip approvals or the guard, or to read or send a secret. It would persist past this session; confirm it is yours." : signal === "hooks" ? "The AI changes the hooks in the agent's settings. Hooks are how node9 and your other checks run before each tool call; a change here can disarm them." : "The AI writes to a file every later agent session loads as instructions (CLAUDE.md, AGENTS.md, memory, agents, commands). Confirm the change is yours.";
15771
16273
  return {
15772
16274
  decision: value === "log" ? "allow" : value,
@@ -18033,6 +18535,7 @@ var SENSITIVE_PATTERNS = [
18033
18535
  // generic credentials files
18034
18536
  ];
18035
18537
  function isSensitivePath(p) {
18538
+ if (isPublicSshMaterial(p)) return false;
18036
18539
  return isPasswordHashPath(p) || SENSITIVE_PATTERNS.some((re) => re.test(p));
18037
18540
  }
18038
18541
  function splitOnPipe(cmd) {
@@ -18676,7 +19179,9 @@ var DAEMON_CMDLINES = [
18676
19179
  "node9 daemon start"
18677
19180
  ];
18678
19181
  var DAEMON_NAMES = ["node", "node9"];
18679
- var KILLALL_NAMES = /* @__PURE__ */ new Set(["node", "node9", "node.exe", "node9.exe"]);
19182
+ var KILLALL_NAMES = /* @__PURE__ */ new Set(["node9", "node9.exe"]);
19183
+ var ORDINARY_NODE_CMDLINES = ["node server.js"];
19184
+ var ORDINARY_NODE_NAMES = ["node"];
18680
19185
  var STOP_SYSTEMCTL = /* @__PURE__ */ new Set(["stop", "disable", "mask", "kill"]);
18681
19186
  var STOP_LAUNCHCTL = /* @__PURE__ */ new Set(["unload", "bootout", "remove", "stop", "kill", "disable"]);
18682
19187
  var PKILL_VALUE_FLAGS = /* @__PURE__ */ new Set([
@@ -18706,11 +19211,16 @@ function patternSelects(pattern, targets) {
18706
19211
  if (pieces.length === 0) return false;
18707
19212
  return targets.some((t) => pieces.every((p) => t.includes(p)));
18708
19213
  }
19214
+ function aimedAtDaemon(pattern, full) {
19215
+ return pattern.split("|").some(
19216
+ (alternative) => patternSelects(alternative, full ? DAEMON_CMDLINES : DAEMON_NAMES) && !patternSelects(alternative, full ? ORDINARY_NODE_CMDLINES : ORDINARY_NODE_NAMES)
19217
+ );
19218
+ }
18709
19219
  function sourceText(bytes, pos, end) {
18710
19220
  if (typeof pos !== "number" || typeof end !== "number" || pos < 0 || end < pos) return "";
18711
19221
  return new TextDecoder().decode(bytes.subarray(pos, end));
18712
19222
  }
18713
- var base2 = (w) => (w ?? "").split(/[\\/]/).pop()?.toLowerCase() ?? "";
19223
+ var base3 = (w) => (w ?? "").split(/[\\/]/).pop()?.toLowerCase() ?? "";
18714
19224
  function nextOperand(words, from) {
18715
19225
  for (let i = from; i < words.length; i++) {
18716
19226
  const w = words[i];
@@ -18720,7 +19230,7 @@ function nextOperand(words, from) {
18720
19230
  return -1;
18721
19231
  }
18722
19232
  function node9Command(words, h) {
18723
- const head = base2(words[h]);
19233
+ const head = base3(words[h]);
18724
19234
  if (head !== "node9" && head !== "node9.cmd" && words[h] !== "@node9/proxy") return null;
18725
19235
  const s = nextOperand(words, h + 1);
18726
19236
  const sub = s < 0 ? "" : (words[s] ?? "").toLowerCase();
@@ -18732,7 +19242,7 @@ function node9Command(words, h) {
18732
19242
  }
18733
19243
  var HOME_PID_FILE_RE = /(?:^|[\s"'(=`])(?:~|\$HOME|\$\{HOME\}|\/home\/[^/\s]+|\/Users\/[^/\s]+|\/root)\/\.node9\/daemon\.pid/;
18734
19244
  function killsDaemon(words, texts, h, daemonPid) {
18735
- const head = base2(words[h]);
19245
+ const head = base3(words[h]);
18736
19246
  const args = words.slice(h + 1);
18737
19247
  if (head === "kill") {
18738
19248
  for (let i = 0; i < args.length; i++) {
@@ -18766,13 +19276,13 @@ function killsDaemon(words, texts, h, daemonPid) {
18766
19276
  pattern = w;
18767
19277
  }
18768
19278
  if (pattern === null) return null;
18769
- return patternSelects(pattern, full ? DAEMON_CMDLINES : DAEMON_NAMES) ? `pkill ${full ? "-f " : ""}${pattern}` : null;
19279
+ return aimedAtDaemon(pattern, full) ? `pkill ${full ? "-f " : ""}${pattern}` : null;
18770
19280
  }
18771
19281
  if (head === "killall") {
18772
19282
  const regex = args.some((w) => w === "-r" || w === "--regexp");
18773
19283
  for (const w of args) {
18774
19284
  if (w === null || w.startsWith("-")) continue;
18775
- if (regex ? patternSelects(w, DAEMON_NAMES) : KILLALL_NAMES.has(w.toLowerCase()))
19285
+ if (regex ? aimedAtDaemon(w, false) : KILLALL_NAMES.has(w.toLowerCase()))
18776
19286
  return `killall ${w}`;
18777
19287
  }
18778
19288
  return null;
@@ -18790,7 +19300,7 @@ function killsDaemon(words, texts, h, daemonPid) {
18790
19300
  return null;
18791
19301
  }
18792
19302
  function stopsService(words, h) {
18793
- const head = base2(words[h]);
19303
+ const head = base3(words[h]);
18794
19304
  const args = words.slice(h + 1).map((w) => (w ?? "").toLowerCase());
18795
19305
  if (head === "systemctl") {
18796
19306
  const action = args.find((w) => STOP_SYSTEMCTL.has(w));
@@ -18819,7 +19329,7 @@ function analyzeNode9Disarm(command, daemonPid = null, depth = 0) {
18819
19329
  const h = unwrapCommandHead(words);
18820
19330
  shown = node9Command(words, h) ?? killsDaemon(words, texts, h, daemonPid) ?? stopsService(words, h);
18821
19331
  if (shown === null) {
18822
- const payload = literalShellPayload(words, base2(words[0]));
19332
+ const payload = literalShellPayload(words, base3(words[0]));
18823
19333
  if (payload) {
18824
19334
  const inner = analyzeNode9Disarm(payload, daemonPid, depth + 1);
18825
19335
  if (inner) shown = inner.reason.replace(/^node9 switched off by the agent: /, "");
@@ -19514,7 +20024,15 @@ var MAX_DESTINATIONS = 200;
19514
20024
  var MAX_SCAN_CHARS = 1e5;
19515
20025
  var EMAIL_RE = /[\p{L}\p{N}._%+-]+@[\p{L}\p{N}](?:[\p{L}\p{N}-]*[\p{L}\p{N}])?(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]*[\p{L}\p{N}])?)*\.\p{L}{2,}/gu;
19516
20026
  var URL_RE = /\b(?:[a-z][a-z0-9+.-]*:\/\/|www\.)[^\s<>"'`){}]+/gi;
19517
- var IBAN_RE = /\b[A-Z]{2}\d{2}(?:[ -]?[A-Z0-9]{4}){2,7}(?:[ -]?[A-Z0-9]{1,4})?\b/g;
20027
+ var IBAN_RE = /\b[A-Z]{2}\d{2}(?:[ -]?[A-Z0-9]{4}){2,7}(?:[ -]?[A-Z0-9]{1,4})?\b/gi;
20028
+ var ACCOUNT_SHAPE_RE = /^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/;
20029
+ function accountOf(written) {
20030
+ if (written !== written.toUpperCase()) return null;
20031
+ const groups = written.split(/[ -]+/);
20032
+ const printed = groups.length > 1 && groups.slice(0, -1).every((g) => g.length === 4);
20033
+ const compact = printed ? groups.join("") : groups[0];
20034
+ return ACCOUNT_SHAPE_RE.test(compact) ? compact : null;
20035
+ }
19518
20036
  var RECIPIENT_KEYS = /* @__PURE__ */ new Set([
19519
20037
  "to",
19520
20038
  "cc",
@@ -19559,11 +20077,28 @@ function hostOfUrl(value) {
19559
20077
  return null;
19560
20078
  }
19561
20079
  }
20080
+ function ibanOf(written) {
20081
+ const compact = written.replace(/[ -]/g, "").toUpperCase();
20082
+ if (!validateIban(compact)) return null;
20083
+ const length = IBAN_LENGTH[compact.slice(0, 2)];
20084
+ const iban = compact.slice(0, length);
20085
+ if (written === written.toUpperCase()) return iban;
20086
+ let at = 0;
20087
+ for (const group of written.split(/[ -]+/)) {
20088
+ at += group.length;
20089
+ if (at === length) return iban;
20090
+ if (at > length) break;
20091
+ }
20092
+ return null;
20093
+ }
19562
20094
  function addIbans(text, out) {
19563
- for (const m of text.toUpperCase().matchAll(IBAN_RE)) {
19564
- const compact = m[0].replace(/[ -]/g, "");
19565
- if (validateIban(compact)) out.add(`iban:${compact}`);
19566
- else if (/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/.test(compact)) out.add(`account:${compact}`);
20095
+ for (const m of text.matchAll(IBAN_RE)) {
20096
+ const iban = ibanOf(m[0]);
20097
+ if (iban) out.add(`iban:${iban}`);
20098
+ else {
20099
+ const account = accountOf(m[0]);
20100
+ if (account) out.add(`account:${account}`);
20101
+ }
19567
20102
  if (out.size >= MAX_DESTINATIONS) return;
19568
20103
  }
19569
20104
  }
@@ -19611,8 +20146,8 @@ function walk2(value, key, out, depth) {
19611
20146
  s.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "").replace(/^\/\//, "").split(/[/?#]/)[0].replace(/:\d+$/, "")
19612
20147
  );
19613
20148
  if (h && (h.includes(":") || /\.\p{L}{2,}$/u.test(h))) out.add(`host:${h}`);
19614
- const acct = s.replace(/[ .-]/g, "").toUpperCase();
19615
- if (/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/.test(acct) && !validateIban(acct))
20149
+ const acct = s.replace(/[ .-]/g, "");
20150
+ if (acct === acct.toUpperCase() && ACCOUNT_SHAPE_RE.test(acct) && !validateIban(acct))
19616
20151
  out.add(`account:${acct}`);
19617
20152
  }
19618
20153
  return;
@@ -19815,8 +20350,8 @@ function hasRoutingNumber(text) {
19815
20350
  return false;
19816
20351
  }
19817
20352
  var PII_IBAN_RE = /\b[A-Z]{2}\d{2}(?:[A-Z0-9]|[ -][A-Z0-9]){11,30}\b/;
19818
- function* validCardRuns(text, base3, exemptFractions = true) {
19819
- const re = new RegExp(base3.source, "g");
20353
+ function* validCardRuns(text, base4, exemptFractions = true) {
20354
+ const re = new RegExp(base4.source, "g");
19820
20355
  let m;
19821
20356
  while ((m = re.exec(text)) !== null) {
19822
20357
  const digits = m[0].replace(/\D/g, "");
@@ -19829,17 +20364,17 @@ function* validCardRuns(text, base3, exemptFractions = true) {
19829
20364
  }
19830
20365
  }
19831
20366
  function hasValidCard(text) {
19832
- for (const base3 of CARD_PATTERNS) {
19833
- if (!validCardRuns(text, base3).next().done) return true;
20367
+ for (const base4 of CARD_PATTERNS) {
20368
+ if (!validCardRuns(text, base4).next().done) return true;
19834
20369
  }
19835
20370
  return false;
19836
20371
  }
19837
20372
  function replaceValidCards(text, replace, { exemptFractions = true } = {}) {
19838
20373
  let out = text;
19839
- for (const base3 of CARD_PATTERNS) {
20374
+ for (const base4 of CARD_PATTERNS) {
19840
20375
  let res = "";
19841
20376
  let last = 0;
19842
- for (const run of validCardRuns(out, base3, exemptFractions)) {
20377
+ for (const run of validCardRuns(out, base4, exemptFractions)) {
19843
20378
  res += out.slice(last, run.index) + replace(run.digits);
19844
20379
  last = run.index + run.length;
19845
20380
  }
@@ -20128,9 +20663,9 @@ function maskLeaf(value, key, depth) {
20128
20663
  const used = /* @__PURE__ */ new Set();
20129
20664
  return Object.fromEntries(
20130
20665
  Object.entries(value).map(([k, v]) => {
20131
- const base3 = maskPersonalData(k);
20132
- let name = base3;
20133
- for (let n = 2; used.has(name); n++) name = `${base3}#${n}`;
20666
+ const base4 = maskPersonalData(k);
20667
+ let name = base4;
20668
+ for (let n = 2; used.has(name); n++) name = `${base4}#${n}`;
20134
20669
  used.add(name);
20135
20670
  return [name, maskLeaf(v, k, depth + 1)];
20136
20671
  })
@@ -20372,7 +20907,7 @@ function classifyCall(head, args, prefixes, env, state, out) {
20372
20907
  }
20373
20908
  case "scp":
20374
20909
  case "rsync": {
20375
- const pos = positionals(args, VALUE_FLAGS[head] ?? /* @__PURE__ */ new Set()).filter(
20910
+ const pos = positionals(args, VALUE_FLAGS2[head] ?? /* @__PURE__ */ new Set()).filter(
20376
20911
  (p) => p !== null
20377
20912
  );
20378
20913
  if (pos.length < 2) return;
@@ -20994,7 +21529,7 @@ function summarizeBlast(result, opts = {}) {
20994
21529
  // src/scan/destructive-regex.ts
20995
21530
  var DESTRUCTIVE_OP_RE = /\brm\s+-[rRf]+\b|\bDROP\s+(TABLE|DATABASE|COLLECTION|SCHEMA)\b|\bTRUNCATE\s+TABLE\b|\bgit\s+push\s+(--force|-f)\b|\bFLUSHALL\b|\bFLUSHDB\b|\bkubectl\s+delete\b|\bhelm\s+uninstall\b/i;
20996
21531
  var PRIVILEGE_ESCALATION_RE = /\bchmod\s+(0?777|\+x)\b|\bchown\s+root\b/i;
20997
- var SENSITIVE_PATH_RE = /[\\/]\.aws(?:[\\/]|$)|^\.aws[\\/]|[\\/]\.ssh(?:[\\/]|$)|^\.ssh[\\/]|(?:^|[\\/])\.env(?![\w-])(?:[\w.-]*\.local$|(?!\.(?:example|sample|template)\b)(?!\.test$)[\w.-]*$)|\.config\/gcloud\/credentials\.db\b|\.docker\/config\.json\b|\.netrc\b|\.npmrc\b|\.node9\/credentials\.json\b/i;
21532
+ var SENSITIVE_PATH_RE = /[\\/]\.aws(?:[\\/]|$)|^\.aws[\\/]|[\\/]\.ssh(?:$|[\\/](?!(?:known_hosts(?:\.old)?|authorized_keys2?|[^\\/]+\.pub)$))|^\.ssh[\\/](?!(?:known_hosts(?:\.old)?|authorized_keys2?|[^\\/]+\.pub)$)|(?:^|[\\/])\.env(?![\w-])(?:[\w.-]*\.local$|(?!\.(?:example|sample|template)\b)(?!\.test$)[\w.-]*$)|\.config\/gcloud\/credentials\.db\b|\.docker\/config\.json\b|\.netrc\b|\.npmrc\b|\.node9\/credentials\.json\b/i;
20998
21533
  var FILE_TOOLS = /* @__PURE__ */ new Set([
20999
21534
  "read",
21000
21535
  "read_file",
@@ -21197,8 +21732,8 @@ function matchCanaryArgs(args, values) {
21197
21732
 
21198
21733
  // src/scan/canonical.ts
21199
21734
  var LONG_OUTPUT_THRESHOLD_BYTES = 100 * 1024;
21200
- var CANONICAL_EXTRACTOR_VERSION = "canonical-v39";
21201
- var CANONICAL_EXTRACTOR_HASH = "1c4a57ad24e7c8c3";
21735
+ var CANONICAL_EXTRACTOR_VERSION = "canonical-v40";
21736
+ var CANONICAL_EXTRACTOR_HASH = "0981d8f2268c7d69";
21202
21737
  var DEDUPE_PREVIEW_LEN = 120;
21203
21738
  function extractCanonicalFindings(call, ctx) {
21204
21739
  const out = [];
@@ -21701,12 +22236,14 @@ var ENGINE_VERSION = "1.4.0";
21701
22236
  PATTERN_VERB_NAMES,
21702
22237
  POSTURE_CATEGORY_OWASP,
21703
22238
  PRIVILEGE_ESCALATION_RE,
22239
+ PUBLIC_SSH_NAME_SOURCE,
21704
22240
  REALTIME_PII_PATTERNS,
21705
22241
  REPLACED_SHIELDS,
21706
22242
  SCAN_REPO_RULES_WITHOUT_RISK,
21707
22243
  SCAN_SIGNAL_WEIGHTS,
21708
22244
  SENSITIVE_PATH_RE,
21709
22245
  SENSITIVE_PATH_REGEXES,
22246
+ SHELL_INTERPRETERS,
21710
22247
  SSRF_MAX_HOST,
21711
22248
  STARTUP_NAMES,
21712
22249
  SYSTEM_AUTH_DIRS,
@@ -21807,6 +22344,7 @@ var ENGINE_VERSION = "1.4.0";
21807
22344
  isPrivateHost,
21808
22345
  isProtectedHomePath,
21809
22346
  isPublicRegistryHost,
22347
+ isPublicSshMaterial,
21810
22348
  isRecordOnly,
21811
22349
  isShellShapedTool,
21812
22350
  isShieldVerdict,