Skip to content

[Detector] - Restore and Refactor Detectors starting with *CA* #4315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

amanfcp
Copy link
Contributor

@amanfcp amanfcp commented Jul 14, 2025

Description:

  • Restored caflou, calorieninja, cannyio detectors' health
  • Refactor verification logic across multiple detectors to use a unified verifyMatch function
  • Updated integration tests to reflect changes in secret retrieval and verification processes
  • Adjusted regex patterns for improved accuracy in detecting API keys
  • Enhanced error handling for API responses.

Note:

I'm having trouble creating test accounts in Captain Data (.co domain for <V4) and Caspio. The accounts are stuck in verification state.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

…d `verifyMatch` function. Updated integration tests to reflect changes in secret retrieval and verification processes. Adjusted regex patterns for improved accuracy in detecting API keys. Enhanced error handling for API responses.
@amanfcp amanfcp requested a review from a team as a code owner July 14, 2025 11:29
Copy link
Contributor

@shahzadhaider1 shahzadhaider1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work.
I have added some feedback.

@@ -26,7 +27,7 @@ var (

// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"cashboard"}) + `\b([0-9A-Z]{3}-[0-9A-Z]{3}-[0-9A-Z]{3}-[0-9A-Z]{3})\b`)
userPat = regexp.MustCompile(detectors.PrefixRegex([]string{"cashboard"}) + `\b([0-9a-z]{1,})\b`)
userPat = regexp.MustCompile(detectors.PrefixRegex([]string{"username"}) + `\b([0-9a-z]{1,})\b`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't remove the cashboard keyword, because the regex pattern seems too generic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a prefix for catching the username once the chunk is inside the detector.
The reason for removing cashboard keyword is that it will create unnecessary sets of credentials.

amanfcp added 2 commits July 18, 2025 17:53
…tectors to return actual errors instead of nil. This improves error reporting and debugging capabilities.
@@ -74,6 +66,33 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
return results, nil
}

func verifyMatch(ctx context.Context, client *http.Client, token string) (bool, error) {
req, err := http.NewRequestWithContext(ctx, "GET", "https://app.caflou.com/api/v1/accounts", nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Seems like a good opportunity to replace nil and hard coded strings with http.NoBody and http.MethodGet in all of the detectors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants