fix(discordbottoken): detect standalone tokens and modern token formats#5014
fix(discordbottoken): detect standalone tokens and modern token formats#5014lukem-ts wants to merge 1 commit into
Conversation
|
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e8b1d57. Configure here.
| Raw: []byte(token), | ||
| Redacted: decodeBotID(token), | ||
| SecretParts: map[string]string{"key": token}, | ||
| } |
There was a problem hiding this comment.
Removed RawV2 breaks existing integration test
Medium Severity
The detectors.Result no longer sets RawV2, but the existing integration test (discordbottoken_integration_test.go line 101–102) calls t.Fatalf when RawV2 is empty. This means the integration test suite will unconditionally fatal when run with the detectors build tag. Either RawV2 needs to be populated or the integration test needs to be updated to reflect the new single-credential design.
Reviewed by Cursor Bugbot for commit e8b1d57. Configure here.
Corpora Test ResultsScans a corpus of real-world public code against only the detectors changed in this PR, then compares unique match counts between the PR build and the main baseline to catch regex regressions. Verification is disabled — each detector's regex is measured independently. 0 new · 1 clean | Scoped to:
|


Description:
The detector required a separate 17-digit ID co-located with the bot token (idPat), and the result loop nested the ID inside the token loop, so a bot token leaked on its own produced zero results. The bot ID is already embedded in the token's first segment, making the separate ID both redundant and the primary reason detection failed.
Changes:
Checklist:
make test-community)?make lintthis requires golangci-lint)?Note
Low Risk
Scoped to the Discord bot token detector’s regex, result shape, and outbound verification call; improves detection without touching auth or core engine paths.
Overview
Fixes Discord bot token detection when only the token string is present (no co-located 17-digit ID). The detector now matches standalone three-segment tokens with looser segment lengths (
{23,28}.{6,7}.{27,40}) so modern formats are included while legacy24.6.27shapes still match.Redaction derives the bot snowflake ID by base64url-decoding the token’s first segment instead of requiring a separate
idmatch. Results drop the oldid/RawV2pairing and dedupe tokens per chunk.Verification moves from
GET /api/v8/users/{id}toGET /api/v10/users/@mewithAuthorization: Bot <token>, classifies 401 as unverified, and on 200 can attachbot_idandusernameinExtraData. Tests cover modern and legacy token shapes without a separate numeric ID in the input.Reviewed by Cursor Bugbot for commit e8b1d57. Bugbot is set up for automated code reviews on this repo. Configure here.