@blen/fedreg-mcp-server 2.2.1 → 2.2.3
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/CHANGELOG.md +13 -1
- package/README.md +2 -2
- package/SECURITY.md +6 -4
- package/dist/accounts/provider.d.ts.map +1 -1
- package/dist/accounts/provider.js +1 -1
- package/dist/accounts/provider.js.map +1 -1
- package/dist/sandbox/deno.d.ts +26 -4
- package/dist/sandbox/deno.d.ts.map +1 -1
- package/dist/sandbox/deno.js +337 -151
- package/dist/sandbox/deno.js.map +1 -1
- package/dist/sandbox/isolate.d.ts +10 -0
- package/dist/sandbox/isolate.d.ts.map +1 -1
- package/dist/sandbox/isolate.js +153 -66
- package/dist/sandbox/isolate.js.map +1 -1
- package/dist/sandbox/limits.d.ts +62 -0
- package/dist/sandbox/limits.d.ts.map +1 -0
- package/dist/sandbox/limits.js +87 -0
- package/dist/sandbox/limits.js.map +1 -0
- package/dist/sandbox/types.d.ts +3 -0
- package/dist/sandbox/types.d.ts.map +1 -1
- package/dist/sdk/bindings.js +1 -1
- package/dist/server/mcpServer.js +1 -1
- package/dist/server/wellKnown.js +1 -1
- package/dist/server/wellKnown.js.map +1 -1
- package/dist/web/assets/{index-CsbyqDsu.js → index-B_2tneZo.js} +6 -6
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
package/dist/sandbox/deno.js
CHANGED
|
@@ -1,203 +1,389 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { existsSync, mkdtempSync, rmSync, writeFileSync, chmodSync } from 'node:fs';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
+
import { log } from '../util/logger.js';
|
|
5
6
|
import { preflight } from './policy.js';
|
|
7
|
+
import { DEFAULT_LIMITS, LOG_LINE_OVERHEAD, LOG_TRUNCATED, LogSink, MAX_ERROR_MESSAGE, boundMessage, checkRpcArgs, finishValue, policyMessage, resultTooLarge } from './limits.js';
|
|
6
8
|
/**
|
|
7
|
-
* Deno
|
|
8
|
-
*
|
|
9
|
-
*
|
|
9
|
+
* Deno sandbox.
|
|
10
|
+
*
|
|
11
|
+
* Boundary: Node host (owns the deadline, byte budgets, and the child's lifetime)
|
|
12
|
+
* → `deno run` of a fixed supervisor script with NO --allow-* flags (deny-by-default: no net, fs,
|
|
13
|
+
* env, ffi, subprocess), a minimal environment, and no user code on disk
|
|
14
|
+
* → a module Worker that receives the user code by message. Before user code runs, the worker's
|
|
15
|
+
* ambient globals that could reach the process or the protocol (`Deno`, `postMessage`, `fetch`,
|
|
16
|
+
* `Worker`, ...) are replaced with `undefined` and `console` is redirected to log messages.
|
|
17
|
+
*
|
|
18
|
+
* Protocol: the supervisor talks to the host over stdin/stdout with one JSON frame per line,
|
|
19
|
+
* prefixed by a random token the supervisor generates and announces before the worker exists.
|
|
20
|
+
* The worker never sees the token, so it cannot forge frames; any other stdout bytes are treated
|
|
21
|
+
* as untrusted log text. All child output is untrusted: frames are size-bounded and validated, the
|
|
22
|
+
* execution settles exactly once, and the process group is killed on every exit path. A frame can
|
|
23
|
+
* never cancel the host's deadline or its cleanup.
|
|
10
24
|
*/
|
|
11
25
|
export class DenoRunner {
|
|
26
|
+
limits;
|
|
12
27
|
kind = 'deno';
|
|
28
|
+
static supervisorPath;
|
|
29
|
+
constructor(limits = DEFAULT_LIMITS) {
|
|
30
|
+
this.limits = limits;
|
|
31
|
+
}
|
|
13
32
|
async available() {
|
|
14
33
|
return await new Promise(resolve => {
|
|
15
|
-
const p = spawn('deno', ['--version'], { stdio: 'ignore' });
|
|
34
|
+
const p = spawn('deno', ['--version'], { stdio: 'ignore', env: childEnv() });
|
|
16
35
|
p.on('error', () => resolve(false));
|
|
17
36
|
p.on('exit', code => resolve(code === 0));
|
|
18
37
|
});
|
|
19
38
|
}
|
|
39
|
+
/** The supervisor holds no user data; it is written once per process, readable only by us. */
|
|
40
|
+
static supervisor() {
|
|
41
|
+
// Re-check on disk: a long-lived server's temp dir may be reaped by a tmp cleaner.
|
|
42
|
+
if (!DenoRunner.supervisorPath || !existsSync(DenoRunner.supervisorPath)) {
|
|
43
|
+
const dir = mkdtempSync(join(tmpdir(), 'fedreg-deno-'));
|
|
44
|
+
chmodSync(dir, 0o700);
|
|
45
|
+
const path = join(dir, 'supervisor.js');
|
|
46
|
+
writeFileSync(path, SUPERVISOR_SOURCE, { mode: 0o600 });
|
|
47
|
+
DenoRunner.supervisorPath = path;
|
|
48
|
+
process.once('exit', () => { try {
|
|
49
|
+
rmSync(dir, { recursive: true, force: true });
|
|
50
|
+
}
|
|
51
|
+
catch { /* ignore */ } });
|
|
52
|
+
}
|
|
53
|
+
return DenoRunner.supervisorPath;
|
|
54
|
+
}
|
|
20
55
|
async execute(opts, rpc) {
|
|
21
56
|
const started = Date.now();
|
|
57
|
+
const limits = { ...this.limits, ...(opts.limits ?? {}) };
|
|
58
|
+
const timeoutMs = opts.timeoutMs ?? 15_000;
|
|
59
|
+
const fail = (name, message, logs = []) => ({ ok: false, logs, error: { name, message }, durationMs: Date.now() - started });
|
|
22
60
|
const policy = preflight(opts.code);
|
|
23
|
-
if (!policy.ok)
|
|
24
|
-
return
|
|
61
|
+
if (!policy.ok)
|
|
62
|
+
return fail('PolicyError', policyMessage(policy.errors));
|
|
63
|
+
if (Buffer.byteLength(opts.code, 'utf8') > limits.maxCodeBytes)
|
|
64
|
+
return fail('CodeTooLarge', `Code exceeds ${limits.maxCodeBytes} bytes.`);
|
|
65
|
+
let child;
|
|
66
|
+
try {
|
|
67
|
+
child = spawn('deno', [
|
|
68
|
+
'run', '--no-prompt', '--no-config', '--no-lock', '--no-remote', '--no-npm', '--quiet',
|
|
69
|
+
`--v8-flags=--max-old-space-size=${Math.max(16, opts.memoryMb ?? 64)}`,
|
|
70
|
+
DenoRunner.supervisor(),
|
|
71
|
+
], { stdio: ['pipe', 'pipe', 'pipe'], env: childEnv(), detached: process.platform !== 'win32' });
|
|
25
72
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// reads the program from stdin until EOF, but we keep stdin open as the RPC
|
|
29
|
-
// channel, so it would never start. A file path leaves stdin free for RPC.
|
|
30
|
-
const tmpDir = mkdtempSync(join(tmpdir(), 'fedreg-deno-'));
|
|
31
|
-
const runnerPath = join(tmpDir, 'runner.ts');
|
|
32
|
-
writeFileSync(runnerPath, runner);
|
|
33
|
-
const cleanup = () => { try {
|
|
34
|
-
rmSync(tmpDir, { recursive: true, force: true });
|
|
73
|
+
catch (err) {
|
|
74
|
+
return fail('SpawnError', err.message);
|
|
35
75
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
76
|
+
const logs = new LogSink(limits.maxLogBytes, limits.maxLogLines);
|
|
77
|
+
return await new Promise(resolve => {
|
|
78
|
+
let settled = false;
|
|
79
|
+
let token;
|
|
80
|
+
let partial = [];
|
|
81
|
+
let partialLen = 0;
|
|
82
|
+
let bufferedBytes = 0;
|
|
83
|
+
let pendingRpc = 0;
|
|
84
|
+
// Choosing the outcome and tearing down are separate: the first terminal event fixes the
|
|
85
|
+
// result, and the promise resolves once the child has exited (bounded wait).
|
|
86
|
+
let exited = false;
|
|
87
|
+
const exitWaiters = [];
|
|
88
|
+
child.once('close', () => { exited = true; for (const w of exitWaiters.splice(0))
|
|
89
|
+
w(); });
|
|
90
|
+
const settle = (result) => {
|
|
91
|
+
if (settled)
|
|
92
|
+
return;
|
|
93
|
+
settled = true;
|
|
94
|
+
clearTimeout(deadline);
|
|
95
|
+
const outcome = { ...result, logs: logs.lines(), durationMs: Date.now() - started };
|
|
96
|
+
killTree(child);
|
|
97
|
+
if (exited)
|
|
98
|
+
return resolve(outcome);
|
|
99
|
+
// Normally the child exits within milliseconds of the kill. If it has not after 2 s, kill
|
|
100
|
+
// again, log it, and return the result anyway.
|
|
101
|
+
const giveUp = setTimeout(() => {
|
|
102
|
+
log.error('sandbox.teardown_pending', { pid: child.pid });
|
|
103
|
+
killTree(child);
|
|
104
|
+
resolve(outcome);
|
|
105
|
+
}, 2000);
|
|
106
|
+
exitWaiters.push(() => { clearTimeout(giveUp); resolve(outcome); });
|
|
107
|
+
};
|
|
108
|
+
const deadline = setTimeout(() => settle({ ok: false, error: { name: 'TimeoutError', message: `Execution exceeded ${timeoutMs}ms` } }), timeoutMs);
|
|
109
|
+
child.on('error', err => settle({ ok: false, error: { name: 'SpawnError', message: err.message } }));
|
|
110
|
+
// 'close', not 'exit': stdout may still hold the final frame when the process exits.
|
|
111
|
+
child.on('close', code => settle({ ok: false, error: { name: 'ExitError', message: `The sandbox exited unexpectedly (code ${code}).` } }));
|
|
112
|
+
const send = (frame) => {
|
|
113
|
+
if (settled || !token)
|
|
114
|
+
return;
|
|
115
|
+
let line;
|
|
46
116
|
try {
|
|
47
|
-
|
|
117
|
+
line = `${token}${JSON.stringify(frame)}\n`;
|
|
48
118
|
}
|
|
49
|
-
catch {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (msg.kind === 'log') {
|
|
76
|
-
logs.push(msg.text);
|
|
119
|
+
catch {
|
|
120
|
+
// An SDK result that cannot be serialized must still answer the call, or the sandbox waits for the deadline.
|
|
121
|
+
const f = frame;
|
|
122
|
+
if (f.t !== 'rpc-result')
|
|
123
|
+
return;
|
|
124
|
+
line = `${token}${JSON.stringify({ t: 'rpc-result', id: f.id, ok: false, error: { name: 'TypeError', message: 'The SDK result is not JSON-serializable.' } })}\n`;
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
child.stdin.write(line);
|
|
128
|
+
}
|
|
129
|
+
catch { /* child gone; exit handler settles */ }
|
|
130
|
+
};
|
|
131
|
+
const onFrame = async (raw) => {
|
|
132
|
+
let msg;
|
|
133
|
+
try {
|
|
134
|
+
msg = JSON.parse(raw);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return settle({ ok: false, error: { name: 'SandboxProtocolError', message: 'The sandbox sent a malformed frame.' } });
|
|
138
|
+
}
|
|
139
|
+
if (msg.t === 'log' && typeof msg.text === 'string')
|
|
140
|
+
return logs.push(msg.text);
|
|
141
|
+
if (msg.t === 'rpc' && Number.isSafeInteger(msg.id) && typeof msg.binding === 'string'
|
|
142
|
+
&& Array.isArray(msg.path) && Array.isArray(msg.args)) {
|
|
143
|
+
if (pendingRpc >= limits.maxPendingRpc) {
|
|
144
|
+
return send({ t: 'rpc-result', id: msg.id, ok: false, error: { name: 'TooManyPendingCalls', message: `At most ${limits.maxPendingRpc} SDK calls may be pending at once.` } });
|
|
77
145
|
}
|
|
78
|
-
|
|
146
|
+
const tooBig = checkRpcArgs(msg.args, limits);
|
|
147
|
+
if (tooBig)
|
|
148
|
+
return send({ t: 'rpc-result', id: msg.id, ok: false, error: tooBig });
|
|
149
|
+
pendingRpc++;
|
|
150
|
+
try {
|
|
79
151
|
const res = await rpc.dispatch({ binding: msg.binding, path: msg.path, args: msg.args });
|
|
80
|
-
|
|
152
|
+
send({ t: 'rpc-result', id: msg.id, ok: res.ok, value: res.value, error: res.error });
|
|
81
153
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
child.stdin.end();
|
|
86
|
-
}
|
|
87
|
-
catch { /* ignore */ }
|
|
88
|
-
resolve({
|
|
89
|
-
ok: msg.ok,
|
|
90
|
-
logs,
|
|
91
|
-
value: msg.value,
|
|
92
|
-
error: msg.error,
|
|
93
|
-
durationMs: Date.now() - started,
|
|
94
|
-
});
|
|
154
|
+
finally {
|
|
155
|
+
pendingRpc--;
|
|
95
156
|
}
|
|
157
|
+
return;
|
|
96
158
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
159
|
+
if (msg.t === 'done') {
|
|
160
|
+
if (msg.ok === true && typeof msg.json === 'string')
|
|
161
|
+
return settle(finishValue(msg.json, limits));
|
|
162
|
+
if (msg.tooLarge === true && typeof msg.size === 'number')
|
|
163
|
+
return settle({ ok: false, error: resultTooLarge(msg.size, limits) });
|
|
164
|
+
const e = (msg.error ?? {});
|
|
165
|
+
return settle({
|
|
166
|
+
ok: false,
|
|
167
|
+
error: {
|
|
168
|
+
name: typeof e.name === 'string' ? e.name.slice(0, 100) : 'Error',
|
|
169
|
+
message: typeof e.message === 'string' ? boundMessage(e.message) : 'Execution failed',
|
|
170
|
+
...(typeof e.status === 'number' ? { status: e.status } : {}),
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return settle({ ok: false, error: { name: 'SandboxProtocolError', message: 'The sandbox sent an unexpected frame.' } });
|
|
175
|
+
};
|
|
176
|
+
child.stdout.setEncoding('utf8');
|
|
177
|
+
child.stdout.on('data', (chunk) => {
|
|
178
|
+
if (settled)
|
|
179
|
+
return;
|
|
180
|
+
bufferedBytes += Buffer.byteLength(chunk, 'utf8');
|
|
181
|
+
if (bufferedBytes > limits.maxStdoutBytes) {
|
|
182
|
+
return settle({ ok: false, error: { name: 'OutputTooLarge', message: `The sandbox produced more than ${limits.maxStdoutBytes} bytes of output.` } });
|
|
183
|
+
}
|
|
184
|
+
// Split only the new chunk, so a long unterminated frame is never rescanned or re-flattened.
|
|
185
|
+
const segments = chunk.split('\n');
|
|
186
|
+
const tail = segments.pop();
|
|
187
|
+
for (const seg of segments) {
|
|
188
|
+
if (settled)
|
|
189
|
+
return;
|
|
190
|
+
const line = partial.length ? partial.join('') + seg : seg;
|
|
191
|
+
partial = [];
|
|
192
|
+
partialLen = 0;
|
|
193
|
+
if (!token) {
|
|
194
|
+
// The supervisor's first line announces the frame token; nothing else may precede it.
|
|
195
|
+
const m = /^FEDREG-SANDBOX ([0-9a-f]{64})$/.exec(line);
|
|
196
|
+
if (!m)
|
|
197
|
+
return settle({ ok: false, error: { name: 'SandboxProtocolError', message: 'The sandbox did not start correctly.' } });
|
|
198
|
+
token = m[1];
|
|
199
|
+
send({ t: 'start', code: opts.code, bindings: opts.bindings ?? [], limits: {
|
|
200
|
+
maxLogBytes: limits.maxLogBytes, maxLogLines: limits.maxLogLines, logLineOverhead: LOG_LINE_OVERHEAD,
|
|
201
|
+
logTruncated: LOG_TRUNCATED, maxRpcArgBytes: limits.maxRpcArgBytes, maxResultBytes: limits.maxResultBytes,
|
|
202
|
+
maxError: MAX_ERROR_MESSAGE,
|
|
203
|
+
} });
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (line.startsWith(token)) {
|
|
207
|
+
onFrame(line.slice(token.length)).catch(err => settle({ ok: false, error: { name: 'SandboxProtocolError', message: boundMessage(String(err?.message ?? err)) } }));
|
|
208
|
+
}
|
|
209
|
+
else if (line.length)
|
|
210
|
+
logs.push(line);
|
|
211
|
+
}
|
|
212
|
+
if (settled)
|
|
213
|
+
return;
|
|
214
|
+
partial.push(tail);
|
|
215
|
+
partialLen += tail.length;
|
|
216
|
+
if (partialLen > limits.maxFrameBytes) {
|
|
217
|
+
settle({ ok: false, error: { name: 'OutputTooLarge', message: `A sandbox message exceeded ${limits.maxFrameBytes} bytes.` } });
|
|
109
218
|
}
|
|
110
219
|
});
|
|
220
|
+
child.stderr.setEncoding('utf8');
|
|
221
|
+
child.stderr.on('data', (chunk) => { if (!settled)
|
|
222
|
+
logs.push(chunk.trimEnd()); });
|
|
223
|
+
child.stdin.on('error', () => { });
|
|
111
224
|
});
|
|
112
225
|
}
|
|
113
226
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
227
|
+
/** Only what Deno needs to start; never the server's secrets. */
|
|
228
|
+
function childEnv() {
|
|
229
|
+
const env = { NO_COLOR: '1', DENO_NO_UPDATE_CHECK: '1', DENO_NO_PROMPT: '1' };
|
|
230
|
+
for (const k of ['PATH', 'HOME', 'DENO_DIR', 'TMPDIR', 'SystemRoot', 'USERPROFILE', 'LOCALAPPDATA']) {
|
|
231
|
+
if (process.env[k])
|
|
232
|
+
env[k] = process.env[k];
|
|
233
|
+
}
|
|
234
|
+
return env;
|
|
118
235
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
236
|
+
/** Kill the child and anything it started. POSIX: the whole process group. */
|
|
237
|
+
function killTree(child) {
|
|
238
|
+
try {
|
|
239
|
+
child.stdin.destroy();
|
|
240
|
+
}
|
|
241
|
+
catch { /* ignore */ }
|
|
242
|
+
if (child.exitCode !== null || child.signalCode !== null)
|
|
243
|
+
return;
|
|
244
|
+
if (process.platform !== 'win32' && child.pid) {
|
|
245
|
+
try {
|
|
246
|
+
process.kill(-child.pid, 'SIGKILL');
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
catch { /* fall through */ }
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
child.kill('SIGKILL');
|
|
253
|
+
}
|
|
254
|
+
catch { /* ignore */ }
|
|
132
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Runs in Deno with no permissions. Holds no user data until the start frame arrives over stdin.
|
|
258
|
+
* Binding names come from the host (pre-validated identifiers) and are only used as object keys.
|
|
259
|
+
*/
|
|
260
|
+
export const SUPERVISOR_SOURCE = String.raw `
|
|
261
|
+
const enc = new TextEncoder();
|
|
262
|
+
const bytes = new Uint8Array(32);
|
|
263
|
+
crypto.getRandomValues(bytes);
|
|
264
|
+
const TOKEN = Array.from(bytes, b => b.toString(16).padStart(2, '0')).join('');
|
|
265
|
+
const writeLine = (s) => { const b = enc.encode(s + '\n'); let o = 0; while (o < b.length) o += Deno.stdout.writeSync(b.subarray(o)); };
|
|
266
|
+
const frame = (obj) => writeLine(TOKEN + JSON.stringify(obj));
|
|
267
|
+
writeLine('FEDREG-SANDBOX ' + TOKEN);
|
|
133
268
|
|
|
134
|
-
|
|
269
|
+
const WORKER_SOURCE = ${'`'}
|
|
270
|
+
// Trusted primitives, captured before user code exists: budgets below use these, so user code that
|
|
271
|
+
// replaces JSON.stringify, TextEncoder or Promise.prototype.then cannot push oversized data out.
|
|
272
|
+
const post = self.postMessage.bind(self);
|
|
273
|
+
const listen = self.addEventListener.bind(self);
|
|
274
|
+
const S = JSON.stringify, P = JSON.parse, Str = String, apply = Reflect.apply, then = Promise.prototype.then;
|
|
275
|
+
const encoder = new TextEncoder(), encode = TextEncoder.prototype.encode, sl = String.prototype.slice;
|
|
276
|
+
// The intrinsic %TypedArray%.prototype.byteLength getter, captured: user code may redefine
|
|
277
|
+
// Uint8Array.prototype.length, but cannot change a getter we already hold.
|
|
278
|
+
const byteLength = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), 'byteLength').get;
|
|
279
|
+
const bytes = (s) => apply(byteLength, apply(encode, encoder, [s]), []);
|
|
280
|
+
const cut = (s, n) => s.length > n ? apply(sl, s, [0, n]) : s;
|
|
281
|
+
let started = false;
|
|
135
282
|
const pending = new Map();
|
|
136
283
|
let nextId = 1;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
while (inbuf.length >= 9) {
|
|
147
|
-
const lenHex = dec.decode(inbuf.subarray(0, 8));
|
|
148
|
-
const len = parseInt(lenHex, 16);
|
|
149
|
-
if (isNaN(len)) { inbuf = new Uint8Array(0); break; }
|
|
150
|
-
if (inbuf.length < 9 + len) break;
|
|
151
|
-
const payload = dec.decode(inbuf.subarray(9, 9 + len));
|
|
152
|
-
inbuf = inbuf.subarray(9 + len);
|
|
153
|
-
const msg = JSON.parse(payload);
|
|
154
|
-
if (msg.kind === 'rpc-result') {
|
|
155
|
-
const cb = pending.get(msg.id);
|
|
156
|
-
if (cb) { pending.delete(msg.id); cb(msg); }
|
|
157
|
-
}
|
|
158
|
-
}
|
|
284
|
+
listen('message', (ev) => {
|
|
285
|
+
const m = ev.data;
|
|
286
|
+
if (m && m.t === 'rpc-result') {
|
|
287
|
+
const p = pending.get(m.id);
|
|
288
|
+
if (!p) return;
|
|
289
|
+
pending.delete(m.id);
|
|
290
|
+
if (m.ok) p.resolve(m.value);
|
|
291
|
+
else { const e = new Error(String(m.error?.message ?? 'SDK call failed')); e.name = String(m.error?.name ?? 'Error'); if (typeof m.error?.status === 'number') e.status = m.error.status; p.reject(e); }
|
|
292
|
+
return;
|
|
159
293
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
294
|
+
if (!m || m.t !== 'start' || started) return;
|
|
295
|
+
started = true;
|
|
296
|
+
run(String(m.code), Array.isArray(m.bindings) ? m.bindings.map(String) : [], m.limits || {});
|
|
297
|
+
});
|
|
298
|
+
let L = {};
|
|
163
299
|
function call(binding, path, args) {
|
|
164
300
|
return new Promise((resolve, reject) => {
|
|
301
|
+
let json;
|
|
302
|
+
try { json = S(args ?? []); } catch (e) { reject(new TypeError('SDK arguments must be JSON-serializable')); return; }
|
|
303
|
+
if (typeof json !== 'string' || bytes(json) > L.maxRpcArgBytes) { const e = new Error('SDK call arguments exceed ' + L.maxRpcArgBytes + ' bytes.'); e.name = 'ArgumentsTooLarge'; reject(e); return; }
|
|
165
304
|
const id = nextId++;
|
|
166
|
-
pending.set(id,
|
|
167
|
-
|
|
168
|
-
else resolve(r.value);
|
|
169
|
-
});
|
|
170
|
-
writeFrame({ kind: 'rpc', id, binding, path, args });
|
|
305
|
+
pending.set(id, { resolve, reject });
|
|
306
|
+
post({ t: 'rpc', id, binding, path, args: P(json) });
|
|
171
307
|
});
|
|
172
308
|
}
|
|
173
|
-
|
|
174
309
|
function makeProxy(binding) {
|
|
175
|
-
const handler = (path) => new Proxy(function(){}, {
|
|
176
|
-
get(_, key) { return handler([...path, String(key)]); },
|
|
310
|
+
const handler = (path) => new Proxy(function () {}, {
|
|
311
|
+
get(_, key) { return typeof key === 'symbol' ? undefined : handler([...path, String(key)]); },
|
|
177
312
|
apply(_, __, args) { return call(binding, path, args); },
|
|
178
313
|
});
|
|
179
314
|
return handler([]);
|
|
180
315
|
}
|
|
316
|
+
function run(code, bindings, limits) {
|
|
317
|
+
L = limits;
|
|
318
|
+
const show = (v) => { if (typeof v === 'string') return v; try { const j = S(v); return j === undefined ? Str(v) : j; } catch { return Str(v); } };
|
|
319
|
+
let logBytes = 0, logLines = 0, logDone = false;
|
|
320
|
+
const log = (...a) => {
|
|
321
|
+
if (logDone) return;
|
|
322
|
+
let text = '';
|
|
323
|
+
for (let i = 0; i < a.length; i++) text += (i ? ' ' : '') + show(a[i]);
|
|
324
|
+
text = cut(text, L.maxLogBytes);
|
|
325
|
+
logBytes += bytes(text) + L.logLineOverhead; logLines++;
|
|
326
|
+
if (logBytes > L.maxLogBytes - L.logTruncated.length - L.logLineOverhead || logLines >= L.maxLogLines) { logDone = true; text = L.logTruncated; }
|
|
327
|
+
post({ t: 'log', text });
|
|
328
|
+
};
|
|
329
|
+
self.console = { log, info: log, warn: log, error: log, debug: log };
|
|
330
|
+
for (const k of ['Deno', 'postMessage', 'close', 'fetch', 'WebSocket', 'WebSocketStream', 'Worker', 'EventSource',
|
|
331
|
+
'navigator', 'caches', 'localStorage', 'sessionStorage', 'importScripts', 'BroadcastChannel']) {
|
|
332
|
+
try { Object.defineProperty(self, k, { value: undefined, writable: false, configurable: false }); } catch {}
|
|
333
|
+
}
|
|
334
|
+
for (const name of bindings) {
|
|
335
|
+
try { Object.defineProperty(self, name, { value: makeProxy(name), writable: false, configurable: false }); } catch {}
|
|
336
|
+
}
|
|
337
|
+
let fn;
|
|
338
|
+
try { fn = new Function('"use strict"; return (async () => {\\n' + code + '\\n})();'); }
|
|
339
|
+
catch (e) { post({ t: 'done', ok: false, error: { name: Str(e?.name ?? 'SyntaxError'), message: cut(Str(e?.message ?? e), L.maxError) } }); return; }
|
|
340
|
+
const fail = (e) => {
|
|
341
|
+
let name = 'Error', message = '', status;
|
|
342
|
+
try { name = cut(Str(e?.name ?? 'Error'), 100); message = cut(Str(e?.message !== undefined ? e.message : e), L.maxError); status = typeof e?.status === 'number' ? e.status : undefined; } catch {}
|
|
343
|
+
post({ t: 'done', ok: false, error: { name, message, ...(status === undefined ? {} : { status }) } });
|
|
344
|
+
};
|
|
345
|
+
const done = (value) => {
|
|
346
|
+
let json;
|
|
347
|
+
try { json = S(value === undefined ? null : value); } catch (e) { fail({ name: 'TypeError', message: 'The returned value is not JSON-serializable' }); return; }
|
|
348
|
+
if (typeof json !== 'string') json = 'null';
|
|
349
|
+
const size = bytes(json);
|
|
350
|
+
if (size > L.maxResultBytes) post({ t: 'done', ok: false, tooLarge: true, size });
|
|
351
|
+
else post({ t: 'done', ok: true, json });
|
|
352
|
+
};
|
|
353
|
+
let started;
|
|
354
|
+
try { started = fn(); } catch (e) { fail(e); return; }
|
|
355
|
+
apply(then, started, [done, fail]);
|
|
356
|
+
}
|
|
357
|
+
${'`'};
|
|
181
358
|
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
${userCode}
|
|
359
|
+
const url = URL.createObjectURL(new Blob([WORKER_SOURCE], { type: 'application/javascript' }));
|
|
360
|
+
const worker = new Worker(url, { type: 'module' });
|
|
361
|
+
worker.onmessage = (ev) => {
|
|
362
|
+
const m = ev.data;
|
|
363
|
+
if (!m || typeof m !== 'object') return;
|
|
364
|
+
if (m.t === 'log') frame({ t: 'log', text: String(m.text).slice(0, 65536) });
|
|
365
|
+
else if (m.t === 'rpc') frame({ t: 'rpc', id: m.id, binding: m.binding, path: m.path, args: m.args });
|
|
366
|
+
else if (m.t === 'done') frame({ t: 'done', ok: m.ok === true, json: m.json, error: m.error, tooLarge: m.tooLarge === true, size: m.size });
|
|
191
367
|
};
|
|
368
|
+
worker.onerror = (e) => { e.preventDefault(); frame({ t: 'done', ok: false, error: { name: 'Error', message: String(e.message ?? 'Worker error') } }); };
|
|
192
369
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
370
|
+
// Host → supervisor: token-prefixed JSON lines on stdin.
|
|
371
|
+
const dec = new TextDecoder();
|
|
372
|
+
let buf = '';
|
|
373
|
+
for await (const chunk of Deno.stdin.readable) {
|
|
374
|
+
buf += dec.decode(chunk, { stream: true });
|
|
375
|
+
let nl;
|
|
376
|
+
while ((nl = buf.indexOf('\n')) >= 0) {
|
|
377
|
+
const line = buf.slice(0, nl);
|
|
378
|
+
buf = buf.slice(nl + 1);
|
|
379
|
+
if (!line.startsWith(TOKEN)) continue;
|
|
380
|
+
let msg;
|
|
381
|
+
try { msg = JSON.parse(line.slice(TOKEN.length)); } catch { continue; }
|
|
382
|
+
if (msg.t === 'start') worker.postMessage({ t: 'start', code: msg.code, bindings: msg.bindings, limits: msg.limits });
|
|
383
|
+
else if (msg.t === 'rpc-result') worker.postMessage(msg);
|
|
384
|
+
}
|
|
202
385
|
}
|
|
386
|
+
// The host went away (stdin closed): do not leave a possibly busy Worker running as an orphan.
|
|
387
|
+
Deno.exit(0);
|
|
388
|
+
`;
|
|
203
389
|
//# sourceMappingURL=deno.js.map
|
package/dist/sandbox/deno.js.map
CH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C,CAAC;IAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IACrD,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI;QAAE,OAAO;IACjE,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;QAC9C,IAAI,CAAC;YAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YAAC,OAAO;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,kBAAkB,CAAC,CAAC;IACnF,CAAC;IACD,IAAI,CAAC;QAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;AACvD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;wBASnB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwFzB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BJ,CAAC"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { ExecuteOptions, ExecuteResult, RpcBridge, SandboxRunner } from './types.js';
|
|
2
|
+
import { type SandboxLimits } from './limits.js';
|
|
3
|
+
/**
|
|
4
|
+
* isolated-vm sandbox: a fresh V8 isolate per execution with a heap cap. The host owns a
|
|
5
|
+
* wall-clock deadline that starts before setup: when it fires the isolate
|
|
6
|
+
* is disposed, which stops running code and rejects anything it awaits, and the execution settles
|
|
7
|
+
* once. V8's own `timeout` stays as a second guard for synchronous loops. This runs in the server
|
|
8
|
+
* process, so for hosted multi-user execution prefer the Deno runner (separate process).
|
|
9
|
+
*/
|
|
2
10
|
export declare class IsolateRunner implements SandboxRunner {
|
|
11
|
+
private readonly limits;
|
|
3
12
|
kind: "isolate";
|
|
13
|
+
constructor(limits?: SandboxLimits);
|
|
4
14
|
available(): Promise<boolean>;
|
|
5
15
|
execute(opts: ExecuteOptions, rpc: RpcBridge): Promise<ExecuteResult>;
|
|
6
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isolate.d.ts","sourceRoot":"","sources":["../../src/sandbox/isolate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"isolate.d.ts","sourceRoot":"","sources":["../../src/sandbox/isolate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE1F,OAAO,EAA0I,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAWzL;;;;;;GAMG;AACH,qBAAa,aAAc,YAAW,aAAa;IAGrC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,IAAI,EAAG,SAAS,CAAU;gBAEG,MAAM,GAAE,aAA8B;IAE7D,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAW7B,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC;CA2I5E"}
|