gosec/report/csv/writer.go

30 lines
517 B
Go
Raw Normal View History

package csv
import (
"encoding/csv"
"io"
2021-05-20 09:16:42 +01:00
"github.com/securego/gosec/v2"
)
//WriteReport write a report in csv format to the output writer
2021-05-20 09:16:42 +01:00
func WriteReport(w io.Writer, data *gosec.ReportInfo) error {
out := csv.NewWriter(w)
defer out.Flush()
for _, issue := range data.Issues {
err := out.Write([]string{
issue.File,
issue.Line,
issue.What,
issue.Severity.String(),
issue.Confidence.String(),
issue.Code,
issue.Cwe.SprintID(),
})
if err != nil {
return err
}
}
return nil
}