Skip to content

Commit

Permalink
permission: resolve reference to absolute path only for fs permission
Browse files Browse the repository at this point in the history
For other candidate permissions, such as "net" or "env", this patch
will pass the reference without resolving it to an absolute path.

Signed-off-by: Daeyeon Jeong <[email protected]>
  • Loading branch information
daeyeon committed May 9, 2023
1 parent 0b3fcfc commit 74bc8eb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/internal/process/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const {
ObjectFreeze,
StringPrototypeStartsWith,
} = primordials;

const permission = internalBinding('permission');
Expand All @@ -24,8 +25,10 @@ module.exports = ObjectFreeze({
if (reference != null) {
// TODO: add support for WHATWG URLs and Uint8Arrays.
validateString(reference, 'reference');
if (!isAbsolute(reference)) {
return permission.has(scope, resolve(reference));
if (StringPrototypeStartsWith(scope, 'fs')) {
if (!isAbsolute(reference)) {
reference = resolve(reference);
}
}
}

Expand Down

0 comments on commit 74bc8eb

Please sign in to comment.