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

deps: cherry-pick 0bcb1d6f from upstream V8 #18212

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

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

# Enable disassembler for `--print-code` v8 options
'v8_enable_disassembler': 1,
Expand Down
5 changes: 5 additions & 0 deletions deps/v8/src/bootstrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5475,6 +5475,11 @@ Genesis::Genesis(
if (!InstallDebuggerNatives()) return;
}

if (FLAG_disallow_code_generation_from_strings) {
native_context()->set_allow_code_gen_from_strings(
isolate->heap()->false_value());
}

ConfigureUtilsObject(context_type);

// Check that the script context table is empty except for the 'this' binding.
Expand Down
2 changes: 2 additions & 0 deletions deps/v8/src/flag-definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@ DEFINE_BOOL(builtins_in_stack_traces, false,
"show built-in functions in stack traces")
DEFINE_BOOL(enable_experimental_builtins, true,
"enable new csa-based experimental builtins")
DEFINE_BOOL(disallow_code_generation_from_strings, false,
"disallow eval and friends")

// builtins.cc
DEFINE_BOOL(allow_unsafe_function_constructor, false,
Expand Down
9 changes: 9 additions & 0 deletions deps/v8/test/mjsunit/disallow-codegen-from-strings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --disallow-code-generation-from-strings

assertThrows("1 + 1", EvalError);
assertThrows(() => eval("1 + 1"), EvalError);
assertThrows(() => Function("x", "return x + 1"), EvalError);