Skip to content

Find, verify, and analyze leaked credentials

Move DecoderType into ResultWithMetadata #3502

Cody Rosead15888a331a
diff --git a/pkg/detectors/detectors.go b/pkg/detectors/detectors.go
index 71fc8514f..14eccba8e 100644
--- a/pkg/detectors/detectors.go
+++ b/pkg/detectors/detectors.go
@@ -89,9 +89,7 @@ type Result struct {
DetectorType detectorspb.DetectorType
// DetectorName is the name of the Detector. Used for custom detectors.
DetectorName string
- // DecoderType is the type of Decoder.
- DecoderType detectorspb.DecoderType
- Verified bool
+ Verified bool
// Raw contains the raw secret identifier data. Prefer IDs over secrets since it is used for deduping after hashing.
Raw []byte
// RawV2 contains the raw secret identifier that is a combination of both the ID and the secret.
@@ -168,6 +166,8 @@ type ResultWithMetadata struct {
Result
// Data from the sources.Chunk which this result was emitted for
Data []byte
+ // DecoderType is the type of decoder that was used to generate this result's data.
+ DecoderType detectorspb.DecoderType
}
// CopyMetadata returns a detector result with included metadata from the source chunk.
diff --git a/pkg/output/github_actions.go b/pkg/output/github_actions.go
index e6beaaa8c..a88a7e4e3 100644
--- a/pkg/output/github_actions.go
+++ b/pkg/output/github_actions.go
@@ -19,7 +19,7 @@ type GitHubActionsPrinter struct{ mu sync.Mutex }
func (p *GitHubActionsPrinter) Print(_ context.Context, r *detectors.ResultWithMetadata) error {
out := gitHubActionsOutputFormat{
DetectorType: r.Result.DetectorType.String(),
- DecoderType: r.Result.DecoderType.String(),
+ DecoderType: r.DecoderType.String(),
Verified: r.Result.Verified,
}
@@ -60,7 +60,7 @@ func (p *GitHubActionsPrinter) Print(_ context.Context, r *detectors.ResultWithM
dedupeCache[key] = struct{}{}
message := fmt.Sprintf("Found %s %s result πŸ·πŸ”‘\n", verifiedStatus, out.DetectorType)
- if r.Result.DecoderType != detectorspb.DecoderType_PLAIN {
+ if r.DecoderType != detectorspb.DecoderType_PLAIN {
message = fmt.Sprintf("Found %s %s result with %s encoding πŸ·πŸ”‘\n", verifiedStatus, out.DetectorType, out.DecoderType)
}
diff --git a/pkg/output/plain.go b/pkg/output/plain.go
index 202e44cc4..91e4c8abb 100644
--- a/pkg/output/plain.go
+++ b/pkg/output/plain.go
@@ -30,7 +30,7 @@ type PlainPrinter struct{ mu sync.Mutex }
func (p *PlainPrinter) Print(_ context.Context, r *detectors.ResultWithMetadata) error {
out := outputFormat{
DetectorType: r.Result.DetectorType.String(),
- DecoderType: r.Result.DecoderType.String(),
+ DecoderType: r.DecoderType.String(),
Verified: r.Result.Verified,
VerificationError: r.Result.VerificationError(),
MetaData: r.SourceMetadata,