Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#5742): using Deno.watchFs with the read whitelist and relative path causes PermissionDenied #5908

Closed
wants to merge 2 commits into from

Conversation

uki00a
Copy link
Contributor

@uki00a uki00a commented May 27, 2020

This PR closes #5742.

  • Fixed the path passed to Permission.check_read to the absolute path format.

@uki00a uki00a changed the title fix(#5742): using Deno.watchFs with the read whitelist and relative p… fix(#5742): using Deno.watchFs with the read whitelist and relative path causes PermissionDenied May 27, 2020
fn test_permissions_read_watch_fs_with_relative_path() {
let (_, err) = util::run_and_collect_output(
true,
"run --allow-read=. complex_permissions_test.ts readWatchFs tls",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be ./tls if you are testing for relative path?

);
assert!(!err.contains(util::PERMISSION_DENIED_PATTERN));
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better way to write this test is:

#[test]
fn test_permissions_read_watch_fs_with_relative_path() {
  let status = util::deno_cmd()
    .current_dir(&util::tests_path())
    .arg("run")
    .arg("--allow-read=.")
    .arg("complex_permissions_test.ts")
    .arg("readWatchFs")
    .arg("tls")
    .spawn()
    .unwrap()
    .wait()
    .unwrap();
  assert!(status.success());
}

It's not necessary to collect output - we just need to check the process didn't fail.

@nayeemrmn
Copy link
Collaborator

@ry This error has popped up a lot. FYI as part of #5642 I've moved the path resolution to cli/permissions.rs so you don't have to resolve everywhere else.

@uki00a
Copy link
Contributor Author

uki00a commented May 28, 2020

@tumile @ry @nayeemrmn Thanks for comments and suggestions!
As @nayeemrmn has said, this problem will be resolved as part of #5642.
So, I'll close this PR.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Permission denied when using Deno.watchFs() relative path
4 participants