Skip to content

Commit af019e5

Browse files
jakobkummerowMylesBorins
authored andcommitted
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} Refs: v8/v8@0bcb1d6
1 parent bd4773a commit af019e5

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
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.3',
30+
'v8_embedder_string': '-node.4',
3131

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

deps/v8/src/bootstrapper.cc

Lines changed: 5 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ DEFINE_BOOL(builtins_in_stack_traces, false,
766766
"show built-in functions in stack traces")
767767
DEFINE_BOOL(enable_experimental_builtins, true,
768768
"enable new csa-based experimental builtins")
769+
DEFINE_BOOL(disallow_code_generation_from_strings, false,
770+
"disallow eval and friends")
769771

770772
// builtins.cc
771773
DEFINE_BOOL(allow_unsafe_function_constructor, false,
Lines changed: 9 additions & 0 deletions
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)