Переглянути джерело

Exit code update, introduce leaks-exit-code flag (#481)

Zachary Rice 5 роки тому
батько
коміт
3909ebe03b
2 змінених файлів з 5 додано та 0 видалено
  1. 4 0
      main.go
  2. 1 0
      options/options.go

+ 4 - 0
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) {

+ 1 - 0
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"`