Files
gitleaks/report/report.go
T
Bryce Thuilot f3adda07ca feat: use STDOUT when report file not specified (#1642)
* feat: use STDOUT when report file not specified

Signed-off-by: Bryce Thuilot <bryce@thuilot.io>

* fix: update tests

Signed-off-by: Bryce Thuilot <bryce@thuilot.io>

* fix: use only '-' for stdout report

Signed-off-by: Bryce Thuilot <bryce@thuilot.io>

---------

Signed-off-by: Bryce Thuilot <bryce@thuilot.io>
2024-12-05 09:44:07 -06:00

34 lines
718 B
Go

package report
import (
"io"
"strings"
"github.com/zricethezav/gitleaks/v8/config"
)
const (
// https://cwe.mitre.org/data/definitions/798.html
CWE = "CWE-798"
CWE_DESCRIPTION = "Use of Hard-coded Credentials"
)
func Write(findings []Finding, cfg config.Config, ext string, report io.WriteCloser) error {
var err error
ext = strings.ToLower(ext)
switch ext {
case ".json", "json":
err = writeJson(findings, report)
case ".jsonextra", "jsonextra":
err = writeJsonExtra(findings, report)
case ".csv", "csv":
err = writeCsv(findings, report)
case ".xml", "junit":
err = writeJunit(findings, report)
case ".sarif", "sarif":
err = writeSarif(cfg, findings, report)
}
return err
}