report.go 628 B

1234567891011121314151617181920212223242526272829303132
  1. package report
  2. import (
  3. "os"
  4. "strings"
  5. "github.com/zricethezav/gitleaks/v8/config"
  6. )
  7. const (
  8. // https://cwe.mitre.org/data/definitions/798.html
  9. CWE = "CWE-798"
  10. CWE_DESCRIPTION = "Use of Hard-coded Credentials"
  11. )
  12. func Write(findings []Finding, cfg config.Config, ext string, reportPath string) error {
  13. file, err := os.Create(reportPath)
  14. if err != nil {
  15. return err
  16. }
  17. ext = strings.ToLower(ext)
  18. switch ext {
  19. case ".json", "json":
  20. err = writeJson(findings, file)
  21. case ".csv", "csv":
  22. err = writeCsv(findings, file)
  23. case ".sarif", "sarif":
  24. err = writeSarif(cfg, findings, file)
  25. }
  26. return err
  27. }