2021-05-06 08:31:51 +01:00
|
|
|
package csv
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/csv"
|
|
|
|
"github.com/securego/gosec/v2/report/core"
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
|
|
|
//WriteReport write a report in csv format to the output writer
|
|
|
|
func WriteReport(w io.Writer, data *core.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,
|
2021-05-07 15:54:34 +01:00
|
|
|
issue.Cwe.SprintID(),
|
2021-05-06 08:31:51 +01:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|