Skip to content

Commit 8a54f4f

Browse files
jakobkummerowMylesBorins
authored andcommittedMar 6, 2018
deps: cherry-pick 0bcb1d6f from upstream V8
Original commit message: Introduce --disallow-code-generation-from-strings Exposing the existing Context::AllowCodeGenerationFromStrings(false) API to the command line. Bug: v8:7134 Change-Id: I062ccff0b03c5bcf6878c41c455c0ded37a1d743 Reviewed-on: https://chromium-review.googlesource.com/809631 Reviewed-by: Michael Starzinger <[email protected]> Commit-Queue: Jakob Kummerow <[email protected]> Cr-Commit-Position: refs/heads/master@{#49911} PR-URL: #18212 Refs: v8/v8@0bcb1d6 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Gus Caplan <[email protected]>
1 parent c221355 commit 8a54f4f

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed
 

‎common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
# Reset this number to 0 on major V8 upgrades.
2929
# Increment by one for each non-official patch applied to deps/v8.
30-
'v8_embedder_string': '-node.4',
30+
'v8_embedder_string': '-node.5',
3131

3232
# Enable disassembler for `--print-code` v8 options
3333
'v8_enable_disassembler': 1,

‎deps/v8/src/bootstrapper.cc

+5
Original file line numberDiff line numberDiff line change
@@ -5475,6 +5475,11 @@ Genesis::Genesis(
54755475
if (!InstallDebuggerNatives()) return;
54765476
}
54775477

5478+
if (FLAG_disallow_code_generation_from_strings) {
5479+
native_context()->set_allow_code_gen_from_strings(
5480+
isolate->heap()->false_value());
5481+
}
5482+
54785483
ConfigureUtilsObject(context_type);
54795484

54805485
// Check that the script context table is empty except for the 'this' binding.

‎deps/v8/src/flag-definitions.h

+2
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,8 @@ DEFINE_BOOL(builtins_in_stack_traces, false,
768768
"show built-in functions in stack traces")
769769
DEFINE_BOOL(enable_experimental_builtins, true,
770770
"enable new csa-based experimental builtins")
771+
DEFINE_BOOL(disallow_code_generation_from_strings, false,
772+
"disallow eval and friends")
771773

772774
// builtins.cc
773775
DEFINE_BOOL(allow_unsafe_function_constructor, false,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright 2017 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --disallow-code-generation-from-strings
6+
7+
assertThrows("1 + 1", EvalError);
8+
assertThrows(() => eval("1 + 1"), EvalError);
9+
assertThrows(() => Function("x", "return x + 1"), EvalError);

0 commit comments

Comments
 (0)
Please sign in to comment.