summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaeyeon Jeong <daeyeon.dev@gmail.com>2023-05-11 23:50:44 +0900
committerMichaƫl Zasso <targos@protonmail.com>2023-05-12 11:57:22 +0200
commitaf86625a0580561aaac460c1cefa2b8e8a17482a (patch)
tree956a7b2c50b57f72f4a552a6234dc4708a4b6d5c
parent0c06bfd8dcb02f39e95e27029cfbf8ff5f1ce1e2 (diff)
downloadnode-new-af86625a0580561aaac460c1cefa2b8e8a17482a.tar.gz
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>
-rw-r--r--lib/internal/process/permission.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/internal/process/permission.js b/lib/internal/process/permission.js
index 4b48493adc..e400dcae9f 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);
+ }
}
}