diff options
author | Thomas <hakerh403@gmail.com> | 2019-02-10 12:39:23 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-03-02 00:07:53 +0100 |
commit | e9ed6b988f9b8a5a9db8deb4f06c759cf226a1a5 (patch) | |
tree | 15e919f561064361c1439a06e8425ff85aa0502a /src/inspector_js_api.cc | |
parent | fc4c0de92fcbd25236de6eac35afab620ffc1e27 (diff) | |
download | node-new-e9ed6b988f9b8a5a9db8deb4f06c759cf226a1a5.tar.gz |
console: prevent constructing console methods
Ref: https://github.com/nodejs/node/issues/25987
PR-URL: https://github.com/nodejs/node/pull/26096
Refs: https://github.com/nodejs/node/issues/25987
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Diffstat (limited to 'src/inspector_js_api.cc')
-rw-r--r-- | src/inspector_js_api.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index c2e80d93fd..c54c09d427 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -272,7 +272,17 @@ void Initialize(Local<Object> target, Local<Value> unused, Environment* env = Environment::GetCurrent(context); Agent* agent = env->inspector_agent(); - env->SetMethod(target, "consoleCall", InspectorConsoleCall); + + v8::Local<v8::Function> consoleCallFunc = + env->NewFunctionTemplate(InspectorConsoleCall, v8::Local<v8::Signature>(), + v8::ConstructorBehavior::kThrow, + v8::SideEffectType::kHasSideEffect) + ->GetFunction(context) + .ToLocalChecked(); + auto name_string = FIXED_ONE_BYTE_STRING(env->isolate(), "consoleCall"); + target->Set(context, name_string, consoleCallFunc).FromJust(); + consoleCallFunc->SetName(name_string); + env->SetMethod( target, "setConsoleExtensionInstaller", SetConsoleExtensionInstaller); if (agent->WillWaitForConnect()) |