Skip to content

Commit af86625

Browse files
daeyeontargos
authored andcommitted
permission: resolve reference to absolute path only for fs permission
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>
1 parent 0c06bfd commit af86625

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/internal/process/permission.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {
44
ObjectFreeze,
5+
StringPrototypeStartsWith,
56
} = primordials;
67

78
const permission = internalBinding('permission');
@@ -24,8 +25,10 @@ module.exports = ObjectFreeze({
2425
if (reference != null) {
2526
// TODO: add support for WHATWG URLs and Uint8Arrays.
2627
validateString(reference, 'reference');
27-
if (!isAbsolute(reference)) {
28-
return permission.has(scope, resolve(reference));
28+
if (StringPrototypeStartsWith(scope, 'fs')) {
29+
if (!isAbsolute(reference)) {
30+
reference = resolve(reference);
31+
}
2932
}
3033
}
3134

0 commit comments

Comments
 (0)