2021-05-06 08:31:51 +01:00
|
|
|
package sonar
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io"
|
2021-05-20 09:16:42 +01:00
|
|
|
|
|
|
|
"github.com/securego/gosec/v2"
|
2021-05-06 08:31:51 +01:00
|
|
|
)
|
|
|
|
|
2021-05-31 09:44:12 +01:00
|
|
|
// WriteReport write a report in sonar format to the output writer
|
2021-05-20 09:16:42 +01:00
|
|
|
func WriteReport(w io.Writer, data *gosec.ReportInfo, rootPaths []string) error {
|
2021-05-06 08:31:51 +01:00
|
|
|
si, err := GenerateReport(rootPaths, data)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
raw, err := json.MarshalIndent(si, "", "\t")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
_, err = w.Write(raw)
|
|
|
|
return err
|
|
|
|
}
|