From 6834fe8fdaf75fcae79839e78f83711652634c7f Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Mon, 2 Dec 2024 12:46:13 +0100 Subject: [PATCH] fix: remove permission check for CWD --- ext/fs/ops.rs | 3 --- tests/integration/compile_tests.rs | 15 --------------- tests/integration/run_tests.rs | 8 +++++--- .../npm/deno_run_cowsay_no_permissions.out | 2 -- tests/unit/dir_test.ts | 10 ---------- 5 files changed, 5 insertions(+), 33 deletions(-) delete mode 100644 tests/testdata/npm/deno_run_cowsay_no_permissions.out diff --git a/ext/fs/ops.rs b/ext/fs/ops.rs index 5e64585e0c051e..128fb8f85afdf7 100644 --- a/ext/fs/ops.rs +++ b/ext/fs/ops.rs @@ -158,9 +158,6 @@ where { let fs = state.borrow::(); let path = fs.cwd()?; - state - .borrow_mut::

() - .check_read_blind(&path, "CWD", "Deno.cwd()")?; let path_str = path_into_string(path.into_os_string())?; Ok(path_str) } diff --git a/tests/integration/compile_tests.rs b/tests/integration/compile_tests.rs index fa6364a136414c..356146d72d0632 100644 --- a/tests/integration/compile_tests.rs +++ b/tests/integration/compile_tests.rs @@ -921,21 +921,6 @@ fn compile_npm_vfs_implicit_read_permissions() { }); } -#[test] -fn compile_npm_no_permissions() { - run_npm_bin_compile_test(RunNpmBinCompileOptions { - input_specifier: "npm:cowsay@1.5.0", - copy_temp_dir: None, - compile_args: vec![], - run_args: vec!["Hello"], - output_file: "npm/deno_run_cowsay_no_permissions.out", - node_modules_local: false, - input_name: None, - expected_name: "cowsay", - exit_code: 1, - }); -} - #[test] fn compile_npm_cowsay_explicit() { run_npm_bin_compile_test(RunNpmBinCompileOptions { diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index 18cded90cb3164..ecefb655167635 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -361,10 +361,12 @@ fn permissions_prompt_allow_all_2() { console.write_line_raw("A"); console.expect("✅ Granted all sys access."); + let text = console.read_until("Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)"); // "read" permissions - console.expect(concat!( - "┏ ⚠️ Deno requests read access to .\r\n", - "┠─ Requested by `Deno.cwd()` API.\r\n", + test_util::assertions::assert_wildcard_match(&text, concat!( + "\r\n", + "┏ ⚠️ Deno requests read access to \"[WILDCARD]/tests/testdata/\".\r\n", + "┠─ Requested by `Deno.lstatSync()` API.\r\n", "┠─ To see a stack trace for this prompt, set the DENO_TRACE_PERMISSIONS environmental variable.\r\n", "┠─ Learn more at: https://docs.deno.com/go/--allow-read\r\n", "┠─ Run again with --allow-read to bypass this prompt.\r\n", diff --git a/tests/testdata/npm/deno_run_cowsay_no_permissions.out b/tests/testdata/npm/deno_run_cowsay_no_permissions.out deleted file mode 100644 index 25b79d9a7dce23..00000000000000 --- a/tests/testdata/npm/deno_run_cowsay_no_permissions.out +++ /dev/null @@ -1,2 +0,0 @@ -error: Uncaught (in promise) NotCapable: Requires read access to , specify the required permissions during compilation using `deno compile --allow-read` -[WILDCARD] diff --git a/tests/unit/dir_test.ts b/tests/unit/dir_test.ts index 1e702f549a4552..2dccd070f19777 100644 --- a/tests/unit/dir_test.ts +++ b/tests/unit/dir_test.ts @@ -38,16 +38,6 @@ Deno.test({ permissions: { read: true, write: true } }, function dirCwdError() { } }); -Deno.test({ permissions: { read: false } }, function dirCwdPermError() { - assertThrows( - () => { - Deno.cwd(); - }, - Deno.errors.NotCapable, - "Requires read access to , run again with the --allow-read flag", - ); -}); - Deno.test( { permissions: { read: true, write: true } }, function dirChdirError() {