@@ -22,9 +22,9 @@ import (
22
22
"os"
23
23
"time"
24
24
25
- "github.com/rs/zerolog/log"
26
25
"github.com/spf13/cobra"
27
26
27
+ "github.com/zricethezav/gitleaks/v8/logging"
28
28
"github.com/zricethezav/gitleaks/v8/report"
29
29
"github.com/zricethezav/gitleaks/v8/sources"
30
30
)
@@ -48,7 +48,7 @@ var detectCmd = &cobra.Command{
48
48
func runDetect (cmd * cobra.Command , args []string ) {
49
49
source , err := cmd .Flags ().GetString ("source" )
50
50
if err != nil {
51
- log .Fatal ().Err (err ).Msg ("could not get source" )
51
+ logging .Fatal ().Err (err ).Msg ("could not get source" )
52
52
}
53
53
initConfig (source )
54
54
@@ -64,24 +64,24 @@ func runDetect(cmd *cobra.Command, args []string) {
64
64
65
65
// set follow symlinks flag
66
66
if detector .FollowSymlinks , err = cmd .Flags ().GetBool ("follow-symlinks" ); err != nil {
67
- log .Fatal ().Err (err ).Msg ("" )
67
+ logging .Fatal ().Err (err ).Msg ("" )
68
68
}
69
69
// set exit code
70
70
exitCode , err := cmd .Flags ().GetInt ("exit-code" )
71
71
if err != nil {
72
- log .Fatal ().Err (err ).Msg ("could not get exit code" )
72
+ logging .Fatal ().Err (err ).Msg ("could not get exit code" )
73
73
}
74
74
75
75
// determine what type of scan:
76
76
// - git: scan the history of the repo
77
77
// - no-git: scan files by treating the repo as a plain directory
78
78
noGit , err := cmd .Flags ().GetBool ("no-git" )
79
79
if err != nil {
80
- log .Fatal ().Err (err ).Msg ("could not call GetBool() for no-git" )
80
+ logging .Fatal ().Err (err ).Msg ("could not call GetBool() for no-git" )
81
81
}
82
82
fromPipe , err := cmd .Flags ().GetBool ("pipe" )
83
83
if err != nil {
84
- log .Fatal ().Err (err ).Msg ("could not call GetBool() for pipe" )
84
+ logging .Fatal ().Err (err ).Msg ("could not call GetBool() for pipe" )
85
85
}
86
86
87
87
// start the detector scan
@@ -94,20 +94,20 @@ func runDetect(cmd *cobra.Command, args []string) {
94
94
detector .Config .Allowlist .PathAllowed ,
95
95
)
96
96
if err != nil {
97
- log .Fatal ().Err (err )
97
+ logging .Fatal ().Err (err )
98
98
}
99
99
100
100
findings , err = detector .DetectFiles (paths )
101
101
if err != nil {
102
102
// don't exit on error, just log it
103
- log .Error ().Err (err ).Msg ("failed scan directory" )
103
+ logging .Error ().Err (err ).Msg ("failed scan directory" )
104
104
}
105
105
} else if fromPipe {
106
106
findings , err = detector .DetectReader (os .Stdin , 10 )
107
107
if err != nil {
108
108
// log fatal to exit, no need to continue since a report
109
109
// will not be generated when scanning from a pipe...for now
110
- log .Fatal ().Err (err ).Msg ("failed scan input from stdin" )
110
+ logging .Fatal ().Err (err ).Msg ("failed scan input from stdin" )
111
111
}
112
112
} else {
113
113
var (
@@ -116,16 +116,16 @@ func runDetect(cmd *cobra.Command, args []string) {
116
116
)
117
117
logOpts , err = cmd .Flags ().GetString ("log-opts" )
118
118
if err != nil {
119
- log .Fatal ().Err (err ).Msg ("could not call GetString() for log-opts" )
119
+ logging .Fatal ().Err (err ).Msg ("could not call GetString() for log-opts" )
120
120
}
121
121
gitCmd , err = sources .NewGitLogCmd (source , logOpts )
122
122
if err != nil {
123
- log .Fatal ().Err (err ).Msg ("could not create Git cmd" )
123
+ logging .Fatal ().Err (err ).Msg ("could not create Git cmd" )
124
124
}
125
125
findings , err = detector .DetectGit (gitCmd )
126
126
if err != nil {
127
127
// don't exit on error, just log it
128
- log .Error ().Err (err ).Msg ("failed to scan Git repository" )
128
+ logging .Error ().Err (err ).Msg ("failed to scan Git repository" )
129
129
}
130
130
}
131
131
0 commit comments