src,permission: handle process.chdir on pm

PR-URL: https://github.com/nodejs/node/pull/53175
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
This commit is contained in:
Rafael Gonzaga authored and Michaël Zasso committed 2024-09-21 12:26:53 +02:00
1 parent 90b632ee02
commit ef1c0d7def
2 files changed
+13

No files matched your search

+2
View File
@@ -83,6 +83,8 @@ static void Chdir(const FunctionCallbackInfo<Value>& args) {
CHECK_EQ(args.Length(), 1);
CHECK(args[0]->IsString());
Utf8Value path(env->isolate(), args[0]);
THROW_IF_INSUFFICIENT_PERMISSIONS(
env, permission::PermissionScope::kFileSystemRead, path.ToStringView());
int err = uv_chdir(*path);
if (err) {
// Also include the original working directory, since that will usually
+11
View File
@@ -387,6 +387,17 @@ const regularFile = __filename;
}));
}
// process.chdir
{
assert.throws(() => {
process.chdir(blockedFolder);
}, common.expectsError({
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemRead',
resource: blockedFolder,
}));
}
// fs.lstat
{
assert.throws(() => {