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 path normalization in resolve_from_cwd() #2875

Merged
merged 4 commits into from
Sep 7, 2019

Conversation

nayeemrmn
Copy link
Collaborator

Fixes #2718.

test.js:

Deno.readDirSync("..");
console.log("OK");

deno --no-prompt --allow-read="." test.js
Before: OK
After: error: Uncaught PermissionDenied: permission denied ...

@ry
Copy link
Member

ry commented Sep 7, 2019

Cool - but is there some way we can get a unit test for this?

@nayeemrmn nayeemrmn force-pushed the path-normalization branch 2 times, most recently from edde8dc to abc5e9b Compare September 7, 2019 12:29
@nayeemrmn
Copy link
Collaborator Author

nayeemrmn commented Sep 7, 2019

@ry Done. I wanted to add something to permissions.rs as well, but the whitelist checker in there assumes paths that are already normalised (which is handled prior in individual ops via resolve_from_cwd()) so they'd still fail. This could do with a refactor.

cli/fs.rs Outdated Show resolved Hide resolved
cli/fs.rs Show resolved Hide resolved
@ry
Copy link
Member

ry commented Sep 7, 2019

Looks good - just a few comments --^

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM

@ry ry merged commit 718c8c4 into denoland:master Sep 7, 2019
@nayeemrmn nayeemrmn deleted the path-normalization branch September 7, 2019 19:43
@txiklerr
Copy link

txiklerr commented Nov 5, 2020

This bug remains unfixed :(

@kitsonk
Copy link
Contributor

kitsonk commented Nov 5, 2020

@ChiKler 😕 I just ran it and it works as expected:

❯ deno run --allow-read="." test.js
error: Uncaught PermissionDenied: read access to "/Users/kitsonk/github", run again with the --allow-read flag
    at processResponse (core.js:224:13)
    at Object.jsonOpSync (core.js:248:12)
    at Object.readDirSync (deno:cli/rt/30_fs.js:109:12)
    at file:///Users/kitsonk/github/test/test.js:1:6

Why do you think it isn't fixed?

@txiklerr
Copy link

txiklerr commented Nov 8, 2020

@ChiKler 😕 I just ran it and it works as expected:

❯ deno run --allow-read="." test.js
error: Uncaught PermissionDenied: read access to "/Users/kitsonk/github", run again with the --allow-read flag
    at processResponse (core.js:224:13)
    at Object.jsonOpSync (core.js:248:12)
    at Object.readDirSync (deno:cli/rt/30_fs.js:109:12)
    at file:///Users/kitsonk/github/test/test.js:1:6

Why do you think it isn't fixed?

Here's an example (am I doing something wrong?):
https://github.com/ChiKler/-Deno-error-Uncaught-PermissionDenied-read-access-to-CWD-

@nayeemrmn
Copy link
Collaborator Author

@ChiKler I believe that's because you use copySync() from std, which (without a good reason) calls path.resolve() which requires CWD access. It shouldn't call path.resolve(), could you open an issue?

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.

--allow-read and --allow-write whitelists broken
4 participants