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 <daeyeon.dev@gmail.com>
PR-URL: #47930
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
  • Loading branch information
daeyeon authored and targos committed May 12, 2023
1 parent 0c06bfd commit af86625
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 af86625

Please sign in to comment.