terminalSandboxMxcRuntime.ts ×11

Frontier kind: Code frontier

unlabeled · c_6fa9cfa7bd14

9 tests · 12912 LOC · 57 files · introduces 0 tests · 88 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
20 ranges88 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2073 ranges12912 lines · 57 files · Browse complete extent
All tests (intent)
9 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 88 introduced LOC across 20 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/sandbox/common/terminalSandboxMxcRuntime.ts 47 introduced LOC · 11 ranges

Open complete file

65
66 async createConfig(options: IWindowsMxcConfigOptions, buildSandboxPayload: IWindowsMxcBuildSandboxPayload): Promise<IWindowsMxcConfig> {
67 > const tempDirPath = this.toWindowsPath(options.tempDir); terminalSandboxMxcRuntime.ts
68 > const shell = options.shell
69 > ? this._quoteWindowsCommandLineArgument(options.shell)
70 : 'pwsh.exe';
71 > const commandLine = `${shell} -NoProfile -Command ${this._quoteWindowsCommandLineArgument(options.command)}`; terminalSandboxMxcRuntime.ts
72 > const cwd = options.cwd ? this.toWindowsPath(options.cwd) : tempDirPath;
73 > const policy: IWindowsMxcSandboxPolicy = {
74 > version: options.schemaVersion ?? this._configVersion,
75 > timeoutMs: 0,
76 > filesystem: {
77 > readwritePaths: options.allowWritePaths.map(path => this._normalizeWindowsPath(path)),
78 > readonlyPaths: [tempDirPath, ...(options.shell && win32.isAbsolute(options.shell) ? [win32.dirname(options.shell)] : []), ...options.allowReadPaths].map(path => this._normalizeWindowsPath(path)),
79 > deniedPaths: options.denyReadPaths.map(path => this._normalizeWindowsPath(path)),
80 > },
81 > network: this._createNetworkPolicy(options.allowNetwork),
82 > ui: {
83 > allowWindows: true,
84 > clipboard: 'none',
85 > allowInputInjection: false,
86 > },
87 > };
88 >
89 > const config = await buildSandboxPayload(commandLine, policy, cwd);
90 > if (!config?.process) {
91 throw new Error('Unable to build Windows MXC sandbox payload');
92 }
94 > config.process.env = [...options.env];
95 >
96 > return config;
97 > }
98
99 wrapCommand(executablePath: string, configPath: string): string {
100 > return `& ${this._quotePowerShellArgument(executablePath)} ${this._quotePowerShellArgument(configPath)}`; terminalSandboxMxcRuntime.ts
101 > }
102
103 wrapUnsandboxedCommand(command: string): string {
106
107 toWindowsPath(uri: URI): string {
108 > let value: string; terminalSandboxMxcRuntime.ts
109 > if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') {
110 value = `\\\\${uri.authority}${uri.path}`;
111 > } else if (/^\/[a-zA-Z]:/.test(uri.path)) { terminalSandboxMxcRuntime.ts
112 > value = uri.path.slice(1);
113 > } else {
114 value = uri.fsPath;
115 }
116 > return this._normalizeWindowsPath(value); terminalSandboxMxcRuntime.ts
117 > }
118
119 private _normalizeWindowsPath(path: string): string {
120 > return path.replace(/\//g, '\\'); terminalSandboxMxcRuntime.ts
121 > }
122
123 private _createNetworkPolicy(allowNetwork: boolean): NonNullable<IWindowsMxcSandboxPolicy['network']> {
124 > // MXC does not support per-host network policies on Windows. Rely on the terminalSandboxMxcRuntime.ts
125 > // overall allow/block policy instead of emitting unsupported host lists.
126 > return { allowOutbound: allowNetwork };
127 > }
128
129 private _quotePowerShellArgument(value: string): string {
130 > return `'${value.replace(/'/g, `''`)}'`; terminalSandboxMxcRuntime.ts
131 > }
132
133 private _quoteWindowsCommandLineArgument(value: string): string {
134 > return `"${value.replace(/(\\*)"/g, '$1$1\\"').replace(/\\+$/g, '$&$&')}"`; terminalSandboxMxcRuntime.ts
135 > }
136 }
src/vs/platform/sandbox/common/terminalSandboxEngine.ts 41 introduced LOC · 9 ranges

Open complete file

267
268 if (this._os === OperatingSystem.Windows) {
269 > if (!this._mxcPath) { terminalSandboxEngine.ts
270 throw new Error('MXC executable path not resolved');
271 }
272 > return { terminalSandboxEngine.ts
273 > command: this._windowsMxcRuntime.wrapCommand(this._mxcPath, this._sandboxConfigPath),
274 > isSandboxWrapped: true,
275 > requiresAllowNetworkConfirmation: allowNetworkForCommand && !this._isSandboxAllowNetworkConfigured() ? true : undefined,
276 > ...allowNetworkConfirmationMetadata,
277 > };
278 > }
279
280 if (!this._execPath) {
492 private _getBlockedDomains(command: string): { blockedDomains: string[]; deniedDomains: string[] } {
493 if (this._isSandboxAllowNetworkConfigured()) {
494 > return { blockedDomains: [], deniedDomains: [] }; terminalSandboxEngine.ts
495 > }
496
497 const domains = this._extractDomains(command);
636 : {};
637 const windowsFileSystemSetting = this._os === OperatingSystem.Windows
638 > ? this._getSettingValue<ITerminalSandboxFileSystemSetting>(AgentSandboxSettingId.AgentSandboxWindowsFileSystem) ?? {} terminalSandboxEngine.ts
639 : {};
640 const windowsSchemaVersion = this._os === OperatingSystem.Windows
641 > ? this._getSettingValue<string>(AgentSandboxSettingId.AgentSandboxWindowsSchemaVersion) terminalSandboxEngine.ts
642 : undefined;
643 const runtimeSetting = this._getSettingValue<Record<string, unknown>>(AgentSandboxSettingId.AgentSandboxAdvancedRuntime) ?? {};
652 let denyWritePaths: string[] | undefined;
653 if (this._os === OperatingSystem.Windows) {
654 > const filesystemPolicy = await this._getWindowsMxcFilesystemPolicy(); terminalSandboxEngine.ts
655 > const env = await this._getWindowsMxcEnvironment();
656 > allowWritePaths = await this._resolveFileSystemPaths([
657 > ...await this._updateAllowWritePathsWithWorkspaceFolders(windowsFileSystemSetting.allowWrite),
658 > ...filesystemPolicy.readwritePaths
659 > ]);
660 > allowReadPaths = await this._resolveFileSystemPaths([...(windowsFileSystemSetting.allowRead ?? []), ...filesystemPolicy.readonlyPaths]);
661 > denyReadPaths = await this._resolveFileSystemPaths(windowsFileSystemSetting.denyRead ?? []);
662 > this._windowsMxcEnvironment = env;
663 } else if (this._os === OperatingSystem.Macintosh) {
664 allowWritePaths = (await this._resolveFileSystemPaths(await this._updateAllowWritePathsWithWorkspaceFolders(macFileSystemSetting.allowWrite, commandRuntimeAllowWritePaths))).filter(path => path !== configFilePath);
673 }
674 const sandboxSettings = this._os === OperatingSystem.Windows ? await this._windowsMxcRuntime.createConfig({
675 > command: this._commandLine ?? '', terminalSandboxEngine.ts
676 > shell: this._commandShell,
677 > cwd: this._commandCwd ?? this._getDefaultWindowsMxcCwd(),
678 > tempDir: this._tempDir,
679 > schemaVersion: windowsSchemaVersion,
680 > allowNetwork,
681 > allowReadPaths,
682 > allowWritePaths,
683 > denyReadPaths,
684 > env: this._windowsMxcEnvironment ?? [],
685 }, this._buildSandboxPayload) : {
686 network: allowNetwork ? { allowedDomains: [], deniedDomains: [], enabled: false } : this.getResolvedNetworkDomains(),
875
876 private async _getWindowsMxcFilesystemPolicy(): Promise<IWindowsMxcFilesystemPolicy> {
877 > if (!this._windowsMxcFilesystemPolicy) { terminalSandboxEngine.ts
878 > this._windowsMxcFilesystemPolicy = await this._host.getWindowsMxcFilesystemPolicy() ?? { readonlyPaths: [], readwritePaths: [] };
879 > }
880 > return this._windowsMxcFilesystemPolicy;
881 > }
882
883 private async _getWindowsMxcEnvironment(): Promise<string[]> {
884 > if (!this._windowsMxcEnvironment) { terminalSandboxEngine.ts
885 > this._windowsMxcEnvironment = await this._host.getWindowsMxcEnvironment() ?? [];
886 > }
887 > return this._windowsMxcEnvironment;
888 > }
889
890 private _pathJoin = (...segments: string[]) => {