Skip to content

Commit af86625

Browse files
daeyeontargos
authored andcommittedMay 12, 2023
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 <[email protected]> PR-URL: #47930 Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Marco Ippolito <[email protected]>
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)
Please sign in to comment.