@@ -26,6 +26,9 @@ import (
26
26
"github.com/trufflesecurity/trufflehog/v3/pkg/decoders"
27
27
"github.com/trufflesecurity/trufflehog/v3/pkg/engine"
28
28
"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"
29
32
"github.com/trufflesecurity/trufflehog/v3/pkg/sources/git"
30
33
)
31
34
@@ -246,7 +249,41 @@ func run(state overseer.State) {
246
249
os .RemoveAll (repoPath )
247
250
}
248
251
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 )
250
287
if err != nil {
251
288
logrus .WithError (err ).Fatal ("could not marshal result" )
252
289
}
0 commit comments