Skip to content

Commit

Permalink
added zohocrm scanner in defaults.go, updated zohocrm verification en…
Browse files Browse the repository at this point in the history
…dpoint
  • Loading branch information
nabeelalam committed Nov 1, 2024
1 parent 1a36281 commit 34059d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pkg/detectors/zohocrm/zohocrm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ type Scanner struct {
}

type UnauthorizedResponseBody struct {
Code string `json:"code"`
Details map[string]interface{} `json:"details"`
Message string `json:"message"`
Status string `json:"status"`
Code string `json:"code"`
}

// Ensure the Scanner satisfies the interface at compile time.
Expand Down Expand Up @@ -74,7 +71,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result

// Verifies the Zoho CRM API key by making an HTTP request to the Zoho CRM API.
func verifyMatch(ctx context.Context, client *http.Client, token string) (bool, error) {
endpoint := "https://www.zohoapis.com/crm/v2/Leads"
endpoint := "https://www.zohoapis.com/crm/v7/Leads?fields=Email&per_page=1"

req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions pkg/detectors/zohocrm/zohocrm_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
)

// TestZohocrm_FromChunk verifies the validity of a ZohoCRM access token
// Note: The token validity test relies on an access token stored in the GCP secret manager.
// Since Zoho CRM tokens expire after 60 minutes, this test will eventually fail once the token becomes invalid.
// The official guide linked below can be followed in order to generate a new valid access token:
// https://www.zoho.com/accounts/protocol/oauth/self-client/authorization-code-flow.html

func TestZohocrm_FromChunk(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
Expand Down
2 changes: 2 additions & 0 deletions pkg/engine/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/zipbooks"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/zipcodeapi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/zipcodebase"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/zohocrm"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/zonkafeedback"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/zulipchat"
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
Expand Down Expand Up @@ -1644,6 +1645,7 @@ func DefaultDetectors() []detectors.Detector {
apimetrics.Scanner{},
captainDataV1.Scanner{},
captainDataV2.Scanner{},
zohocrm.Scanner{},
}

// Automatically initialize all detectors that implement
Expand Down

0 comments on commit 34059d5

Please sign in to comment.