Add RawV2 Results to the JSON Output (#1273)

* Add RawV2 to JSON Output

* Adding RawV2 results to Azure, Datadog and GCP Detectors
This commit is contained in:
Yassine Ilmi 2023-04-21 01:31:53 +02:00 committed by GitHub
parent cec1543894
commit a002ba9a75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View file

@ -54,6 +54,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
s := detectors.Result{
DetectorType: detectorspb.DetectorType_Azure,
Raw: []byte(clientSecret[2]),
RawV2: []byte(clientID[2] + clientSecret[2] + tenantID[2]),
Redacted: clientID[2],
}

View file

@ -51,6 +51,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
s1 := detectors.Result{
DetectorType: detectorspb.DetectorType_DatadogToken,
Raw: []byte(resMatch),
RawV2: []byte(resMatch + resApiMatch),
}
if verify {

View file

@ -29,6 +29,9 @@ func PrintJSON(r *detectors.ResultWithMetadata) error {
Verified bool
// Raw contains the raw secret data.
Raw string
// RawV2 contains the raw secret identifier that is a combination of both the ID and the secret.
// This is used for secrets that are multi part and could have the same ID. Ex: AWS credentials
RawV2 string
// Redacted contains the redacted version of the raw secret identification data for display purposes.
// A secret ID should be used if available.
Redacted string
@ -44,6 +47,7 @@ func PrintJSON(r *detectors.ResultWithMetadata) error {
DecoderName: r.DecoderType.String(),
Verified: r.Verified,
Raw: string(r.Raw),
RawV2: string(r.RawV2),
Redacted: r.Redacted,
ExtraData: r.ExtraData,
StructuredData: r.StructuredData,