electron - disable remote module in all windows (#101224)
This commit is contained in:
parent
c5237f6d5a
commit
4f65b91444
|
@ -134,7 +134,11 @@ export class CodeApplication extends Disposable {
|
||||||
//
|
//
|
||||||
// !!! DO NOT CHANGE without consulting the documentation !!!
|
// !!! DO NOT CHANGE without consulting the documentation !!!
|
||||||
//
|
//
|
||||||
// app.on('remote-get-guest-web-contents', event => event.preventDefault()); // TODO@Matt revisit this need for <webview>
|
app.on('remote-get-guest-web-contents', event => {
|
||||||
|
this.logService.trace('App#on(remote-get-guest-web-contents): prevented');
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
app.on('remote-require', (event, sender, module) => {
|
app.on('remote-require', (event, sender, module) => {
|
||||||
this.logService.trace('App#on(remote-require): prevented');
|
this.logService.trace('App#on(remote-require): prevented');
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,8 @@ export class ProxyAuthHandler extends Disposable {
|
||||||
title: 'VS Code',
|
title: 'VS Code',
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
webviewTag: true,
|
|
||||||
enableWebSQL: false,
|
enableWebSQL: false,
|
||||||
|
enableRemoteModule: false,
|
||||||
nativeWindowOpen: true
|
nativeWindowOpen: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,6 +47,7 @@ export class SharedProcess implements ISharedProcess {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
webgl: false,
|
webgl: false,
|
||||||
enableWebSQL: false,
|
enableWebSQL: false,
|
||||||
|
enableRemoteModule: false,
|
||||||
nativeWindowOpen: true,
|
nativeWindowOpen: true,
|
||||||
disableBlinkFeatures: 'Auxclick' // do NOT change, allows us to identify this window as shared-process in the process explorer
|
disableBlinkFeatures: 'Auxclick' // do NOT change, allows us to identify this window as shared-process in the process explorer
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,6 @@ import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifec
|
||||||
import { IStorageMainService } from 'vs/platform/storage/node/storageMainService';
|
import { IStorageMainService } from 'vs/platform/storage/node/storageMainService';
|
||||||
import { IFileService } from 'vs/platform/files/common/files';
|
import { IFileService } from 'vs/platform/files/common/files';
|
||||||
|
|
||||||
const RUN_TEXTMATE_IN_WORKER = false;
|
|
||||||
|
|
||||||
export interface IWindowCreationOptions {
|
export interface IWindowCreationOptions {
|
||||||
state: IWindowState;
|
state: IWindowState;
|
||||||
extensionDevelopmentPath?: string[];
|
extensionDevelopmentPath?: string[];
|
||||||
|
@ -168,9 +166,9 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: URI.parse(this.doGetPreloadUrl()).fsPath,
|
preload: URI.parse(this.doGetPreloadUrl()).fsPath,
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
nodeIntegrationInWorker: RUN_TEXTMATE_IN_WORKER,
|
|
||||||
webviewTag: true,
|
webviewTag: true,
|
||||||
enableWebSQL: false,
|
enableWebSQL: false,
|
||||||
|
enableRemoteModule: false,
|
||||||
nativeWindowOpen: true
|
nativeWindowOpen: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||||
import { WindowDriverChannel, WindowDriverRegistryChannelClient } from 'vs/platform/driver/node/driver';
|
import { WindowDriverChannel, WindowDriverRegistryChannelClient } from 'vs/platform/driver/node/driver';
|
||||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProcessService';
|
import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProcessService';
|
||||||
import { remote } from 'electron';
|
|
||||||
import { timeout } from 'vs/base/common/async';
|
import { timeout } from 'vs/base/common/async';
|
||||||
import { BaseWindowDriver } from 'vs/platform/driver/browser/baseDriver';
|
import { BaseWindowDriver } from 'vs/platform/driver/browser/baseDriver';
|
||||||
import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron';
|
import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron';
|
||||||
|
@ -32,11 +31,10 @@ class WindowDriver extends BaseWindowDriver {
|
||||||
private async _click(selector: string, clickCount: number, offset?: { x: number, y: number }): Promise<void> {
|
private async _click(selector: string, clickCount: number, offset?: { x: number, y: number }): Promise<void> {
|
||||||
const { x, y } = await this._getElementXY(selector, offset);
|
const { x, y } = await this._getElementXY(selector, offset);
|
||||||
|
|
||||||
const webContents = remote.getCurrentWebContents();
|
await this.electronService.sendInputEvent({ type: 'mouseDown', x, y, button: 'left', clickCount } as any);
|
||||||
webContents.sendInputEvent({ type: 'mouseDown', x, y, button: 'left', clickCount } as any);
|
|
||||||
await timeout(10);
|
await timeout(10);
|
||||||
|
|
||||||
webContents.sendInputEvent({ type: 'mouseUp', x, y, button: 'left', clickCount } as any);
|
await this.electronService.sendInputEvent({ type: 'mouseUp', x, y, button: 'left', clickCount } as any);
|
||||||
await timeout(100);
|
await timeout(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ export interface ICommonElectronService {
|
||||||
openDevTools(options?: OpenDevToolsOptions): Promise<void>;
|
openDevTools(options?: OpenDevToolsOptions): Promise<void>;
|
||||||
toggleDevTools(): Promise<void>;
|
toggleDevTools(): Promise<void>;
|
||||||
startCrashReporter(options: CrashReporterStartOptions): Promise<void>;
|
startCrashReporter(options: CrashReporterStartOptions): Promise<void>;
|
||||||
|
sendInputEvent(event: { type: 'mouseDown' | 'mouseUp'; x: number; y: number; clickCount: number; }): Promise<void>;
|
||||||
|
|
||||||
// Connectivity
|
// Connectivity
|
||||||
resolveProxy(url: string): Promise<string | undefined>;
|
resolveProxy(url: string): Promise<string | undefined>;
|
||||||
|
|
|
@ -459,6 +459,13 @@ export class ElectronMainService implements IElectronMainService {
|
||||||
crashReporter.start(options);
|
crashReporter.start(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async sendInputEvent(windowId: number | undefined, event: { type: 'mouseDown' | 'mouseUp'; x: number; y: number; clickCount: number; }): Promise<void> {
|
||||||
|
const window = this.windowById(windowId);
|
||||||
|
if (window && (event.type === 'mouseDown' || event.type === 'mouseUp')) {
|
||||||
|
window.win.webContents.sendInputEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
private windowById(windowId: number | undefined): ICodeWindow | undefined {
|
private windowById(windowId: number | undefined): ICodeWindow | undefined {
|
||||||
|
|
|
@ -197,6 +197,7 @@ export class IssueMainService implements ICommonIssueService {
|
||||||
preload: URI.parse(require.toUrl('vs/base/parts/sandbox/electron-browser/preload.js')).fsPath,
|
preload: URI.parse(require.toUrl('vs/base/parts/sandbox/electron-browser/preload.js')).fsPath,
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
enableWebSQL: false,
|
enableWebSQL: false,
|
||||||
|
enableRemoteModule: false,
|
||||||
nativeWindowOpen: true
|
nativeWindowOpen: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -249,6 +250,7 @@ export class IssueMainService implements ICommonIssueService {
|
||||||
preload: URI.parse(require.toUrl('vs/base/parts/sandbox/electron-browser/preload.js')).fsPath,
|
preload: URI.parse(require.toUrl('vs/base/parts/sandbox/electron-browser/preload.js')).fsPath,
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
enableWebSQL: false,
|
enableWebSQL: false,
|
||||||
|
enableRemoteModule: false,
|
||||||
nativeWindowOpen: true
|
nativeWindowOpen: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -314,7 +314,6 @@ function getSuggestEnabledInputOptions(ariaLabel?: string): IEditorOptions {
|
||||||
cursorWidth: 1,
|
cursorWidth: 1,
|
||||||
fontFamily: DEFAULT_FONT_FAMILY,
|
fontFamily: DEFAULT_FONT_FAMILY,
|
||||||
ariaLabel: ariaLabel || '',
|
ariaLabel: ariaLabel || '',
|
||||||
|
|
||||||
snippetSuggestions: 'none',
|
snippetSuggestions: 'none',
|
||||||
suggest: { filterGraceful: false, showIcons: false },
|
suggest: { filterGraceful: false, showIcons: false },
|
||||||
autoClosingBrackets: 'never'
|
autoClosingBrackets: 'never'
|
||||||
|
|
|
@ -232,6 +232,7 @@ export class TestElectronService implements IElectronService {
|
||||||
async writeClipboardBuffer(format: string, buffer: Uint8Array, type?: 'selection' | 'clipboard' | undefined): Promise<void> { }
|
async writeClipboardBuffer(format: string, buffer: Uint8Array, type?: 'selection' | 'clipboard' | undefined): Promise<void> { }
|
||||||
async readClipboardBuffer(format: string): Promise<Uint8Array> { return Uint8Array.from([]); }
|
async readClipboardBuffer(format: string): Promise<Uint8Array> { return Uint8Array.from([]); }
|
||||||
async hasClipboard(format: string, type?: 'selection' | 'clipboard' | undefined): Promise<boolean> { return false; }
|
async hasClipboard(format: string, type?: 'selection' | 'clipboard' | undefined): Promise<boolean> { return false; }
|
||||||
|
async sendInputEvent(event: { type: 'mouseDown' | 'mouseUp'; x: number; y: number; clickCount: number; }): Promise<void> { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function workbenchInstantiationService(): ITestInstantiationService {
|
export function workbenchInstantiationService(): ITestInstantiationService {
|
||||||
|
|
|
@ -118,6 +118,7 @@ app.on('ready', () => {
|
||||||
webviewTag: true,
|
webviewTag: true,
|
||||||
preload: path.join(__dirname, '..', '..', '..', 'src', 'vs', 'base', 'parts', 'sandbox', 'electron-browser', 'preload.js'), // ensure similar environment as VSCode as tests may depend on this
|
preload: path.join(__dirname, '..', '..', '..', 'src', 'vs', 'base', 'parts', 'sandbox', 'electron-browser', 'preload.js'), // ensure similar environment as VSCode as tests may depend on this
|
||||||
enableWebSQL: false,
|
enableWebSQL: false,
|
||||||
|
enableRemoteModule: false,
|
||||||
nativeWindowOpen: true
|
nativeWindowOpen: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue