diff --git a/main.go b/main.go index 32bc61f9..26f3c459 100644 --- a/main.go +++ b/main.go @@ -61,6 +61,10 @@ func main() { log.Error(err) os.Exit(1) } + + if len(scannerReport.Leaks) != 0 { + os.Exit(opts.CodeOnLeak) + } } func listenForInterrupt(stopScan chan os.Signal) { diff --git a/options/options.go b/options/options.go index 0b6cbeea..f8480a6c 100644 --- a/options/options.go +++ b/options/options.go @@ -37,6 +37,7 @@ type Options struct { Redact bool `long:"redact" description:"Redact secrets from log messages and leaks"` Debug bool `long:"debug" description:"Log debug messages"` NoGit bool `long:"no-git" description:"Treat git repos as plain directories and scan those files"` + CodeOnLeak int `long:"leaks-exit-code" default:"1" description:"Exit code when leaks have been encountered"` // Report Options Report string `short:"o" long:"report" description:"Report output path"`