terminalSandboxEngine.ts ×11

Frontier kind: Code frontier

unlabeled · c_2a185ca864f0

35 tests · 12505 LOC · 56 files · introduces 0 tests · 55 LOC · 4 files

Introduces — evidence that enters the hierarchy at this concept

Code
18 ranges55 lines · 4 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1947 ranges12505 lines · 56 files · Browse complete extent
All tests (intent)
35 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.

4 files ranked by introduced lines: 55 introduced LOC across 18 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/sandbox/common/terminalSandboxEngine.ts 35 introduced LOC · 11 ranges

Open complete file

603
604 private async _resolveRuntimeInfo(): Promise<void> {
605 > if (this._runtimeResolved) { terminalSandboxEngine.ts
606 return;
607 }
608 > this._runtimeResolved = true; terminalSandboxEngine.ts
609 > const runtimeInfo = await this._host.getRuntimeInfo();
610 > this._appRoot = runtimeInfo.appRoot;
611 > this._execPath = runtimeInfo.execPath;
612 > this._runAsNode = runtimeInfo.runAsNode ?? false;
613 > this._userHome = await this._host.getUserHome();
614 > this._srtPath = this._pathJoin(this._appRoot, 'node_modules', '@vscode', 'sandbox-runtime', 'dist', 'cli.js');
615 > const nativeModulesDir = runtimeInfo.nativeModulesDir ?? 'node_modules';
616 > const rgPlatform = this._os === OperatingSystem.Windows ? 'win32' : this._os === OperatingSystem.Macintosh ? 'darwin' : 'linux';
617 > const rgBinary = this._os === OperatingSystem.Windows ? 'rg.exe' : 'rg';
618 > this._rgPath = this._pathJoin(this._appRoot, nativeModulesDir, '@vscode', 'ripgrep-universal', 'bin', `${rgPlatform}-${arch}`, rgBinary);
619 > this._mxcPath = this._windowsMxcRuntime.getExecutablePath(this._appRoot, nativeModulesDir, runtimeInfo.arch);
620 > }
621
622 private async _createSandboxConfig(): Promise<string | undefined> {
843
844 private _getCommandRuntimeFileSystemPaths(runtimeSetting: Record<string, unknown>, key: 'allowRead' | 'allowWrite'): string[] {
845 > const filesystem = runtimeSetting.filesystem; terminalSandboxEngine.ts
846 > if (!this._isObjectForSandboxConfigMerge(filesystem)) {
847 return [];
848 }
854
855 return paths.filter((path): path is string => typeof path === 'string');
857
858 private _mergeAdditionalSandboxConfigProperties(target: Record<string, unknown>, additional: Record<string, unknown>): void {
871
872 private _isObjectForSandboxConfigMerge(value: unknown): value is Record<string, unknown> {
873 > return typeof value === 'object' && value !== null && !Array.isArray(value); terminalSandboxEngine.ts
874 > }
875
876 private async _getWindowsMxcFilesystemPolicy(): Promise<IWindowsMxcFilesystemPolicy> {
898
899 private _getUriPath(uri: URI): string {
900 > return this._os === OperatingSystem.Windows ? this._windowsMxcRuntime.toWindowsPath(uri) : uri.path; terminalSandboxEngine.ts
901 > }
902
903 private async _initTempDir(): Promise<void> {
904 > if (!(await this.isEnabled())) { terminalSandboxEngine.ts
905 return;
906 }
907 > this._needsForceUpdateConfigFile = true; terminalSandboxEngine.ts
908 > this._tempDir = await this._host.getSandboxTempDir();
909 > if (this._tempDir) {
910 > await this._fileService.createFolder(this._tempDir);
911 > this._defaultWritePaths.push(this._getUriPath(this._tempDir));
912 > } else {
913 this._logService.warn('TerminalSandboxEngine: Cannot create sandbox settings file because no tmpDir is available in this environment');
914 }
916
917 private async _updateAllowWritePathsWithWorkspaceFolders(configuredAllowWrite: string[] | undefined, commandRuntimeAllowWrite: string[] = []): Promise<string[]> {
918 > const writeRootPaths = this._host.getWriteRoots().map(folder => this._getUriPath(folder)); terminalSandboxEngine.ts
919 > return [...new Set([...writeRootPaths, ...this._defaultWritePaths, ...await this._getWorkspaceStorageReadPaths(), ...(configuredAllowWrite ?? []), ...commandRuntimeAllowWrite])];
920 > }
921
922 private _updateDenyReadPathsWithHome(configuredDenyRead: string[] | undefined): string[] {
1040
1041 private async _getWorkspaceStorageReadPaths(): Promise<string[]> {
1042 > const root = await this._host.getWorkspaceStorageReadRoot(); terminalSandboxEngine.ts
1043 > return root ? [this._getUriPath(root)] : [];
1044 > }
1045
1046 private _getDefaultWindowsMxcCwd(): URI | undefined {
src/vs/platform/sandbox/common/terminalSandboxReadAllowList.ts 10 introduced LOC · 3 ranges

Open complete file

339 }
340
341 > function getTerminalSandboxReadAllowListForCommandDetails(os: OperatingSystem, commandDetails: readonly ITerminalSandboxCommand[]): readonly string[] { terminalSandboxReadAllowList.ts
342 > const operations = new Set<TerminalSandboxReadAllowListOperation>();
343 > for (const command of commandDetails) {
344 for (const rule of terminalSandboxReadAllowListCommandDetailRules) {
345 if (matchesTerminalSandboxCommandRule(command, rule, { os })) {
348 }
349 }
351 > const paths = [...operations].flatMap(operation => getTerminalSandboxReadAllowListForOperation(operation, os));
352 > return [...new Set(paths)];
353 > }
354
355 /**
375
376 export function getTerminalSandboxReadAllowListForCommands(os: OperatingSystem, commandKeywords: readonly string[], commandDetails: readonly ITerminalSandboxCommand[] = []): readonly string[] {
377 > if (commandKeywords.length === 0) { terminalSandboxReadAllowList.ts
378 > return getTerminalSandboxReadAllowListForCommandDetails(os, commandDetails);
379 > }
380
381 const operations = new Set<TerminalSandboxReadAllowListOperation>();
src/vs/platform/sandbox/common/terminalSandboxRuntimeConfigurationPerOperation.ts 7 introduced LOC · 3 ranges

Open complete file

68
69 export function getTerminalSandboxRuntimeConfigurationForCommands(os: OperatingSystem, commandDetails: readonly ITerminalSandboxCommand[]): Record<string, unknown> {
70 > const operations = new Set<TerminalSandboxRuntimeConfigurationOperation>(); terminalSandboxRuntimeConfigurationPerOperation.ts
71 > for (const command of commandDetails) {
72 for (const rule of terminalSandboxRuntimeConfigurationCommandRules) {
73 if (matchesTerminalSandboxCommandRule(command, rule, { os }) && shouldApplyRuntimeConfigurationOperation(rule.value, commandDetails)) {
76 }
77 }
79 > const configuration: Record<string, unknown> = {};
80 > for (const operation of operations) {
81 mergeAdditionalSandboxConfigProperties(configuration, getTerminalSandboxRuntimeConfigurationForOperation(operation, os));
82 }
84 > }
85
86 function shouldApplyRuntimeConfigurationOperation(operation: TerminalSandboxRuntimeConfigurationOperation, commandDetails: readonly ITerminalSandboxCommand[]): boolean {
src/vs/platform/sandbox/common/terminalSandboxMxcRuntime.ts 3 introduced LOC · 1 range

Open complete file

49
50 getExecutablePath(appRoot: string, nativeModulesDir: string, arch: string | undefined): string {
51 > const binArch = arch === 'arm64' ? 'arm64' : 'x64'; terminalSandboxMxcRuntime.ts
52 > return win32.join(appRoot, nativeModulesDir, '@microsoft', 'mxc-sdk', 'bin', binArch, 'wxc-exec.exe');
53 > }
54
55 getRuntimeReadPaths(appRoot: string | undefined, executablePath: string | undefined): string[] {