Rename AnalysisInfo field to SecretParts on detectors.Result (#4911)
Mechanical rename of the detectors.Result.AnalysisInfo field to SecretParts to prepare for its replacement for Raw.
This commit is contained in:
@@ -71,7 +71,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr)
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{"key": key}
|
||||
s1.SecretParts = map[string]string{"key": key}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr)
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{"key": key}
|
||||
s1.SecretParts = map[string]string{"key": key}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr, match)
|
||||
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{"token": match}
|
||||
s1.SecretParts = map[string]string{"token": match}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr, match)
|
||||
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{"token": match}
|
||||
s1.SecretParts = map[string]string{"token": match}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(err, keyMatch)
|
||||
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": keyMatch,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ func TestAnthropic_FromChunk(t *testing.T) {
|
||||
t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "SecretParts")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("Anthropic.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr)
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"client_id": id,
|
||||
"client_secret": secret,
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr, token)
|
||||
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"domain": url,
|
||||
"token": token,
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"domain": url,
|
||||
"token": token,
|
||||
}
|
||||
|
||||
+2
-2
@@ -142,7 +142,7 @@ func TestArtifactoryreferencetoken_FromChunk(t *testing.T) {
|
||||
t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "primarySecret", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "primarySecret", "SecretParts")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("Artifactoryreferencetoken.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
@@ -188,7 +188,7 @@ func TestArtifactoryreferencetoken_FromChunk_WithCustomEndpoint(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "primarySecret", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "primarySecret", "SecretParts")
|
||||
if diff := cmp.Diff(got, want, ignoreOpts); diff != "" {
|
||||
t.Errorf("Artifactoryreferencetoken.FromData() diff: (-got +want)\n%s", diff)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
isVerified, err := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(err, resMatch)
|
||||
s1.AnalysisInfo = map[string]string{"key": resMatch}
|
||||
s1.SecretParts = map[string]string{"key": resMatch}
|
||||
}
|
||||
|
||||
results = append(results, s1)
|
||||
|
||||
@@ -95,7 +95,7 @@ func TestAsanaOauth_FromChunk(t *testing.T) {
|
||||
t.Fatalf("no raw secret present: \n %+v", got[i])
|
||||
}
|
||||
got[i].Raw = nil
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
if diff := pretty.Compare(got, tt.want); diff != "" {
|
||||
t.Errorf("AsanaOauth.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
|
||||
@@ -53,7 +53,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(err, resMatch)
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{"key": resMatch}
|
||||
s1.SecretParts = map[string]string{"key": resMatch}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr, match)
|
||||
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": match,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
uniqueOrgIdMatches[match[1]] = struct{}{}
|
||||
}
|
||||
if len(uniqueOrgIdMatches) == 0 {
|
||||
// we only need an org ID to pass into AnalysisInfo
|
||||
// we only need an org ID to pass into SecretParts
|
||||
// if we don't find one, we can still verify the key
|
||||
// we can add a dummy entry here just to make sure a result is returned
|
||||
uniqueOrgIdMatches[""] = struct{}{}
|
||||
@@ -97,11 +97,11 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
s1.SetVerificationError(verificationErr, match)
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": match,
|
||||
}
|
||||
if orgId != "" {
|
||||
s1.AnalysisInfo["organization_id"] = orgId
|
||||
s1.SecretParts["organization_id"] = orgId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func TestAtlassian_FromChunk(t *testing.T) {
|
||||
t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "ExtraData", "primarySecret", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "ExtraData", "primarySecret", "SecretParts")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("Atlassian.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ func TestAtlassian_Pattern(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAtlassian_AnalysisInfo_KeyAndOrgId tests if both the key and organization id are populated into AnalysisInfo
|
||||
// TestAtlassian_SecretParts_KeyAndOrgId tests if both the key and organization id are populated into SecretParts
|
||||
// given that they are present in the input data chunk
|
||||
func TestAtlassian_AnalysisInfo_KeyAndOrgId(t *testing.T) {
|
||||
func TestAtlassian_SecretParts_KeyAndOrgId(t *testing.T) {
|
||||
client := common.SaneHttpClient()
|
||||
d := Scanner{client: client}
|
||||
|
||||
@@ -118,16 +118,16 @@ func TestAtlassian_AnalysisInfo_KeyAndOrgId(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Len(t, results, 1, "mismatch in result count: expected %d, got %d", 1, len(results))
|
||||
result := results[0]
|
||||
require.NotNil(t, result.AnalysisInfo, "AnalysisInfo is nil")
|
||||
require.NotNil(t, result.SecretParts, "SecretParts is nil")
|
||||
|
||||
assert.Equal(t, key, result.AnalysisInfo["key"], "mismatch in key")
|
||||
assert.Equal(t, orgId, result.AnalysisInfo["organization_id"], "mismatch in organization_id")
|
||||
assert.Equal(t, key, result.SecretParts["key"], "mismatch in key")
|
||||
assert.Equal(t, orgId, result.SecretParts["organization_id"], "mismatch in organization_id")
|
||||
})
|
||||
}
|
||||
|
||||
// TestAtlassian_AnalysisInfo_KeyOnly tests if only key is populated into AnalysisInfo
|
||||
// TestAtlassian_SecretParts_KeyOnly tests if only key is populated into SecretParts
|
||||
// given that only the key and no organization_id is present in the input data chunk
|
||||
func TestAtlassian_AnalysisInfo_KeyOnly(t *testing.T) {
|
||||
func TestAtlassian_SecretParts_KeyOnly(t *testing.T) {
|
||||
client := common.SaneHttpClient()
|
||||
d := Scanner{client: client}
|
||||
|
||||
@@ -156,8 +156,8 @@ func TestAtlassian_AnalysisInfo_KeyOnly(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Len(t, results, 1, "mismatch in result count: expected %d, got %d", 1, len(results))
|
||||
result := results[0]
|
||||
require.NotNil(t, result.AnalysisInfo, "AnalysisInfo is nil")
|
||||
require.NotNil(t, result.SecretParts, "SecretParts is nil")
|
||||
|
||||
assert.Equal(t, key, result.AnalysisInfo["key"], "mismatch in key")
|
||||
assert.Equal(t, key, result.SecretParts["key"], "mismatch in key")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ func (s scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
ExtraData: map[string]string{
|
||||
"resource_type": aws.ResourceTypes[idMatch[:4]],
|
||||
},
|
||||
AnalysisInfo: map[string]string{
|
||||
SecretParts: map[string]string{
|
||||
"access_key_id": idMatch,
|
||||
"secret_access_key": secretMatch,
|
||||
},
|
||||
|
||||
@@ -110,7 +110,7 @@ func TestAxonaut_FromChunk(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "ExtraData", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "ExtraData", "SecretParts")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("AzureApiManagementRepositoryKey.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.ExtraData = extraData
|
||||
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.ExtraData = extraData
|
||||
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resPrivateKey)
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key_name": resKeyName,
|
||||
"key": resPrivateKey,
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr)
|
||||
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"token": token,
|
||||
"domain": domain,
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ func TestDatabricksToken_FromChunk(t *testing.T) {
|
||||
t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "SecretParts")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("DatabricksToken.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resApiMatch, baseURL)
|
||||
if isVerified {
|
||||
s1.Verified = isVerified
|
||||
s1.AnalysisInfo = map[string]string{"api_key": resApiMatch, "endpoint": baseURL}
|
||||
s1.SecretParts = map[string]string{"api_key": resApiMatch, "endpoint": baseURL}
|
||||
// break the loop once we've successfully validated the token against a baseURL
|
||||
break
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func TestDataDogApiKey_FromChunk(t *testing.T) {
|
||||
{
|
||||
DetectorType: detector_typepb.DetectorType_DatadogApikey,
|
||||
Verified: true,
|
||||
AnalysisInfo: map[string]string{
|
||||
SecretParts: map[string]string{
|
||||
"api_key": apiKey,
|
||||
"endpoint": datdogEndpoint,
|
||||
},
|
||||
|
||||
@@ -142,7 +142,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
s1.Verified = true
|
||||
s1.AnalysisInfo = map[string]string{"api_key": resApiMatch, "app_key": resAppMatch, "endpoint": baseURL}
|
||||
s1.SecretParts = map[string]string{"api_key": resApiMatch, "app_key": resAppMatch, "endpoint": baseURL}
|
||||
var serviceResponse userServiceResponse
|
||||
if err := json.NewDecoder(res.Body).Decode(&serviceResponse); err == nil {
|
||||
// setup emails
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestDatadogToken_FromChunk(t *testing.T) {
|
||||
ExtraData: map[string]string{
|
||||
"Type": "Application+APIKey",
|
||||
},
|
||||
AnalysisInfo: map[string]string{
|
||||
SecretParts: map[string]string{
|
||||
"api_key": apiKey,
|
||||
"app_key": appKey,
|
||||
"endpoint": endpoint,
|
||||
|
||||
@@ -126,7 +126,7 @@ func TestDeepseek_FromChunk(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "SecretParts")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("Deepseek.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -119,10 +119,11 @@ type Result struct {
|
||||
// information about the verification status of the candidate secret, such as if the verification request timed out.
|
||||
verificationError error
|
||||
|
||||
// AnalysisInfo should be set with information required for credential
|
||||
// analysis to run. The keys of the map are analyzer specific and
|
||||
// should match what is expected in the corresponding analyzer.
|
||||
AnalysisInfo map[string]string
|
||||
// SecretParts holds the individual components of a (potentially multi-part)
|
||||
// credential, keyed by a component name. It is used by analyzers where
|
||||
// the keys are analyzer specific and should match what the
|
||||
// corresponding analyzer expects.
|
||||
SecretParts map[string]string
|
||||
|
||||
// primarySecret is used when a detector has multiple secret patterns.
|
||||
// This secret is designated to determine the line number.
|
||||
|
||||
@@ -54,7 +54,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr)
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": token,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ func TestDigitalOceanToken_FromChunk(t *testing.T) {
|
||||
t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "SecretParts")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("DigitalOceanToken.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr)
|
||||
s1.Verified = verified
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": newAccessToken,
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.Verified = verified
|
||||
s1.SetVerificationError(verificationErr)
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": token,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func TestDigitalOceanV2_FromChunk(t *testing.T) {
|
||||
t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "SecretParts")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("DigitalOceanV2.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.ExtraData = extraData
|
||||
s1.SetVerificationError(verificationErr)
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"username": username,
|
||||
"pat": token,
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.ExtraData = extraData
|
||||
s1.SetVerificationError(verificationErr)
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"username": username,
|
||||
"pat": token,
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestDockerhub_FromChunk(t *testing.T) {
|
||||
{
|
||||
DetectorType: detector_typepb.DetectorType_Dockerhub,
|
||||
Verified: true,
|
||||
AnalysisInfo: map[string]string{
|
||||
SecretParts: map[string]string{
|
||||
"username": username,
|
||||
"pat": pat,
|
||||
},
|
||||
@@ -74,7 +74,7 @@ func TestDockerhub_FromChunk(t *testing.T) {
|
||||
{
|
||||
DetectorType: detector_typepb.DetectorType_Dockerhub,
|
||||
Verified: true,
|
||||
AnalysisInfo: map[string]string{
|
||||
SecretParts: map[string]string{
|
||||
"username": strings.Split(email, "-")[0],
|
||||
"pat": pat,
|
||||
},
|
||||
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr)
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{"token": key}
|
||||
s1.SecretParts = map[string]string{"token": key}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr, match)
|
||||
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": match,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr, match)
|
||||
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": match,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func TestElevenlabs_FromChunk(t *testing.T) {
|
||||
t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "SecretParts")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("Elevenlabs.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr, match)
|
||||
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": match,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ func TestFastlyPersonalToken_FromChunk(t *testing.T) {
|
||||
t.Fatalf("no raw secret present: \n %+v", got[i])
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "SecretParts")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("FastlyPersonalToken.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(err, resMatch)
|
||||
}
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{"token": resMatch}
|
||||
s1.SecretParts = map[string]string{"token": resMatch}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(err, resMatch)
|
||||
}
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{"token": resMatch}
|
||||
s1.SecretParts = map[string]string{"token": resMatch}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ func TestFlyio_FromChunk(t *testing.T) {
|
||||
t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "SecretParts")
|
||||
ignoreUnexported := cmpopts.IgnoreUnexported(detectors.Result{})
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts, ignoreUnexported); diff != "" {
|
||||
t.Errorf("Flyio.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
|
||||
@@ -118,7 +118,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
"rotation_guide": "https://howtorotate.com/docs/tutorials/gcp/",
|
||||
"project": creds.ProjectID,
|
||||
},
|
||||
AnalysisInfo: map[string]string{
|
||||
SecretParts: map[string]string{
|
||||
"key": string(credBytes),
|
||||
},
|
||||
}
|
||||
@@ -149,7 +149,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if creds.Type != "" {
|
||||
result.AnalysisInfo["type"] = creds.Type
|
||||
result.SecretParts["type"] = creds.Type
|
||||
}
|
||||
|
||||
if verify {
|
||||
|
||||
@@ -133,7 +133,7 @@ func TestGCP_FromChunk(t *testing.T) {
|
||||
}
|
||||
got[i].Raw = nil
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "SecretParts")
|
||||
ignoreUnexported := cmpopts.IgnoreUnexported(detectors.Result{})
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts, ignoreUnexported); diff != "" {
|
||||
t.Errorf("GCP.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
|
||||
@@ -123,7 +123,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
"rotation_guide": "https://howtorotate.com/docs/tutorials/github/",
|
||||
"version": fmt.Sprintf("%d", s.Version()),
|
||||
},
|
||||
AnalysisInfo: map[string]string{"key": token},
|
||||
SecretParts: map[string]string{"key": token},
|
||||
}
|
||||
|
||||
if verify {
|
||||
|
||||
@@ -63,7 +63,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
"rotation_guide": "https://howtorotate.com/docs/tutorials/github/",
|
||||
"version": fmt.Sprintf("%d", s.Version()),
|
||||
},
|
||||
AnalysisInfo: map[string]string{"key": token},
|
||||
SecretParts: map[string]string{"key": token},
|
||||
}
|
||||
|
||||
if verify {
|
||||
|
||||
@@ -217,7 +217,7 @@ func TestGitHub_FromChunk(t *testing.T) {
|
||||
t.Fatal("no raw secret present")
|
||||
}
|
||||
got[i].Raw = nil
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
if diff := pretty.Compare(got, tt.want); diff != "" {
|
||||
t.Errorf("GitHub.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
|
||||
@@ -99,7 +99,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
|
||||
// for verified keys set the analysis info
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
"host": endpoint,
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ func TestGitlab_FromChunk(t *testing.T) {
|
||||
if (got[i].VerificationError() != nil) != tt.wantVerificationErr {
|
||||
t.Fatalf(" wantVerificationError = %v, verification error = %v,", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
opts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "primarySecret")
|
||||
if diff := cmp.Diff(got, tt.want, opts); diff != "" {
|
||||
@@ -287,7 +287,7 @@ func TestGitlab_FromChunk_WithV2Secrets(t *testing.T) {
|
||||
if (got[i].VerificationError() != nil) != tt.wantVerificationErr {
|
||||
t.Fatalf(" wantVerificationError = %v, verification error = %v,", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
opts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError")
|
||||
if diff := cmp.Diff(got, tt.want, opts); diff != "" {
|
||||
@@ -381,7 +381,7 @@ func TestGitlab_FromChunk_WithV3Secrets(t *testing.T) {
|
||||
if (got[i].VerificationError() != nil) != tt.wantVerificationErr {
|
||||
t.Fatalf(" wantVerificationError = %v, verification error = %v,", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
opts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "primarySecret")
|
||||
if diff := cmp.Diff(got, tt.want, opts); diff != "" {
|
||||
|
||||
@@ -101,7 +101,7 @@ func TestGitlabV2_FromChunk_WithV1Secrets(t *testing.T) {
|
||||
if (got[i].VerificationError() != nil) != tt.wantVerificationErr {
|
||||
t.Fatalf(" wantVerificationError = %v, verification error = %v,", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
opts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "primarySecret")
|
||||
if diff := cmp.Diff(got, tt.want, opts); diff != "" {
|
||||
@@ -195,7 +195,7 @@ func TestGitlabV2_FromChunk_WithV3Secrets(t *testing.T) {
|
||||
if (got[i].VerificationError() != nil) != tt.wantVerificationErr {
|
||||
t.Fatalf(" wantVerificationError = %v, verification error = %v,", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
opts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "primarySecret")
|
||||
if diff := cmp.Diff(got, tt.want, opts); diff != "" {
|
||||
@@ -374,7 +374,7 @@ func TestGitlabV2_FromChunk(t *testing.T) {
|
||||
if (got[i].VerificationError() != nil) != tt.wantVerificationErr {
|
||||
t.Fatalf(" wantVerificationError = %v, verification error = %v,", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
opts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "primarySecret")
|
||||
if diff := cmp.Diff(got, tt.want, opts); diff != "" {
|
||||
|
||||
@@ -82,7 +82,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
|
||||
// for verified keys set the analysis info
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
"host": endpoint,
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
|
||||
// for verified keys set the analysis info
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
"host": endpoint,
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ func TestGitlabV3_FromChunk(t *testing.T) {
|
||||
if (got[i].VerificationError() != nil) != tt.wantVerificationErr {
|
||||
t.Fatalf(" wantVerificationError = %v, verification error = %v,", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
opts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "primarySecret")
|
||||
if diff := cmp.Diff(got, tt.want, opts); diff != "" {
|
||||
@@ -280,7 +280,7 @@ func TestGitlabV3_FromChunk_WithV1Secrets(t *testing.T) {
|
||||
if (got[i].VerificationError() != nil) != tt.wantVerificationErr {
|
||||
t.Fatalf(" wantVerificationError = %v, verification error = %v,", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
opts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "primarySecret")
|
||||
if diff := cmp.Diff(got, tt.want, opts); diff != "" {
|
||||
@@ -362,7 +362,7 @@ func TestGitlabV3_FromChunk_WithV2Secrets(t *testing.T) {
|
||||
if (got[i].VerificationError() != nil) != tt.wantVerificationErr {
|
||||
t.Fatalf(" wantVerificationError = %v, verification error = %v,", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
opts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError")
|
||||
if diff := cmp.Diff(got, tt.want, opts); diff != "" {
|
||||
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr, match)
|
||||
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": match,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr, match)
|
||||
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": match,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.Verified = isVerified
|
||||
s1.ExtraData = extraData
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
s1.AnalysisInfo = map[string]string{"key": resMatch}
|
||||
s1.SecretParts = map[string]string{"key": resMatch}
|
||||
}
|
||||
|
||||
results = append(results, s1)
|
||||
|
||||
@@ -190,7 +190,7 @@ func TestHuggingface_FromChunk(t *testing.T) {
|
||||
if (got[i].VerificationError() != nil) != tt.wantVerificationErr {
|
||||
t.Fatalf(" wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
|
||||
@@ -102,7 +102,7 @@ matchLoop:
|
||||
err = pingRes.err
|
||||
result.SetVerificationError(err, jdbcConn)
|
||||
}
|
||||
result.AnalysisInfo = map[string]string{
|
||||
result.SecretParts = map[string]string{
|
||||
"connection_string": jdbcConn,
|
||||
}
|
||||
// TODO: specialized redaction
|
||||
|
||||
@@ -125,7 +125,7 @@ func TestJdbcVerified(t *testing.T) {
|
||||
Verified: true,
|
||||
Redacted: fmt.Sprintf("jdbc:postgresql://%s:%s/%s?sslmode=disable&password=%s&user=%s",
|
||||
postgresHost, postgresPort.Port(), postgresDB, strings.Repeat("*", len(postgresPass)), postgresUser),
|
||||
AnalysisInfo: map[string]string{
|
||||
SecretParts: map[string]string{
|
||||
"connection_string": fmt.Sprintf("jdbc:postgresql://%s:%s/%s?sslmode=disable&password=%s&user=%s",
|
||||
postgresHost, postgresPort.Port(), postgresDB, postgresPass, postgresUser),
|
||||
},
|
||||
@@ -147,7 +147,7 @@ func TestJdbcVerified(t *testing.T) {
|
||||
Verified: true,
|
||||
Redacted: fmt.Sprintf(`jdbc:mysql://%s:%s@tcp(%s:%s)/%s`,
|
||||
mysqlUser, strings.Repeat("*", len(mysqlPass)), mysqlHost, mysqlPort.Port(), mysqlDatabase),
|
||||
AnalysisInfo: map[string]string{
|
||||
SecretParts: map[string]string{
|
||||
"connection_string": fmt.Sprintf(`jdbc:mysql://%s:%s@tcp(%s:%s)/%s`,
|
||||
mysqlUser, mysqlPass, mysqlHost, mysqlPort.Port(), mysqlDatabase),
|
||||
},
|
||||
@@ -169,7 +169,7 @@ func TestJdbcVerified(t *testing.T) {
|
||||
Verified: true,
|
||||
Redacted: fmt.Sprintf("jdbc:sqlserver://odbc:server=%s;port=%s;database=%s;password=%s",
|
||||
sqlServerHost, sqlServerPort.Port(), sqlServerDatabase, strings.Repeat("*", len(sqlServerPass))),
|
||||
AnalysisInfo: map[string]string{
|
||||
SecretParts: map[string]string{
|
||||
"connection_string": fmt.Sprintf("jdbc:sqlserver://odbc:server=%s;port=%s;database=%s;password=%s",
|
||||
sqlServerHost, sqlServerPort.Port(), sqlServerDatabase, sqlServerPass),
|
||||
},
|
||||
@@ -322,7 +322,7 @@ func TestJdbc_FromChunk(t *testing.T) {
|
||||
t.Fatal("no raw secret present")
|
||||
}
|
||||
got[i].Raw = nil
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
if diff := pretty.Compare(got, tt.want); diff != "" {
|
||||
t.Errorf("Jdbc.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
|
||||
@@ -119,7 +119,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr, token)
|
||||
}
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"token": token,
|
||||
"domain": domain,
|
||||
"email": email,
|
||||
|
||||
@@ -91,7 +91,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, token)
|
||||
if isVerified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"token": token,
|
||||
"domain": domain,
|
||||
"email": email,
|
||||
|
||||
@@ -82,7 +82,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
|
||||
// only api keys can be analyzed
|
||||
if strings.HasPrefix(resMatch, "api-") {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ func TestLaunchDarkly_FromChunk(t *testing.T) {
|
||||
t.Fatalf("no raw secret present: \n %+v", got[i])
|
||||
}
|
||||
got[i].Raw = nil
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
|
||||
// Do we expect to be comparing the ExtraData?
|
||||
got[i].ExtraData = nil
|
||||
|
||||
@@ -64,7 +64,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
result.Verified = true
|
||||
}
|
||||
}
|
||||
result.AnalysisInfo = map[string]string{
|
||||
result.SecretParts = map[string]string{
|
||||
"key": match,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestMailchimp_FromChunk(t *testing.T) {
|
||||
t.Fatal("no raw secret present")
|
||||
}
|
||||
got[i].Raw = nil
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
got[i].ExtraData = nil
|
||||
}
|
||||
if diff := pretty.Compare(got, tt.want); diff != "" {
|
||||
|
||||
@@ -61,7 +61,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1 := detectors.Result{
|
||||
DetectorType: s.Type(),
|
||||
Raw: []byte(match),
|
||||
AnalysisInfo: map[string]string{"key": match},
|
||||
SecretParts: map[string]string{"key": match},
|
||||
}
|
||||
|
||||
if verify {
|
||||
|
||||
@@ -129,7 +129,7 @@ func TestMailgun_FromChunk(t *testing.T) {
|
||||
t.Fatalf("no raw secret present: \n %+v", got[i])
|
||||
}
|
||||
got[i].Raw = nil
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
got[i].ExtraData = nil
|
||||
}
|
||||
if diff := pretty.Compare(got, tt.want); diff != "" {
|
||||
|
||||
@@ -52,7 +52,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr)
|
||||
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ func TestMonday_FromChunk(t *testing.T) {
|
||||
t.Fatalf("no raw secret present: \n %+v", got[i])
|
||||
}
|
||||
got[i].Raw = nil
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
if diff := pretty.Compare(got, tt.want); diff != "" {
|
||||
t.Errorf("Monday.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
|
||||
@@ -104,7 +104,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
r.SetVerificationError(vErr, password)
|
||||
|
||||
if isVerified {
|
||||
r.AnalysisInfo = map[string]string{
|
||||
r.SecretParts = map[string]string{
|
||||
"key": connStr,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
}
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
"secret": resSecretMatch,
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr, match)
|
||||
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{"key": match}
|
||||
s1.SecretParts = map[string]string{"key": match}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestNetlify_FromChunk(t *testing.T) {
|
||||
t.Fatalf("no raw secret present: \n %+v", got[i])
|
||||
}
|
||||
got[i].Raw = nil
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
if diff := pretty.Compare(got, tt.want); diff != "" {
|
||||
t.Errorf("Netlify.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
|
||||
@@ -64,7 +64,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(verificationErr, match)
|
||||
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{"key": match}
|
||||
s1.SecretParts = map[string]string{"key": match}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestNetlify_FromChunk(t *testing.T) {
|
||||
t.Fatalf("no raw secret present: \n %+v", got[i])
|
||||
}
|
||||
got[i].Raw = nil
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
if diff := pretty.Compare(got, tt.want); diff != "" {
|
||||
t.Errorf("Netlify.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
|
||||
@@ -67,7 +67,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
r.Verified = isVerified
|
||||
r.SetVerificationError(vErr, token)
|
||||
if isVerified {
|
||||
r.AnalysisInfo = map[string]string{"key": token}
|
||||
r.SecretParts = map[string]string{"key": token}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
// Notion returns 401 for all non-valid keys, thus 403 indicates it has fine-tuned permissions,
|
||||
// /v1/search, /v1/databases/*, etc. may work.
|
||||
s1.Verified = true
|
||||
s1.AnalysisInfo = map[string]string{"key": resMatch}
|
||||
s1.SecretParts = map[string]string{"key": resMatch}
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -60,7 +60,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
s1.Verified = true
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
s1.Verified = true
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.Verified = verified
|
||||
s1.ExtraData = extraData
|
||||
s1.SetVerificationError(verificationErr)
|
||||
s1.AnalysisInfo = map[string]string{"key": token}
|
||||
s1.SecretParts = map[string]string{"key": token}
|
||||
}
|
||||
|
||||
results = append(results, s1)
|
||||
|
||||
@@ -100,7 +100,7 @@ func TestOpenAI_FromChunk(t *testing.T) {
|
||||
}
|
||||
got[i].Raw = nil
|
||||
got[i].ExtraData = nil
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
if diff := pretty.Compare(got, tt.want); diff != "" {
|
||||
t.Errorf("OpenAI.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, token)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, token)
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": token,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func TestOpenAIAdmin_FromChunk(t *testing.T) {
|
||||
t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "AnalysisInfo", "Redacted")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "SecretParts", "Redacted")
|
||||
ignoreUnexported := cmpopts.IgnoreUnexported(detectors.Result{})
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts, ignoreUnexported); diff != "" {
|
||||
t.Errorf("OpenAIAdmin.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
|
||||
@@ -76,7 +76,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
if isVerified {
|
||||
r.Verified = isVerified
|
||||
r.ExtraData = extraData
|
||||
r.AnalysisInfo = map[string]string{
|
||||
r.SecretParts = map[string]string{
|
||||
"key": key,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ func TestOpsgenie_FromChunk(t *testing.T) {
|
||||
t.Fatalf("no raw secret present: \n %+v", got[i])
|
||||
}
|
||||
got[i].Raw = nil
|
||||
got[i].AnalysisInfo = nil
|
||||
got[i].SecretParts = nil
|
||||
}
|
||||
if diff := pretty.Compare(got, tt.want); diff != "" {
|
||||
t.Errorf("Opsgenie.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
|
||||
@@ -88,7 +88,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.ExtraData = map[string]string{"environment": fmt.Sprintf("https://%s.plaid.com", environment)}
|
||||
s1.SetVerificationError(verificationErr, id, secret)
|
||||
if s1.Verified {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"secret": secret,
|
||||
"id": id,
|
||||
"token": token,
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestPlaidKey_FromChunk(t *testing.T) {
|
||||
DetectorType: detector_typepb.DetectorType_PlaidKey,
|
||||
Verified: true,
|
||||
RawV2: []byte(fmt.Sprintf("%s:%s:%s", secret, id, token)),
|
||||
AnalysisInfo: map[string]string{
|
||||
SecretParts: map[string]string{
|
||||
"secret": secret,
|
||||
"id": id,
|
||||
"token": token,
|
||||
@@ -115,7 +115,7 @@ func TestPlaidKey_FromChunk(t *testing.T) {
|
||||
t.Fatalf("no raw v2 secret present: \n %+v", got[i])
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "AnalysisInfo", "ExtraData")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "SecretParts", "ExtraData")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("PlaidKey.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
s1.Verified = true
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"id": username,
|
||||
"token": password,
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func TestPlanetscale_FromChunk(t *testing.T) {
|
||||
t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError())
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "AnalysisInfo", "ExtraData")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "SecretParts", "ExtraData")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("Planetscale.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) ([]dete
|
||||
isVerified, verificationErr := verifyPostgres(params)
|
||||
result.Verified = isVerified
|
||||
result.SetVerificationError(verificationErr, password)
|
||||
result.AnalysisInfo = map[string]string{
|
||||
result.SecretParts = map[string]string{
|
||||
"connection_string": string(raw),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ func TestPostgres_FromChunk(t *testing.T) {
|
||||
t.Fatalf("wantVerificationError = %v, verification error = %v", tt.want[i].VerificationError(), got[i].VerificationError())
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "verificationError", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "verificationError", "SecretParts")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("Postgres.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
s1.Verified = true
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
}
|
||||
} else if res.StatusCode == 401 {
|
||||
@@ -69,7 +69,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
s1.Verified = true
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
isVerified, verificationErr := verifyPostman(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func TestPostman_FromChunk(t *testing.T) {
|
||||
t.Errorf("Postman.FromData() error = %v, wantErr %v", got[i].VerificationError(), tt.wantVerificationErr)
|
||||
}
|
||||
}
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "AnalysisInfo")
|
||||
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "SecretParts")
|
||||
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
|
||||
t.Errorf("Postman.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
s1.SetVerificationError(err)
|
||||
|
||||
if valid {
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"key": resMatch,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
// enabled th
|
||||
s1.AnalysisInfo = map[string]string{
|
||||
s1.SecretParts = map[string]string{
|
||||
"token": token,
|
||||
}
|
||||
} else {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user