Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Fix crash when scanning with json-legacy flag on a github repo. (#491)
ahravac6fc02f3650
diff --git a/main.go b/main.goindex a5e45314f..f290207fc 100644--- a/main.go+++ b/main.go@@ -167,9 +167,9 @@ func run(state overseer.State) {}var repoPath string+ var remote boolswitch cmd {case gitScan.FullCommand():- var remote boolrepoPath, remote, err = git.PrepareRepo(*gitScanURI)if err != nil || repoPath == "" {logrus.WithError(err).Fatal("error preparing git repo for scanning")@@ -219,12 +219,20 @@ func run(state overseer.State) {switch {case *jsonLegacy:+ repoPath, remote, err = git.PrepareRepo(r.SourceMetadata.GetGithub().Repository)+ if err != nil || repoPath == "" {+ logrus.WithError(err).Fatal("error preparing git repo for scanning")+ }legacy := output.ConvertToLegacyJSON(&r, repoPath)out, err := json.Marshal(legacy)if err != nil {logrus.WithError(err).Fatal("could not marshal result")}fmt.Println(string(out))++ if remote {+ os.RemoveAll(repoPath)+ }case *jsonOut:out, err := json.Marshal(r)if err != nil {diff --git a/pkg/output/legacy_json.go b/pkg/output/legacy_json.goindex 08c80a386..08a7d906a 100644--- a/pkg/output/legacy_json.go+++ b/pkg/output/legacy_json.go@@ -32,7 +32,7 @@ func ConvertToLegacyJSON(r *detectors.ResultWithMetadata, repoPath string) *Lega// output format.repo, err := gogit.PlainOpenWithOptions(repoPath, &gogit.PlainOpenOptions{DetectDotGit: true})if err != nil {- logrus.WithError(err).Fatalf("could open repo: %s", repoPath)+ logrus.WithError(err).Fatalf("could not open repo: %s", repoPath)}fileName := source.GetFile()