(
code: string,
opts?: { timeout?: number },
)
| 2 | import { createQuickJSIsolateDriver } from '../src/isolate-driver' |
| 3 | |
| 4 | async function runInIsolate( |
| 5 | code: string, |
| 6 | opts?: { timeout?: number }, |
| 7 | ): Promise<{ |
| 8 | success: boolean |
| 9 | value: unknown |
| 10 | error?: { name: string; message: string } |
| 11 | }> { |
| 12 | const driver = createQuickJSIsolateDriver() |
| 13 | const context = await driver.createContext({ |
| 14 | bindings: {}, |
| 15 | ...(opts?.timeout !== undefined && { timeout: opts.timeout }), |
| 16 | }) |
| 17 | try { |
| 18 | const res = await context.execute(code) |
| 19 | return { |
| 20 | success: res.success, |
| 21 | value: res.value, |
| 22 | ...(res.error !== undefined && { error: res.error }), |
| 23 | } |
| 24 | } finally { |
| 25 | await context.dispose() |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | describe('QuickJS isolate — sandbox escape attempts', () => { |
| 30 | it('does not expose `process`', async () => { |
no test coverage detected