Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sandbox - mitigate native crash from ipcRenderer usages (#157765) #157794

Merged
merged 1 commit into from
Aug 10, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class SharedProcessMain extends Disposable {
// application is shutting down anyways.
//
const eventName = 'vscode:electron-main->shared-process=disposeWorker';
const onDisposeWorker = (event: unknown, configuration: ISharedProcessWorkerConfiguration) => this.onDisposeWorker(configuration);
const onDisposeWorker = (event: unknown, configuration: ISharedProcessWorkerConfiguration) => { this.onDisposeWorker(configuration); };
ipcRenderer.on(eventName, onDisposeWorker);
this._register(toDisposable(() => ipcRenderer.removeListener(eventName, onDisposeWorker)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class TerminalNativeContribution extends Disposable implements IWorkbench
) {
super();

ipcRenderer.on('vscode:openFiles', (_: unknown, request: INativeOpenFileRequest) => this._onOpenFileRequest(request));
ipcRenderer.on('vscode:openFiles', (_: unknown, request: INativeOpenFileRequest) => { this._onOpenFileRequest(request); });
this._register(nativeHostService.onDidResumeOS(() => this._onOsResume()));

this._terminalService.setNativeDelegate({
Expand Down
48 changes: 26 additions & 22 deletions src/vs/workbench/electron-sandbox/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,36 +180,40 @@ export class NativeWindow extends Disposable {
});

// Support openFiles event for existing and new files
ipcRenderer.on('vscode:openFiles', (event: unknown, request: IOpenFileRequest) => this.onOpenFiles(request));
ipcRenderer.on('vscode:openFiles', (event: unknown, request: IOpenFileRequest) => { this.onOpenFiles(request); });

// Support addFolders event if we have a workspace opened
ipcRenderer.on('vscode:addFolders', (event: unknown, request: IAddFoldersRequest) => this.onAddFoldersRequest(request));
ipcRenderer.on('vscode:addFolders', (event: unknown, request: IAddFoldersRequest) => { this.onAddFoldersRequest(request); });

// Message support
ipcRenderer.on('vscode:showInfoMessage', (event: unknown, message: string) => this.notificationService.info(message));
ipcRenderer.on('vscode:showInfoMessage', (event: unknown, message: string) => { this.notificationService.info(message); });

// Shell Environment Issue Notifications
ipcRenderer.on('vscode:showResolveShellEnvError', (event: unknown, message: string) => this.notificationService.prompt(
Severity.Error,
message,
[{
label: localize('learnMore', "Learn More"),
run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2149667')
}]
));

ipcRenderer.on('vscode:showCredentialsError', (event: unknown, message: string) => this.notificationService.prompt(
Severity.Error,
localize('keychainWriteError', "Writing login information to the keychain failed with error '{0}'.", message),
[{
label: localize('troubleshooting', "Troubleshooting Guide"),
run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2190713')
}]
));
ipcRenderer.on('vscode:showResolveShellEnvError', (event: unknown, message: string) => {
this.notificationService.prompt(
Severity.Error,
message,
[{
label: localize('learnMore', "Learn More"),
run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2149667')
}]
);
});

ipcRenderer.on('vscode:showCredentialsError', (event: unknown, message: string) => {
this.notificationService.prompt(
Severity.Error,
localize('keychainWriteError', "Writing login information to the keychain failed with error '{0}'.", message),
[{
label: localize('troubleshooting', "Troubleshooting Guide"),
run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2190713')
}]
);
});

// Fullscreen Events
ipcRenderer.on('vscode:enterFullScreen', async () => setFullscreen(true));
ipcRenderer.on('vscode:leaveFullScreen', async () => setFullscreen(false));
ipcRenderer.on('vscode:enterFullScreen', async () => { setFullscreen(true); });
ipcRenderer.on('vscode:leaveFullScreen', async () => { setFullscreen(false); });

// Proxy Login Dialog
ipcRenderer.on('vscode:openProxyAuthenticationDialog', async (event: unknown, payload: { authInfo: AuthInfo; username?: string; password?: string; replyChannel: string }) => {
Expand Down