@@ -16,7 +16,9 @@ export enum CommandCategory {
1616 Destructive ,
1717}
1818
19- export const dangerousPatterns = new Set ( [ '<(' , '$(' , '`' , '>' , '&&' , '||' ] )
19+ export const dangerousPatterns = new Set ( [ '<(' , '$(' , '`' ] )
20+ export const splitOperators = new Set ( [ '|' , '&&' , '||' , '>' ] )
21+ export const splitOperatorsArray = Array . from ( splitOperators )
2022export const commandCategories = new Map < string , CommandCategory > ( [
2123 // ReadOnly commands
2224 [ 'ls' , CommandCategory . ReadOnly ] ,
@@ -163,17 +165,17 @@ export class ExecuteBash {
163165 return { requiresAcceptance : true }
164166 }
165167
166- // Split commands by pipe and process each segment
168+ // Split commands by operators and process each segment
167169 let currentCmd : string [ ] = [ ]
168170 const allCommands : string [ ] [ ] = [ ]
169171
170172 for ( const arg of args ) {
171- if ( arg === '|' ) {
173+ if ( splitOperators . has ( arg ) ) {
172174 if ( currentCmd . length > 0 ) {
173175 allCommands . push ( currentCmd )
174176 }
175177 currentCmd = [ ]
176- } else if ( arg . includes ( '|' ) ) {
178+ } else if ( splitOperatorsArray . some ( ( op ) => arg . includes ( op ) ) ) {
177179 return { requiresAcceptance : true }
178180 } else {
179181 currentCmd . push ( arg )
@@ -208,12 +210,12 @@ export class ExecuteBash {
208210 ) {
209211 return { requiresAcceptance : true , warning : highRiskCommandWarningMessage }
210212 }
211- return { requiresAcceptance : false }
213+ continue
212214 default :
213215 return { requiresAcceptance : true , warning : highRiskCommandWarningMessage }
214216 }
215217 }
216- return { requiresAcceptance : true }
218+ return { requiresAcceptance : false }
217219 } catch ( error ) {
218220 this . logger . warn ( `Error while checking acceptance: ${ ( error as Error ) . message } ` )
219221 return { requiresAcceptance : true }
0 commit comments