fix: apply module search paths restriction on worker and child process (#41118)

This commit is contained in:
Cheng Zhao 2024-01-26 17:29:04 +09:00 committed by GitHub
parent 6c9f9de40a
commit db2bf1a0d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 76 additions and 85 deletions

View file

@ -7,6 +7,16 @@ import type * as ipcRendererUtilsModule from '@electron/internal/renderer/ipc-re
const Module = require('module') as NodeJS.ModuleInternal;
// We do not want to allow use of the VM module in the renderer process as
// it conflicts with Blink's V8::Context internal logic.
const originalModuleLoad = Module._load;
Module._load = function (request: string) {
if (request === 'vm') {
console.warn('The vm module of Node.js is deprecated in the renderer process and will be removed.');
}
return originalModuleLoad.apply(this, arguments as any);
};
// Make sure globals like "process" and "global" are always available in preload
// scripts even after they are deleted in "loaded" script.
//
@ -33,9 +43,6 @@ Module.wrapper = [
// init.js, we need to restore it here.
process.argv.splice(1, 1);
// Clear search paths.
require('../common/reset-search-paths');
// Import common settings.
require('@electron/internal/common/init');