Skip to content

Find, verify, and analyze leaked credentials

Add RawV2 Results to the JSON Output (#1273)

Yassine Ilmia002ba9a7543
diff --git a/pkg/detectors/azure/azure.go b/pkg/detectors/azure/azure.go
index 509f44f86..57868cb5e 100644
--- a/pkg/detectors/azure/azure.go
+++ b/pkg/detectors/azure/azure.go
@@ -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],
}
diff --git a/pkg/detectors/datadogtoken/datadogtoken.go b/pkg/detectors/datadogtoken/datadogtoken.go
index 4e86ba620..fe75fc705 100644
--- a/pkg/detectors/datadogtoken/datadogtoken.go
+++ b/pkg/detectors/datadogtoken/datadogtoken.go
@@ -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 {
diff --git a/pkg/output/json.go b/pkg/output/json.go
index 2d3aecdb6..a37c5830e 100644
--- a/pkg/output/json.go
+++ b/pkg/output/json.go
@@ -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,