From 74bc8eb16431793e5677770bf9fe9f6629f69629 Mon Sep 17 00:00:00 2001 From: Daeyeon Jeong Date: Tue, 9 May 2023 13:15:22 +0900 Subject: [PATCH] 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 --- lib/internal/process/permission.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/internal/process/permission.js b/lib/internal/process/permission.js index 4b48493adc7709..e400dcae9f934e 100644 --- a/lib/internal/process/permission.js +++ b/lib/internal/process/permission.js @@ -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); + } } }