Skip to content

Detect Mapbox secret tokens without flagging public tokens - #86

Merged
omerbek merged 1 commit into
omerbek:mainfrom
jwalith4418-Mj:fix/69-mapbox-secret-tokens
Dec 1, 2026
Merged

omerbek merged 1 commit into
omerbek:mainfrom
jwalith4418-Mj:fix/69-mapbox-secret-tokens

Conversation

@jwalith4418-Mj

Copy link
Copy Markdown
Contributor

Fixes #69.

Add the Mapbox secret-token pattern to SECRET_PATTERNS. Mapbox documents a literal sk/pk header, a base64url JSON payload, and a signature: https://docs.mapbox.com/api/accounts/tokens/#token-format. Only sk matches; browser-safe pk tokens remain unreported.

The existing eyJ candidate literal already reaches this detector. Runtime-generated fake-token tests cover the full file-scanning path, exactly one secret finding (no JWT/Supabase duplicate), and no finding for the corresponding public token. No real credentials or provider requests are used.

Validation:

  • Both new regressions fail on the unchanged base (no secret finding), then pass with the pattern.
  • Linux python3 -m unittest discover: 121 tests pass.
  • python3 repodx.py .: 100/100, zero findings (Linux and Windows).
  • Scan three other real local checkouts (Bench, CLI-MCP, Khamseen): no secret findings; existing hygiene suggestions remain.

A Windows full-suite attempt hit six existing temporary-Git initialization failures; the complete Linux suite passes. No assertions or checks were weakened.

AI assistance: implemented and validated with OpenAI Codex. Claimed in #69 before implementation.

AI-assisted implementation and validation with OpenAI Codex.

@omerbek omerbek left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Verified locally on Windows (CPython 3.11) before merging:

  • Both new tests fail on main (AssertionError: 0 != 1) and pass with the pattern — red before green.
  • Full suite: 119 tests on main, 121 on this branch, with the same single pre-existing Windows-only error (OSError: [Errno 22] for the odd name .js fixture — a filename Windows cannot create). Nothing new fails.
  • python repodx.py . → 100/100 (A), 0 findings.
  • Adversarial checks on the pattern: sk.<payload>.<sig> is reported (including inside an ?access_token= URL); pk. is not; ask./tsk. do not match, so the � holds; a bare eyJ… JWT does not match; and a too-short sk.eyJabc.def does not match, so the {20,} floors hold.

Matches #69 exactly, one line of detection plus two tests, no assertions weakened. Thanks for the clear writeup and for claiming the issue first.

@omerbek
omerbek merged commit e132ba0 into omerbek:main Dec 1, 2026
3 checks passed
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.

Detect Mapbox secret tokens (sk.eyJ...) but not public ones (pk.)

2 participants