@node9/proxy 2.47.0 → 2.47.2

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/scan-ink.mjs CHANGED
@@ -237,14 +237,15 @@ import path from "path";
237
237
  import os from "os";
238
238
 
239
239
  // packages/policy-engine/dist/index.mjs
240
+ import { fileURLToPath } from "url";
240
241
  import picomatch from "picomatch";
241
242
  import safeRegex from "safe-regex2";
242
243
  import pm from "picomatch";
243
- import mvdanSh2 from "mvdan-sh";
244
- import mvdanSh from "mvdan-sh";
245
- import mvdanSh3 from "mvdan-sh";
244
+ import { createRequire } from "module";
246
245
  import safeRegex2 from "safe-regex2";
247
246
  import { createHash as createHash2 } from "crypto";
247
+ var getFilename = () => fileURLToPath(import.meta.url);
248
+ var __filename2 = /* @__PURE__ */ getFilename();
248
249
  var MAX_REGEX_LENGTH = 256;
249
250
  function validateRegex(pattern) {
250
251
  if (!pattern) return "Pattern is required";
@@ -2934,7 +2935,25 @@ function isLockedCheck(def) {
2934
2935
  var LEGACY_TO_ID = new Map(
2935
2936
  CHECKS.flatMap((c) => (c.legacy ?? []).map((l) => [l, c.id]))
2936
2937
  );
2937
- var { syntax } = mvdanSh;
2938
+ var syntax = null;
2939
+ function getSyntax() {
2940
+ if (syntax === null) {
2941
+ const req = createRequire(__filename2);
2942
+ syntax = req("mvdan-sh").syntax;
2943
+ }
2944
+ return syntax;
2945
+ }
2946
+ function lazy(compute) {
2947
+ let done = false;
2948
+ let value;
2949
+ return () => {
2950
+ if (!done) {
2951
+ value = compute();
2952
+ done = true;
2953
+ }
2954
+ return value;
2955
+ };
2956
+ }
2938
2957
  var KINDS = {
2939
2958
  File: { nodes: ["Stmts"] },
2940
2959
  Stmt: { nodes: ["Cmd", "Redirs"], scalars: ["Negated", "Background", "Coprocess"] },
@@ -2993,7 +3012,7 @@ function isGoNode(v) {
2993
3012
  return v !== null && typeof v === "object" && typeof v.Pos === "function";
2994
3013
  }
2995
3014
  function toPlainTree(goNode) {
2996
- const kind = syntax.NodeType(goNode);
3015
+ const kind = getSyntax().NodeType(goNode);
2997
3016
  const out = { kind, pos: goNode.Pos().Offset(), end: goNode.End().Offset() };
2998
3017
  const spec = KINDS[kind];
2999
3018
  if (!spec) {
@@ -3278,8 +3297,7 @@ var PHP = [
3278
3297
  ],
3279
3298
  ["permissions", /\b(?:chmod|chown|chgrp|lchown|lchgrp)\s*\(/]
3280
3299
  ];
3281
- var { syntax: syntax2 } = mvdanSh2;
3282
- var sharedParser = syntax2.NewParser();
3300
+ var sharedParser = lazy(() => getSyntax().NewParser());
3283
3301
  var SHELL_INTERPRETERS = /* @__PURE__ */ new Set([
3284
3302
  "bash",
3285
3303
  "sh",
@@ -3304,7 +3322,7 @@ function parseShared(command) {
3304
3322
  }
3305
3323
  let parsed;
3306
3324
  try {
3307
- parsed = toPlainTree(sharedParser.Parse(command, "cmd"));
3325
+ parsed = toPlainTree(sharedParser().Parse(command, "cmd"));
3308
3326
  } catch {
3309
3327
  parsed = PARSE_FAIL;
3310
3328
  }
@@ -3829,18 +3847,23 @@ var FS_OP_PRESCREEN_RE = new RegExp(
3829
3847
  var currentStmtOffset = Number.MAX_SAFE_INTEGER;
3830
3848
  function probeBinOp(src) {
3831
3849
  try {
3832
- const cmd = toPlainTree(syntax2.NewParser().Parse(src, "probe"))?.Stmts?.[0]?.Cmd;
3850
+ const cmd = toPlainTree(getSyntax().NewParser().Parse(src, "probe"))?.Stmts?.[0]?.Cmd;
3833
3851
  if (cmd && cmd.kind === "BinaryCmd") return cmd.Op;
3834
3852
  } catch {
3835
3853
  }
3836
3854
  return null;
3837
3855
  }
3838
- var AND_OP = probeBinOp("a && b");
3839
- var OR_OP = probeBinOp("a || b");
3840
- var AND_OR_OPS = new Set([AND_OP, OR_OP].filter((o) => o !== null));
3856
+ var andOrOps = lazy(() => {
3857
+ const and = probeBinOp("a && b");
3858
+ const or = probeBinOp("a || b");
3859
+ return {
3860
+ AND_OP: and,
3861
+ AND_OR_OPS: new Set([and, or].filter((o) => o !== null))
3862
+ };
3863
+ });
3841
3864
  function deriveRedirOp(sample) {
3842
3865
  try {
3843
- const f = toPlainTree(sharedParser.Parse(sample, "cmd"));
3866
+ const f = toPlainTree(sharedParser().Parse(sample, "cmd"));
3844
3867
  let op = -1;
3845
3868
  walk(f, (node) => {
3846
3869
  const n = node;
@@ -3852,14 +3875,13 @@ function deriveRedirOp(sample) {
3852
3875
  return -1;
3853
3876
  }
3854
3877
  }
3855
- var REDIR_TRUNCATE_OPS = /* @__PURE__ */ new Set([deriveRedirOp(">_f")]);
3856
- var REDIR_FILE_IN_OPS = new Set(
3857
- [deriveRedirOp("cat < f"), deriveRedirOp("cat <> f")].filter((op) => op >= 0)
3878
+ var REDIR_TRUNCATE_OPS = lazy(() => /* @__PURE__ */ new Set([deriveRedirOp(">_f")]));
3879
+ var REDIR_FILE_IN_OPS = lazy(
3880
+ () => new Set([deriveRedirOp("cat < f"), deriveRedirOp("cat <> f")].filter((op) => op >= 0))
3881
+ );
3882
+ var REDIR_HEREDOC_OPS = lazy(
3883
+ () => /* @__PURE__ */ new Set([deriveRedirOp("cat <<X\nX"), deriveRedirOp("cat <<-X\nX")])
3858
3884
  );
3859
- var REDIR_HEREDOC_OPS = /* @__PURE__ */ new Set([
3860
- deriveRedirOp("cat <<X\nX"),
3861
- deriveRedirOp("cat <<-X\nX")
3862
- ]);
3863
3885
  var BASH_TOOL_NAMES = /* @__PURE__ */ new Set([
3864
3886
  "bash",
3865
3887
  "execute_bash",
@@ -3880,33 +3902,36 @@ var MCP_EXECUTORS = /* @__PURE__ */ new Set([
3880
3902
  "run_terminal_command",
3881
3903
  "start_process"
3882
3904
  ]);
3883
- var { syntax: syntax3 } = mvdanSh3;
3884
3905
  function opOf(sample) {
3885
3906
  return parseShared(sample).Stmts[0].Redirs[0].Op;
3886
3907
  }
3887
- var WRITES = new Set([">x", ">>x", ">|x", "&>x", "&>>x", "<>x"].map(opOf));
3888
- var APPENDS = new Set([">>x", "&>>x"].map(opOf));
3889
- var READS = new Set(["<x", "<>x"].map(opOf));
3890
- var DUP_OUT = opOf(">&x");
3891
- var HERE_STRING = opOf("<<<x");
3892
- var AND = parseShared("a && b").Stmts[0].Cmd.Op;
3893
- var OR = parseShared("a || b").Stmts[0].Cmd.Op;
3894
- var DEFAULT_OPS = new Set(
3895
- ["${x:-y}", "${x-y}", "${x:=y}", "${x=y}"].map(
3896
- (s) => parseShared(`echo ${s}`).Stmts[0].Cmd.Args[1].Parts[0].Exp.Op
3908
+ var ops = lazy(() => ({
3909
+ WRITES: new Set([">x", ">>x", ">|x", "&>x", "&>>x", "<>x"].map(opOf)),
3910
+ APPENDS: new Set([">>x", "&>>x"].map(opOf)),
3911
+ READS: new Set(["<x", "<>x"].map(opOf)),
3912
+ /** `>&word` with a non-numeric word is `&>word` in bash. */
3913
+ DUP_OUT: opOf(">&x"),
3914
+ HERE_STRING: opOf("<<<x"),
3915
+ AND: parseShared("a && b").Stmts[0].Cmd.Op,
3916
+ OR: parseShared("a || b").Stmts[0].Cmd.Op,
3917
+ /** `${x:-d}` `${x-d}` `${x:=d}` `${x=d}`: the default is the value when x is unset. */
3918
+ DEFAULT_OPS: new Set(
3919
+ ["${x:-y}", "${x-y}", "${x:=y}", "${x=y}"].map(
3920
+ (s) => parseShared(`echo ${s}`).Stmts[0].Cmd.Args[1].Parts[0].Exp.Op
3921
+ )
3897
3922
  )
3898
- );
3899
- var SEQUENCE_OPS = (() => {
3900
- const ops = /* @__PURE__ */ new Set();
3923
+ }));
3924
+ var SEQUENCE_OPS = lazy(() => {
3925
+ const ops2 = /* @__PURE__ */ new Set();
3901
3926
  for (const text of ["x && y", "x || y"]) {
3902
3927
  try {
3903
3928
  const f = parseShared(text);
3904
- if (typeof f !== "symbol") ops.add(f.Stmts[0].Cmd.Op);
3929
+ if (typeof f !== "symbol") ops2.add(f.Stmts[0].Cmd.Op);
3905
3930
  } catch {
3906
3931
  }
3907
3932
  }
3908
- return ops;
3909
- })();
3933
+ return ops2;
3934
+ });
3910
3935
  var BIP39_ENGLISH = `abandon
3911
3936
  ability
3912
3937
  able
@@ -7137,13 +7162,13 @@ var REUSED_SIGNALS = INJECTION_SIGNALS.map(
7137
7162
  } : sig
7138
7163
  );
7139
7164
  var NEVER_NEGATED = /* @__PURE__ */ new Set([SIGNALS[1].any[0]]);
7140
- var RDR_IN = (() => {
7165
+ var RDR_IN = lazy(() => {
7141
7166
  try {
7142
7167
  return parseShared("x <y").Stmts[0].Redirs[0].Op;
7143
7168
  } catch {
7144
7169
  return null;
7145
7170
  }
7146
- })();
7171
+ });
7147
7172
  var SHELLS = /* @__PURE__ */ new Set([...SHELL_INTERPRETERS, "mksh", "ash", "csh", "tcsh"]);
7148
7173
  var NETCATS = /* @__PURE__ */ new Set(["nc", "ncat", "netcat", "nc.traditional", "nc.openbsd"]);
7149
7174
  var NET_CLIENTS = /* @__PURE__ */ new Set([...NETCATS, "telnet", "socat"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node9/proxy",
3
- "version": "2.47.0",
3
+ "version": "2.47.2",
4
4
  "description": "Access control for AI agents. Set what Claude Code, Codex, Gemini, Cursor and any MCP server are allowed to do, review risky actions before they run, and keep every action on the record.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
File without changes
File without changes