File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -169,8 +169,31 @@ func runTaskCommand(cmd *cobra.Command, args []string) error {
169169
170170 // Prepare environment injects
171171 shimsDir := env .GetShimsDir ()
172+
173+ // Safe PATH merging to avoid hardcoded colons and exponential explosion on Windows
174+ newPath := shimsDir + string (os .PathListSeparator ) + env .Get ("PATH" )
175+
176+ // Deduplicate inline to keep PATH clean
177+ parts := strings .Split (newPath , string (os .PathListSeparator ))
178+ seen := make (map [string ]bool )
179+ var result []string
180+ for _ , p := range parts {
181+ if p == "" {
182+ continue
183+ }
184+ key := p
185+ if string (os .PathSeparator ) == "\\ " { // Windows check
186+ key = strings .ToLower (p )
187+ }
188+ if ! seen [key ] {
189+ seen [key ] = true
190+ result = append (result , p )
191+ }
192+ }
193+ cleanPath := strings .Join (result , string (os .PathListSeparator ))
194+
172195 envInjects := []string {
173- fmt .Sprintf ("PATH=%s:%s " , shimsDir , env . Get ( "PATH" ) ),
196+ fmt .Sprintf ("PATH=%s" , cleanPath ),
174197 }
175198
176199 isFix , _ := cmd .Flags ().GetBool ("fix" )
You can’t perform that action at this time.
0 commit comments