secure-exec 0.0.1 → 0.1.0-rc.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/LICENSE +191 -0
- package/README.md +7 -0
- package/dist/bridge/active-handles.d.ts +21 -0
- package/dist/bridge/active-handles.js +60 -0
- package/dist/bridge/child-process.d.ts +87 -0
- package/dist/bridge/child-process.js +523 -0
- package/dist/bridge/fs.d.ts +227 -0
- package/dist/bridge/fs.js +1572 -0
- package/dist/bridge/index.d.ts +10 -0
- package/dist/bridge/index.js +41 -0
- package/dist/bridge/module.d.ts +73 -0
- package/dist/bridge/module.js +329 -0
- package/dist/bridge/network.d.ts +208 -0
- package/dist/bridge/network.js +1117 -0
- package/dist/bridge/os.d.ts +13 -0
- package/dist/bridge/os.js +257 -0
- package/dist/bridge/polyfills.d.ts +2 -0
- package/dist/bridge/polyfills.js +12 -0
- package/dist/bridge/process.d.ts +64 -0
- package/dist/bridge/process.js +916 -0
- package/dist/bridge-loader.d.ts +1 -0
- package/dist/bridge-loader.js +2 -0
- package/dist/bridge-setup.d.ts +1 -0
- package/dist/bridge-setup.js +2 -0
- package/dist/bridge.js +10586 -0
- package/dist/browser/driver.d.ts +42 -0
- package/dist/browser/driver.js +263 -0
- package/dist/browser/index.d.ts +5 -0
- package/dist/browser/index.js +4 -0
- package/dist/browser/worker.d.ts +1 -0
- package/dist/browser/worker.js +3 -0
- package/dist/browser-runtime.d.ts +6 -0
- package/dist/browser-runtime.js +4 -0
- package/dist/esm-compiler.d.ts +1 -0
- package/dist/esm-compiler.js +2 -0
- package/dist/execution.d.ts +1 -0
- package/dist/execution.js +2 -0
- package/dist/fs-helpers.d.ts +2 -0
- package/dist/fs-helpers.js +1 -0
- package/dist/generated/isolate-runtime.d.ts +19 -0
- package/dist/generated/isolate-runtime.js +21 -0
- package/dist/generated/polyfills.d.ts +82 -0
- package/dist/generated/polyfills.js +82 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +11 -0
- package/dist/isolate-runtime/apply-custom-global-policy.js +54 -0
- package/dist/isolate-runtime/apply-timing-mitigation-freeze.js +44 -0
- package/dist/isolate-runtime/apply-timing-mitigation-off.js +14 -0
- package/dist/isolate-runtime/bridge-attach.js +29 -0
- package/dist/isolate-runtime/bridge-initial-globals.js +78 -0
- package/dist/isolate-runtime/eval-script-result.js +8 -0
- package/dist/isolate-runtime/global-exposure-helpers.js +36 -0
- package/dist/isolate-runtime/init-commonjs-module-globals.js +28 -0
- package/dist/isolate-runtime/override-process-cwd.js +8 -0
- package/dist/isolate-runtime/override-process-env.js +8 -0
- package/dist/isolate-runtime/require-setup.js +606 -0
- package/dist/isolate-runtime/set-commonjs-file-globals.js +36 -0
- package/dist/isolate-runtime/set-stdin-data.js +10 -0
- package/dist/isolate-runtime/setup-dynamic-import.js +64 -0
- package/dist/isolate-runtime/setup-fs-facade.js +40 -0
- package/dist/isolate.d.ts +1 -0
- package/dist/isolate.js +2 -0
- package/dist/module-resolver.d.ts +1 -0
- package/dist/module-resolver.js +2 -0
- package/dist/node/bridge-setup.d.ts +1 -0
- package/dist/node/bridge-setup.js +2 -0
- package/dist/node/driver.d.ts +2 -0
- package/dist/node/driver.js +2 -0
- package/dist/node/esm-compiler.d.ts +1 -0
- package/dist/node/esm-compiler.js +2 -0
- package/dist/node/execution-driver.d.ts +2 -0
- package/dist/node/execution-driver.js +2 -0
- package/dist/node/execution-lifecycle.d.ts +1 -0
- package/dist/node/execution-lifecycle.js +2 -0
- package/dist/node/isolate-bootstrap.d.ts +2 -0
- package/dist/node/isolate-bootstrap.js +1 -0
- package/dist/node/module-access.d.ts +2 -0
- package/dist/node/module-access.js +2 -0
- package/dist/node/module-resolver.d.ts +1 -0
- package/dist/node/module-resolver.js +2 -0
- package/dist/package-bundler.d.ts +2 -0
- package/dist/package-bundler.js +1 -0
- package/dist/polyfills.d.ts +1 -0
- package/dist/polyfills.js +2 -0
- package/dist/python-runtime.d.ts +2 -0
- package/dist/python-runtime.js +2 -0
- package/dist/runtime-driver.d.ts +1 -0
- package/dist/runtime-driver.js +1 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +2 -0
- package/dist/shared/api-types.d.ts +1 -0
- package/dist/shared/api-types.js +1 -0
- package/dist/shared/bridge-contract.d.ts +2 -0
- package/dist/shared/bridge-contract.js +1 -0
- package/dist/shared/console-formatter.d.ts +2 -0
- package/dist/shared/console-formatter.js +1 -0
- package/dist/shared/errors.d.ts +2 -0
- package/dist/shared/errors.js +1 -0
- package/dist/shared/esm-utils.d.ts +1 -0
- package/dist/shared/esm-utils.js +2 -0
- package/dist/shared/global-exposure.d.ts +2 -0
- package/dist/shared/global-exposure.js +1 -0
- package/dist/shared/in-memory-fs.d.ts +1 -0
- package/dist/shared/in-memory-fs.js +2 -0
- package/dist/shared/permissions.d.ts +1 -0
- package/dist/shared/permissions.js +2 -0
- package/dist/shared/require-setup.d.ts +1 -0
- package/dist/shared/require-setup.js +2 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -0
- package/package.json +51 -4
- package/index.js +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as nodeOs from "os";
|
|
2
|
+
export interface OSConfig {
|
|
3
|
+
platform?: string;
|
|
4
|
+
arch?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
release?: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
homedir?: string;
|
|
9
|
+
tmpdir?: string;
|
|
10
|
+
hostname?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const os: typeof nodeOs;
|
|
13
|
+
export default os;
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// OS module polyfill for isolated-vm
|
|
3
|
+
// Provides Node.js os module emulation for sandbox compatibility
|
|
4
|
+
import { exposeCustomGlobal } from "../shared/global-exposure.js";
|
|
5
|
+
// Get config with defaults
|
|
6
|
+
const config = {
|
|
7
|
+
platform: (typeof _osConfig !== "undefined" && _osConfig.platform) || "linux",
|
|
8
|
+
arch: (typeof _osConfig !== "undefined" && _osConfig.arch) || "x64",
|
|
9
|
+
type: (typeof _osConfig !== "undefined" && _osConfig.type) || "Linux",
|
|
10
|
+
release: (typeof _osConfig !== "undefined" && _osConfig.release) || "5.15.0",
|
|
11
|
+
version: (typeof _osConfig !== "undefined" && _osConfig.version) || "#1 SMP",
|
|
12
|
+
homedir: (typeof _osConfig !== "undefined" && _osConfig.homedir) || "/root",
|
|
13
|
+
tmpdir: (typeof _osConfig !== "undefined" && _osConfig.tmpdir) || "/tmp",
|
|
14
|
+
hostname: (typeof _osConfig !== "undefined" && _osConfig.hostname) || "sandbox",
|
|
15
|
+
};
|
|
16
|
+
// Signal constants
|
|
17
|
+
const signals = {
|
|
18
|
+
SIGHUP: 1,
|
|
19
|
+
SIGINT: 2,
|
|
20
|
+
SIGQUIT: 3,
|
|
21
|
+
SIGILL: 4,
|
|
22
|
+
SIGTRAP: 5,
|
|
23
|
+
SIGABRT: 6,
|
|
24
|
+
SIGIOT: 6,
|
|
25
|
+
SIGBUS: 7,
|
|
26
|
+
SIGFPE: 8,
|
|
27
|
+
SIGKILL: 9,
|
|
28
|
+
SIGUSR1: 10,
|
|
29
|
+
SIGSEGV: 11,
|
|
30
|
+
SIGUSR2: 12,
|
|
31
|
+
SIGPIPE: 13,
|
|
32
|
+
SIGALRM: 14,
|
|
33
|
+
SIGTERM: 15,
|
|
34
|
+
SIGSTKFLT: 16,
|
|
35
|
+
SIGCHLD: 17,
|
|
36
|
+
SIGCONT: 18,
|
|
37
|
+
SIGSTOP: 19,
|
|
38
|
+
SIGTSTP: 20,
|
|
39
|
+
SIGTTIN: 21,
|
|
40
|
+
SIGTTOU: 22,
|
|
41
|
+
SIGURG: 23,
|
|
42
|
+
SIGXCPU: 24,
|
|
43
|
+
SIGXFSZ: 25,
|
|
44
|
+
SIGVTALRM: 26,
|
|
45
|
+
SIGPROF: 27,
|
|
46
|
+
SIGWINCH: 28,
|
|
47
|
+
SIGIO: 29,
|
|
48
|
+
SIGPOLL: 29,
|
|
49
|
+
SIGPWR: 30,
|
|
50
|
+
SIGSYS: 31,
|
|
51
|
+
};
|
|
52
|
+
// Errno constants
|
|
53
|
+
const errno = {
|
|
54
|
+
E2BIG: 7,
|
|
55
|
+
EACCES: 13,
|
|
56
|
+
EADDRINUSE: 98,
|
|
57
|
+
EADDRNOTAVAIL: 99,
|
|
58
|
+
EAFNOSUPPORT: 97,
|
|
59
|
+
EAGAIN: 11,
|
|
60
|
+
EALREADY: 114,
|
|
61
|
+
EBADF: 9,
|
|
62
|
+
EBADMSG: 74,
|
|
63
|
+
EBUSY: 16,
|
|
64
|
+
ECANCELED: 125,
|
|
65
|
+
ECHILD: 10,
|
|
66
|
+
ECONNABORTED: 103,
|
|
67
|
+
ECONNREFUSED: 111,
|
|
68
|
+
ECONNRESET: 104,
|
|
69
|
+
EDEADLK: 35,
|
|
70
|
+
EDESTADDRREQ: 89,
|
|
71
|
+
EDOM: 33,
|
|
72
|
+
EDQUOT: 122,
|
|
73
|
+
EEXIST: 17,
|
|
74
|
+
EFAULT: 14,
|
|
75
|
+
EFBIG: 27,
|
|
76
|
+
EHOSTUNREACH: 113,
|
|
77
|
+
EIDRM: 43,
|
|
78
|
+
EILSEQ: 84,
|
|
79
|
+
EINPROGRESS: 115,
|
|
80
|
+
EINTR: 4,
|
|
81
|
+
EINVAL: 22,
|
|
82
|
+
EIO: 5,
|
|
83
|
+
EISCONN: 106,
|
|
84
|
+
EISDIR: 21,
|
|
85
|
+
ELOOP: 40,
|
|
86
|
+
EMFILE: 24,
|
|
87
|
+
EMLINK: 31,
|
|
88
|
+
EMSGSIZE: 90,
|
|
89
|
+
EMULTIHOP: 72,
|
|
90
|
+
ENAMETOOLONG: 36,
|
|
91
|
+
ENETDOWN: 100,
|
|
92
|
+
ENETRESET: 102,
|
|
93
|
+
ENETUNREACH: 101,
|
|
94
|
+
ENFILE: 23,
|
|
95
|
+
ENOBUFS: 105,
|
|
96
|
+
ENODATA: 61,
|
|
97
|
+
ENODEV: 19,
|
|
98
|
+
ENOENT: 2,
|
|
99
|
+
ENOEXEC: 8,
|
|
100
|
+
ENOLCK: 37,
|
|
101
|
+
ENOLINK: 67,
|
|
102
|
+
ENOMEM: 12,
|
|
103
|
+
ENOMSG: 42,
|
|
104
|
+
ENOPROTOOPT: 92,
|
|
105
|
+
ENOSPC: 28,
|
|
106
|
+
ENOSR: 63,
|
|
107
|
+
ENOSTR: 60,
|
|
108
|
+
ENOSYS: 38,
|
|
109
|
+
ENOTCONN: 107,
|
|
110
|
+
ENOTDIR: 20,
|
|
111
|
+
ENOTEMPTY: 39,
|
|
112
|
+
ENOTSOCK: 88,
|
|
113
|
+
ENOTSUP: 95,
|
|
114
|
+
ENOTTY: 25,
|
|
115
|
+
ENXIO: 6,
|
|
116
|
+
EOPNOTSUPP: 95,
|
|
117
|
+
EOVERFLOW: 75,
|
|
118
|
+
EPERM: 1,
|
|
119
|
+
EPIPE: 32,
|
|
120
|
+
EPROTO: 71,
|
|
121
|
+
EPROTONOSUPPORT: 93,
|
|
122
|
+
EPROTOTYPE: 91,
|
|
123
|
+
ERANGE: 34,
|
|
124
|
+
EROFS: 30,
|
|
125
|
+
ESPIPE: 29,
|
|
126
|
+
ESRCH: 3,
|
|
127
|
+
ESTALE: 116,
|
|
128
|
+
ETIME: 62,
|
|
129
|
+
ETIMEDOUT: 110,
|
|
130
|
+
ETXTBSY: 26,
|
|
131
|
+
EWOULDBLOCK: 11,
|
|
132
|
+
EXDEV: 18,
|
|
133
|
+
};
|
|
134
|
+
// Priority constants
|
|
135
|
+
const priority = {
|
|
136
|
+
PRIORITY_LOW: 19,
|
|
137
|
+
PRIORITY_BELOW_NORMAL: 10,
|
|
138
|
+
PRIORITY_NORMAL: 0,
|
|
139
|
+
PRIORITY_ABOVE_NORMAL: -7,
|
|
140
|
+
PRIORITY_HIGH: -14,
|
|
141
|
+
PRIORITY_HIGHEST: -20,
|
|
142
|
+
};
|
|
143
|
+
// OS module implementation
|
|
144
|
+
const os = {
|
|
145
|
+
// Platform information
|
|
146
|
+
platform() {
|
|
147
|
+
return config.platform;
|
|
148
|
+
},
|
|
149
|
+
arch() {
|
|
150
|
+
return config.arch;
|
|
151
|
+
},
|
|
152
|
+
type() {
|
|
153
|
+
return config.type;
|
|
154
|
+
},
|
|
155
|
+
release() {
|
|
156
|
+
return config.release;
|
|
157
|
+
},
|
|
158
|
+
version() {
|
|
159
|
+
return config.version;
|
|
160
|
+
},
|
|
161
|
+
// Directory information
|
|
162
|
+
homedir() {
|
|
163
|
+
return config.homedir;
|
|
164
|
+
},
|
|
165
|
+
tmpdir() {
|
|
166
|
+
return config.tmpdir;
|
|
167
|
+
},
|
|
168
|
+
// System information
|
|
169
|
+
hostname() {
|
|
170
|
+
return config.hostname;
|
|
171
|
+
},
|
|
172
|
+
// User information
|
|
173
|
+
userInfo(_options) {
|
|
174
|
+
return {
|
|
175
|
+
username: "root",
|
|
176
|
+
uid: 0,
|
|
177
|
+
gid: 0,
|
|
178
|
+
shell: "/bin/bash",
|
|
179
|
+
homedir: config.homedir,
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
// CPU information
|
|
183
|
+
cpus() {
|
|
184
|
+
return [
|
|
185
|
+
{
|
|
186
|
+
model: "Virtual CPU",
|
|
187
|
+
speed: 2000,
|
|
188
|
+
times: {
|
|
189
|
+
user: 100000,
|
|
190
|
+
nice: 0,
|
|
191
|
+
sys: 50000,
|
|
192
|
+
idle: 800000,
|
|
193
|
+
irq: 0,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
];
|
|
197
|
+
},
|
|
198
|
+
// Memory information
|
|
199
|
+
totalmem() {
|
|
200
|
+
return 1073741824; // 1GB
|
|
201
|
+
},
|
|
202
|
+
freemem() {
|
|
203
|
+
return 536870912; // 512MB
|
|
204
|
+
},
|
|
205
|
+
// System load
|
|
206
|
+
loadavg() {
|
|
207
|
+
return [0.1, 0.1, 0.1];
|
|
208
|
+
},
|
|
209
|
+
// System uptime
|
|
210
|
+
uptime() {
|
|
211
|
+
return 3600; // 1 hour
|
|
212
|
+
},
|
|
213
|
+
// Network interfaces (empty - not supported in sandbox)
|
|
214
|
+
networkInterfaces() {
|
|
215
|
+
return {};
|
|
216
|
+
},
|
|
217
|
+
// System endianness
|
|
218
|
+
endianness() {
|
|
219
|
+
return "LE";
|
|
220
|
+
},
|
|
221
|
+
// Line endings
|
|
222
|
+
EOL: "\n",
|
|
223
|
+
// Dev null path
|
|
224
|
+
devNull: "/dev/null",
|
|
225
|
+
// Machine type
|
|
226
|
+
machine() {
|
|
227
|
+
return config.arch;
|
|
228
|
+
},
|
|
229
|
+
// Constants
|
|
230
|
+
constants: {
|
|
231
|
+
signals,
|
|
232
|
+
errno,
|
|
233
|
+
priority,
|
|
234
|
+
dlopen: {
|
|
235
|
+
RTLD_LAZY: 1,
|
|
236
|
+
RTLD_NOW: 2,
|
|
237
|
+
RTLD_GLOBAL: 256,
|
|
238
|
+
RTLD_LOCAL: 0,
|
|
239
|
+
},
|
|
240
|
+
UV_UDP_REUSEADDR: 4,
|
|
241
|
+
},
|
|
242
|
+
// Priority getters/setters (stubs)
|
|
243
|
+
getPriority(_pid) {
|
|
244
|
+
return 0;
|
|
245
|
+
},
|
|
246
|
+
setPriority(pid, priority) {
|
|
247
|
+
void pid;
|
|
248
|
+
void priority;
|
|
249
|
+
},
|
|
250
|
+
// Parallelism hint
|
|
251
|
+
availableParallelism() {
|
|
252
|
+
return 1;
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
// Expose to global for require() to use.
|
|
256
|
+
exposeCustomGlobal("_osModule", os);
|
|
257
|
+
export default os;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Early polyfills - this file must be imported FIRST before any other modules
|
|
3
|
+
// that might use TextEncoder/TextDecoder (like whatwg-url)
|
|
4
|
+
import { TextEncoder, TextDecoder } from "text-encoding-utf-8";
|
|
5
|
+
// Install on globalThis so other modules can use them
|
|
6
|
+
if (typeof globalThis.TextEncoder === "undefined") {
|
|
7
|
+
globalThis.TextEncoder = TextEncoder;
|
|
8
|
+
}
|
|
9
|
+
if (typeof globalThis.TextDecoder === "undefined") {
|
|
10
|
+
globalThis.TextDecoder = TextDecoder;
|
|
11
|
+
}
|
|
12
|
+
export { TextEncoder, TextDecoder };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type * as nodeProcess from "process";
|
|
2
|
+
import { TextEncoder, TextDecoder } from "./polyfills";
|
|
3
|
+
export interface ProcessConfig {
|
|
4
|
+
platform?: string;
|
|
5
|
+
arch?: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
cwd?: string;
|
|
8
|
+
env?: Record<string, string>;
|
|
9
|
+
argv?: string[];
|
|
10
|
+
execPath?: string;
|
|
11
|
+
pid?: number;
|
|
12
|
+
ppid?: number;
|
|
13
|
+
uid?: number;
|
|
14
|
+
gid?: number;
|
|
15
|
+
stdin?: string;
|
|
16
|
+
timingMitigation?: "off" | "freeze";
|
|
17
|
+
frozenTimeMs?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class ProcessExitError extends Error {
|
|
20
|
+
code: number;
|
|
21
|
+
constructor(code: number);
|
|
22
|
+
}
|
|
23
|
+
declare const _stdout: any;
|
|
24
|
+
declare const _stderr: any;
|
|
25
|
+
type StdinListener = (data: unknown) => void;
|
|
26
|
+
declare const _stdin: any;
|
|
27
|
+
declare const process: Partial<typeof nodeProcess> & {
|
|
28
|
+
stdout: typeof _stdout;
|
|
29
|
+
stderr: typeof _stderr;
|
|
30
|
+
stdin: typeof _stdin;
|
|
31
|
+
_cwd: string;
|
|
32
|
+
_umask: number;
|
|
33
|
+
};
|
|
34
|
+
export default process;
|
|
35
|
+
declare class TimerHandle {
|
|
36
|
+
_id: number;
|
|
37
|
+
_destroyed: boolean;
|
|
38
|
+
constructor(id: number);
|
|
39
|
+
ref(): this;
|
|
40
|
+
unref(): this;
|
|
41
|
+
hasRef(): boolean;
|
|
42
|
+
refresh(): this;
|
|
43
|
+
[Symbol.toPrimitive](): number;
|
|
44
|
+
}
|
|
45
|
+
export declare function setTimeout(callback: (...args: unknown[]) => void, delay?: number, ...args: unknown[]): TimerHandle;
|
|
46
|
+
export declare function clearTimeout(timer: TimerHandle | number | undefined): void;
|
|
47
|
+
export declare function setInterval(callback: (...args: unknown[]) => void, delay?: number, ...args: unknown[]): TimerHandle;
|
|
48
|
+
export declare function clearInterval(timer: TimerHandle | number | undefined): void;
|
|
49
|
+
export declare function setImmediate(callback: (...args: unknown[]) => void, ...args: unknown[]): TimerHandle;
|
|
50
|
+
export declare function clearImmediate(id: TimerHandle | number | undefined): void;
|
|
51
|
+
export declare const URL: any;
|
|
52
|
+
export declare const URLSearchParams: any;
|
|
53
|
+
export { TextEncoder, TextDecoder };
|
|
54
|
+
export declare const Buffer: BufferConstructor;
|
|
55
|
+
export declare const cryptoPolyfill: {
|
|
56
|
+
getRandomValues<T extends ArrayBufferView>(array: T): T;
|
|
57
|
+
randomUUID(): string;
|
|
58
|
+
subtle: {
|
|
59
|
+
digest(): Promise<ArrayBuffer>;
|
|
60
|
+
encrypt(): Promise<ArrayBuffer>;
|
|
61
|
+
decrypt(): Promise<ArrayBuffer>;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export declare function setupGlobals(): void;
|