Skip to content

Commit

Permalink
fix: added protection against while-true condition in unbounded for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesimpson36 committed Jan 1, 2025
1 parent 305f316 commit ae8a93a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func determineIfFormattedErrorIsAcceptable(formattedErr error, originalErr error
if equivalenceRating >= 80 {
return formattedErr
}
return originalErr
return fmt.Errorf("%s", originalErr.Error())
}

func cleanupExecError(filename string, err error) error {
Expand All @@ -407,7 +407,8 @@ func cleanupExecError(filename string, err error) error {
}
current := err
fileLocations := []TraceableError{}
for {
maxIterations := 100
for i := 0; i < maxIterations && current != nil; i++ {
if current == nil {
break
}
Expand All @@ -420,6 +421,9 @@ func cleanupExecError(filename string, err error) error {
fileLocations = append(fileLocations, traceable)
current = errors.Unwrap(current)
}
if current != nil {
return fmt.Errorf("%s", err.Error())
}

prevMessage := ""
for i := len(fileLocations) - 1; i >= 0; i-- {
Expand Down

0 comments on commit ae8a93a

Please sign in to comment.