Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fe169ce
Move terminalLinkHandler, electron-browser->browser
Tyriar Mar 5, 2019
5d2a154
Add terminal-specific tslint rule to allow vscode-xterm imports
Tyriar Mar 5, 2019
8afa777
Remove os dep in terminalEnvironment
Tyriar Mar 5, 2019
cc73497
Merge remote-tracking branch 'origin/master' into tyriar/69115
Tyriar Mar 5, 2019
badedf5
Move terminalEnvironment, node->common
Tyriar Mar 5, 2019
5b7bdac
Move terminalActions, electron-browser->browser
Tyriar Mar 5, 2019
3760c27
Move terminalPanel, electron-browser->browser
Tyriar Mar 5, 2019
2675ffe
Move parts of terminalService up to common/browser
Tyriar Mar 5, 2019
1d1dbdc
Move TerminalConfigHelper, electron-browser->browser
Tyriar Mar 5, 2019
b5dcee0
Move terminal CSS and images to browser
Tyriar Mar 5, 2019
00f5bdb
Move terminalCommandTracker, node->browser
Tyriar Mar 5, 2019
415c088
Move a lot of terminalService to common/browser
Tyriar Mar 5, 2019
d9af6b9
Remove execFile dep in terminal instance, unify 2 path prep functions
Tyriar Mar 5, 2019
877f090
Move terminalProcessManager to node
Tyriar Mar 5, 2019
23fbca3
Break node dependency in TerminalInstance
Tyriar Mar 5, 2019
b5a06eb
Move terminalInstance, electron-browser->browser
Tyriar Mar 5, 2019
03f23dd
Remove duplicate getWindowsBuildNumber definitions
Tyriar Mar 5, 2019
6d5ab92
Move terminalProcessExtHostProxy, node->common
Tyriar Mar 5, 2019
437f7f6
Move TerminalProcessManager, node->browser
Tyriar Mar 5, 2019
ff5ae22
Remove more from electron-browser/terminalService
Tyriar Mar 5, 2019
3a10272
Create browser/terminal.contribution.ts
Tyriar Mar 5, 2019
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
20 changes: 10 additions & 10 deletions src/tsconfig.strictNullChecks.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,31 +278,31 @@
"./vs/workbench/contrib/surveys/electron-browser/languageSurveys.contribution.ts",
"./vs/workbench/contrib/surveys/electron-browser/nps.contribution.ts",

"./vs/workbench/contrib/terminal/browser/terminalActions.ts",
"./vs/workbench/contrib/terminal/browser/terminalCommandTracker.ts",
"./vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts",
"./vs/workbench/contrib/terminal/browser/terminalFindWidget.ts",
"./vs/workbench/contrib/terminal/browser/terminalInstance.ts",
"./vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts",
"./vs/workbench/contrib/terminal/browser/terminalPanel.ts",
"./vs/workbench/contrib/terminal/browser/terminalProcessManager.ts",
"./vs/workbench/contrib/terminal/browser/terminalQuickOpen.ts",
"./vs/workbench/contrib/terminal/browser/terminalTab.ts",
"./vs/workbench/contrib/terminal/browser/terminalWidgetManager.ts",
"./vs/workbench/contrib/terminal/common/terminal.ts",
"./vs/workbench/contrib/terminal/common/terminalColorRegistry.ts",
"./vs/workbench/contrib/terminal/common/terminalCommands.ts",
"./vs/workbench/contrib/terminal/common/terminalEnvironment.ts",
"./vs/workbench/contrib/terminal/common/terminalMenu.ts",
"./vs/workbench/contrib/terminal/common/terminalProcessExtHostProxy.ts",
"./vs/workbench/contrib/terminal/common/terminalService.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalActions.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalConfigHelper.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalInstance.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalLinkHandler.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalPanel.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalProcessManager.ts",
"./vs/workbench/contrib/terminal/node/terminal.ts",
"./vs/workbench/contrib/terminal/node/terminalCommandTracker.ts",
"./vs/workbench/contrib/terminal/node/terminalEnvironment.ts",
"./vs/workbench/contrib/terminal/node/terminalProcess.ts",
"./vs/workbench/contrib/terminal/node/terminalProcessExtHostProxy.ts",
"./vs/workbench/contrib/terminal/node/windowsShellHelper.ts",
"./vs/workbench/contrib/terminal/test/electron-browser/terminalColorRegistry.test.ts",
"./vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts",
"./vs/workbench/contrib/terminal/test/electron-browser/terminalConfigHelper.test.ts",
"./vs/workbench/contrib/terminal/test/electron-browser/terminalLinkHandler.test.ts",
"./vs/workbench/contrib/terminal/test/node/terminalCommandTracker.test.ts",
"./vs/workbench/contrib/terminal/test/node/terminalEnvironment.test.ts",
"./vs/workbench/contrib/themes/browser/themes.contribution.ts",
"./vs/workbench/contrib/themes/test/electron-browser/themes.test.contribution.ts",
Expand Down
29 changes: 29 additions & 0 deletions src/vs/base/common/processes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { IProcessEnvironment } from 'vs/base/common/platform';

/**
* Options to be passed to the external program or shell.
*/
Expand Down Expand Up @@ -84,3 +86,30 @@ export const enum TerminateResponseCode {
AccessDenied = 2,
ProcessNotFound = 3,
}

/**
* Sanitizes a VS Code process environment by removing all Electron/VS Code-related values.
*/
export function sanitizeProcessEnvironment(env: IProcessEnvironment, ...preserve: string[]): void {
const set = preserve.reduce((set, key) => {
set[key] = true;
return set;
}, {} as Record<string, boolean>);
const keysToRemove = [
/^ELECTRON_.+$/,
/^GOOGLE_API_KEY$/,
/^VSCODE_.+$/,
/^SNAP(|_.*)$/
];
const envKeys = Object.keys(env);
envKeys
.filter(key => !set[key])
.forEach(envKey => {
for (let i = 0; i < keysToRemove.length; i++) {
if (envKey.search(keysToRemove[i]) !== -1) {
delete env[envKey];
break;
}
}
});
}
27 changes: 0 additions & 27 deletions src/vs/base/node/processes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,33 +72,6 @@ export function getWindowsShell(): string {
return process.env['comspec'] || 'cmd.exe';
}

/**
* Sanitizes a VS Code process environment by removing all Electron/VS Code-related values.
*/
export function sanitizeProcessEnvironment(env: Platform.IProcessEnvironment, ...preserve: string[]): void {
const set = preserve.reduce((set, key) => {
set[key] = true;
return set;
}, {} as Record<string, boolean>);
const keysToRemove = [
/^ELECTRON_.+$/,
/^GOOGLE_API_KEY$/,
/^VSCODE_.+$/,
/^SNAP(|_.*)$/
];
const envKeys = Object.keys(env);
envKeys
.filter(key => !set[key])
.forEach(envKey => {
for (let i = 0; i < keysToRemove.length; i++) {
if (envKey.search(keysToRemove[i]) !== -1) {
delete env[envKey];
break;
}
}
});
}

export abstract class AbstractProcess<TProgressData> {
private cmd: string;
private args: string[];
Expand Down
33 changes: 33 additions & 0 deletions src/vs/base/test/common/processes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as assert from 'assert';
import * as processes from 'vs/base/common/processes';

suite('Processes', () => {
test('sanitizeProcessEnvironment', () => {
let env = {
FOO: 'bar',
ELECTRON_ENABLE_STACK_DUMPING: 'x',
ELECTRON_ENABLE_LOGGING: 'x',
ELECTRON_NO_ASAR: 'x',
ELECTRON_NO_ATTACH_CONSOLE: 'x',
ELECTRON_RUN_AS_NODE: 'x',
GOOGLE_API_KEY: 'x',
VSCODE_CLI: 'x',
VSCODE_DEV: 'x',
VSCODE_IPC_HOOK: 'x',
VSCODE_LOGS: 'x',
VSCODE_NLS_CONFIG: 'x',
VSCODE_PORTABLE: 'x',
VSCODE_PID: 'x',
VSCODE_NODE_CACHED_DATA_DIR: 'x',
VSCODE_NEW_VAR: 'x'
};
processes.sanitizeProcessEnvironment(env);
assert.equal(env['FOO'], 'bar');
assert.equal(Object.keys(env).length, 1);
});
});
25 changes: 0 additions & 25 deletions src/vs/base/test/node/processes/processes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,4 @@ suite('Processes', () => {
}
});
});


test('sanitizeProcessEnvironment', () => {
let env = {
FOO: 'bar',
ELECTRON_ENABLE_STACK_DUMPING: 'x',
ELECTRON_ENABLE_LOGGING: 'x',
ELECTRON_NO_ASAR: 'x',
ELECTRON_NO_ATTACH_CONSOLE: 'x',
ELECTRON_RUN_AS_NODE: 'x',
GOOGLE_API_KEY: 'x',
VSCODE_CLI: 'x',
VSCODE_DEV: 'x',
VSCODE_IPC_HOOK: 'x',
VSCODE_LOGS: 'x',
VSCODE_NLS_CONFIG: 'x',
VSCODE_PORTABLE: 'x',
VSCODE_PID: 'x',
VSCODE_NODE_CACHED_DATA_DIR: 'x',
VSCODE_NEW_VAR: 'x'
};
processes.sanitizeProcessEnvironment(env);
assert.equal(env['FOO'], 'bar');
assert.equal(Object.keys(env).length, 1);
});
});
10 changes: 6 additions & 4 deletions src/vs/workbench/api/node/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import pkg from 'vs/platform/product/node/package';
import * as os from 'os';
import { URI, UriComponents } from 'vs/base/common/uri';
import * as platform from 'vs/base/common/platform';
import * as terminalEnvironment from 'vs/workbench/contrib/terminal/node/terminalEnvironment';
import * as terminalEnvironment from 'vs/workbench/contrib/terminal/common/terminalEnvironment';
import { Event, Emitter } from 'vs/base/common/event';
import { ExtHostTerminalServiceShape, MainContext, MainThreadTerminalServiceShape, IMainContext, ShellLaunchConfigDto } from 'vs/workbench/api/node/extHost.protocol';
import { ExtHostConfiguration } from 'vs/workbench/api/node/extHostConfiguration';
import { ILogService } from 'vs/platform/log/common/log';
import { EXT_HOST_CREATION_DELAY } from 'vs/workbench/contrib/terminal/common/terminal';
import { TerminalProcess } from 'vs/workbench/contrib/terminal/node/terminalProcess';
import { timeout } from 'vs/base/common/async';
import { sanitizeProcessEnvironment } from 'vs/base/node/processes';
import { sanitizeProcessEnvironment } from 'vs/base/common/processes';

const RENDERER_NO_PROCESS_ID = -1;

Expand Down Expand Up @@ -429,7 +431,7 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {

// TODO: @daniel
const activeWorkspaceRootUri = URI.revive(activeWorkspaceRootUriComponents);
const initialCwd = terminalEnvironment.getCwd(shellLaunchConfig, activeWorkspaceRootUri, terminalConfig.cwd);
const initialCwd = terminalEnvironment.getCwd(shellLaunchConfig, os.homedir(), activeWorkspaceRootUri, terminalConfig.cwd);

// TODO: Pull in and resolve config settings
// // Resolve env vars from config and shell
Expand All @@ -450,7 +452,7 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {

// Continue env initialization, merging in the env from the launch
// config and adding keys that are needed to create the process
terminalEnvironment.addTerminalEnvironmentKeys(env, platform.locale, terminalConfig.get('setLocaleVariables'));
terminalEnvironment.addTerminalEnvironmentKeys(env, pkg.version, platform.locale, terminalConfig.get('setLocaleVariables'));

// Fork the process and listen for messages
this._logService.debug(`Terminal process launching on ext host`, shellLaunchConfig, initialCwd, cols, rows, env);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import * as Objects from 'vs/base/common/objects';
import * as Types from 'vs/base/common/types';
import * as Platform from 'vs/base/common/platform';
import * as Async from 'vs/base/common/async';
import * as os from 'os';
import { IStringDictionary, values } from 'vs/base/common/collections';
import { LinkedMap, Touch } from 'vs/base/common/map';
import Severity from 'vs/base/common/severity';
Expand Down Expand Up @@ -42,6 +41,7 @@ import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
import { URI } from 'vs/base/common/uri';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { Schemas } from 'vs/base/common/network';
import { getWindowsBuildNumber } from 'vs/workbench/contrib/terminal/node/terminal';

interface TerminalData {
terminal: ITerminalInstance;
Expand Down Expand Up @@ -745,7 +745,7 @@ export class TerminalTaskSystem implements ITaskSystem {
if (!shellSpecified) {
toAdd.push('-Command');
}
} else if ((basename === 'bash.exe') || (basename === 'zsh.exe') || ((basename === 'wsl.exe') && (this.getWindowsBuildNumber() < 17763))) { // See https://github.com/Microsoft/vscode/issues/67855
} else if ((basename === 'bash.exe') || (basename === 'zsh.exe') || ((basename === 'wsl.exe') && (getWindowsBuildNumber() < 17763))) { // See https://github.com/Microsoft/vscode/issues/67855
windowsShellArgs = false;
if (!shellSpecified) {
toAdd.push('-c');
Expand Down Expand Up @@ -1213,15 +1213,6 @@ export class TerminalTaskSystem implements ITaskSystem {
return result;
}

private getWindowsBuildNumber(): number {
const osVersion = (/(\d+)\.(\d+)\.(\d+)/g).exec(os.release());
let buildNumber: number = 0;
if (osVersion && osVersion.length === 4) {
buildNumber = parseInt(osVersion[3]);
}
return buildNumber;
}

private registerLinkMatchers(terminal: ITerminalInstance, problemMatchers: ProblemMatcher[]): number[] {
let result: number[] = [];
/*
Expand Down
Loading