Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// See https://github.com/nodejs/node/issues/8071#issuecomment-240259088
// It will prevent console.log from calling the "inspect" property,
// which can be kinda messy with Proxies
require("util").inspect.defaultOptions.customInspect = false;
if (argv["dangerous-vm"]) {
lib.verbose("Analyzing with native vm module (dangerous!)");
const vm = require("vm");
vm.runInNewContext(code, sandbox, {
displayErrors: true,
// lineOffset: -fs.readFileSync(path.join(__dirname, "patch.js"), "utf8").split("\n").length,
filename: "sample.js",
});
} else {
lib.debug("Analyzing with vm2 v" + require("vm2/package.json").version);
const vm = new VM({
timeout: (argv.timeout || 10) * 1000,
sandbox,
});
vm.run(code);
}
function ActiveXObject(name) {
lib.verbose(`New ActiveXObject: ${name}`);
name = name.toLowerCase();
if (name.match("xmlhttp") || name.match("winhttprequest"))
return require("./emulator/XMLHTTP");
if (name.match("dom")) {
return {
createElement: require("./emulator/DOM"),