2021-05-06 08:31:51 +01:00
|
|
|
package html
|
|
|
|
|
|
|
|
import (
|
2021-11-15 15:17:22 +00:00
|
|
|
// use go embed to import template
|
|
|
|
_ "embed"
|
2021-05-06 08:31:51 +01:00
|
|
|
"html/template"
|
|
|
|
"io"
|
2021-05-20 09:16:42 +01:00
|
|
|
|
|
|
|
"github.com/securego/gosec/v2"
|
2021-05-06 08:31:51 +01:00
|
|
|
)
|
|
|
|
|
2021-11-15 15:17:22 +00:00
|
|
|
//go:embed template.html
|
|
|
|
var templateContent string
|
|
|
|
|
2021-05-31 09:44:12 +01:00
|
|
|
// WriteReport write a report in html format to the output writer
|
2021-05-20 09:16:42 +01:00
|
|
|
func WriteReport(w io.Writer, data *gosec.ReportInfo) error {
|
2021-05-06 08:31:51 +01:00
|
|
|
t, e := template.New("gosec").Parse(templateContent)
|
|
|
|
if e != nil {
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
return t.Execute(w, data)
|
|
|
|
}
|