fix: prevent node mode to be used as script runner by other apps (#40579)
This commit is contained in:
parent
9aa73abe78
commit
cb0da6ff34
8 changed files with 301 additions and 88 deletions
22
spec/fixtures/api/fork-with-node-options.js
vendored
Normal file
22
spec/fixtures/api/fork-with-node-options.js
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
const { execFileSync } = require('node:child_process');
|
||||
const path = require('node:path');
|
||||
|
||||
const fixtures = path.resolve(__dirname, '..');
|
||||
|
||||
const env = {
|
||||
ELECTRON_RUN_AS_NODE: 'true',
|
||||
// Process will exit with 1 if NODE_OPTIONS is accepted.
|
||||
NODE_OPTIONS: `--require "${path.join(fixtures, 'module', 'fail.js')}"`
|
||||
};
|
||||
// Provide a lower cased NODE_OPTIONS in case some code ignores case sensitivity
|
||||
// when reading NODE_OPTIONS.
|
||||
env.node_options = env.NODE_OPTIONS;
|
||||
try {
|
||||
execFileSync(process.argv[2],
|
||||
['--require', path.join(fixtures, 'module', 'noop.js')],
|
||||
{ env, stdio: 'inherit' });
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.log('NODE_OPTIONS passed to child');
|
||||
process.exit(1);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue