Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Updated stdout to print results in alphabetical order for consistent output (#1032)
ahmed2060ae1c47be
diff --git a/pkg/output/plain.go b/pkg/output/plain.goindex a8284d898..70b1cd3e7 100644--- a/pkg/output/plain.go+++ b/pkg/output/plain.go@@ -3,10 +3,13 @@ package outputimport ("encoding/json""fmt"+ "sort""strings""github.com/fatih/color""github.com/sirupsen/logrus"+ "golang.org/x/text/cases"+ "golang.org/x/text/language""github.com/trufflesecurity/trufflehog/v3/pkg/detectors""github.com/trufflesecurity/trufflehog/v3/pkg/pb/source_metadatapb"@@ -43,11 +46,20 @@ func PrintPlainOutput(r *detectors.ResultWithMetadata) {printer.Printf("Detector Type: %s\n", out.DetectorType)printer.Printf("Decoder Type: %s\n", out.DecoderType)printer.Printf("Raw result: %s\n", whitePrinter.Sprint(out.Raw))++ var aggregateData = make(map[string]interface{})+ var aggregateDataKeys []string+for _, data := range meta {for k, v := range data {- printer.Printf("%s: %v\n", strings.Title(k), v)+ aggregateDataKeys = append(aggregateDataKeys, k)+ aggregateData[k] = v}}+ sort.Strings(aggregateDataKeys)+ for _, k := range aggregateDataKeys {+ printer.Printf("%s: %v\n", cases.Title(language.AmericanEnglish).String(k), aggregateData[k])+ }fmt.Println("")}