Skip to content

Commit 2b83f00

Browse files
authored
src,permission: fix permission.has on empty param
PR-URL: #60674 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: René <[email protected]>
1 parent d4bc5b0 commit 2b83f00

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/permission/fs_permission.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,17 @@ bool FSPermission::is_granted(Environment* env,
176176
case PermissionScope::kFileSystem:
177177
return allow_all_in_ && allow_all_out_;
178178
case PermissionScope::kFileSystemRead:
179+
if (param.empty()) {
180+
return allow_all_in_;
181+
}
179182
return !deny_all_in_ &&
180-
((param.empty() && allow_all_in_) || allow_all_in_ ||
181-
is_tree_granted(env, &granted_in_fs_, param));
183+
(allow_all_in_ || is_tree_granted(env, &granted_in_fs_, param));
182184
case PermissionScope::kFileSystemWrite:
185+
if (param.empty()) {
186+
return allow_all_out_;
187+
}
183188
return !deny_all_out_ &&
184-
((param.empty() && allow_all_out_) || allow_all_out_ ||
185-
is_tree_granted(env, &granted_out_fs_, param));
189+
(allow_all_out_ || is_tree_granted(env, &granted_out_fs_, param));
186190
default:
187191
return false;
188192
}

test/parallel/test-permission-has.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Flags: --permission --allow-fs-read=*
1+
// Flags: --permission --allow-fs-read=* --allow-fs-write=.
22
'use strict';
33

44
const common = require('../common');

0 commit comments

Comments
 (0)