main.go 651 B

12345678910111213141516171819202122232425262728
  1. package main
  2. import (
  3. "os"
  4. "strings"
  5. log "github.com/sirupsen/logrus"
  6. gitleaks "github.com/zricethezav/gitleaks/src"
  7. )
  8. func main() {
  9. report, err := gitleaks.Run(gitleaks.ParseOpts())
  10. if err != nil {
  11. if strings.Contains(err.Error(), "whitelisted") {
  12. log.Info(err.Error())
  13. os.Exit(0)
  14. }
  15. log.Error(err)
  16. os.Exit(gitleaks.ErrExit)
  17. }
  18. if len(report.Leaks) != 0 {
  19. log.Warnf("%d leaks detected. %d commits inspected in %s", len(report.Leaks), report.Commits, report.Duration)
  20. os.Exit(gitleaks.LeakExit)
  21. } else {
  22. log.Infof("%d leaks detected. %d commits inspected in %s", len(report.Leaks), report.Commits, report.Duration)
  23. }
  24. }