From 99d693da5c1b753d15fb7c744de0c4cb87098c93 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Wed, 7 Feb 2018 10:42:26 -0500 Subject: [PATCH] lib: replace `eval` with `vm.runInThisContext` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/18623 Refs: https://github.com/nodejs/node/pull/18212#pullrequestreview-94616927 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- lib/internal/v8_prof_processor.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/internal/v8_prof_processor.js b/lib/internal/v8_prof_processor.js index 9c63430f964917..0d9cfd6df4d12a 100644 --- a/lib/internal/v8_prof_processor.js +++ b/lib/internal/v8_prof_processor.js @@ -1,4 +1,7 @@ -/* eslint-disable strict */ +'use strict'; + +const vm = require('vm'); + const scriptFiles = [ 'internal/v8_prof_polyfill', 'internal/deps/v8/tools/splaytree', @@ -31,9 +34,9 @@ if (process.platform === 'darwin') { tickArguments.push('--windows'); } tickArguments.push.apply(tickArguments, process.argv.slice(1)); -script = `(function() { +script = `(function(require) { arguments = ${JSON.stringify(tickArguments)}; function write (s) { process.stdout.write(s) } ${script} -})()`; -eval(script); +})`; +vm.runInThisContext(script)(require);