Skip to content

Commit 5ab24ee

Browse files
authored
Conform to new shell env API shape (#192)
Adding isTrusted field as part of shell env api, meaning the shape would change a bit. Accessing shell env would be `.env.value` instead of `.env`. Trying to prevent breaking where this api is already being used, so that I can safely merge: microsoft/vscode#240971
1 parent 96d3257 commit 5ab24ee

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"publisher": "ms-python",
77
"preview": true,
88
"engines": {
9-
"vscode": "^1.97.0"
9+
"vscode": "^1.98.0-20250221"
1010
},
1111
"categories": [
1212
"Other"

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
230230
updateViewsAndStatus(statusBar, workspaceView, managerView, api);
231231
}),
232232
onDidChangeTerminalShellIntegration(async (e) => {
233-
const envVar = e.shellIntegration?.env;
233+
const envVar = e.shellIntegration?.env.value;
234234
if (envVar) {
235235
if (envVar['VIRTUAL_ENV']) {
236236
const env = await api.resolveEnvironment(Uri.file(envVar['VIRTUAL_ENV']));

src/vscode.proposed.terminalShellEnv.d.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,30 @@
66
declare module 'vscode' {
77
// @anthonykim1 @tyriar https://github.com/microsoft/vscode/issues/227467
88

9+
export interface TerminalShellIntegrationEnvironment {
10+
/**
11+
* The dictionary of environment variables.
12+
*/
13+
value: { [key: string]: string | undefined } | undefined;
14+
15+
/**
16+
* Whether the environment came from a trusted source and is therefore safe to use its
17+
* values in a manner that could lead to execution of arbitrary code. If this value is
18+
* `false`, {@link value} should either not be used for something that could lead to arbitrary
19+
* code execution, or the user should be warned beforehand.
20+
*
21+
* This is `true` only when the environment was reported explicitly and it used a nonce for
22+
* verification.
23+
*/
24+
isTrusted: boolean;
25+
}
26+
927
export interface TerminalShellIntegration {
1028
/**
1129
* The environment of the shell process. This is undefined if the shell integration script
1230
* does not send the environment.
1331
*/
14-
readonly env: { [key: string]: string | undefined } | undefined;
32+
readonly env: TerminalShellIntegrationEnvironment;
1533
}
1634

1735
// TODO: Is it fine that this shares onDidChangeTerminalShellIntegration with cwd and the shellIntegration object itself?

0 commit comments

Comments
 (0)