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

expandGlob always requires read access to CWD #2652

Closed
thomaslaurie opened this issue Sep 14, 2022 · 1 comment · Fixed by #3692
Closed

expandGlob always requires read access to CWD #2652

thomaslaurie opened this issue Sep 14, 2022 · 1 comment · Fixed by #3692
Labels
bug Something isn't working needs triage

Comments

@thomaslaurie
Copy link

Regardless of the root specified, running expandGlob will prompt for --allow-read access to the CWD.

main.ts:

import {expandGlob} from 'https://deno.land/[email protected]/fs/expand_glob.ts';

for await (const entry of expandGlob('**/*.js', {root: './subfolder'})) {
	console.log(entry);
}

Running deno run main.ts --allow-read=./subfolder

will produce:

⚠️  ️Deno requests read access to <CWD>. Run again with --allow-read to bypass this prompt.
   Allow? [y/n (y = yes allow, n = no deny)]  n
error: Uncaught PermissionDenied: Requires read access to <CWD>, run again with the --allow-read flag
    : joinGlobs([Deno.cwd(), root], globOptions);
                      ^
    at Object.opSync (deno:core/01_core.js:172:12)
    at Object.cwd (deno:runtime/js/30_fs.js:65:17)
    at expandGlob (https://deno.land/[email protected]/fs/expand_glob.ts:87:23)
    at expandGlob.next (<anonymous>)
    at file:///C:/path/to/main.ts:5:18

Swapping both or either of the root or --allow-read paths for absolute paths produces a similar permission denial:

⚠️  ️Deno requests read access to "C:\path\to\subfolder". Run again with --allow-read to bypass this prompt.
   Allow? [y/n (y = yes allow, n = no deny)]  n
error: Uncaught (in promise) PermissionDenied: Requires read access to "C:\path\to\subfolder", run again with the --allow-read flag
  const info = await Deno.stat(path);
               ^
    at async Object.stat (deno:runtime/js/30_fs.js:230:17)
    at async _createWalkEntry (https://deno.land/[email protected]/fs/walk.ts:25:16)
    at async expandGlob (https://deno.land/[email protected]/fs/expand_glob.ts:108:21)        
    at async file:///C:/path/to/main.ts:5:18        

Expected behavior

Using a root path that is within the boundary granted by --allow-read should just work, it should not prompt for read permissions of the entire CWD.

Environment

  • OS: Windows 11
  • deno version: 1.22.2
  • std version: 0.95.0
@thomaslaurie thomaslaurie added bug Something isn't working needs triage labels Sep 14, 2022
@iuioiua
Copy link
Contributor

iuioiua commented Sep 14, 2022

Related: #1136.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants