Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
require('../common');
const vm = require('vm');
// Check that we do not accidentally query attributes.
// Issue: https://github.com/nodejs/node/issues/11902
const handler = {
getOwnPropertyDescriptor: (target, prop) => {
throw new Error('whoops');
}
};
const sandbox = new Proxy({ foo: 'bar' }, handler);
const context = vm.createContext(sandbox);
vm.runInContext('', context);
function getContext(sandboxExtras){
sandbox = getBaseSandbox();
sandboxExtras = sandboxExtras || {};
for (var attrname in sandboxExtras){
sandbox[attrname] = sandboxExtras[attrname];
}
// create a context for the vm using the sandbox data
var context = vm.createContext(sandbox)
// load Handlebars and Ember into the sandbox
vm.runInContext(HANDLEBARSJS, context, 'handlebars.js')
vm.runInContext(EMBERJS, context, 'ember.js')
return context;
}
async function runScript(scriptString, sandbox) {
const context = vm.createContext(sandbox);
scriptString += `;
(async () => {
const testResult = eval(test);
if (typeof testResult === 'function') {
const __result = testResult(() => code);
if (isPromise(__result)) {
await __result;
}
}
})();`;
const script = new vm.Script(scriptString);
script.runInContext(context);
}
function evaluate (vm) {
if (vm.hasEvaluated) {
return
}
vm.script = new NodeVM.Script(vm.code)
vm.sandbox = createNewSandbox(vm)
vm.context = NodeVM.createContext(vm.sandbox)
vm.script.runInContext(vm.context)
vm.hasEvaluated = true
}
var startUp = function () {
context = vm.createContext(ctx);
runInContext("var window = this;", "lib/index.js#startUp");
//loadFile(pathlib.join(__dirname, 'jquery_node.js'));
fws.forEach(loadFramework);
loadFile(pathlib.join(curdir, '..', 'frameworks','foundation', 'system', 'benchmark.js'));
//util.log("filesLoaded: " + util.inspect(filesLoadedInContext));
};