1
>
/*---------------------------------------------------------------------------------------------
sandboxHelper.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { execFile } from 'child_process';
7
>
import { getCaseInsensitive } from '../../../base/common/objects.js';
8
>
import { win32 } from '../../../base/common/path.js';
9
>
import { isLinux, isWindows } from '../../../base/common/platform.js';
10
>
import { getOSReleaseInfo } from '../../../base/node/osReleaseInfo.js';
11
>
import { findExecutable } from '../../../base/node/processes.js';
12
>
import { ISandboxDependencyStatus, ISandboxHelperService, type IWindowsMxcConfig, IWindowsMxcFilesystemPolicy, type IWindowsMxcPolicyContainment, type IWindowsMxcSandboxPolicy } from '../common/sandboxHelperService.js';
13
>
14
>
type FindCommand = (command: string) => Promise<string | undefined>;
15
>
type BubblewrapProbe = (command: string) => Promise<{ usable: boolean; error?: string }>;
16
>
type ResolveLinuxInstallEnvironment = () => Promise<{ distributionIds: readonly string[]; isRoot: boolean }>;
17
>
18
>
const linuxDependencyInstallCommands: readonly { distributionIds: readonly string[]; commands: readonly [executable: string, command: string][] }[] = [
19
>
{ distributionIds: ['debian', 'ubuntu', 'linuxmint', 'pop', 'elementary', 'kali', 'raspbian'], commands: [['apt-get', 'apt-get update && apt-get install -y'], ['apt', 'apt update && apt install -y']] },
20
>
{ distributionIds: ['fedora', 'rhel', 'centos', 'rocky', 'almalinux'], commands: [['dnf', 'dnf install -y'], ['yum', 'yum install -y']] },
21
>
{ distributionIds: ['arch', 'manjaro', 'endeavouros'], commands: [['pacman', 'pacman -S --needed --noconfirm']] },
22
>
{ distributionIds: ['suse', 'opensuse', 'opensuse-leap', 'opensuse-tumbleweed'], commands: [['zypper', 'zypper --non-interactive install']] },
23
>
{ distributionIds: ['alpine'], commands: [['apk', 'apk add']] },
24
>
];
25
>
26
>
export class SandboxHelperService implements ISandboxHelperService {
27
>
declare readonly _serviceBrand: undefined;
28
>
29
>
static async checkSandboxDependenciesWith(findCommand: FindCommand, linux: boolean = isLinux, probeBubblewrap: BubblewrapProbe = command => SandboxHelperService._probeBubblewrap(command), resolveInstallEnvironment: ResolveLinuxInstallEnvironment = () => SandboxHelperService._resolveLinuxInstallEnvironment()): Promise<ISandboxDependencyStatus | undefined> {
30
>
if (!linux) {
31
return undefined;
32
}