Skip to content

Commit 83da3e0

Browse files
committed
src,permission: handle process.chdir on pm
1 parent 01c281f commit 83da3e0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/node_process_methods.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ static void Chdir(const FunctionCallbackInfo<Value>& args) {
8383
CHECK_EQ(args.Length(), 1);
8484
CHECK(args[0]->IsString());
8585
Utf8Value path(env->isolate(), args[0]);
86+
THROW_IF_INSUFFICIENT_PERMISSIONS(
87+
env, permission::PermissionScope::kFileSystemRead, path.ToStringView());
8688
int err = uv_chdir(*path);
8789
if (err) {
8890
// Also include the original working directory, since that will usually

test/fixtures/permission/fs-read.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,14 @@ const regularFile = __filename;
361361
resource: path.toNamespacedPath(blockedFile),
362362
}));
363363
}
364+
365+
// process.chdir
366+
{
367+
assert.throws(() => {
368+
process.chdir(blockedFolder);
369+
}, common.expectsError({
370+
code: 'ERR_ACCESS_DENIED',
371+
permission: 'FileSystemRead',
372+
resource: path.toNamespacedPath(blockedFolder),
373+
}));
374+
}

0 commit comments

Comments
 (0)