summaryrefslogtreecommitdiff
path: root/runtime/ops
diff options
context:
space:
mode:
authorColin Ihrig <cjihrig@gmail.com>2022-09-14 11:59:20 -0400
committerGitHub <noreply@github.com>2022-09-14 11:59:20 -0400
commit19deec449428ffac823e2d94de56bc1482a11865 (patch)
treecb1d8fd16ce08c0db15b615c167be30d78a66141 /runtime/ops
parent7b982829930bfcfbb70d0bb377f90939d122efed (diff)
fix(ops): add node.js env variable allowlist (#15893)
This commit allows the Node compatibility layer to skip environment variable permission checks when --unstable is passed and the variable name is one that Node uses. Fixes: https://github.com/denoland/deno/issues/15890
Diffstat (limited to 'runtime/ops')
-rw-r--r--runtime/ops/os.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/runtime/ops/os.rs b/runtime/ops/os.rs
index 5d275a836..21a94b0fb 100644
--- a/runtime/ops/os.rs
+++ b/runtime/ops/os.rs
@@ -8,6 +8,7 @@ use deno_core::url::Url;
use deno_core::Extension;
use deno_core::OpState;
use deno_core::{op, ExtensionBuilder};
+use deno_node::NODE_ENV_VAR_ALLOWLIST;
use serde::Serialize;
use std::collections::HashMap;
use std::env;
@@ -99,7 +100,14 @@ fn op_get_env(
state: &mut OpState,
key: String,
) -> Result<Option<String>, AnyError> {
- state.borrow_mut::<Permissions>().env.check(&key)?;
+ let skip_permission_check =
+ state.borrow::<crate::ops::UnstableChecker>().unstable
+ && NODE_ENV_VAR_ALLOWLIST.contains(&key);
+
+ if !skip_permission_check {
+ state.borrow_mut::<Permissions>().env.check(&key)?;
+ }
+
if key.is_empty() || key.contains(&['=', '\0'] as &[char]) {
return Err(type_error("Key contains invalid characters."));
}