diff options
author | Colin Ihrig <cjihrig@gmail.com> | 2022-09-14 11:59:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-14 11:59:20 -0400 |
commit | 19deec449428ffac823e2d94de56bc1482a11865 (patch) | |
tree | cb1d8fd16ce08c0db15b615c167be30d78a66141 /ext/node/lib.rs | |
parent | 7b982829930bfcfbb70d0bb377f90939d122efed (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 'ext/node/lib.rs')
-rw-r--r-- | ext/node/lib.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/node/lib.rs b/ext/node/lib.rs index da8ca3003..42348915e 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -8,6 +8,7 @@ use deno_core::url::Url; use deno_core::Extension; use deno_core::OpState; use once_cell::sync::Lazy; +use std::collections::HashSet; use std::path::Path; use std::path::PathBuf; use std::rc::Rc; @@ -59,6 +60,15 @@ pub static NODE_GLOBAL_THIS_NAME: Lazy<String> = Lazy::new(|| { format!("__DENO_NODE_GLOBAL_THIS_{}__", seconds) }); +pub static NODE_ENV_VAR_ALLOWLIST: Lazy<HashSet<String>> = Lazy::new(|| { + // The full list of environment variables supported by Node.js is available + // at https://nodejs.org/api/cli.html#environment-variables + let mut set = HashSet::new(); + set.insert("NODE_DEBUG".to_string()); + set.insert("NODE_OPTIONS".to_string()); + set +}); + struct Unstable(pub bool); pub fn init<P: NodePermissions + 'static>( |