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 /cli | |
| 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 'cli')
4 files changed, 23 insertions, 0 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 118623760..d4dfbb32b 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -2839,3 +2839,15 @@ itest!(nested_error { output: "nested_error.ts.out", exit_code: 1, }); + +itest!(node_env_var_allowlist_with_unstable_flag { + args: "run --unstable --no-prompt node_env_var_allowlist.ts", + output: "node_env_var_allowlist_with_unstable_flag.ts.out", + exit_code: 1, +}); + +itest!(node_env_var_allowlist_without_unstable_flag { + args: "run --no-prompt node_env_var_allowlist.ts", + output: "node_env_var_allowlist_without_unstable_flag.ts.out", + exit_code: 1, +}); diff --git a/cli/tests/testdata/node_env_var_allowlist.ts b/cli/tests/testdata/node_env_var_allowlist.ts new file mode 100644 index 000000000..95da38c24 --- /dev/null +++ b/cli/tests/testdata/node_env_var_allowlist.ts @@ -0,0 +1,2 @@ +console.log(Deno.env.get("NODE_DEBUG") ?? "ok"); +Deno.env.get("NOT_NODE_DEBUG"); diff --git a/cli/tests/testdata/node_env_var_allowlist_with_unstable_flag.ts.out b/cli/tests/testdata/node_env_var_allowlist_with_unstable_flag.ts.out new file mode 100644 index 000000000..62f335c0f --- /dev/null +++ b/cli/tests/testdata/node_env_var_allowlist_with_unstable_flag.ts.out @@ -0,0 +1,5 @@ +ok +[WILDCARD]error: Uncaught PermissionDenied: Requires env access to "NOT_NODE_DEBUG", run again with the --allow-env flag +Deno.env.get("NOT_NODE_DEBUG"); + ^ + at [WILDCARD] diff --git a/cli/tests/testdata/node_env_var_allowlist_without_unstable_flag.ts.out b/cli/tests/testdata/node_env_var_allowlist_without_unstable_flag.ts.out new file mode 100644 index 000000000..ac92cdb6b --- /dev/null +++ b/cli/tests/testdata/node_env_var_allowlist_without_unstable_flag.ts.out @@ -0,0 +1,4 @@ +[WILDCARD]error: Uncaught PermissionDenied: Requires env access to "NODE_DEBUG", run again with the --allow-env flag +console.log(Deno.env.get("NODE_DEBUG") ?? "ok"); + ^ + at [WILDCARD] |
