@node9/policy-engine 2.64.0 → 2.65.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.js CHANGED
@@ -2952,6 +2952,10 @@ var SCAN_REPO_RULE_OWASP = [
2952
2952
  ["CI-3.mcp-inline-credential", "ASI03"],
2953
2953
  ["CI-3.mcp-unpinned", "ASI04"],
2954
2954
  ["CI-3.plugin-unpinned", "ASI04"],
2955
+ // A1: a package the agent runs, or a dependency a change adds, that is malicious, unowned,
2956
+ // removed or a look-alike: the supply chain.
2957
+ ["CI-3.package-", "ASI04"],
2958
+ ["CI-3.dependency-added-", "ASI04"],
2955
2959
  // CI-4: secrets an agent step can reach
2956
2960
  ["CI-4.", "ASI03"],
2957
2961
  // CI-6: instruction files and skills
@@ -16352,6 +16356,8 @@ function parseNpmSpec(raw) {
16352
16356
  return { name, version: exact ? exact[1] : void 0 };
16353
16357
  }
16354
16358
  var NPM_VALUE_FLAGS = /* @__PURE__ */ new Set([
16359
+ "--package",
16360
+ // `npm --package=<pkg> exec <cmd>`: read by the exec branch
16355
16361
  "--registry",
16356
16362
  "--prefix",
16357
16363
  "--cache",
@@ -16373,6 +16379,8 @@ var NPM_VALUE_FLAGS = /* @__PURE__ */ new Set([
16373
16379
  "--libc"
16374
16380
  ]);
16375
16381
  var PNPM_VALUE_FLAGS = /* @__PURE__ */ new Set([
16382
+ "--package",
16383
+ // `pnpm --package=<pkg> dlx <cmd>`: read by the dlx branch
16376
16384
  "--registry",
16377
16385
  "-C",
16378
16386
  "--dir",
@@ -16588,9 +16596,10 @@ function operands(words, from, valueFlags) {
16588
16596
  }
16589
16597
  return out;
16590
16598
  }
16591
- function flagValues(words, from, names) {
16599
+ function flagValues(words, from, names, until = words.length) {
16592
16600
  const out = [];
16593
- for (let i = from; i >= 0 && i < words.length; i++) {
16601
+ const end = until < 0 ? words.length : Math.min(until, words.length);
16602
+ for (let i = from; i >= 0 && i < end; i++) {
16594
16603
  const w = words[i];
16595
16604
  if (w === null) continue;
16596
16605
  for (const n of names) {
@@ -16998,8 +17007,9 @@ function pushPy(out, manager, specs, limit = Infinity) {
16998
17007
  n++;
16999
17008
  }
17000
17009
  }
17001
- function npxPackages(words, from) {
17002
- const explicit = flagValues(words, from, ["-p", "--package"]);
17010
+ function npxPackages(words, from, before = []) {
17011
+ const explicit = [...before];
17012
+ const take = (v) => explicit.push(...v.split(",").filter((x) => x.length > 0));
17003
17013
  for (let i = from; i >= 0 && i < words.length; i++) {
17004
17014
  const w = words[i];
17005
17015
  if (w === null) return explicit;
@@ -17008,7 +17018,14 @@ function npxPackages(words, from) {
17008
17018
  return explicit.length > 0 ? explicit : next ? [next] : [];
17009
17019
  }
17010
17020
  if (w.startsWith("-")) {
17011
- if (w === "-p" || w === "--package" || w === "-c" || w === "--call") i++;
17021
+ if (w === "-p" || w === "--package") {
17022
+ const v = words[i + 1];
17023
+ if (typeof v === "string") take(v);
17024
+ i++;
17025
+ } else if (w.startsWith("-p=") || w.startsWith("--package="))
17026
+ take(w.slice(w.indexOf("=") + 1));
17027
+ else if (w === "-c" || w === "--call")
17028
+ i++;
17012
17029
  else if (takesValue(w, NPM_VALUE_FLAGS)) i++;
17013
17030
  continue;
17014
17031
  }
@@ -17017,9 +17034,9 @@ function npxPackages(words, from) {
17017
17034
  return explicit;
17018
17035
  }
17019
17036
  function uvxPackages(words, from) {
17020
- const from_ = flagValues(words, from, ["--from"]);
17021
- const withs = flagValues(words, from, ["--with"]);
17022
17037
  const first = verbIndex(words, from, UV_VALUE_FLAGS);
17038
+ const from_ = flagValues(words, from, ["--from"], first);
17039
+ const withs = flagValues(words, from, ["--with"], first);
17023
17040
  const tool = first >= 0 && from_.length === 0 ? [words[first]] : [];
17024
17041
  return [...from_, ...tool, ...withs];
17025
17042
  }
@@ -17062,7 +17079,12 @@ function fromCall(words, out, depth) {
17062
17079
  const verb = lower(words[v]);
17063
17080
  if (v < 0) return;
17064
17081
  if (NPM_INSTALL_VERBS.has(verb)) pushNpm(out, "npm", operands(words, v + 1, NPM_VALUE_FLAGS));
17065
- else if (NPM_EXEC_VERBS.has(verb)) pushNpm(out, "npm exec", npxPackages(words, v + 1));
17082
+ else if (NPM_EXEC_VERBS.has(verb)) {
17083
+ const before = flagValues(words, start + 1, ["--package"], v);
17084
+ const sep = words.indexOf("--", v + 1);
17085
+ const after = flagValues(words, v + 1, ["--package"], sep < 0 ? words.length : sep);
17086
+ pushNpm(out, "npm exec", [.../* @__PURE__ */ new Set([...npxPackages(words, v + 1, before), ...after])]);
17087
+ }
17066
17088
  return;
17067
17089
  }
17068
17090
  case "npx":
@@ -17074,7 +17096,12 @@ function fromCall(words, out, depth) {
17074
17096
  if (v < 0) return;
17075
17097
  if (PNPM_INSTALL_VERBS.has(verb))
17076
17098
  pushNpm(out, "pnpm", operands(words, v + 1, PNPM_VALUE_FLAGS));
17077
- else if (DLX_VERBS.has(verb)) pushNpm(out, "pnpm dlx", npxPackages(words, v + 1));
17099
+ else if (DLX_VERBS.has(verb))
17100
+ pushNpm(
17101
+ out,
17102
+ "pnpm dlx",
17103
+ npxPackages(words, v + 1, flagValues(words, start + 1, ["--package"], v))
17104
+ );
17078
17105
  return;
17079
17106
  }
17080
17107
  case "yarn": {
@@ -17128,7 +17155,12 @@ function fromCall(words, out, depth) {
17128
17155
  const v = verbIndex(words, start + 1, PIPX_VALUE_FLAGS);
17129
17156
  const verb = lower(words[v]);
17130
17157
  if (v < 0) return;
17131
- const spec = flagValues(words, v + 1, ["--spec"]);
17158
+ const spec = flagValues(
17159
+ words,
17160
+ v + 1,
17161
+ ["--spec"],
17162
+ verb === "run" ? verbIndex(words, v + 1, PIPX_VALUE_FLAGS) : words.length
17163
+ );
17132
17164
  if (verb === "install")
17133
17165
  pushPy(out, "pipx", [...spec, ...operands(words, v + 1, PIPX_VALUE_FLAGS)]);
17134
17166
  else if (verb === "run")
@@ -17149,7 +17181,16 @@ function fromCall(words, out, depth) {
17149
17181
  return;
17150
17182
  }
17151
17183
  if (verb === "run") {
17152
- pushPy(out, "uv run", flagValues(words, v + 1, ["--with", "--with-editable"]));
17184
+ pushPy(
17185
+ out,
17186
+ "uv run",
17187
+ flagValues(
17188
+ words,
17189
+ v + 1,
17190
+ ["--with", "--with-editable"],
17191
+ verbIndex(words, v + 1, UV_VALUE_FLAGS)
17192
+ )
17193
+ );
17153
17194
  return;
17154
17195
  }
17155
17196
  const v2 = verbIndex(words, v + 1, UV_VALUE_FLAGS);
package/dist/index.mjs CHANGED
@@ -2685,6 +2685,10 @@ var SCAN_REPO_RULE_OWASP = [
2685
2685
  ["CI-3.mcp-inline-credential", "ASI03"],
2686
2686
  ["CI-3.mcp-unpinned", "ASI04"],
2687
2687
  ["CI-3.plugin-unpinned", "ASI04"],
2688
+ // A1: a package the agent runs, or a dependency a change adds, that is malicious, unowned,
2689
+ // removed or a look-alike: the supply chain.
2690
+ ["CI-3.package-", "ASI04"],
2691
+ ["CI-3.dependency-added-", "ASI04"],
2688
2692
  // CI-4: secrets an agent step can reach
2689
2693
  ["CI-4.", "ASI03"],
2690
2694
  // CI-6: instruction files and skills
@@ -16085,6 +16089,8 @@ function parseNpmSpec(raw) {
16085
16089
  return { name, version: exact ? exact[1] : void 0 };
16086
16090
  }
16087
16091
  var NPM_VALUE_FLAGS = /* @__PURE__ */ new Set([
16092
+ "--package",
16093
+ // `npm --package=<pkg> exec <cmd>`: read by the exec branch
16088
16094
  "--registry",
16089
16095
  "--prefix",
16090
16096
  "--cache",
@@ -16106,6 +16112,8 @@ var NPM_VALUE_FLAGS = /* @__PURE__ */ new Set([
16106
16112
  "--libc"
16107
16113
  ]);
16108
16114
  var PNPM_VALUE_FLAGS = /* @__PURE__ */ new Set([
16115
+ "--package",
16116
+ // `pnpm --package=<pkg> dlx <cmd>`: read by the dlx branch
16109
16117
  "--registry",
16110
16118
  "-C",
16111
16119
  "--dir",
@@ -16321,9 +16329,10 @@ function operands(words, from, valueFlags) {
16321
16329
  }
16322
16330
  return out;
16323
16331
  }
16324
- function flagValues(words, from, names) {
16332
+ function flagValues(words, from, names, until = words.length) {
16325
16333
  const out = [];
16326
- for (let i = from; i >= 0 && i < words.length; i++) {
16334
+ const end = until < 0 ? words.length : Math.min(until, words.length);
16335
+ for (let i = from; i >= 0 && i < end; i++) {
16327
16336
  const w = words[i];
16328
16337
  if (w === null) continue;
16329
16338
  for (const n of names) {
@@ -16731,8 +16740,9 @@ function pushPy(out, manager, specs, limit = Infinity) {
16731
16740
  n++;
16732
16741
  }
16733
16742
  }
16734
- function npxPackages(words, from) {
16735
- const explicit = flagValues(words, from, ["-p", "--package"]);
16743
+ function npxPackages(words, from, before = []) {
16744
+ const explicit = [...before];
16745
+ const take = (v) => explicit.push(...v.split(",").filter((x) => x.length > 0));
16736
16746
  for (let i = from; i >= 0 && i < words.length; i++) {
16737
16747
  const w = words[i];
16738
16748
  if (w === null) return explicit;
@@ -16741,7 +16751,14 @@ function npxPackages(words, from) {
16741
16751
  return explicit.length > 0 ? explicit : next ? [next] : [];
16742
16752
  }
16743
16753
  if (w.startsWith("-")) {
16744
- if (w === "-p" || w === "--package" || w === "-c" || w === "--call") i++;
16754
+ if (w === "-p" || w === "--package") {
16755
+ const v = words[i + 1];
16756
+ if (typeof v === "string") take(v);
16757
+ i++;
16758
+ } else if (w.startsWith("-p=") || w.startsWith("--package="))
16759
+ take(w.slice(w.indexOf("=") + 1));
16760
+ else if (w === "-c" || w === "--call")
16761
+ i++;
16745
16762
  else if (takesValue(w, NPM_VALUE_FLAGS)) i++;
16746
16763
  continue;
16747
16764
  }
@@ -16750,9 +16767,9 @@ function npxPackages(words, from) {
16750
16767
  return explicit;
16751
16768
  }
16752
16769
  function uvxPackages(words, from) {
16753
- const from_ = flagValues(words, from, ["--from"]);
16754
- const withs = flagValues(words, from, ["--with"]);
16755
16770
  const first = verbIndex(words, from, UV_VALUE_FLAGS);
16771
+ const from_ = flagValues(words, from, ["--from"], first);
16772
+ const withs = flagValues(words, from, ["--with"], first);
16756
16773
  const tool = first >= 0 && from_.length === 0 ? [words[first]] : [];
16757
16774
  return [...from_, ...tool, ...withs];
16758
16775
  }
@@ -16795,7 +16812,12 @@ function fromCall(words, out, depth) {
16795
16812
  const verb = lower(words[v]);
16796
16813
  if (v < 0) return;
16797
16814
  if (NPM_INSTALL_VERBS.has(verb)) pushNpm(out, "npm", operands(words, v + 1, NPM_VALUE_FLAGS));
16798
- else if (NPM_EXEC_VERBS.has(verb)) pushNpm(out, "npm exec", npxPackages(words, v + 1));
16815
+ else if (NPM_EXEC_VERBS.has(verb)) {
16816
+ const before = flagValues(words, start + 1, ["--package"], v);
16817
+ const sep = words.indexOf("--", v + 1);
16818
+ const after = flagValues(words, v + 1, ["--package"], sep < 0 ? words.length : sep);
16819
+ pushNpm(out, "npm exec", [.../* @__PURE__ */ new Set([...npxPackages(words, v + 1, before), ...after])]);
16820
+ }
16799
16821
  return;
16800
16822
  }
16801
16823
  case "npx":
@@ -16807,7 +16829,12 @@ function fromCall(words, out, depth) {
16807
16829
  if (v < 0) return;
16808
16830
  if (PNPM_INSTALL_VERBS.has(verb))
16809
16831
  pushNpm(out, "pnpm", operands(words, v + 1, PNPM_VALUE_FLAGS));
16810
- else if (DLX_VERBS.has(verb)) pushNpm(out, "pnpm dlx", npxPackages(words, v + 1));
16832
+ else if (DLX_VERBS.has(verb))
16833
+ pushNpm(
16834
+ out,
16835
+ "pnpm dlx",
16836
+ npxPackages(words, v + 1, flagValues(words, start + 1, ["--package"], v))
16837
+ );
16811
16838
  return;
16812
16839
  }
16813
16840
  case "yarn": {
@@ -16861,7 +16888,12 @@ function fromCall(words, out, depth) {
16861
16888
  const v = verbIndex(words, start + 1, PIPX_VALUE_FLAGS);
16862
16889
  const verb = lower(words[v]);
16863
16890
  if (v < 0) return;
16864
- const spec = flagValues(words, v + 1, ["--spec"]);
16891
+ const spec = flagValues(
16892
+ words,
16893
+ v + 1,
16894
+ ["--spec"],
16895
+ verb === "run" ? verbIndex(words, v + 1, PIPX_VALUE_FLAGS) : words.length
16896
+ );
16865
16897
  if (verb === "install")
16866
16898
  pushPy(out, "pipx", [...spec, ...operands(words, v + 1, PIPX_VALUE_FLAGS)]);
16867
16899
  else if (verb === "run")
@@ -16882,7 +16914,16 @@ function fromCall(words, out, depth) {
16882
16914
  return;
16883
16915
  }
16884
16916
  if (verb === "run") {
16885
- pushPy(out, "uv run", flagValues(words, v + 1, ["--with", "--with-editable"]));
16917
+ pushPy(
16918
+ out,
16919
+ "uv run",
16920
+ flagValues(
16921
+ words,
16922
+ v + 1,
16923
+ ["--with", "--with-editable"],
16924
+ verbIndex(words, v + 1, UV_VALUE_FLAGS)
16925
+ )
16926
+ );
16886
16927
  return;
16887
16928
  }
16888
16929
  const v2 = verbIndex(words, v + 1, UV_VALUE_FLAGS);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node9/policy-engine",
3
- "version": "2.64.0",
3
+ "version": "2.65.0",
4
4
  "description": "Shared policy evaluation engine for node9 — DLP, smart rules, AST shell parsing, shields, loop detection. Pure functions, no I/O. Used by both node9-proxy and the node9 SaaS firewall.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://node9.ai",