Skip to content

Commit d3c0126

Browse files
meganroggeMegan Rogge
andauthored
Block auto-approved file writes with literal tilde (#316311)
Add ~ to the variable/sub-command detection regex in commandLineFileWriteAnalyzer so paths like ~/foo that the shell will expand are not auto-approved based on a static path that does not match what bash will open. Co-authored-by: Megan Rogge <meganrogge@Megans-MacBook-Pro.local>
1 parent 130f343 commit d3c0126

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ 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+
if (fileUri.fsPath.match(/[$\(\){}`~]/)) {
150150
isAutoApproveAllowed = false;
151-
this._log('File write blocked due to likely containing a variable or sub-command', fileUri.toString());
151+
this._log('File write blocked due to likely containing a variable, sub-command, or tilde expansion', fileUri.toString());
152152
break;
153153
}
154154

0 commit comments

Comments
 (0)