Merge pull request #578 from replicatedhq/emosbaugh/sc-48809/analyze-api-fromanalyzerresult-invalid-memory

filter nil analyzer results to prevent panic
This commit is contained in:
Ethan Mosbaugh
2022-05-23 14:35:39 -07:00
committed by GitHub
2 changed files with 9 additions and 2 deletions
+5 -2
View File
@@ -38,8 +38,11 @@ func AnalyzeLocal(localBundlePath string, analyzers []*troubleshootv1beta2.Analy
continue
}
if analyzeResult != nil {
analyzeResults = append(analyzeResults, analyzeResult...)
// Filter nil results to prevent panic
for _, r := range analyzeResult {
if r != nil {
analyzeResults = append(analyzeResults, r)
}
}
}
+4
View File
@@ -69,6 +69,10 @@ func FromAnalyzerResult(input []*analyze.AnalyzeResult) []*Result {
result := make([]*Result, 0)
for _, i := range input {
// Continue on nil result to prevent panic
if i == nil {
continue
}
name := reg.ReplaceAllString(strings.ToLower(i.Title), ".")
r := &Result{
Meta: Meta{