mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 04:34:46 +01:00
feat(report): allow user-defined templates (#1650)
This commit is contained in:
1 parent
e393d299bc
commit
83e99bacf1
72 files changed
+586
-549
No files matched your search
+3
-14
@@ -5,23 +5,12 @@ import (
|
||||
"io"
|
||||
)
|
||||
|
||||
func writeJson(findings []Finding, w io.WriteCloser) error {
|
||||
if len(findings) == 0 {
|
||||
findings = []Finding{}
|
||||
}
|
||||
for i := range findings {
|
||||
// Remove `Line` from JSON output
|
||||
findings[i].Line = ""
|
||||
}
|
||||
return writeJsonExtra(findings, w)
|
||||
type JsonReporter struct {
|
||||
}
|
||||
|
||||
func writeJsonExtra(findings []Finding, w io.WriteCloser) error {
|
||||
if len(findings) == 0 {
|
||||
findings = []Finding{}
|
||||
}
|
||||
defer w.Close()
|
||||
var _ Reporter = (*JsonReporter)(nil)
|
||||
|
||||
func (t *JsonReporter) Write(w io.WriteCloser, findings []Finding) error {
|
||||
encoder := json.NewEncoder(w)
|
||||
encoder.SetIndent("", " ")
|
||||
return encoder.Encode(findings)
|
||||
|
||||
Reference in new issue
Block a user