Updated stdout to print results in alphabetical order for consistent output (#1032)
This commit is contained in:
+13
-1
@@ -3,10 +3,13 @@ package output
|
||||
import (
|
||||
"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("")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user