@node9/proxy 2.46.1 → 2.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/scan-ink.mjs CHANGED
@@ -237,20 +237,14 @@ import path from "path";
237
237
  import os from "os";
238
238
 
239
239
  // packages/policy-engine/dist/index.mjs
240
- import mvdanSh3 from "mvdan-sh";
241
240
  import picomatch from "picomatch";
242
241
  import safeRegex from "safe-regex2";
243
242
  import pm from "picomatch";
244
- import mvdanSh from "mvdan-sh";
245
243
  import mvdanSh2 from "mvdan-sh";
244
+ import mvdanSh from "mvdan-sh";
245
+ import mvdanSh3 from "mvdan-sh";
246
246
  import safeRegex2 from "safe-regex2";
247
247
  import { createHash as createHash2 } from "crypto";
248
- import mvdanSh4 from "mvdan-sh";
249
- import mvdanSh5 from "mvdan-sh";
250
- import mvdanSh6 from "mvdan-sh";
251
- import mvdanSh8 from "mvdan-sh";
252
- import mvdanSh7 from "mvdan-sh";
253
- import mvdanSh9 from "mvdan-sh";
254
248
  var MAX_REGEX_LENGTH = 256;
255
249
  function validateRegex(pattern) {
256
250
  if (!pattern) return "Pattern is required";
@@ -2940,6 +2934,117 @@ function isLockedCheck(def) {
2940
2934
  var LEGACY_TO_ID = new Map(
2941
2935
  CHECKS.flatMap((c) => (c.legacy ?? []).map((l) => [l, c.id]))
2942
2936
  );
2937
+ var { syntax } = mvdanSh;
2938
+ var KINDS = {
2939
+ File: { nodes: ["Stmts"] },
2940
+ Stmt: { nodes: ["Cmd", "Redirs"], scalars: ["Negated", "Background", "Coprocess"] },
2941
+ CallExpr: { nodes: ["Assigns", "Args"] },
2942
+ Assign: { nodes: ["Name", "Value", "Index", "Array"], scalars: ["Append", "Naked"] },
2943
+ Word: { nodes: ["Parts"] },
2944
+ Lit: { scalars: ["Value"] },
2945
+ SglQuoted: { scalars: ["Value", "Dollar"] },
2946
+ DblQuoted: { nodes: ["Parts"], scalars: ["Dollar"] },
2947
+ ParamExp: {
2948
+ nodes: ["Param", "Index", "Slice", "Repl", "Exp"],
2949
+ scalars: ["Short", "Excl", "Length", "Width"]
2950
+ },
2951
+ CmdSubst: { nodes: ["Stmts"], scalars: ["Backquotes", "TempFile", "ReplyVar"] },
2952
+ ArithmExp: { nodes: ["X"], scalars: ["Bracket", "Unsigned"] },
2953
+ ArithmCmd: { nodes: ["X"], scalars: ["Unsigned"] },
2954
+ ProcSubst: { nodes: ["Stmts"], scalars: ["Op"] },
2955
+ ExtGlob: { nodes: ["Pattern"], scalars: ["Op"] },
2956
+ BraceExp: { nodes: ["Elems"], scalars: ["Sequence"] },
2957
+ // only with SplitBraces, unused here
2958
+ BinaryCmd: { nodes: ["X", "Y"], scalars: ["Op"] },
2959
+ BinaryArithm: { nodes: ["X", "Y"], scalars: ["Op"] },
2960
+ UnaryArithm: { nodes: ["X"], scalars: ["Op", "Post"] },
2961
+ ParenArithm: { nodes: ["X"] },
2962
+ BinaryTest: { nodes: ["X", "Y"], scalars: ["Op"] },
2963
+ UnaryTest: { nodes: ["X"], scalars: ["Op"] },
2964
+ ParenTest: { nodes: ["X"] },
2965
+ Redirect: { nodes: ["N", "Word", "Hdoc"], scalars: ["Op"] },
2966
+ Block: { nodes: ["Stmts"] },
2967
+ Subshell: { nodes: ["Stmts"] },
2968
+ IfClause: { nodes: ["Cond", "Then", "Else"] },
2969
+ WhileClause: { nodes: ["Cond", "Do"], scalars: ["Until"] },
2970
+ ForClause: { nodes: ["Loop", "Do"], scalars: ["Select"] },
2971
+ WordIter: { nodes: ["Name", "Items"] },
2972
+ CStyleLoop: { nodes: ["Init", "Cond", "Post"] },
2973
+ CaseClause: { nodes: ["Word", "Items"] },
2974
+ CaseItem: { nodes: ["Patterns", "Stmts"], scalars: ["Op"] },
2975
+ FuncDecl: { nodes: ["Name", "Body"], scalars: ["RsrvWord"] },
2976
+ DeclClause: { nodes: ["Variant", "Args"], notWalked: ["Variant"] },
2977
+ LetClause: { nodes: ["Exprs"] },
2978
+ TimeClause: { nodes: ["Stmt"], scalars: ["PosixFormat"] },
2979
+ CoprocClause: { nodes: ["Name", "Stmt"] },
2980
+ TestClause: { nodes: ["X"] },
2981
+ TestDecl: { nodes: ["Description", "Body"] },
2982
+ ArrayExpr: { nodes: ["Elems"] },
2983
+ ArrayElem: { nodes: ["Index", "Value"] },
2984
+ Comment: { scalars: ["Text"] }
2985
+ };
2986
+ var STRUCTS = {
2987
+ "ParamExp.Slice": { nodes: ["Offset", "Length"], notWalked: ["Offset", "Length"] },
2988
+ "ParamExp.Repl": { nodes: ["Orig", "With"], scalars: ["All"] },
2989
+ "ParamExp.Exp": { nodes: ["Word"], scalars: ["Op"] }
2990
+ };
2991
+ var unknownKinds = /* @__PURE__ */ new Set();
2992
+ function isGoNode(v) {
2993
+ return v !== null && typeof v === "object" && typeof v.Pos === "function";
2994
+ }
2995
+ function toPlainTree(goNode) {
2996
+ const kind = syntax.NodeType(goNode);
2997
+ const out = { kind, pos: goNode.Pos().Offset(), end: goNode.End().Offset() };
2998
+ const spec = KINDS[kind];
2999
+ if (!spec) {
3000
+ unknownKinds.add(kind);
3001
+ return out;
3002
+ }
3003
+ convertFields(goNode, spec, out, kind);
3004
+ return out;
3005
+ }
3006
+ function convertFields(goNode, spec, out, kind) {
3007
+ for (const f of spec.scalars ?? []) out[f] = goNode[f];
3008
+ for (const f of spec.nodes ?? []) {
3009
+ const v = goNode[f];
3010
+ if (v === void 0 || v === null) {
3011
+ out[f] = null;
3012
+ } else if (Array.isArray(v)) {
3013
+ out[f] = v.map((c) => isGoNode(c) ? toPlainTree(c) : c);
3014
+ } else if (isGoNode(v)) {
3015
+ out[f] = toPlainTree(v);
3016
+ } else if (typeof v === "object" && STRUCTS[`${kind}.${f}`]) {
3017
+ const sub = { struct: `${kind}.${f}` };
3018
+ convertFields(v, STRUCTS[`${kind}.${f}`], sub, `${kind}.${f}`);
3019
+ out[f] = sub;
3020
+ } else {
3021
+ out[f] = v;
3022
+ }
3023
+ }
3024
+ }
3025
+ function childrenOf(n) {
3026
+ const spec = n.kind ? KINDS[n.kind] : STRUCTS[n.struct];
3027
+ if (!spec?.nodes) return [];
3028
+ const out = [];
3029
+ for (const f of spec.nodes) {
3030
+ if (spec.notWalked?.includes(f)) continue;
3031
+ const v = n[f];
3032
+ if (!v) continue;
3033
+ if (Array.isArray(v)) {
3034
+ for (const c of v) if (c) out.push(c);
3035
+ } else if (v.kind) {
3036
+ out.push(v);
3037
+ } else if (v.struct) {
3038
+ out.push(...childrenOf(v));
3039
+ }
3040
+ }
3041
+ return out;
3042
+ }
3043
+ function walk(root, fn) {
3044
+ if (!root) return;
3045
+ if (!fn(root)) return;
3046
+ for (const c of childrenOf(root)) walk(c, fn);
3047
+ }
2943
3048
  var INVISIBLE_RE = /[­͏؜᠎​-‏‪-‮⁠-⁤-︀-️]|[\u{E0000}-\u{E007F}]/gu;
2944
3049
  var INVISIBLE_ONE = new RegExp(`^(?:${INVISIBLE_RE.source.split("|")[0]})$`, "u");
2945
3050
  var HOMOGLYPHS = {
@@ -3173,8 +3278,8 @@ var PHP = [
3173
3278
  ],
3174
3279
  ["permissions", /\b(?:chmod|chown|chgrp|lchown|lchgrp)\s*\(/]
3175
3280
  ];
3176
- var { syntax } = mvdanSh;
3177
- var sharedParser = syntax.NewParser();
3281
+ var { syntax: syntax2 } = mvdanSh2;
3282
+ var sharedParser = syntax2.NewParser();
3178
3283
  var SHELL_INTERPRETERS = /* @__PURE__ */ new Set([
3179
3284
  "bash",
3180
3285
  "sh",
@@ -3187,7 +3292,7 @@ var SHELL_INTERPRETERS = /* @__PURE__ */ new Set([
3187
3292
  "powershell",
3188
3293
  "pwsh"
3189
3294
  ]);
3190
- var AST_CACHE_MAX = 5e3;
3295
+ var AST_CACHE_MAX = 256;
3191
3296
  var astCache = /* @__PURE__ */ new Map();
3192
3297
  var PARSE_FAIL = /* @__PURE__ */ Symbol("parse-fail");
3193
3298
  function parseShared(command) {
@@ -3199,7 +3304,7 @@ function parseShared(command) {
3199
3304
  }
3200
3305
  let parsed;
3201
3306
  try {
3202
- parsed = sharedParser.Parse(command, "cmd");
3307
+ parsed = toPlainTree(sharedParser.Parse(command, "cmd"));
3203
3308
  } catch {
3204
3309
  parsed = PARSE_FAIL;
3205
3310
  }
@@ -3724,8 +3829,8 @@ var FS_OP_PRESCREEN_RE = new RegExp(
3724
3829
  var currentStmtOffset = Number.MAX_SAFE_INTEGER;
3725
3830
  function probeBinOp(src) {
3726
3831
  try {
3727
- const cmd = syntax.NewParser().Parse(src, "probe")?.Stmts?.[0]?.Cmd;
3728
- if (cmd && syntax.NodeType(cmd) === "BinaryCmd") return cmd.Op;
3832
+ const cmd = toPlainTree(syntax2.NewParser().Parse(src, "probe"))?.Stmts?.[0]?.Cmd;
3833
+ if (cmd && cmd.kind === "BinaryCmd") return cmd.Op;
3729
3834
  } catch {
3730
3835
  }
3731
3836
  return null;
@@ -3735,11 +3840,11 @@ var OR_OP = probeBinOp("a || b");
3735
3840
  var AND_OR_OPS = new Set([AND_OP, OR_OP].filter((o) => o !== null));
3736
3841
  function deriveRedirOp(sample) {
3737
3842
  try {
3738
- const f = sharedParser.Parse(sample, "cmd");
3843
+ const f = toPlainTree(sharedParser.Parse(sample, "cmd"));
3739
3844
  let op = -1;
3740
- syntax.Walk(f, (node) => {
3845
+ walk(f, (node) => {
3741
3846
  const n = node;
3742
- if (n && syntax.NodeType(n) === "Redirect" && op < 0) op = n.Op;
3847
+ if (n && n.kind === "Redirect" && op < 0) op = n.Op;
3743
3848
  return true;
3744
3849
  });
3745
3850
  return op;
@@ -3775,7 +3880,7 @@ var MCP_EXECUTORS = /* @__PURE__ */ new Set([
3775
3880
  "run_terminal_command",
3776
3881
  "start_process"
3777
3882
  ]);
3778
- var { syntax: syntax2 } = mvdanSh2;
3883
+ var { syntax: syntax3 } = mvdanSh3;
3779
3884
  function opOf(sample) {
3780
3885
  return parseShared(sample).Stmts[0].Redirs[0].Op;
3781
3886
  }
@@ -3791,7 +3896,6 @@ var DEFAULT_OPS = new Set(
3791
3896
  (s) => parseShared(`echo ${s}`).Stmts[0].Cmd.Args[1].Parts[0].Exp.Op
3792
3897
  )
3793
3898
  );
3794
- var { syntax: syntax3 } = mvdanSh3;
3795
3899
  var SEQUENCE_OPS = (() => {
3796
3900
  const ops = /* @__PURE__ */ new Set();
3797
3901
  for (const text of ["x && y", "x || y"]) {
@@ -7033,7 +7137,6 @@ var REUSED_SIGNALS = INJECTION_SIGNALS.map(
7033
7137
  } : sig
7034
7138
  );
7035
7139
  var NEVER_NEGATED = /* @__PURE__ */ new Set([SIGNALS[1].any[0]]);
7036
- var { syntax: syntax4 } = mvdanSh4;
7037
7140
  var RDR_IN = (() => {
7038
7141
  try {
7039
7142
  return parseShared("x <y").Stmts[0].Redirs[0].Op;
@@ -7041,8 +7144,6 @@ var RDR_IN = (() => {
7041
7144
  return null;
7042
7145
  }
7043
7146
  })();
7044
- var { syntax: syntax5 } = mvdanSh5;
7045
- var { syntax: syntax6 } = mvdanSh6;
7046
7147
  var SHELLS = /* @__PURE__ */ new Set([...SHELL_INTERPRETERS, "mksh", "ash", "csh", "tcsh"]);
7047
7148
  var NETCATS = /* @__PURE__ */ new Set(["nc", "ncat", "netcat", "nc.traditional", "nc.openbsd"]);
7048
7149
  var NET_CLIENTS = /* @__PURE__ */ new Set([...NETCATS, "telnet", "socat"]);
@@ -7064,7 +7165,6 @@ var SENDERS = /* @__PURE__ */ new Set([
7064
7165
  "invoke-restmethod",
7065
7166
  "openssl"
7066
7167
  ]);
7067
- var { syntax: syntax7 } = mvdanSh7;
7068
7168
  var EDITOR_HEADS = ["code", "code-insiders", "codium", "vscodium", "cursor"];
7069
7169
  var MANAGER_HEADS = /* @__PURE__ */ new Set([
7070
7170
  "gem",
@@ -7094,7 +7194,6 @@ var MANAGER_HEADS = /* @__PURE__ */ new Set([
7094
7194
  "poetry",
7095
7195
  "pipenv"
7096
7196
  ]);
7097
- var { syntax: syntax8 } = mvdanSh8;
7098
7197
  var TUNING_FIELDS = [
7099
7198
  { checkId: "network.unknown-host", name: "allow", legacy: ["egress", "allow"] },
7100
7199
  { checkId: "network.unknown-host", name: "deny", legacy: ["egress", "deny"] },
@@ -7252,7 +7351,6 @@ var NATIONAL_ID_LABEL_RE = new RegExp(
7252
7351
  ].join(""),
7253
7352
  "iu"
7254
7353
  );
7255
- var { syntax: syntax9 } = mvdanSh9;
7256
7354
  var PUBLISH = {
7257
7355
  npm: { verbs: /* @__PURE__ */ new Set(["publish"]), registry: "registry.npmjs.org", flag: ["--registry"] },
7258
7356
  pnpm: { verbs: /* @__PURE__ */ new Set(["publish"]), registry: "registry.npmjs.org", flag: ["--registry"] },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node9/proxy",
3
- "version": "2.46.1",
3
+ "version": "2.47.0",
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",