Answer the question
In order to leave comments, you need to log in
Hiding global access in node.js?
Task: to make it so that some code executing on the server through eval (or through the function constructor, it doesn’t matter) in any way could not access the global object and require.
A simple solution:
function runCode(code) {
var global, require;
eval(code);
}
// evaled code:
console.log(global); // -> undefined
// evaled code:
var global = eval("(new ('hello'.constructor.constructor)('return global;'))()");
console.log(global); // !!!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question