Skip to content

Add explicit prefix-based secret token detection#9

Merged
Jeffrin-dev merged 1 commit intomainfrom
codex/add-regex-patterns-for-api-keys
Mar 29, 2026
Merged

Add explicit prefix-based secret token detection#9
Jeffrin-dev merged 1 commit intomainfrom
codex/add-regex-patterns-for-api-keys

Conversation

@Jeffrin-dev
Copy link
Copy Markdown
Owner

Motivation

  • The existing detector relied on entropy heuristics and optional detect-secrets plugins which missed prefix-style tokens such as modern OpenAI keys (e.g. sk-proj-...).
  • Deterministic prefix-based regexes are more reliable for common token formats and should be evaluated before entropy scoring and independent of detect-secrets availability.

Description

  • Added PREFIX_PATTERNS to SecretsDetector with regexes for sk- (OpenAI), ghp_ (GitHub), AKIA (AWS access keys), and xoxb- (Slack bot tokens).
  • Implemented _detect_prefix_patterns and wired it so prefix matches are collected and merged before library-based and entropy-based detections.
  • Updated and added parametrized tests in tests/test_policy_and_secrets.py to cover all four explicit patterns.

Testing

  • Ran pytest -q tests/test_policy_and_secrets.py and all tests passed (8 passed).

Codex Task

@Jeffrin-dev Jeffrin-dev merged commit a6de7a6 into main Mar 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant