Skip to content

Commit ff31c97

Browse files
authored
lib: add --allow-fs-vfs to permission available flags
Without it, --allow-fs-vfs was accepted without --permission and was not propagated to child processes like the other --allow-* flags. Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: #66554 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
1 parent 45b9f05 commit ff31c97

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎lib/internal/process/permission.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ module.exports = ObjectFreeze({
7474
const flags = [
7575
'--allow-fs-read',
7676
'--allow-fs-write',
77+
'--allow-fs-vfs',
7778
'--allow-addons',
7879
'--allow-child-process',
7980
'--allow-env',
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const { isMainThread } = require('worker_threads');
5+
6+
if (!isMainThread) {
7+
common.skip('This test only works on a main thread');
8+
}
9+
10+
const { spawnSyncAndAssert, spawnSyncAndExit } = require('../common/child_process');
11+
12+
// --allow-fs-vfs requires the permission model.
13+
spawnSyncAndExit(
14+
process.execPath,
15+
['--allow-fs-vfs', '-e', ''],
16+
{
17+
status: 1,
18+
signal: null,
19+
stderr: /--permission is required/,
20+
},
21+
);
22+
23+
if (process.config.variables.node_without_node_options) {
24+
common.skip('missing NODE_OPTIONS support');
25+
}
26+
27+
// A child process inherits --allow-fs-vfs along with --permission.
28+
const child = `
29+
const { spawnSync } = require('child_process');
30+
const { stdout } = spawnSync(process.execPath, [
31+
'-p', 'process.env.NODE_OPTIONS',
32+
], { encoding: 'utf8' });
33+
process.stdout.write(stdout);
34+
`;
35+
36+
spawnSyncAndAssert(
37+
process.execPath,
38+
['--permission', '--allow-fs-vfs', '--allow-child-process', '-e', child],
39+
{
40+
stdout: /(^|\s)--allow-fs-vfs(\s|$)/,
41+
},
42+
);

0 commit comments

Comments
 (0)