mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 13:14:22 +01:00
adding pretty print option
This commit is contained in:
1 parent
315ee56024
commit
c8f9560aa3
2 files changed
+10
-4
No files matched your search
+6
-1
@@ -114,7 +114,12 @@ func (manager *Manager) receiveLeaks() {
|
|||||||
for leak := range manager.leakChan {
|
for leak := range manager.leakChan {
|
||||||
manager.leaks = append(manager.leaks, leak)
|
manager.leaks = append(manager.leaks, leak)
|
||||||
if manager.Opts.Verbose {
|
if manager.Opts.Verbose {
|
||||||
b, _ := json.Marshal(leak)
|
var b []byte
|
||||||
|
if manager.Opts.PrettyPrint {
|
||||||
|
b, _ = json.MarshalIndent(leak, "", " ")
|
||||||
|
} else {
|
||||||
|
b, _ = json.Marshal(leak)
|
||||||
|
}
|
||||||
fmt.Println(string(b))
|
fmt.Println(string(b))
|
||||||
}
|
}
|
||||||
manager.leakWG.Done()
|
manager.leakWG.Done()
|
||||||
|
|||||||
+4
-3
@@ -18,9 +18,9 @@ import (
|
|||||||
// This block defines the exit codes. Success
|
// This block defines the exit codes. Success
|
||||||
const (
|
const (
|
||||||
// No leaks or early exit due to invalid options
|
// No leaks or early exit due to invalid options
|
||||||
Success int = iota + 1
|
Success = 0
|
||||||
LeaksPresent
|
LeaksPresent = 1
|
||||||
ErrorEncountered
|
ErrorEncountered = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
// Options stores values of command line options
|
// Options stores values of command line options
|
||||||
@@ -45,6 +45,7 @@ type Options struct {
|
|||||||
Redact bool `long:"redact" description:"redact secrets from log messages and leaks"`
|
Redact bool `long:"redact" description:"redact secrets from log messages and leaks"`
|
||||||
Debug bool `long:"debug" description:"log debug messages"`
|
Debug bool `long:"debug" description:"log debug messages"`
|
||||||
RepoConfig bool `long:"repo-config" description:"Load config from target repo. Config file must be \".gitleaks.toml\" or \"gitleaks.toml\""`
|
RepoConfig bool `long:"repo-config" description:"Load config from target repo. Config file must be \".gitleaks.toml\" or \"gitleaks.toml\""`
|
||||||
|
PrettyPrint bool `long:"pretty" description:"Pretty print json if leaks are present"`
|
||||||
|
|
||||||
// Hosts
|
// Hosts
|
||||||
Host string `long:"host" description:"git hosting service like gitlab or github. Supported hosts include: Github, Gitlab"`
|
Host string `long:"host" description:"git hosting service like gitlab or github. Supported hosts include: Github, Gitlab"`
|
||||||
|
|||||||
Reference in new issue
Block a user