Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: whitelist new V8 flag in NODE_OPTIONS #30094

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions doc/api/cli.md
Expand Up @@ -127,6 +127,15 @@ added: v12.0.0

Specify the file name of the CPU profile generated by `--cpu-prof`.

### `--disallow-code-generation-from-strings`
<!-- YAML
added: v9.8.0
-->

Make built-in language features like `eval` and `new Function` that generate
code from strings throw an exception instead. This does not affect the Node.js
`vm` module.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice catch about vm!


### `--enable-fips`
<!-- YAML
added: v6.0.0
Expand Down Expand Up @@ -1056,6 +1065,7 @@ Node.js options that are allowed are:
V8 options that are allowed are:
<!-- node-options-v8 start -->
* `--abort-on-uncaught-exception`
* `--disallow-code-generation-from-strings`
* `--interpreted-frames-native-stack`
* `--max-old-space-size`
* `--perf-basic-prof-only-functions`
Expand Down
5 changes: 5 additions & 0 deletions doc/node.1
Expand Up @@ -100,6 +100,11 @@ The default is
File name of the V8 CPU profile generated with
.Fl -cpu-prof
.
.It Fl -disallow-code-generation-from-strings
Make built-in language features like `eval` and `new Function` that generate
code from strings throw an exception instead. This does not affect the Node.js
`vm` module.
.
.It Fl -enable-fips
Enable FIPS-compliant crypto at startup.
Requires Node.js to be built with
Expand Down
4 changes: 4 additions & 0 deletions src/node_options.cc
Expand Up @@ -581,6 +581,10 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
V8Option{},
kAllowedInEnvironment);
AddOption("--stack-trace-limit", "", V8Option{}, kAllowedInEnvironment);
AddOption("--disallow-code-generation-from-strings",
"disallow eval and friends",
V8Option{},
kAllowedInEnvironment);

#ifdef NODE_REPORT
AddOption("--report-uncaught-exception",
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-cli-node-options.js
Expand Up @@ -60,6 +60,7 @@ if (common.hasCrypto) {

// V8 options
expect('--abort_on-uncaught_exception', 'B\n');
expect('--disallow-code-generation-from-strings', 'B\n');
expect('--max-old-space-size=0', 'B\n');
expect('--stack-trace-limit=100',
/(\s*at f \(\[eval\]:1:\d*\)\r?\n){100}/,
Expand Down