mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
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: https://github.com/nodejs/node/pull/47930 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
This commit is contained in:
1 parent
0c06bfd8dc
commit
af86625a05
1 file changed
+5
-2
@@ -2,6 +2,7 @@
|
||||
|
||||
const {
|
||||
ObjectFreeze,
|
||||
StringPrototypeStartsWith,
|
||||
} = primordials;
|
||||
|
||||
const permission = internalBinding('permission');
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user