From 9955b8796e09c04ead31b27e89ec7c755f47138b Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Mon, 12 Aug 2024 14:10:52 +0530 Subject: [PATCH] feat: safe mode updates --- .../bruno-js/src/sandbox/isolatedvm/index.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/bruno-js/src/sandbox/isolatedvm/index.js b/packages/bruno-js/src/sandbox/isolatedvm/index.js index 9290b112c..2606939e9 100644 --- a/packages/bruno-js/src/sandbox/isolatedvm/index.js +++ b/packages/bruno-js/src/sandbox/isolatedvm/index.js @@ -4,7 +4,6 @@ const addBrunoRequestShimToContext = require('./shims/bruno-request'); const addConsoleShimToContext = require('./shims/console'); const addBrunoResponseShimToContext = require('./shims/bruno-response'); const addTestShimToContext = require('./shims/test'); -const fs = require('fs'); const addLibraryShimsToContext = require('./shims/lib'); // execute `npm run build:isolated-vm:inbuilt-modules` if the below file doesn't exist @@ -243,12 +242,16 @@ const executeInIsolatedVMAsync = async ({ await context.global.set('global', context.global.derefInto()); context.evalSync(` - let bru = {}; - let req = {}; - let res = {}; - let console = {}; - global.requireObject = {}; - `); + let bru = {}; + let req = {}; + let res = {}; + let console = {}; + global.requireObject = {}; + global.require = (module) => { + return global.requireObject[module]; + } + `); + await addLibraryShimsToContext(this.context); context.global.setSync('log', function (...args) { console.debug(...args);