Skip to content

Commit 1b50d58

Browse files
dileepyavanZhichao Lizhichlialexdimalszomoru
authored
Cherry pick/msrc 1.123 to release 1.123 (#55) (#320698)
* OTel visibility in Copilot Chat UI (#47) * [msrc/1.123] 114763 * Add maxAttributeSizeChars configuration to OpenTelemetry settings --------- (cherry picked from commit 042dc59) * Prompt before connecting to non-loopback remote host:port authorities (#46) A direct `<host>:<port>` remote authority (no resolver `+` prefix) bypasses resolver extensions and connects straight to the given server. Since this form can originate from untrusted sources (e.g. the `remoteAuthority` of a `.code-workspace` file), a crafted workspace could silently point the window's extension host backend at an attacker-controlled server. Centralize a confirmation prompt at the connection point in the renderer: when resolving a direct authority whose host is not loopback (localhost, 127.0.0.1, ::1), ask the user to confirm before connecting and abort if declined. Add `isLoopbackHost` helper and tests. (cherry picked from commit 9505d0f) * GitHub - improve host parsing (#48) (cherry picked from commit 4b6e246) * path traversal fix (#50) * fix path traversal * fix compilation (cherry picked from commit 9b31ff8) * Path - improve isEqualOrParent calculation (#49) (cherry picked from commit 0f1ba1e) * Version bump to 1.123.1 (#52) (cherry picked from commit db24d8b) * copilot: update engines.vscode to ^1.123.1 (cherry picked from commit ffa3c3f) * upgrading version to 1.123.2 * cherrypicking changes --------- (cherry picked from commit 3c631b164c239e7aeaaae7c626b46c527b361af2) Co-authored-by: Zhichao Li <Li.Zhichao@microsoft.com> Co-authored-by: Zhichao Li <zhichli@microsoft.com> Co-authored-by: Alexandru Dima <alexdima@microsoft.com> Co-authored-by: Ladislau Szomoru <lszomoru@microsoft.com> Co-authored-by: Sandeep Somavarapu <sasomava@microsoft.com> Co-authored-by: ulugbekna <ulugbekna@gmail.com> Co-authored-by: Megan Rogge <Megan.Rogge@microsoft.com>
1 parent a118f82 commit 1b50d58

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineFileWriteAnalyzer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ export class CommandLineFileWriteAnalyzer extends Disposable implements ICommand
146146
const fileUri = URI.isUri(fileWrite) ? fileWrite : URI.file(fileWrite);
147147
// TODO: Handle command substitutions/complex destinations properly https://github.com/microsoft/vscode/issues/274167
148148
// TODO: Handle environment variables properly https://github.com/microsoft/vscode/issues/274166
149-
if (fileUri.fsPath.match(/[$\(\){}`~]/)) {
149+
// `~` catches POSIX tilde expansion (e.g. `~/foo`) and `%` catches Windows
150+
// environment variable expansions (e.g. `%APPDATA%\foo`). Neither is
151+
// recognized as absolute by `posix.isAbsolute` / `win32.isAbsolute`, so
152+
// without this guard they would be joined onto cwd and incorrectly classified
153+
// as inside the workspace while expanding at runtime to a location outside it.
154+
if (fileUri.fsPath.match(/[$\(\){}`~%]/)) {
150155
isAutoApproveAllowed = false;
151156
this._log('File write blocked due to likely containing a variable, sub-command, or tilde expansion', fileUri.toString());
152157
break;

src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/electron-browser/commandLineAnalyzer/commandLineFileWriteAnalyzer.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ suite('CommandLineFileWriteAnalyzer', () => {
118118
test('variable in filename - block', () => t('echo hello > $HOME/file.txt', 'outsideWorkspace', false, 1));
119119
test('command substitution - block', () => t('echo hello > $(pwd)/file.txt', 'outsideWorkspace', false, 1));
120120
test('brace expansion - block', () => t('echo hello > {a,b}.txt', 'outsideWorkspace', false, 1));
121+
test('tilde expansion - block', () => t('echo hello > ~/file.txt', 'outsideWorkspace', false, 1));
122+
test('percent-style variable - block', () => t('echo hello > %HOME%/file.txt', 'outsideWorkspace', false, 1));
121123
});
122124

123125
suite('blockDetectedFileWrites: all', () => {
@@ -300,6 +302,8 @@ suite('CommandLineFileWriteAnalyzer', () => {
300302
test('no redirections - allow', () => t('Write-Host "hello"', 'outsideWorkspace', true, 0));
301303
test('variable in filename - block', () => t('Write-Host "hello" > $env:TEMP\\file.txt', 'outsideWorkspace', false, 1));
302304
test('subexpression - block', () => t('Write-Host "hello" > $(Get-Date).log', 'outsideWorkspace', false, 1));
305+
test('percent-style variable - block', () => t('Write-Host "hello" > %APPDATA%\\file.txt', 'outsideWorkspace', false, 1));
306+
test('tilde expansion - block', () => t('Write-Host "hello" > ~\\file.txt', 'outsideWorkspace', false, 1));
303307
});
304308

305309
suite('blockDetectedFileWrites: all', () => {

0 commit comments

Comments
 (0)