| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 30ae8ab commit 980c651
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -643,17 +643,17 @@ function initializePermission() { | |||
| 643 | 643 | ObjectFreeze(require('path')); | |
| 644 | 644 | const { has, drop } = require('internal/process/permission'); | |
| 645 | 645 | const warnFlags = [ | |
| 646 | - '--allow-addons', | ||
| 647 | - '--allow-child-process', | ||
| 648 | - '--allow-inspector', | ||
| 649 | - '--allow-wasi', | ||
| 650 | - '--allow-worker', | ||
| 646 | + { flag: '--allow-addons', enabled: true, code: 'PERM0001' }, | ||
| 647 | + { flag: '--allow-child-process', enabled: true, code: 'PERM0002' }, | ||
| 648 | + { flag: '--allow-inspector', enabled: true, code: 'PERM0004' }, | ||
| 649 | + { flag: '--allow-wasi', enabled: true, code: 'PERM0005' }, | ||
| 650 | + { flag: '--allow-worker', enabled: true, code: 'PERM0006' }, | ||
| 651 | 651 | ]; | |
| 652 | - for (const flag of warnFlags) { | ||
| 653 | - if (getOptionValue(flag)) { | ||
| 652 | + for (const { flag, enabled, code } of warnFlags) { | ||
| 653 | + if (enabled && getOptionValue(flag)) { | ||
| 654 | 654 | process.emitWarning( | |
| 655 | 655 | `The flag ${flag} must be used with extreme caution. ` + | |
| 656 | - 'It could invalidate the permission model.', 'SecurityWarning'); | ||
| 656 | + 'It could invalidate the permission model.', 'SecurityWarning', code); | ||
| 657 | 657 | } | |
| 658 | 658 | } | |
| 659 | 659 | const warnCommaFlags = [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,20 @@ for (const flag of warnFlags) { | |||
| 21 | 21 | ] | |
| 22 | 22 | ); | |
| 23 | 23 | ||
| 24 | - assert.match(stderr.toString(), new RegExp(`SecurityWarning: The flag ${RegExp.escape(flag)} must be used with extreme caution`)); | ||
| 24 | + assert.match(stderr.toString(), new RegExp(`\\[PERM\\d{4}\\] SecurityWarning: The flag ${RegExp.escape(flag)} must be used with extreme caution`)); | ||
| 25 | 25 | assert.strictEqual(status, 0); | |
| 26 | 26 | } | |
| 27 | + | ||
| 28 | + const { status, stderr } = spawnSync( | ||
| 29 | + process.execPath, | ||
| 30 | + [ | ||
| 31 | + '--permission', '--allow-child-process', '--allow-wasi', '--disable-warning=PERM0002', '-e', | ||
| 32 | + 'setTimeout(() => {}, 1)', | ||
| 33 | + ] | ||
| 34 | + ); | ||
| 35 | + | ||
| 36 | + // Disabled warning does not appear | ||
| 37 | + assert.doesNotMatch(stderr.toString(), new RegExp(`The flag --allow-child-process must be used with extreme caution`)); | ||
| 38 | + // But non-disabled warnings still appear | ||
| 39 | + assert.match(stderr.toString(), new RegExp(`The flag --allow-wasi must be used with extreme caution`)); | ||
| 40 | + assert.strictEqual(status, 0); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments