Skip to content

Commit c98437f

Browse files
committed
Add more safe commands
Fixes microsoft#259668
1 parent 065f528 commit c98437f

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,35 +89,47 @@ export const terminalChatAgentToolsConfiguration: IStringDictionary<IConfigurati
8989
default: {
9090
// Safe and common readonly commands (automatically approved)
9191
echo: true,
92-
'Write-Host': true,
93-
'Write-Output': true,
9492
ls: true,
9593
find: true,
96-
'Get-ChildItem': true,
9794
pwd: true,
98-
'Get-Location': true,
9995
cat: true,
10096
head: true,
10197
tail: true,
102-
'Get-Content': true,
10398
grep: true,
10499
wc: true,
105-
'Select-Object': true,
106-
'Select-String': true,
107-
'Where-Obejct': true,
108-
'Measure-Object': true,
109100
sort: true,
110101
uniq: true,
111-
'Sort-Object': true,
102+
tr: true,
112103
which: true,
113-
'Get-Command': true,
114104
date: true,
115-
'Get-Date': true,
105+
time: true,
106+
env: true,
107+
printenv: true,
108+
uname: true,
116109
hostname: true,
117-
'Get-Host': true,
118110
ps: true,
119-
'Get-Process': true,
120111
whoami: true,
112+
basename: true,
113+
dirname: true,
114+
realpath: true,
115+
readlink: true,
116+
stat: true,
117+
file: true,
118+
du: true,
119+
df: true,
120+
// While these PowerShell verbs can have side effects, they are generally innocuous (eg.
121+
// updating OS-level file access info) and and often have prompts if they're more
122+
// involved (eg. Get-Credential)
123+
'/Get-[a-z0-9]/i': true,
124+
'/Select-[a-z0-9]/i': true,
125+
'/Measure-[a-z0-9]/i': true,
126+
'/Compare-[a-z0-9]/i': true,
127+
'/Format-[a-z0-9]/i': true,
128+
'/Sort-[a-z0-9]/i': true,
129+
'Write-Host': true,
130+
'Write-Output': true,
131+
'Split-Path': true,
132+
'Join-Path': true,
121133

122134
// There are countless dangerous commands available on the command line, the defaults here
123135
// include common ones that the user is likely to want to explicitly approve first. This is

0 commit comments

Comments
 (0)