Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 9 additions & 11 deletions lib/internal/process/pre_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,20 +682,18 @@ function initializePermission() {
ObjectFreeze(require('path'));
const { has, drop } = require('internal/process/permission');
const warnFlags = [
'--allow-addons',
'--allow-child-process',
'--allow-inspector',
'--allow-wasi',
'--allow-worker',
{ flag: '--allow-addons', enabled: true, code: 'PERM0001' },
{ flag: '--allow-child-process', enabled: true, code: 'PERM0002' },
{ flag: '--allow-ffi', enabled: process.config.variables.node_use_ffi, code: 'PERM0003' },
{ flag: '--allow-inspector', enabled: true, code: 'PERM0004' },
{ flag: '--allow-wasi', enabled: true, code: 'PERM0005' },
{ flag: '--allow-worker', enabled: true, code: 'PERM0006' },
];
if (process.config.variables.node_use_ffi) {
warnFlags.splice(2, 0, '--allow-ffi');
}
for (const flag of warnFlags) {
if (getOptionValue(flag)) {
for (const { flag, enabled, code } of warnFlags) {
if (enabled && getOptionValue(flag)) {
process.emitWarning(
`The flag ${flag} must be used with extreme caution. ` +
'It could invalidate the permission model.', 'SecurityWarning');
'It could invalidate the permission model.', 'SecurityWarning', code);
}
}
const warnCommaFlags = [
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-permission-warning-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ for (const flag of warnFlags) {
]
);

assert.match(stderr.toString(), new RegExp(`SecurityWarning: The flag ${RegExp.escape(flag)} must be used with extreme caution`));
assert.match(stderr.toString(), new RegExp(`\\[PERM\\d{4}\\] SecurityWarning: The flag ${RegExp.escape(flag)} must be used with extreme caution`));
assert.strictEqual(status, 0);
}
Loading