@node9/policy-engine 2.63.0 → 2.64.1
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 +53 -11
- package/dist/index.mjs +53 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2941,6 +2941,11 @@ var SCAN_REPO_RULE_OWASP = [
|
|
|
2941
2941
|
["CI-1.hook-remote-code", "ASI05"],
|
|
2942
2942
|
["CI-1.hook-script", "ASI05"],
|
|
2943
2943
|
["CI-1.unfollowable-symlink", "ASI04"],
|
|
2944
|
+
// A9: a worm's start-up trigger or loader is a compromised supply chain; a plain
|
|
2945
|
+
// folder-open task is code that runs by itself.
|
|
2946
|
+
["CI-1.worm-startup", "ASI04"],
|
|
2947
|
+
["CI-1.worm-loader", "ASI04"],
|
|
2948
|
+
["CI-1.folder-open-task", "ASI05"],
|
|
2944
2949
|
// CI-2: workflows that run agents on outside content
|
|
2945
2950
|
["CI-2.", "ASI01"],
|
|
2946
2951
|
// CI-3: MCP servers and plugins
|
|
@@ -16347,6 +16352,8 @@ function parseNpmSpec(raw) {
|
|
|
16347
16352
|
return { name, version: exact ? exact[1] : void 0 };
|
|
16348
16353
|
}
|
|
16349
16354
|
var NPM_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
16355
|
+
"--package",
|
|
16356
|
+
// `npm --package=<pkg> exec <cmd>`: read by the exec branch
|
|
16350
16357
|
"--registry",
|
|
16351
16358
|
"--prefix",
|
|
16352
16359
|
"--cache",
|
|
@@ -16368,6 +16375,8 @@ var NPM_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
|
16368
16375
|
"--libc"
|
|
16369
16376
|
]);
|
|
16370
16377
|
var PNPM_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
16378
|
+
"--package",
|
|
16379
|
+
// `pnpm --package=<pkg> dlx <cmd>`: read by the dlx branch
|
|
16371
16380
|
"--registry",
|
|
16372
16381
|
"-C",
|
|
16373
16382
|
"--dir",
|
|
@@ -16583,9 +16592,10 @@ function operands(words, from, valueFlags) {
|
|
|
16583
16592
|
}
|
|
16584
16593
|
return out;
|
|
16585
16594
|
}
|
|
16586
|
-
function flagValues(words, from, names) {
|
|
16595
|
+
function flagValues(words, from, names, until = words.length) {
|
|
16587
16596
|
const out = [];
|
|
16588
|
-
|
|
16597
|
+
const end = until < 0 ? words.length : Math.min(until, words.length);
|
|
16598
|
+
for (let i = from; i >= 0 && i < end; i++) {
|
|
16589
16599
|
const w = words[i];
|
|
16590
16600
|
if (w === null) continue;
|
|
16591
16601
|
for (const n of names) {
|
|
@@ -16993,8 +17003,9 @@ function pushPy(out, manager, specs, limit = Infinity) {
|
|
|
16993
17003
|
n++;
|
|
16994
17004
|
}
|
|
16995
17005
|
}
|
|
16996
|
-
function npxPackages(words, from) {
|
|
16997
|
-
const explicit =
|
|
17006
|
+
function npxPackages(words, from, before = []) {
|
|
17007
|
+
const explicit = [...before];
|
|
17008
|
+
const take = (v) => explicit.push(...v.split(",").filter((x) => x.length > 0));
|
|
16998
17009
|
for (let i = from; i >= 0 && i < words.length; i++) {
|
|
16999
17010
|
const w = words[i];
|
|
17000
17011
|
if (w === null) return explicit;
|
|
@@ -17003,7 +17014,14 @@ function npxPackages(words, from) {
|
|
|
17003
17014
|
return explicit.length > 0 ? explicit : next ? [next] : [];
|
|
17004
17015
|
}
|
|
17005
17016
|
if (w.startsWith("-")) {
|
|
17006
|
-
if (w === "-p" || w === "--package"
|
|
17017
|
+
if (w === "-p" || w === "--package") {
|
|
17018
|
+
const v = words[i + 1];
|
|
17019
|
+
if (typeof v === "string") take(v);
|
|
17020
|
+
i++;
|
|
17021
|
+
} else if (w.startsWith("-p=") || w.startsWith("--package="))
|
|
17022
|
+
take(w.slice(w.indexOf("=") + 1));
|
|
17023
|
+
else if (w === "-c" || w === "--call")
|
|
17024
|
+
i++;
|
|
17007
17025
|
else if (takesValue(w, NPM_VALUE_FLAGS)) i++;
|
|
17008
17026
|
continue;
|
|
17009
17027
|
}
|
|
@@ -17012,9 +17030,9 @@ function npxPackages(words, from) {
|
|
|
17012
17030
|
return explicit;
|
|
17013
17031
|
}
|
|
17014
17032
|
function uvxPackages(words, from) {
|
|
17015
|
-
const from_ = flagValues(words, from, ["--from"]);
|
|
17016
|
-
const withs = flagValues(words, from, ["--with"]);
|
|
17017
17033
|
const first = verbIndex(words, from, UV_VALUE_FLAGS);
|
|
17034
|
+
const from_ = flagValues(words, from, ["--from"], first);
|
|
17035
|
+
const withs = flagValues(words, from, ["--with"], first);
|
|
17018
17036
|
const tool = first >= 0 && from_.length === 0 ? [words[first]] : [];
|
|
17019
17037
|
return [...from_, ...tool, ...withs];
|
|
17020
17038
|
}
|
|
@@ -17057,7 +17075,12 @@ function fromCall(words, out, depth) {
|
|
|
17057
17075
|
const verb = lower(words[v]);
|
|
17058
17076
|
if (v < 0) return;
|
|
17059
17077
|
if (NPM_INSTALL_VERBS.has(verb)) pushNpm(out, "npm", operands(words, v + 1, NPM_VALUE_FLAGS));
|
|
17060
|
-
else if (NPM_EXEC_VERBS.has(verb))
|
|
17078
|
+
else if (NPM_EXEC_VERBS.has(verb)) {
|
|
17079
|
+
const before = flagValues(words, start + 1, ["--package"], v);
|
|
17080
|
+
const sep = words.indexOf("--", v + 1);
|
|
17081
|
+
const after = flagValues(words, v + 1, ["--package"], sep < 0 ? words.length : sep);
|
|
17082
|
+
pushNpm(out, "npm exec", [.../* @__PURE__ */ new Set([...npxPackages(words, v + 1, before), ...after])]);
|
|
17083
|
+
}
|
|
17061
17084
|
return;
|
|
17062
17085
|
}
|
|
17063
17086
|
case "npx":
|
|
@@ -17069,7 +17092,12 @@ function fromCall(words, out, depth) {
|
|
|
17069
17092
|
if (v < 0) return;
|
|
17070
17093
|
if (PNPM_INSTALL_VERBS.has(verb))
|
|
17071
17094
|
pushNpm(out, "pnpm", operands(words, v + 1, PNPM_VALUE_FLAGS));
|
|
17072
|
-
else if (DLX_VERBS.has(verb))
|
|
17095
|
+
else if (DLX_VERBS.has(verb))
|
|
17096
|
+
pushNpm(
|
|
17097
|
+
out,
|
|
17098
|
+
"pnpm dlx",
|
|
17099
|
+
npxPackages(words, v + 1, flagValues(words, start + 1, ["--package"], v))
|
|
17100
|
+
);
|
|
17073
17101
|
return;
|
|
17074
17102
|
}
|
|
17075
17103
|
case "yarn": {
|
|
@@ -17123,7 +17151,12 @@ function fromCall(words, out, depth) {
|
|
|
17123
17151
|
const v = verbIndex(words, start + 1, PIPX_VALUE_FLAGS);
|
|
17124
17152
|
const verb = lower(words[v]);
|
|
17125
17153
|
if (v < 0) return;
|
|
17126
|
-
const spec = flagValues(
|
|
17154
|
+
const spec = flagValues(
|
|
17155
|
+
words,
|
|
17156
|
+
v + 1,
|
|
17157
|
+
["--spec"],
|
|
17158
|
+
verb === "run" ? verbIndex(words, v + 1, PIPX_VALUE_FLAGS) : words.length
|
|
17159
|
+
);
|
|
17127
17160
|
if (verb === "install")
|
|
17128
17161
|
pushPy(out, "pipx", [...spec, ...operands(words, v + 1, PIPX_VALUE_FLAGS)]);
|
|
17129
17162
|
else if (verb === "run")
|
|
@@ -17144,7 +17177,16 @@ function fromCall(words, out, depth) {
|
|
|
17144
17177
|
return;
|
|
17145
17178
|
}
|
|
17146
17179
|
if (verb === "run") {
|
|
17147
|
-
pushPy(
|
|
17180
|
+
pushPy(
|
|
17181
|
+
out,
|
|
17182
|
+
"uv run",
|
|
17183
|
+
flagValues(
|
|
17184
|
+
words,
|
|
17185
|
+
v + 1,
|
|
17186
|
+
["--with", "--with-editable"],
|
|
17187
|
+
verbIndex(words, v + 1, UV_VALUE_FLAGS)
|
|
17188
|
+
)
|
|
17189
|
+
);
|
|
17148
17190
|
return;
|
|
17149
17191
|
}
|
|
17150
17192
|
const v2 = verbIndex(words, v + 1, UV_VALUE_FLAGS);
|
package/dist/index.mjs
CHANGED
|
@@ -2674,6 +2674,11 @@ var SCAN_REPO_RULE_OWASP = [
|
|
|
2674
2674
|
["CI-1.hook-remote-code", "ASI05"],
|
|
2675
2675
|
["CI-1.hook-script", "ASI05"],
|
|
2676
2676
|
["CI-1.unfollowable-symlink", "ASI04"],
|
|
2677
|
+
// A9: a worm's start-up trigger or loader is a compromised supply chain; a plain
|
|
2678
|
+
// folder-open task is code that runs by itself.
|
|
2679
|
+
["CI-1.worm-startup", "ASI04"],
|
|
2680
|
+
["CI-1.worm-loader", "ASI04"],
|
|
2681
|
+
["CI-1.folder-open-task", "ASI05"],
|
|
2677
2682
|
// CI-2: workflows that run agents on outside content
|
|
2678
2683
|
["CI-2.", "ASI01"],
|
|
2679
2684
|
// CI-3: MCP servers and plugins
|
|
@@ -16080,6 +16085,8 @@ function parseNpmSpec(raw) {
|
|
|
16080
16085
|
return { name, version: exact ? exact[1] : void 0 };
|
|
16081
16086
|
}
|
|
16082
16087
|
var NPM_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
16088
|
+
"--package",
|
|
16089
|
+
// `npm --package=<pkg> exec <cmd>`: read by the exec branch
|
|
16083
16090
|
"--registry",
|
|
16084
16091
|
"--prefix",
|
|
16085
16092
|
"--cache",
|
|
@@ -16101,6 +16108,8 @@ var NPM_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
|
16101
16108
|
"--libc"
|
|
16102
16109
|
]);
|
|
16103
16110
|
var PNPM_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
16111
|
+
"--package",
|
|
16112
|
+
// `pnpm --package=<pkg> dlx <cmd>`: read by the dlx branch
|
|
16104
16113
|
"--registry",
|
|
16105
16114
|
"-C",
|
|
16106
16115
|
"--dir",
|
|
@@ -16316,9 +16325,10 @@ function operands(words, from, valueFlags) {
|
|
|
16316
16325
|
}
|
|
16317
16326
|
return out;
|
|
16318
16327
|
}
|
|
16319
|
-
function flagValues(words, from, names) {
|
|
16328
|
+
function flagValues(words, from, names, until = words.length) {
|
|
16320
16329
|
const out = [];
|
|
16321
|
-
|
|
16330
|
+
const end = until < 0 ? words.length : Math.min(until, words.length);
|
|
16331
|
+
for (let i = from; i >= 0 && i < end; i++) {
|
|
16322
16332
|
const w = words[i];
|
|
16323
16333
|
if (w === null) continue;
|
|
16324
16334
|
for (const n of names) {
|
|
@@ -16726,8 +16736,9 @@ function pushPy(out, manager, specs, limit = Infinity) {
|
|
|
16726
16736
|
n++;
|
|
16727
16737
|
}
|
|
16728
16738
|
}
|
|
16729
|
-
function npxPackages(words, from) {
|
|
16730
|
-
const explicit =
|
|
16739
|
+
function npxPackages(words, from, before = []) {
|
|
16740
|
+
const explicit = [...before];
|
|
16741
|
+
const take = (v) => explicit.push(...v.split(",").filter((x) => x.length > 0));
|
|
16731
16742
|
for (let i = from; i >= 0 && i < words.length; i++) {
|
|
16732
16743
|
const w = words[i];
|
|
16733
16744
|
if (w === null) return explicit;
|
|
@@ -16736,7 +16747,14 @@ function npxPackages(words, from) {
|
|
|
16736
16747
|
return explicit.length > 0 ? explicit : next ? [next] : [];
|
|
16737
16748
|
}
|
|
16738
16749
|
if (w.startsWith("-")) {
|
|
16739
|
-
if (w === "-p" || w === "--package"
|
|
16750
|
+
if (w === "-p" || w === "--package") {
|
|
16751
|
+
const v = words[i + 1];
|
|
16752
|
+
if (typeof v === "string") take(v);
|
|
16753
|
+
i++;
|
|
16754
|
+
} else if (w.startsWith("-p=") || w.startsWith("--package="))
|
|
16755
|
+
take(w.slice(w.indexOf("=") + 1));
|
|
16756
|
+
else if (w === "-c" || w === "--call")
|
|
16757
|
+
i++;
|
|
16740
16758
|
else if (takesValue(w, NPM_VALUE_FLAGS)) i++;
|
|
16741
16759
|
continue;
|
|
16742
16760
|
}
|
|
@@ -16745,9 +16763,9 @@ function npxPackages(words, from) {
|
|
|
16745
16763
|
return explicit;
|
|
16746
16764
|
}
|
|
16747
16765
|
function uvxPackages(words, from) {
|
|
16748
|
-
const from_ = flagValues(words, from, ["--from"]);
|
|
16749
|
-
const withs = flagValues(words, from, ["--with"]);
|
|
16750
16766
|
const first = verbIndex(words, from, UV_VALUE_FLAGS);
|
|
16767
|
+
const from_ = flagValues(words, from, ["--from"], first);
|
|
16768
|
+
const withs = flagValues(words, from, ["--with"], first);
|
|
16751
16769
|
const tool = first >= 0 && from_.length === 0 ? [words[first]] : [];
|
|
16752
16770
|
return [...from_, ...tool, ...withs];
|
|
16753
16771
|
}
|
|
@@ -16790,7 +16808,12 @@ function fromCall(words, out, depth) {
|
|
|
16790
16808
|
const verb = lower(words[v]);
|
|
16791
16809
|
if (v < 0) return;
|
|
16792
16810
|
if (NPM_INSTALL_VERBS.has(verb)) pushNpm(out, "npm", operands(words, v + 1, NPM_VALUE_FLAGS));
|
|
16793
|
-
else if (NPM_EXEC_VERBS.has(verb))
|
|
16811
|
+
else if (NPM_EXEC_VERBS.has(verb)) {
|
|
16812
|
+
const before = flagValues(words, start + 1, ["--package"], v);
|
|
16813
|
+
const sep = words.indexOf("--", v + 1);
|
|
16814
|
+
const after = flagValues(words, v + 1, ["--package"], sep < 0 ? words.length : sep);
|
|
16815
|
+
pushNpm(out, "npm exec", [.../* @__PURE__ */ new Set([...npxPackages(words, v + 1, before), ...after])]);
|
|
16816
|
+
}
|
|
16794
16817
|
return;
|
|
16795
16818
|
}
|
|
16796
16819
|
case "npx":
|
|
@@ -16802,7 +16825,12 @@ function fromCall(words, out, depth) {
|
|
|
16802
16825
|
if (v < 0) return;
|
|
16803
16826
|
if (PNPM_INSTALL_VERBS.has(verb))
|
|
16804
16827
|
pushNpm(out, "pnpm", operands(words, v + 1, PNPM_VALUE_FLAGS));
|
|
16805
|
-
else if (DLX_VERBS.has(verb))
|
|
16828
|
+
else if (DLX_VERBS.has(verb))
|
|
16829
|
+
pushNpm(
|
|
16830
|
+
out,
|
|
16831
|
+
"pnpm dlx",
|
|
16832
|
+
npxPackages(words, v + 1, flagValues(words, start + 1, ["--package"], v))
|
|
16833
|
+
);
|
|
16806
16834
|
return;
|
|
16807
16835
|
}
|
|
16808
16836
|
case "yarn": {
|
|
@@ -16856,7 +16884,12 @@ function fromCall(words, out, depth) {
|
|
|
16856
16884
|
const v = verbIndex(words, start + 1, PIPX_VALUE_FLAGS);
|
|
16857
16885
|
const verb = lower(words[v]);
|
|
16858
16886
|
if (v < 0) return;
|
|
16859
|
-
const spec = flagValues(
|
|
16887
|
+
const spec = flagValues(
|
|
16888
|
+
words,
|
|
16889
|
+
v + 1,
|
|
16890
|
+
["--spec"],
|
|
16891
|
+
verb === "run" ? verbIndex(words, v + 1, PIPX_VALUE_FLAGS) : words.length
|
|
16892
|
+
);
|
|
16860
16893
|
if (verb === "install")
|
|
16861
16894
|
pushPy(out, "pipx", [...spec, ...operands(words, v + 1, PIPX_VALUE_FLAGS)]);
|
|
16862
16895
|
else if (verb === "run")
|
|
@@ -16877,7 +16910,16 @@ function fromCall(words, out, depth) {
|
|
|
16877
16910
|
return;
|
|
16878
16911
|
}
|
|
16879
16912
|
if (verb === "run") {
|
|
16880
|
-
pushPy(
|
|
16913
|
+
pushPy(
|
|
16914
|
+
out,
|
|
16915
|
+
"uv run",
|
|
16916
|
+
flagValues(
|
|
16917
|
+
words,
|
|
16918
|
+
v + 1,
|
|
16919
|
+
["--with", "--with-editable"],
|
|
16920
|
+
verbIndex(words, v + 1, UV_VALUE_FLAGS)
|
|
16921
|
+
)
|
|
16922
|
+
);
|
|
16881
16923
|
return;
|
|
16882
16924
|
}
|
|
16883
16925
|
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.
|
|
3
|
+
"version": "2.64.1",
|
|
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",
|