@@ -26,6 +26,9 @@ import (
2626 "github.com/trufflesecurity/trufflehog/v3/pkg/decoders"
2727 "github.com/trufflesecurity/trufflehog/v3/pkg/engine"
2828 "github.com/trufflesecurity/trufflehog/v3/pkg/output"
29+ "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
30+ "github.com/trufflesecurity/trufflehog/v3/pkg/pb/source_metadatapb"
31+ "github.com/trufflesecurity/trufflehog/v3/pkg/pb/sourcespb"
2932 "github.com/trufflesecurity/trufflehog/v3/pkg/sources/git"
3033)
3134
@@ -246,7 +249,41 @@ func run(state overseer.State) {
246249 os .RemoveAll (repoPath )
247250 }
248251 case * jsonOut :
249- out , err := json .Marshal (r )
252+ v := & struct {
253+ // SourceMetadata contains source-specific contextual information.
254+ SourceMetadata * source_metadatapb.MetaData
255+ // SourceID is the ID of the source that the API uses to map secrets to specific sources.
256+ SourceID int64
257+ // SourceType is the type of Source.
258+ SourceType sourcespb.SourceType
259+ // SourceName is the name of the Source.
260+ SourceName string
261+ // DetectorType is the type of Detector.
262+ DetectorType detectorspb.DetectorType
263+ // DetectorName is the string name of the DetectorType.
264+ DetectorName string
265+ Verified bool
266+ // Raw contains the raw secret identifier data. Prefer IDs over secrets since it is used for deduping after hashing.
267+ Raw []byte
268+ // Redacted contains the redacted version of the raw secret identification data for display purposes.
269+ // A secret ID should be used if available.
270+ Redacted string
271+ ExtraData map [string ]string
272+ StructuredData * detectorspb.StructuredData
273+ }{
274+ SourceMetadata : r .SourceMetadata ,
275+ SourceID : r .SourceID ,
276+ SourceType : r .SourceType ,
277+ SourceName : r .SourceName ,
278+ DetectorType : r .DetectorType ,
279+ DetectorName : r .DetectorType .String (),
280+ Verified : r .Verified ,
281+ Raw : r .Raw ,
282+ Redacted : r .Redacted ,
283+ ExtraData : r .ExtraData ,
284+ StructuredData : r .StructuredData ,
285+ }
286+ out , err := json .Marshal (v )
250287 if err != nil {
251288 logrus .WithError (err ).Fatal ("could not marshal result" )
252289 }
0 commit comments