64
};
65
}
67
>
}
68
69
export function getTerminalSandboxRuntimeConfigurationForCommands(os: OperatingSystem, commandDetails: readonly ITerminalSandboxCommand[]): Record<string, unknown> {
70
const operations = new Set<TerminalSandboxRuntimeConfigurationOperation>();
71
for (const command of commandDetails) {
73
>
if (matchesTerminalSandboxCommandRule(command, rule, { os }) && shouldApplyRuntimeConfigurationOperation(rule.value, commandDetails)) {
74
>
operations.add(rule.value);
75
>
}
76
>
}
77
>
}
78
79
const configuration: Record<string, unknown> = {};
80
for (const operation of operations) {
82
>
}
83
return configuration;
84
}
85
87
>
switch (operation) {
88
>
case TerminalSandboxRuntimeConfigurationOperation.GnuPG:
89
>
// Docker socket access can grant host-level privileges, so do not allow all Unix
90
>
// sockets when a Docker-related command is part of the sandbox invocation.
91
>
return commandDetails.every(command => !command.keyword.toLowerCase().startsWith('docker'));
92
>
case TerminalSandboxRuntimeConfigurationOperation.Node:
93
return true;
95
>
}
96
98
>
for (const [key, value] of Object.entries(additional)) {
99
>
if (!Object.prototype.hasOwnProperty.call(target, key)) {
100
>
target[key] = value;
101
>
continue;
102
>
}
103
104
const existingValue = target[key];
106
target[key] = [...new Set([...existingValue, ...value])];
107
continue;
108
}
110
mergeAdditionalSandboxConfigProperties(existingValue, value);
111
}
113
>
}
114
115
function isObjectForSandboxConfigMerge(value: unknown): value is Record<string, unknown> {