Skip to content

Find, verify, and analyze leaked credentials

Fix test (#2339)

Dustin Deckerf078df43eb27
diff --git a/pkg/detectors/yelp/yelp.go b/pkg/detectors/yelp/yelp.go
index 3f04269dd..11dd05a5e 100644
--- a/pkg/detectors/yelp/yelp.go
+++ b/pkg/detectors/yelp/yelp.go
@@ -3,10 +3,11 @@ package yelp
import (
"context"
"fmt"
- regexp "github.com/wasilibs/go-re2"
"net/http"
"strings"
+ regexp "github.com/wasilibs/go-re2"
+
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
@@ -69,10 +70,10 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
} else if res.StatusCode == 401 || res.StatusCode == 403 {
// The secret is determinately not verified (nothing to do)
} else {
- s1.VerificationError = fmt.Errorf("unexpected HTTP response status %d", res.StatusCode)
+ s1.SetVerificationError(fmt.Errorf("unexpected HTTP response status %d", res.StatusCode), resMatch)
}
} else {
- s1.VerificationError = err
+ s1.SetVerificationError(err, resMatch)
}
// This function will check false positives for common test words, but also it will make sure the key appears 'random' enough to be a real key.
diff --git a/pkg/detectors/yelp/yelp_test.go b/pkg/detectors/yelp/yelp_test.go
index 64ca842ea..cdb8bebeb 100644
--- a/pkg/detectors/yelp/yelp_test.go
+++ b/pkg/detectors/yelp/yelp_test.go
@@ -134,11 +134,11 @@ func TestYelp_FromChunk(t *testing.T) {
}
got[i].Raw = nil
- if (got[i].VerificationError != nil) != tt.wantVerificationErr {
- t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError)
+ if (got[i].VerificationError() != nil) != tt.wantVerificationErr {
+ t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError())
}
}
- ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "VerificationError")
+ ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError")
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
t.Errorf("SlackWebhook.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
}