@nocobase/plugin-workflow-javascript 2.1.0-alpha.17 → 2.1.0-alpha.19
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/.env.example
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# This is an example of environment variables for the plugin-workflow-javascript plugin.
|
|
2
|
+
# You can merge this file with your existing .env file and customize the values as needed.
|
|
3
|
+
#
|
|
4
|
+
# --- SECURITY WARNING ---
|
|
5
|
+
# * By default, no modules are allowed to be used in the JavaScript node. Your script will be executed in a sandboxed environment by `isolated-vm`.
|
|
6
|
+
#
|
|
7
|
+
# * By setting any module in WORKFLOW_SCRIPT_MODULES, the JavaScript node will use `node:vm` to execute the script,
|
|
8
|
+
# which will cause potential security risks. Please make sure the script content is managed by privileged users,
|
|
9
|
+
# and use it with caution. This will be at your own risk.
|
|
10
|
+
#
|
|
11
|
+
# See the documentation for more details: https://docs.nocobase.com/workflow/nodes/javascript#safe-mode-default
|
|
12
|
+
#
|
|
13
|
+
# Example: lodash,dayjs
|
|
14
|
+
# WORKFLOW_SCRIPT_MODULES=lodash,dayjs
|
|
15
|
+
WORKFLOW_SCRIPT_MODULES=
|
package/dist/externalVersion.js
CHANGED
|
@@ -13,11 +13,11 @@ module.exports = {
|
|
|
13
13
|
"antd-style": "3.7.1",
|
|
14
14
|
"@formily/antd-v5": "1.2.3",
|
|
15
15
|
"@ant-design/icons": "5.6.1",
|
|
16
|
-
"@nocobase/client": "2.1.0-alpha.
|
|
17
|
-
"@nocobase/plugin-workflow": "2.1.0-alpha.
|
|
16
|
+
"@nocobase/client": "2.1.0-alpha.19",
|
|
17
|
+
"@nocobase/plugin-workflow": "2.1.0-alpha.19",
|
|
18
18
|
"antd": "5.24.2",
|
|
19
|
-
"@nocobase/flow-engine": "2.1.0-alpha.
|
|
19
|
+
"@nocobase/flow-engine": "2.1.0-alpha.19",
|
|
20
20
|
"react-i18next": "11.18.6",
|
|
21
21
|
"winston": "3.13.0",
|
|
22
|
-
"@nocobase/server": "2.1.0-alpha.
|
|
22
|
+
"@nocobase/server": "2.1.0-alpha.19"
|
|
23
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"isolated-vm","version":"5.0.4","description":"Access to multiple isolates","main":"isolated-vm.js","types":"isolated-vm.d.ts","engines":{"node":">=18.0.0"},"scripts":{"install":"prebuild-install || (node-gyp rebuild --release -j max && node-gyp clean)","rebuild":"node-gyp rebuild --release -j max","lint":"find src -name '*.cc' | xargs -n1 clang-tidy","test":"node test.js"},"dependencies":{"prebuild-install":"^7.1.2"},"devDependencies":{"isolated-vm":".","prebuild":"^13.0.1"},"binary":{"module_path":"out"},"repository":{"type":"git","url":"git+https://github.com/laverdet/isolated-vm.git"},"author":"https://github.com/laverdet/","license":"ISC","gypfile":true,"bugs":{"url":"https://github.com/laverdet/isolated-vm/issues"},"homepage":"https://github.com/laverdet/isolated-vm#readme","_lastModified":"2026-04-
|
|
1
|
+
{"name":"isolated-vm","version":"5.0.4","description":"Access to multiple isolates","main":"isolated-vm.js","types":"isolated-vm.d.ts","engines":{"node":">=18.0.0"},"scripts":{"install":"prebuild-install || (node-gyp rebuild --release -j max && node-gyp clean)","rebuild":"node-gyp rebuild --release -j max","lint":"find src -name '*.cc' | xargs -n1 clang-tidy","test":"node test.js"},"dependencies":{"prebuild-install":"^7.1.2"},"devDependencies":{"isolated-vm":".","prebuild":"^13.0.1"},"binary":{"module_path":"out"},"repository":{"type":"git","url":"git+https://github.com/laverdet/isolated-vm.git"},"author":"https://github.com/laverdet/","license":"ISC","gypfile":true,"bugs":{"url":"https://github.com/laverdet/isolated-vm/issues"},"homepage":"https://github.com/laverdet/isolated-vm#readme","_lastModified":"2026-04-19T04:13:14.397Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"joi","description":"Object schema validation","version":"17.13.3","repository":"git://github.com/hapijs/joi","main":"lib/index.js","types":"lib/index.d.ts","browser":"dist/joi-browser.min.js","files":["lib/**/*","dist/*"],"keywords":["schema","validation"],"dependencies":{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63","typescript":"4.3.x"},"scripts":{"prepublishOnly":"cd browser && npm install && npm run build","test":"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause","_lastModified":"2026-04-
|
|
1
|
+
{"name":"joi","description":"Object schema validation","version":"17.13.3","repository":"git://github.com/hapijs/joi","main":"lib/index.js","types":"lib/index.d.ts","browser":"dist/joi-browser.min.js","files":["lib/**/*","dist/*"],"keywords":["schema","validation"],"dependencies":{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63","typescript":"4.3.x"},"scripts":{"prepublishOnly":"cd browser && npm install && npm run build","test":"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause","_lastModified":"2026-04-19T04:13:14.872Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"winston-transport","description":"Base stream implementations for winston@3 and up.","version":"4.7.0","main":"index.js","browser":"dist/index.js","scripts":{"lint":"eslint test/*.js index.js --resolve-plugins-relative-to ./node_modules/@dabh/eslint-config-populist","pretest":"npm run lint && npm run build","test":"nyc mocha test/*.test.js","report":"nyc report --reporter=lcov","build":"rimraf dist && babel *.js -d ./dist","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git@github.com:winstonjs/winston-transport.git"},"keywords":["winston","transport","winston3"],"author":"Charlie Robbins <charlie.robbins@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/winstonjs/winston-transport/issues"},"homepage":"https://github.com/winstonjs/winston-transport#readme","dependencies":{"logform":"^2.3.2","readable-stream":"^3.6.0","triple-beam":"^1.3.0"},"devDependencies":{"@types/node":"^20.8.6","abstract-winston-transport":">=0.5.1","assume":"^2.3.0","babel-cli":"^6.26.0","babel-preset-env":"^1.7.0","deep-equal":"^2.0.5","eslint":"^8.8.0","@dabh/eslint-config-populist":"^5.0.0","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^5.0.5","winston-compat":"^0.1.5"},"engines":{"node":">= 12.0.0"},"_lastModified":"2026-04-
|
|
1
|
+
{"name":"winston-transport","description":"Base stream implementations for winston@3 and up.","version":"4.7.0","main":"index.js","browser":"dist/index.js","scripts":{"lint":"eslint test/*.js index.js --resolve-plugins-relative-to ./node_modules/@dabh/eslint-config-populist","pretest":"npm run lint && npm run build","test":"nyc mocha test/*.test.js","report":"nyc report --reporter=lcov","build":"rimraf dist && babel *.js -d ./dist","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git@github.com:winstonjs/winston-transport.git"},"keywords":["winston","transport","winston3"],"author":"Charlie Robbins <charlie.robbins@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/winstonjs/winston-transport/issues"},"homepage":"https://github.com/winstonjs/winston-transport#readme","dependencies":{"logform":"^2.3.2","readable-stream":"^3.6.0","triple-beam":"^1.3.0"},"devDependencies":{"@types/node":"^20.8.6","abstract-winston-transport":">=0.5.1","assume":"^2.3.0","babel-cli":"^6.26.0","babel-preset-env":"^1.7.0","deep-equal":"^2.0.5","eslint":"^8.8.0","@dabh/eslint-config-populist":"^5.0.0","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^5.0.5","winston-compat":"^0.1.5"},"engines":{"node":">= 12.0.0"},"_lastModified":"2026-04-19T04:13:15.583Z"}
|
package/dist/server/Vm.js
CHANGED
|
@@ -11,34 +11,184 @@ const { parentPort, workerData } = require("node:worker_threads");
|
|
|
11
11
|
const { Script } = require("node:vm");
|
|
12
12
|
const Path = require("node:path");
|
|
13
13
|
let timer = null;
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let mainName;
|
|
18
|
-
if (Path.isAbsolute(m)) {
|
|
19
|
-
mainName = m;
|
|
20
|
-
} else if (m.startsWith(".")) {
|
|
21
|
-
mainName = m;
|
|
22
|
-
m = Path.resolve(process.cwd(), m);
|
|
23
|
-
} else {
|
|
24
|
-
mainName = m.split("/").slice(0, m.startsWith("@") ? 2 : 1).join("/");
|
|
25
|
-
}
|
|
26
|
-
if (configuredModules.includes(mainName)) {
|
|
27
|
-
return require(m);
|
|
28
|
-
}
|
|
29
|
-
throw new Error(`module "${m}" not supported`);
|
|
30
|
-
}
|
|
31
|
-
function hardenFunction(fn) {
|
|
32
|
-
Object.setPrototypeOf(fn, null);
|
|
33
|
-
Object.defineProperty(fn, "constructor", {
|
|
14
|
+
function harden(v) {
|
|
15
|
+
Object.setPrototypeOf(v, null);
|
|
16
|
+
Object.defineProperty(v, "constructor", {
|
|
34
17
|
value: null,
|
|
35
18
|
writable: false,
|
|
36
19
|
enumerable: false,
|
|
37
20
|
configurable: false
|
|
38
21
|
});
|
|
39
|
-
return
|
|
22
|
+
return v;
|
|
23
|
+
}
|
|
24
|
+
function createSandboxError(msg) {
|
|
25
|
+
return harden(new Error(msg));
|
|
26
|
+
}
|
|
27
|
+
function resolveProperty(obj, key) {
|
|
28
|
+
const desc = Object.getOwnPropertyDescriptor(obj, key);
|
|
29
|
+
if (!desc) return void 0;
|
|
30
|
+
if ("value" in desc) return desc.value;
|
|
31
|
+
if (desc.get) {
|
|
32
|
+
try {
|
|
33
|
+
return desc.get.call(obj);
|
|
34
|
+
} catch (_) {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
function sanitizeError(e) {
|
|
41
|
+
let msg;
|
|
42
|
+
try {
|
|
43
|
+
msg = e != null && typeof e.message === "string" ? e.message : String(e);
|
|
44
|
+
} catch (_) {
|
|
45
|
+
msg = "unknown error";
|
|
46
|
+
}
|
|
47
|
+
return createSandboxError(msg);
|
|
48
|
+
}
|
|
49
|
+
function sanitizeReturnValue(result) {
|
|
50
|
+
if (result === null || result === void 0) return result;
|
|
51
|
+
if (typeof result !== "object" && typeof result !== "function") return result;
|
|
52
|
+
if (typeof result.then === "function") {
|
|
53
|
+
const cleanThenable = /* @__PURE__ */ Object.create(null);
|
|
54
|
+
const originalThen = result.then.bind(result);
|
|
55
|
+
Object.defineProperty(cleanThenable, "then", {
|
|
56
|
+
value: harden(function(onFulfilled, onRejected) {
|
|
57
|
+
const next = originalThen(
|
|
58
|
+
typeof onFulfilled === "function" ? (v) => onFulfilled(sanitizeForSandbox(v, null, /* @__PURE__ */ new WeakMap())) : onFulfilled,
|
|
59
|
+
typeof onRejected === "function" ? (e) => onRejected(sanitizeError(e)) : onRejected
|
|
60
|
+
);
|
|
61
|
+
return sanitizeReturnValue(next);
|
|
62
|
+
}),
|
|
63
|
+
writable: false,
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: false
|
|
66
|
+
});
|
|
67
|
+
return cleanThenable;
|
|
68
|
+
}
|
|
69
|
+
return sanitizeForSandbox(result, null, /* @__PURE__ */ new WeakMap());
|
|
70
|
+
}
|
|
71
|
+
function sanitizeForSandbox(val, parent, cache) {
|
|
72
|
+
if (!cache) cache = /* @__PURE__ */ new WeakMap();
|
|
73
|
+
if (val === null || val === void 0) return val;
|
|
74
|
+
if (typeof val !== "object" && typeof val !== "function") return val;
|
|
75
|
+
if (cache.has(val)) return cache.get(val);
|
|
76
|
+
if (typeof val === "function") {
|
|
77
|
+
const fn = parent != null ? val.bind(parent) : val;
|
|
78
|
+
const wrapper = function(...args) {
|
|
79
|
+
let ret;
|
|
80
|
+
try {
|
|
81
|
+
ret = fn(...args);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
throw sanitizeError(e);
|
|
84
|
+
}
|
|
85
|
+
return sanitizeReturnValue(ret);
|
|
86
|
+
};
|
|
87
|
+
cache.set(val, wrapper);
|
|
88
|
+
harden(wrapper);
|
|
89
|
+
const SKIP_PROPS = /* @__PURE__ */ new Set(["length", "name", "prototype", "caller", "arguments", "constructor"]);
|
|
90
|
+
for (const key of Object.getOwnPropertyNames(val)) {
|
|
91
|
+
if (SKIP_PROPS.has(key)) continue;
|
|
92
|
+
try {
|
|
93
|
+
const resolved = resolveProperty(val, key);
|
|
94
|
+
if (resolved !== void 0) {
|
|
95
|
+
Object.defineProperty(wrapper, key, {
|
|
96
|
+
value: sanitizeForSandbox(resolved, val, cache),
|
|
97
|
+
writable: false,
|
|
98
|
+
enumerable: true,
|
|
99
|
+
configurable: false
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
} catch (_) {
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return wrapper;
|
|
106
|
+
}
|
|
107
|
+
if (Array.isArray(val)) {
|
|
108
|
+
const len = val.length;
|
|
109
|
+
const cleanArr = /* @__PURE__ */ Object.create(null);
|
|
110
|
+
cache.set(val, cleanArr);
|
|
111
|
+
Object.defineProperty(cleanArr, "length", {
|
|
112
|
+
value: len,
|
|
113
|
+
writable: false,
|
|
114
|
+
enumerable: false,
|
|
115
|
+
configurable: false
|
|
116
|
+
});
|
|
117
|
+
for (let i = 0; i < len; i++) {
|
|
118
|
+
try {
|
|
119
|
+
cleanArr[i] = sanitizeForSandbox(val[i], null, cache);
|
|
120
|
+
} catch (_) {
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
Object.defineProperty(cleanArr, Symbol.iterator, {
|
|
124
|
+
value: harden(function() {
|
|
125
|
+
let idx = 0;
|
|
126
|
+
const iterator = /* @__PURE__ */ Object.create(null);
|
|
127
|
+
iterator.next = harden(function() {
|
|
128
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
129
|
+
if (idx < len) {
|
|
130
|
+
result.value = cleanArr[idx++];
|
|
131
|
+
result.done = false;
|
|
132
|
+
} else {
|
|
133
|
+
result.value = void 0;
|
|
134
|
+
result.done = true;
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
});
|
|
138
|
+
iterator[Symbol.iterator] = harden(function() {
|
|
139
|
+
return iterator;
|
|
140
|
+
});
|
|
141
|
+
return iterator;
|
|
142
|
+
}),
|
|
143
|
+
writable: false,
|
|
144
|
+
enumerable: false,
|
|
145
|
+
configurable: false
|
|
146
|
+
});
|
|
147
|
+
return cleanArr;
|
|
148
|
+
}
|
|
149
|
+
const clean = /* @__PURE__ */ Object.create(null);
|
|
150
|
+
cache.set(val, clean);
|
|
151
|
+
let proto = val;
|
|
152
|
+
while (proto !== null && proto !== Object.prototype) {
|
|
153
|
+
for (const key of Object.getOwnPropertyNames(proto)) {
|
|
154
|
+
if (key === "constructor" || key in clean) continue;
|
|
155
|
+
try {
|
|
156
|
+
const resolved = resolveProperty(proto, key);
|
|
157
|
+
if (resolved !== void 0) {
|
|
158
|
+
clean[key] = sanitizeForSandbox(resolved, val, cache);
|
|
159
|
+
}
|
|
160
|
+
} catch (_) {
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
proto = Object.getPrototypeOf(proto);
|
|
164
|
+
}
|
|
165
|
+
return clean;
|
|
40
166
|
}
|
|
41
|
-
|
|
167
|
+
function customRequire(m) {
|
|
168
|
+
var _a;
|
|
169
|
+
try {
|
|
170
|
+
if (typeof m !== "string") {
|
|
171
|
+
throw new Error("module name must be a string");
|
|
172
|
+
}
|
|
173
|
+
const configuredModules = (((_a = process.env.WORKFLOW_SCRIPT_MODULES) == null ? void 0 : _a.split(",")) ?? []).filter(Boolean);
|
|
174
|
+
let mainName;
|
|
175
|
+
if (Path.isAbsolute(m)) {
|
|
176
|
+
mainName = m;
|
|
177
|
+
} else if (m.startsWith(".")) {
|
|
178
|
+
mainName = m;
|
|
179
|
+
m = Path.resolve(process.cwd(), m);
|
|
180
|
+
} else {
|
|
181
|
+
mainName = m.split("/").slice(0, m.startsWith("@") ? 2 : 1).join("/");
|
|
182
|
+
}
|
|
183
|
+
if (configuredModules.includes(mainName)) {
|
|
184
|
+
return sanitizeForSandbox(require(m));
|
|
185
|
+
}
|
|
186
|
+
throw new Error(`module "${m}" not supported`);
|
|
187
|
+
} catch (e) {
|
|
188
|
+
throw sanitizeError(e);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
harden(customRequire);
|
|
42
192
|
function createSafeConsole(originalConsole) {
|
|
43
193
|
const safe = /* @__PURE__ */ Object.create(null);
|
|
44
194
|
const allowedMethods = [
|
|
@@ -64,8 +214,7 @@ function createSafeConsole(originalConsole) {
|
|
|
64
214
|
];
|
|
65
215
|
for (const key of allowedMethods) {
|
|
66
216
|
if (typeof originalConsole[key] === "function") {
|
|
67
|
-
const bound = originalConsole[key].bind(originalConsole);
|
|
68
|
-
hardenFunction(bound);
|
|
217
|
+
const bound = harden(originalConsole[key].bind(originalConsole));
|
|
69
218
|
Object.defineProperty(safe, key, {
|
|
70
219
|
value: bound,
|
|
71
220
|
writable: false,
|
|
@@ -74,13 +223,7 @@ function createSafeConsole(originalConsole) {
|
|
|
74
223
|
});
|
|
75
224
|
}
|
|
76
225
|
}
|
|
77
|
-
Object.
|
|
78
|
-
value: null,
|
|
79
|
-
writable: false,
|
|
80
|
-
enumerable: false,
|
|
81
|
-
configurable: false
|
|
82
|
-
});
|
|
83
|
-
return Object.freeze(safe);
|
|
226
|
+
return Object.freeze(harden(safe));
|
|
84
227
|
}
|
|
85
228
|
async function main() {
|
|
86
229
|
const { source, args = {}, options = {} } = workerData;
|
|
@@ -105,8 +248,17 @@ async function main() {
|
|
|
105
248
|
const result = script.runInNewContext(context, { timeout: options.timeout });
|
|
106
249
|
return result;
|
|
107
250
|
}
|
|
251
|
+
function toJsonResult(value) {
|
|
252
|
+
if (value === null || value === void 0) return value;
|
|
253
|
+
if (typeof value !== "object" && typeof value !== "function") return value;
|
|
254
|
+
try {
|
|
255
|
+
return JSON.parse(JSON.stringify(value));
|
|
256
|
+
} catch (_) {
|
|
257
|
+
return value;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
108
260
|
main().then((result) => {
|
|
109
|
-
parentPort.postMessage({ type: "result", result });
|
|
261
|
+
parentPort.postMessage({ type: "result", result: toJsonResult(result) });
|
|
110
262
|
}).catch((error) => {
|
|
111
263
|
throw error;
|
|
112
264
|
}).finally(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-workflow-javascript",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.19",
|
|
4
4
|
"displayName": "Workflow: JavaScript",
|
|
5
5
|
"displayName.zh-CN": "工作流:JavaScript 节点",
|
|
6
6
|
"description": "Execute a piece of JavaScript in an isolated Node.js environment.",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"Workflow"
|
|
39
39
|
],
|
|
40
40
|
"license": "Apache-2.0",
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "3d13700360eac1c0f9dbf6a5f167ed396a294a3c"
|
|
42
42
|
}
|