GeezerVison is showing github.com — cli: whitelist new V8 flag in NODE_OPTIONS · nodejs/node@f3196db
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/cli.md +10Lines changed: 10 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -127,6 +127,15 @@ added: v12.0.0 |
127 | 127 |
|
128 | 128 | Specify the file name of the CPU profile generated by `--cpu-prof`. |
129 | 129 |
|
| 130 | +### `--disallow-code-generation-from-strings` |
| 131 | +<!-- YAML |
| 132 | +added: v9.8.0 |
| 133 | +--> |
| 134 | + |
| 135 | +Make built-in language features like `eval` and `new Function` that generate |
| 136 | +code from strings throw an exception instead. This does not affect the Node.js |
| 137 | +`vm` module. |
| 138 | + |
130 | 139 | ### `--enable-fips` |
131 | 140 | <!-- YAML |
132 | 141 | added: v6.0.0 |
@@ -1134,6 +1143,7 @@ Node.js options that are allowed are: |
1134 | 1143 | V8 options that are allowed are: |
1135 | 1144 | <!-- node-options-v8 start --> |
1136 | 1145 | * `--abort-on-uncaught-exception` |
| 1146 | +* `--disallow-code-generation-from-strings` |
1137 | 1147 | * `--interpreted-frames-native-stack` |
1138 | 1148 | * `--max-old-space-size` |
1139 | 1149 | * `--perf-basic-prof-only-functions` |
|
Collapse file
Copy file name to clipboardExpand all lines: doc/node.1 +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -100,6 +100,11 @@ The default is |
100 | 100 | File name of the V8 CPU profile generated with |
101 | 101 | .Fl -cpu-prof |
102 | 102 | . |
| 103 | +.It Fl -disallow-code-generation-from-strings |
| 104 | +Make built-in language features like `eval` and `new Function` that generate |
| 105 | +code from strings throw an exception instead. This does not affect the Node.js |
| 106 | +`vm` module. |
| 107 | +. |
103 | 108 | .It Fl -enable-fips |
104 | 109 | Enable FIPS-compliant crypto at startup. |
105 | 110 | Requires Node.js to be built with |
|
Collapse file
Copy file name to clipboardExpand all lines: src/node_options.cc +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -611,6 +611,10 @@ PerIsolateOptionsParser::PerIsolateOptionsParser( |
611 | 611 | V8Option{}, |
612 | 612 | kAllowedInEnvironment); |
613 | 613 | AddOption("--stack-trace-limit", "", V8Option{}, kAllowedInEnvironment); |
| 614 | + AddOption("--disallow-code-generation-from-strings", |
| 615 | + "disallow eval and friends", |
| 616 | + V8Option{}, |
| 617 | + kAllowedInEnvironment); |
614 | 618 |
|
615 | 619 | #ifdef NODE_REPORT |
616 | 620 | AddOption("--report-uncaught-exception", |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-cli-node-options.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -60,6 +60,7 @@ if (common.hasCrypto) { |
60 | 60 |
|
61 | 61 | // V8 options |
62 | 62 | expect('--abort_on-uncaught_exception', 'B\n'); |
| 63 | +expect('--disallow-code-generation-from-strings', 'B\n'); |
63 | 64 | expect('--max-old-space-size=0', 'B\n'); |
64 | 65 | expect('--stack-trace-limit=100', |
65 | 66 | /(\s*at f \(\[eval\]:1:\d*\)\r?\n){100}/, |
|