65
66
async createConfig(options: IWindowsMxcConfigOptions, buildSandboxPayload: IWindowsMxcBuildSandboxPayload): Promise<IWindowsMxcConfig> {
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 {