@@ -12,7 +12,7 @@ import { split } from 'shlex'
12
12
13
13
export enum CommandCategory {
14
14
ReadOnly ,
15
- HighRisk ,
15
+ Mutate ,
16
16
Destructive ,
17
17
}
18
18
@@ -47,45 +47,37 @@ export const commandCategories = new Map<string, CommandCategory>([
47
47
[ 'netstat' , CommandCategory . ReadOnly ] ,
48
48
[ 'ss' , CommandCategory . ReadOnly ] ,
49
49
[ 'dig' , CommandCategory . ReadOnly ] ,
50
- [ 'grep' , CommandCategory . ReadOnly ] ,
51
50
[ 'wc' , CommandCategory . ReadOnly ] ,
52
51
[ 'sort' , CommandCategory . ReadOnly ] ,
53
52
[ 'diff' , CommandCategory . ReadOnly ] ,
54
53
[ 'head' , CommandCategory . ReadOnly ] ,
55
54
[ 'tail' , CommandCategory . ReadOnly ] ,
56
55
57
- // HighRisk commands
58
- [ 'chmod' , CommandCategory . HighRisk ] ,
59
- [ 'chown' , CommandCategory . HighRisk ] ,
60
- [ 'mv' , CommandCategory . HighRisk ] ,
61
- [ 'cp' , CommandCategory . HighRisk ] ,
62
- [ 'ln' , CommandCategory . HighRisk ] ,
63
- [ 'mount' , CommandCategory . HighRisk ] ,
64
- [ 'umount' , CommandCategory . HighRisk ] ,
65
- [ 'kill' , CommandCategory . HighRisk ] ,
66
- [ 'killall' , CommandCategory . HighRisk ] ,
67
- [ 'pkill' , CommandCategory . HighRisk ] ,
68
- [ 'iptables' , CommandCategory . HighRisk ] ,
69
- [ 'route' , CommandCategory . HighRisk ] ,
70
- [ 'systemctl' , CommandCategory . HighRisk ] ,
71
- [ 'service' , CommandCategory . HighRisk ] ,
72
- [ 'crontab' , CommandCategory . HighRisk ] ,
73
- [ 'at' , CommandCategory . HighRisk ] ,
74
- [ 'tar' , CommandCategory . HighRisk ] ,
75
- [ 'awk' , CommandCategory . HighRisk ] ,
76
- [ 'sed' , CommandCategory . HighRisk ] ,
77
- [ 'wget' , CommandCategory . HighRisk ] ,
78
- [ 'curl' , CommandCategory . HighRisk ] ,
79
- [ 'nc' , CommandCategory . HighRisk ] ,
80
- [ 'ssh' , CommandCategory . HighRisk ] ,
81
- [ 'scp' , CommandCategory . HighRisk ] ,
82
- [ 'ftp' , CommandCategory . HighRisk ] ,
83
- [ 'sftp' , CommandCategory . HighRisk ] ,
84
- [ 'rsync' , CommandCategory . HighRisk ] ,
85
- [ 'chroot' , CommandCategory . HighRisk ] ,
86
- [ 'lsof' , CommandCategory . HighRisk ] ,
87
- [ 'strace' , CommandCategory . HighRisk ] ,
88
- [ 'gdb' , CommandCategory . HighRisk ] ,
56
+ // Mutable commands
57
+ [ 'chmod' , CommandCategory . Mutate ] ,
58
+ [ 'curl' , CommandCategory . Mutate ] ,
59
+ [ 'mount' , CommandCategory . Mutate ] ,
60
+ [ 'umount' , CommandCategory . Mutate ] ,
61
+ [ 'systemctl' , CommandCategory . Mutate ] ,
62
+ [ 'service' , CommandCategory . Mutate ] ,
63
+ [ 'crontab' , CommandCategory . Mutate ] ,
64
+ [ 'at' , CommandCategory . Mutate ] ,
65
+ [ 'nc' , CommandCategory . Mutate ] ,
66
+ [ 'ssh' , CommandCategory . Mutate ] ,
67
+ [ 'scp' , CommandCategory . Mutate ] ,
68
+ [ 'ftp' , CommandCategory . Mutate ] ,
69
+ [ 'sftp' , CommandCategory . Mutate ] ,
70
+ [ 'rsync' , CommandCategory . Mutate ] ,
71
+ [ 'chroot' , CommandCategory . Mutate ] ,
72
+ [ 'strace' , CommandCategory . Mutate ] ,
73
+ [ 'gdb' , CommandCategory . Mutate ] ,
74
+ [ 'apt' , CommandCategory . Mutate ] ,
75
+ [ 'yum' , CommandCategory . Mutate ] ,
76
+ [ 'dnf' , CommandCategory . Mutate ] ,
77
+ [ 'pacman' , CommandCategory . Mutate ] ,
78
+ [ 'exec' , CommandCategory . Mutate ] ,
79
+ [ 'eval' , CommandCategory . Mutate ] ,
80
+ [ 'xargs' , CommandCategory . Mutate ] ,
89
81
90
82
// Destructive commands
91
83
[ 'rm' , CommandCategory . Destructive ] ,
@@ -104,22 +96,18 @@ export const commandCategories = new Map<string, CommandCategory>([
104
96
[ 'insmod' , CommandCategory . Destructive ] ,
105
97
[ 'rmmod' , CommandCategory . Destructive ] ,
106
98
[ 'modprobe' , CommandCategory . Destructive ] ,
107
- [ 'apt' , CommandCategory . Destructive ] ,
108
- [ 'yum' , CommandCategory . Destructive ] ,
109
- [ 'dnf' , CommandCategory . Destructive ] ,
110
- [ 'pacman' , CommandCategory . Destructive ] ,
111
- [ 'perl' , CommandCategory . Destructive ] ,
112
- [ 'python' , CommandCategory . Destructive ] ,
113
- [ 'bash' , CommandCategory . Destructive ] ,
114
- [ 'sh' , CommandCategory . Destructive ] ,
115
- [ 'exec' , CommandCategory . Destructive ] ,
116
- [ 'eval' , CommandCategory . Destructive ] ,
117
- [ 'xargs' , CommandCategory . Destructive ] ,
99
+ [ 'kill' , CommandCategory . Destructive ] ,
100
+ [ 'killall' , CommandCategory . Destructive ] ,
101
+ [ 'pkill' , CommandCategory . Destructive ] ,
102
+ [ 'iptables' , CommandCategory . Destructive ] ,
103
+ [ 'route' , CommandCategory . Destructive ] ,
104
+ [ 'chown' , CommandCategory . Destructive ] ,
118
105
] )
119
106
export const maxBashToolResponseSize : number = 1024 * 1024 // 1MB
120
107
export const lineCount : number = 1024
121
108
export const destructiveCommandWarningMessage = '⚠️ WARNING: Destructive command detected:\n\n'
122
109
export const highRiskCommandWarningMessage = '⚠️ WARNING: High risk command detected:\n\n'
110
+ export const mutateCommandWarningMessage = 'Mutation command:\n\n'
123
111
124
112
export interface ExecuteBashParams {
125
113
command : string
@@ -197,11 +185,8 @@ export class ExecuteBash {
197
185
switch ( category ) {
198
186
case CommandCategory . Destructive :
199
187
return { requiresAcceptance : true , warning : destructiveCommandWarningMessage }
200
- case CommandCategory . HighRisk :
201
- return {
202
- requiresAcceptance : true ,
203
- warning : highRiskCommandWarningMessage ,
204
- }
188
+ case CommandCategory . Mutate :
189
+ return { requiresAcceptance : true , warning : mutateCommandWarningMessage }
205
190
case CommandCategory . ReadOnly :
206
191
if (
207
192
cmdArgs . some ( ( arg ) =>
@@ -212,7 +197,7 @@ export class ExecuteBash {
212
197
}
213
198
continue
214
199
default :
215
- return { requiresAcceptance : true , warning : highRiskCommandWarningMessage }
200
+ return { requiresAcceptance : true }
216
201
}
217
202
}
218
203
return { requiresAcceptance : false }
0 commit comments