mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
fix: support relative path for whitelisting (#2317)
Using `std::fs::canonicalize` to expand path to full existing path, such that later attempt to loop-pop and compare path segment would work.
This commit is contained in:
parent
2edee3367d
commit
d9cdc6788b
4 changed files with 81 additions and 15 deletions
|
@ -92,6 +92,10 @@ class Prompt(object):
|
|||
self.test_outside_test_and_js_dir, test_type)
|
||||
wrap_test(test_name_base + "_inside_tests_and_js_dir",
|
||||
self.test_inside_test_and_js_dir, test_type)
|
||||
wrap_test(test_name_base + "_relative", self.test_relative,
|
||||
test_type)
|
||||
wrap_test(test_name_base + "_no_prefix", self.test_no_prefix,
|
||||
test_type)
|
||||
wrap_test(test_name_base + "_allow_localhost_4545",
|
||||
self.test_allow_localhost_4545)
|
||||
wrap_test(test_name_base + "_allow_deno_land",
|
||||
|
@ -179,6 +183,30 @@ class Prompt(object):
|
|||
assert not PROMPT_PATTERN in stderr
|
||||
assert not PERMISSION_DENIED_PATTERN in stderr
|
||||
|
||||
def test_relative(self, test_type):
|
||||
# Save and restore curdir
|
||||
saved_curdir = os.getcwd()
|
||||
os.chdir(root_path)
|
||||
code, _stdout, stderr = self.run(
|
||||
["--no-prompt", "--allow-" + test_type + "=" + "./tests"],
|
||||
[test_type, "tests/subdir/config.json"], b'')
|
||||
assert code == 0
|
||||
assert not PROMPT_PATTERN in stderr
|
||||
assert not PERMISSION_DENIED_PATTERN in stderr
|
||||
os.chdir(saved_curdir)
|
||||
|
||||
def test_no_prefix(self, test_type):
|
||||
# Save and restore curdir
|
||||
saved_curdir = os.getcwd()
|
||||
os.chdir(root_path)
|
||||
code, _stdout, stderr = self.run(
|
||||
["--no-prompt", "--allow-" + test_type + "=" + "tests"],
|
||||
[test_type, "tests/subdir/config.json"], b'')
|
||||
assert code == 0
|
||||
assert not PROMPT_PATTERN in stderr
|
||||
assert not PERMISSION_DENIED_PATTERN in stderr
|
||||
os.chdir(saved_curdir)
|
||||
|
||||
|
||||
def complex_permissions_test(deno_exe):
|
||||
p = Prompt(deno_exe, ["read", "write", "net"])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue