-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
permissionIssues and PRs related to the Permission ModelIssues and PRs related to the Permission ModelquestionIssues that look for answers.Issues that look for answers.
Description
What is the problem this feature will solve?
Description
Running the following:
$ node --experimental-permission index.js
// index.js
console.log("Hello, world!")
Generates:
node:internal/modules/cjs/loader:178
const result = internalModuleStat(filename);
^
Error: Access to this API has been restricted
at stat (node:internal/modules/cjs/loader:178:18)
at Module._findPath (node:internal/modules/cjs/loader:629:16)
at resolveMainPath (node:internal/modules/run_main:15:25)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:24)
at node:internal/main/run_main_module:23:47 {
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemRead',
resource: '/Users/kenny.lindahl/Dev/test/node-20-permissions/index.js'
}
The problem
The problem with the above error is that the only way for me to make the error go away is to add --allow-fs-read
which i don't want to do as it would make my app more vulnerable.
The solution
The solution is to print what path that was denied so that i can explicitly allow that path
- Node version:
v20.5.0
What is the feature you are proposing to solve the problem?
The same command should generate (similar to Deno):
$ node --experimental-permission index.js
Error: Access to this API has been restricted
{
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemRead',
resource: '/Users/kenny.lindahl/Dev/test/node-20-permissions/index.js',
details: 'Read access was denied for: /the-path-that-was-denied'
}
Note: Observe the added
details
key, which highlights the path that was denied.
And this is needed for me to explicitly allow that path.
What alternatives have you considered?
No response
Metadata
Metadata
Assignees
Labels
permissionIssues and PRs related to the Permission ModelIssues and PRs related to the Permission ModelquestionIssues that look for answers.Issues that look for answers.