mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00

Previously, only child_process.fork propagated the exec arguments (execvArgs) to the child process. This commit adds support for spawn and spawnSync to propagate permission model flags — except when they are already provided explicitly via arguments or through NODE_OPTIONS. Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: https://github.com/nodejs/node/pull/58853 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const {
|
|
ObjectFreeze,
|
|
} = primordials;
|
|
|
|
const permission = internalBinding('permission');
|
|
const { validateString, validateBuffer } = require('internal/validators');
|
|
const { Buffer } = require('buffer');
|
|
const { isBuffer } = Buffer;
|
|
|
|
let _permission;
|
|
|
|
module.exports = ObjectFreeze({
|
|
__proto__: null,
|
|
isEnabled() {
|
|
if (_permission === undefined) {
|
|
const { getOptionValue } = require('internal/options');
|
|
_permission = getOptionValue('--permission');
|
|
}
|
|
return _permission;
|
|
},
|
|
has(scope, reference) {
|
|
validateString(scope, 'scope');
|
|
if (reference != null) {
|
|
// TODO: add support for WHATWG URLs and Uint8Arrays.
|
|
if (isBuffer(reference)) {
|
|
validateBuffer(reference, 'reference');
|
|
} else {
|
|
validateString(reference, 'reference');
|
|
}
|
|
}
|
|
|
|
return permission.has(scope, reference);
|
|
},
|
|
availableFlags() {
|
|
return [
|
|
'--allow-fs-read',
|
|
'--allow-fs-write',
|
|
'--allow-addons',
|
|
'--allow-child-process',
|
|
'--allow-net',
|
|
'--allow-wasi',
|
|
'--allow-worker',
|
|
];
|
|
},
|
|
});
|