Skip to content

Commit 7c90a7f

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} 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 c0d46fe commit 7c90a7f

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.21',
30+
'v8_embedder_string': '-node.22',
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
@@ -5299,6 +5299,11 @@ Genesis::Genesis(
52995299
if (!InstallDebuggerNatives()) return;
53005300
}
53015301

5302+
if (FLAG_disallow_code_generation_from_strings) {
5303+
native_context()->set_allow_code_gen_from_strings(
5304+
isolate->heap()->false_value());
5305+
}
5306+
53025307
ConfigureUtilsObject(context_type);
53035308

53045309
// 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
@@ -734,6 +734,8 @@ DEFINE_BOOL(expose_trigger_failure, false, "expose trigger-failure extension")
734734
DEFINE_INT(stack_trace_limit, 10, "number of stack frames to capture")
735735
DEFINE_BOOL(builtins_in_stack_traces, false,
736736
"show built-in functions in stack traces")
737+
DEFINE_BOOL(disallow_code_generation_from_strings, false,
738+
"disallow eval and friends")
737739

738740
// builtins.cc
739741
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)