From df32c1ce03d2de748cecb76cff383f2851e198c3 Mon Sep 17 00:00:00 2001 From: Wilian Gabriel Date: Thu, 7 Apr 2022 09:18:23 -0300 Subject: [PATCH] analyzer:fix - Fixing details wrong (#1054) Signed-off-by: Wilian Gabriel (cherry picked from commit 39d4c9c7450929ba132472d477f94ac1c44484de) Signed-off-by: Wilian Gabriel --- internal/controllers/analyzer/analyzer.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/controllers/analyzer/analyzer.go b/internal/controllers/analyzer/analyzer.go index c6490c281..d83d661b6 100644 --- a/internal/controllers/analyzer/analyzer.go +++ b/internal/controllers/analyzer/analyzer.go @@ -15,7 +15,6 @@ package analyzer import ( - "bytes" "fmt" "strings" "time" @@ -505,7 +504,7 @@ func (a *Analyzer) setCounterOfDetailsDuplicated( ) (newAnalysisVulnerabilities []analysis.AnalysisVulnerabilities) { for indexAV := range analysisVulnerabilities { currentAV := analysisVulnerabilities[indexAV] - newDetails := bytes.NewBufferString("") + newDetails := "" detailEmptySplit := strings.Split(currentAV.Vulnerability.Details, detailsHeaderText) detailToSetSplit := make([]string, 0) for _, d := range detailEmptySplit { @@ -518,10 +517,10 @@ func (a *Analyzer) setCounterOfDetailsDuplicated( if indexDS+1 == len(detailToSetSplit) { lastChar = "" } - _, _ = fmt.Fprintf(newDetails, "%s(%v/%v) %s%s%s", newDetails, indexDS+1, len(detailToSetSplit), + newDetails = fmt.Sprintf("%s(%v/%v) %s%s%s", newDetails, indexDS+1, len(detailToSetSplit), detailsHeaderText, detail, lastChar) } - currentAV.Vulnerability.Details = newDetails.String() + currentAV.Vulnerability.Details = newDetails newAnalysisVulnerabilities = append(newAnalysisVulnerabilities, currentAV) } return newAnalysisVulnerabilities