Repository: microsoft/vscode (TypeScript) — Feature

Issue:
Sandbox: Enable on Insiders by default



Discussion:

Resolving patch:
diff --git a/src/vs/code/electron-sandbox/issue/issueReporterModel.ts b/src/vs/code/electron-sandbox/issue/issueReporterModel.ts
--- a/src/vs/code/electron-sandbox/issue/issueReporterModel.ts
+++ b/src/vs/code/electron-sandbox/issue/issueReporterModel.ts
@@ -34,6 +34,7 @@ export interface IssueReporterData {
 	experimentInfo?: string;
 	restrictedMode?: boolean;
 	isUnsupported?: boolean;
+	isSandboxed?: boolean;
 }
 
 export class IssueReporterModel {
@@ -77,6 +78,7 @@ ${this.getExtensionVersion()}
 VS Code version: ${this._data.versionInfo && this._data.versionInfo.vscodeVersion}
 OS version: ${this._data.versionInfo && this._data.versionInfo.os}
 Modes:${modes.length ? ' ' + modes.join(', ') : ''}
+Sandboxed: ${this._data.isSandboxed ? 'Yes' : 'No'}
 ${this.getRemoteOSes()}
 ${this.getInfos()}
 <!-- generated by issue reporter -->`;
diff --git a/src/vs/platform/issue/common/issue.ts b/src/vs/platform/issue/common/issue.ts
--- a/src/vs/platform/issue/common/issue.ts
+++ b/src/vs/platform/issue/common/issue.ts
@@ -60,6 +60,7 @@ export interface IssueReporterData extends WindowData {
 	experiments?: string;
 	restrictedMode: boolean;
 	isUnsupported: boolean;
+	isSandboxed: boolean; // TODO@bpasero remove me once sandbox is final
 	githubAccessToken: string;
 	readonly issueTitle?: string;
 	readonly issueBody?: string;
diff --git a/src/vs/platform/windows/electron-main/window.ts b/src/vs/platform/windows/electron-main/window.ts
--- a/src/vs/platform/windows/electron-main/window.ts
+++ b/src/vs/platform/windows/electron-main/window.ts
@@ -42,6 +42,7 @@ import { Color } from 'vs/base/common/color';
 import { IPolicyService } from 'vs/platform/policy/common/policy';
 import { IUserDataProfile, IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
 import { revive } from 'vs/base/common/marshalling';
+import product from 'vs/platform/product/common/product';
 
 export interface IWindowCreationOptions {
 	state: IWindowState;
@@ -189,6 +190,13 @@ export class CodeWindow extends Disposable implements ICodeWindow {
 
 			const windowSettings = this.configurationService.getValue<IWindowSettings | undefined>('window');
 
+			let useSandbox = false;
+			if (typeof windowSettings?.experimental?.useSandbox === 'boolean') {
+				useSandbox = windowSettings.experimental.useSandbox;
+			} else {
+				useSandbox = typeof product.quality === 'string' && product.quality !== 'stable';
+			}
+
 			const options: BrowserWindowConstructorOptions & { experimentalDarkMode: boolean } = {
 				width: this.windowState.width,
 				height: this.windowState.height,
@@ -209,7 +217,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
 					// Enable experimental css highlight api https://chromestatus.com/feature/5436441440026624
 					// Refs https://github.com/microsoft/vscode/issues/140098
 					enableBlinkFeatures: 'HighlightAPI',
-					...windowSettings?.experimental?.useSandbox ?
+					...useSandbox ?
 
 						// Sandbox
 						{
diff --git a/src/vs/workbench/electron-sandbox/desktop.contribution.ts b/src/vs/workbench/electron-sandbox/desktop.contribution.ts
--- a/src/vs/workbench/electron-sandbox/desktop.contribution.ts
+++ b/src/vs/workbench/electron-sandbox/desktop.contribution.ts
@@ -26,6 +26,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
 import { ShutdownReason } from 'vs/workbench/services/lifecycle/common/lifecycle';
 import { NativeWindow } from 'vs/workbench/electron-sandbox/window';
 import { ModifierKeyEmitter } from 'vs/base/browser/dom';
+import product from 'vs/platform/product/common/product';
 
 // Actions
 (function registerActions(): void {
@@ -238,10 +239,10 @@ import { ModifierKeyEmitter } from 'vs/base/browser/dom';
 				'description': localize('window.clickThroughInactive', "If enabled, clicking on an inactive window will both activate the window and trigger the element under the mouse if it is clickable. If disabled, clicking anywhere on an inactive window will activate it only and a second click is required on the element."),
 				'included': isMacintosh
 			},
-			'window.experimental.useSandbox': {
+			'window.experimental.useSandbox': { // TODO@bpasero remove me once sandbox is final
 				type: 'boolean',
 				description: localize('experimentalUseSandbox', "Experimental: When enabled, the window will have sandbox mode enabled via Electron API."),
-				default: false,
+				default: typeof product.quality === 'string' && product.quality !== 'stable', // disabled by default in stable for now
 				'scope': ConfigurationScope.APPLICATION,
 				ignoreSync: true
 			},
diff --git a/src/vs/workbench/electron-sandbox/parts/dialogs/dialogHandler.ts b/src/vs/workbench/electron-sandbox/parts/dialogs/dialogHandler.ts
--- a/src/vs/workbench/electron-sandbox/parts/dialogs/dialogHandler.ts
+++ b/src/vs/workbench/electron-sandbox/parts/dialogs/dialogHandler.ts
@@ -167,7 +167,7 @@ export class NativeDialogHandler implements IDialogHandler {
 
 		const detailString = (useAgo: boolean): string => {
 			return localize({ key: 'aboutDetail', comment: ['Electron, Chromium, Node.js and V8 are product names that need no translation'] },
-				"Version: {0}\nCommit: {1}\nDate: {2}\nElectron: {3}\nChromium: {4}\nNode.js: {5}\nV8: {6}\nOS: {7}",
+				"Version: {0}\nCommit: {1}\nDate: {2}\nElectron: {3}\nChromium: {4}\nNode.js: {5}\nV8: {6}\nOS: {7}\nSandboxed: {8}",
 				version,
 				this.productService.commit || 'Unknown',
 				this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(new Date(this.productService.date), true) + ')' : ''}` : 'Unknown',
@@ -175,7 +175,8 @@ export class NativeDialogHandler implements IDialogHandler {
 				process.versions['chrome'],
 				process.versions['node'],
 				process.versions['v8'],
-				`${osProps.type} ${osProps.arch} ${osProps.release}${isLinuxSnap ? ' snap' : ''}`
+				`${osProps.type} ${osProps.arch} ${osProps.release}${isLinuxSnap ? ' snap' : ''}`,
+				process.sandboxed ? 'Yes' : 'No' // TODO@bpasero remove me once sandbox is final
 			);
 		};
 
diff --git a/src/vs/workbench/services/issue/electron-sandbox/issueService.ts b/src/vs/workbench/services/issue/electron-sandbox/issueService.ts
--- a/src/vs/workbench/services/issue/electron-sandbox/issueService.ts
+++ b/src/vs/workbench/services/issue/electron-sandbox/issueService.ts
@@ -21,6 +21,7 @@ import { IAuthenticationService } from 'vs/workbench/services/authentication/com
 import { registerMainProcessRemoteService } from 'vs/platform/ipc/electron-sandbox/services';
 import { IWorkspaceTrustManagementService } from 'vs/platform/workspace/common/workspaceTrust';
 import { IIntegrityService } from 'vs/workbench/services/integrity/common/integrity';
+import { process } from 'vs/base/parts/sandbox/electron-sandbox/globals';
 
 export class WorkbenchIssueService implements IWorkbenchIssueService {
 	declare readonly _serviceBrand: undefined;
@@ -101,6 +102,7 @@ export class WorkbenchIssueService implements IWorkbenchIssueService {
 			restrictedMode: !this.workspaceTrustManagementService.isWorkspaceTrusted(),
 			isUnsupported,
 			githubAccessToken,
+			isSandboxed: process.sandboxed
 		}, dataOverrides);
 		return this.issueService.openReporter(issueReporterData);
 	}


Test patch:
diff --git a/src/vs/code/test/electron-sandbox/issue/testReporterModel.test.ts b/src/vs/code/test/electron-sandbox/issue/testReporterModel.test.ts
--- a/src/vs/code/test/electron-sandbox/issue/testReporterModel.test.ts
+++ b/src/vs/code/test/electron-sandbox/issue/testReporterModel.test.ts
@@ -34,6 +34,7 @@ undefined
 VS Code version: undefined
 OS version: undefined
 Modes:
+Sandboxed: No
 
 Extensions: none
 <!-- generated by issue reporter -->`);
@@ -65,6 +66,7 @@ undefined
 VS Code version: undefined
 OS version: undefined
 Modes:
+Sandboxed: No
 
 <details>
 <summary>System Info</summary>
@@ -109,6 +111,7 @@ undefined
 VS Code version: undefined
 OS version: undefined
 Modes:
+Sandboxed: No
 
 <details>
 <summary>System Info</summary>
@@ -164,6 +167,7 @@ undefined
 VS Code version: undefined
 OS version: undefined
 Modes:
+Sandboxed: No
 
 <details>
 <summary>System Info</summary>
@@ -221,6 +225,7 @@ undefined
 VS Code version: undefined
 OS version: undefined
 Modes:
+Sandboxed: No
 Remote OS version: Linux x64 4.18.0
 
 <details>
@@ -270,6 +275,7 @@ undefined
 VS Code version: undefined
 OS version: undefined
 Modes:
+Sandboxed: No
 
 <details>
 <summary>System Info</summary>
@@ -301,6 +307,7 @@ undefined
 VS Code version: undefined
 OS version: undefined
 Modes: Restricted, Unsupported
+Sandboxed: No
 
 Extensions: none
 <!-- generated by issue reporter -->`);