feat: add MercadoPago credentials detector#5082
Conversation
Add detector for MercadoPago payment platform credentials (Latin America's
largest payment processor). Detects two credential types:
- Access Token (APP_USR-{16-digit-id}-{6-digit-date}-{32-char-hex}__XX_XX__-{merchant-id})
These are high-severity secrets providing full access to payment processing.
- Public Key (APP_USR-{uuid})
Lower-risk but useful for context in secret reports.
Verification uses MercadoPago's REST API:
- Access tokens: GET /v1/payments/search (returns 200 if valid, 401 if not)
- Public keys: GET /v1/payment_methods (returns 200 if valid, 401 if not)
Keywords: APP_USR-
13 pattern test cases (7 valid, 5 invalid, 1 edge case)
Closes trufflesecurity#4620
|
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 4d5a75f. Configure here.
| t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError()) | ||
| } | ||
| } | ||
| ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError") |
There was a problem hiding this comment.
Integration test ignoreOpts missing fields causes panic
Low Severity
The cmpopts.IgnoreFields call only handles "Raw" and "verificationError", but detectors.Result has additional unexported fields (primarySecret, chunkOffset, chunkOffsetSet) that will cause cmp.Diff to panic when encountering unhandled unexported fields. Additionally, SecretParts is populated by the detector but not listed in the ignore options and not set in the expected want values, which would cause a comparison mismatch. Other detectors (e.g., hashicorpvaultauth) fixed this by using cmpopts.IgnoreUnexported(detectors.Result{}) instead.
Reviewed by Cursor Bugbot for commit 4d5a75f. Configure here.


Summary
Add a new secret detector for MercadoPago, Latin America's largest payment processing platform.
Credential Types Detected
1. Access Token (High Severity)
\bAPP_USR-\d{16}-\d{6}-[a-f0-9]{32}__[A-Z]{2}_[A-Z]{2}__-\d+\b/v1/payments/searchwith Bearer auth2. Public Key (Low Severity)
\bAPP_USR-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\b/v1/payment_methodswith Bearer authVerification
Both types verified against MercadoPago REST API:
Changes
proto/detector_type.proto: AddedMercadoPago = 1054pkg/pb/detector_typepb/detector_type.pb.go: Regeneratedpkg/detectors/mercadopago/mercadopago.go: Detector with dual-regex (access token + public key)pkg/detectors/mercadopago/mercadopago_test.go: 13 pattern test casespkg/detectors/mercadopago/mercadopago_integration_test.go: Integration test templatepkg/engine/defaults/defaults.go: Registered detectorTests (13 cases, all passing)
Closes
Closes #4620
Checklist
go vetcleanNote
Low Risk
Isolated new detector package and enum registration following existing TruffleHog patterns; verification uses read-only GETs with no changes to core scan logic.
Overview
Adds MercadoPago secret scanning for
APP_USR-*credentials: full access tokens (structured merchant token regex) and public keys (UUID-shapedAPP_USR-values), each emitted with distinctSecretPartslabels.When verification is enabled, tokens are checked via read-only MercadoPago API calls (
/v1/payments/searchfor access tokens,/v1/payment_methodsfor public keys), treating 200 as verified and 401/403 as invalid.Registers the new detector as
MercadoPago = 1054in proto/generated enums and wiresmercadopago.Scannerinto default engine detectors, with unit, integration, and benchmark tests.Reviewed by Cursor Bugbot for commit 4d5a75f. Bugbot is set up for automated code reviews on this repo. Configure here.