process: delay creation of process.env after bootstrap/node.js
Make sure that no code is allowed to access process.env during the execution of bootstrap/node.js. PR-URL: https://github.com/nodejs/node/pull/26515 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
1482547441
commit
ee2d2638ad
10
src/node.cc
10
src/node.cc
@ -340,6 +340,16 @@ MaybeLocal<Value> RunBootstrapping(Environment* env) {
|
|||||||
MaybeLocal<Value> result = ExecuteBootstrapper(
|
MaybeLocal<Value> result = ExecuteBootstrapper(
|
||||||
env, "internal/bootstrap/node", &node_params, &node_args);
|
env, "internal/bootstrap/node", &node_params, &node_args);
|
||||||
|
|
||||||
|
Local<Object> env_var_proxy;
|
||||||
|
if (!CreateEnvVarProxy(context, isolate, env->as_callback_data())
|
||||||
|
.ToLocal(&env_var_proxy) ||
|
||||||
|
process
|
||||||
|
->Set(env->context(),
|
||||||
|
FIXED_ONE_BYTE_STRING(env->isolate(), "env"),
|
||||||
|
env_var_proxy)
|
||||||
|
.IsNothing())
|
||||||
|
return MaybeLocal<Value>();
|
||||||
|
|
||||||
env->set_has_run_bootstrapping_code(true);
|
env->set_has_run_bootstrapping_code(true);
|
||||||
|
|
||||||
return scope.EscapeMaybe(result);
|
return scope.EscapeMaybe(result);
|
||||||
|
@ -151,18 +151,6 @@ MaybeLocal<Object> CreateProcessObject(
|
|||||||
ToV8Value(env->context(), exec_args)
|
ToV8Value(env->context(), exec_args)
|
||||||
.ToLocalChecked()).FromJust();
|
.ToLocalChecked()).FromJust();
|
||||||
|
|
||||||
Local<Object> env_var_proxy;
|
|
||||||
if (!CreateEnvVarProxy(context, isolate, env->as_callback_data())
|
|
||||||
.ToLocal(&env_var_proxy))
|
|
||||||
return MaybeLocal<Object>();
|
|
||||||
|
|
||||||
// process.env
|
|
||||||
process
|
|
||||||
->Set(env->context(),
|
|
||||||
FIXED_ONE_BYTE_STRING(env->isolate(), "env"),
|
|
||||||
env_var_proxy)
|
|
||||||
.FromJust();
|
|
||||||
|
|
||||||
READONLY_PROPERTY(process, "pid",
|
READONLY_PROPERTY(process, "pid",
|
||||||
Integer::New(env->isolate(), uv_os_getpid()));
|
Integer::New(env->isolate(), uv_os_getpid()));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user