child_process: propagate config-file permission flags to children

Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs/node/pull/66559
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
This commit is contained in:
Rafael Gonzaga authored and Richard Lau committed 2026-10-12 16:48:51 +00:00
1 parent fc3b067be7
commit 5fd03e6fdf
4 files changed
+38

No files matched your search

+2
View File
@@ -574,9 +574,11 @@ function copyPermissionModelFlagsToEnv(env, key, args) {
}
const flagsToCopy = getPermissionModelFlagsToCopy();
const copiedFlags = new SafeSet();
for (const arg of process.execArgv) {
for (const flag of flagsToCopy) {
if (arg.startsWith(flag)) {
copiedFlags.add(flag);
env[key] = `${env[key] ? env[key] + ' ' + arg : arg}`;
}
}
+16
View File
@@ -0,0 +1,16 @@
const { spawnSync } = require('child_process');
const { status, stdout, stderr } = spawnSync(process.execPath, [
'-p',
`JSON.stringify([
typeof process.permission,
process.permission.has("fs.read"),
process.permission.has("fs.write"),
process.permission.has("child"),
process.permission.has("worker"),
])`,
]);
console.log(JSON.stringify({
status,
stdout: stdout.toString().trim(),
stderr: stderr.toString(),
}));
@@ -0,0 +1,9 @@
{
"permission": {
"allow-child-process": true,
"allow-worker": true,
"allow-fs-read": [
"*"
]
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"permission": {
"permission": true,
"allow-child-process": true,
"allow-worker": true,
"allow-fs-read": [
"*",
"/nonexistent/dir with \"quotes\" and \\backslash"
]
}
}