Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! lib: handle --permission-audit when propagating flags
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
  • Loading branch information
RafaelGSS committed Apr 30, 2026
commit b1ec186c1b720bc302c3efdf4ee09ff86c9faa44
23 changes: 11 additions & 12 deletions test/parallel/test-permission-audit-child-process-inherit-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@ assert.strictEqual(typeof process.permission.has, 'function');

// Child should inherit --permission-audit and the allow-flags via NODE_OPTIONS
{
const { status, stdout, stderr } = childProcess.spawnSync(process.execPath,
[
'-e',
`
const { status, stdout } = childProcess.spawnSync(process.execPath,
[
'-e',
`
console.log(typeof process.permission);
console.log(process.permission.has("fs.write"));
console.log(process.permission.has("fs.read"));
console.log(process.permission.has("child"));
`,
]
]
);
assert.strictEqual(status, 0, `stderr: ${stderr}`);
assert.strictEqual(status, 0);
const [permType, fsWrite, fsRead, child] = stdout.toString().split('\n');
assert.strictEqual(permType, 'object', 'child should have process.permission defined');
assert.strictEqual(permType, 'object');
assert.strictEqual(fsWrite, 'true');
assert.strictEqual(fsRead, 'true');
assert.strictEqual(child, 'true');
}

// Child spawned with explicit --permission should use its own flags, not inherit parent's
{
const { status, stdout, stderr } = childProcess.spawnSync(
const { status, stdout } = childProcess.spawnSync(
process.execPath,
[
'--permission',
Expand All @@ -58,7 +58,7 @@ assert.strictEqual(typeof process.permission.has, 'function');
`,
]
);
assert.strictEqual(status, 0, `stderr: ${stderr}`);
assert.strictEqual(status, 0);
const [permType, fsWrite, fsRead, child] = stdout.toString().split('\n');
assert.strictEqual(permType, 'object');
assert.strictEqual(fsWrite, 'true');
Expand All @@ -68,7 +68,7 @@ assert.strictEqual(typeof process.permission.has, 'function');

// Child spawned with explicit --permission-audit should use its own flags
{
const { status, stdout, stderr } = childProcess.spawnSync(
const { status, stdout } = childProcess.spawnSync(
process.execPath,
[
'--permission-audit',
Expand All @@ -81,11 +81,10 @@ assert.strictEqual(typeof process.permission.has, 'function');
`,
]
);
assert.strictEqual(status, 0, `stderr: ${stderr}`);
assert.strictEqual(status, 0);
const [permType, fsWrite, fsRead] = stdout.toString().split('\n');
assert.strictEqual(permType, 'object');
assert.strictEqual(fsWrite, 'true');
// fs.read was not allowed in the explicit child flags
assert.strictEqual(fsRead, 'false');
}

Expand Down
Loading