Skip to content

Add SecretsDetector with entropy and prefix heuristics and integrate into CLI scan#11

Merged
Jeffrin-dev merged 2 commits intomainfrom
codex/add-regex-patterns-for-api-keys-a3yf4a
Mar 29, 2026
Merged

Add SecretsDetector with entropy and prefix heuristics and integrate into CLI scan#11
Jeffrin-dev merged 2 commits intomainfrom
codex/add-regex-patterns-for-api-keys-a3yf4a

Conversation

@Jeffrin-dev
Copy link
Copy Markdown
Owner

Motivation

  • Provide secret-detection support alongside PII scanning to surface API keys and other high-entropy tokens during scan CLI runs.
  • Use both an optional detect-secrets library and in-house heuristics (Shannon entropy, prefix patterns, and stopword filtering) to reduce false positives.

Description

  • Add shadowaudit.core.secrets.SecretsDetector implementing entropy scoring, candidate extraction, prefix pattern matching, optional detect-secrets integration, and filtering heuristics.
  • Integrate SecretsDetector into the scan CLI command to populate secrets_found on the scan result and set action_taken to detected when either entities or secrets are present.
  • Include explicit prefix patterns for common token formats (e.g., sk-, ghp_, AKIA, xoxb-) and a stopword list plus minimum candidate length to avoid flagging ordinary words.
  • Add and update unit tests to cover entropy scoring, prefix pattern detection, ignoring normal English sentences, and CLI-level secret detection.

Testing

  • Ran the test suite with pytest including the new tests in tests/test_cli_scan.py and tests/test_policy_and_secrets.py.
  • All automated tests, including the new secrets detection and CLI tests, passed successfully.

Codex Task

@Jeffrin-dev Jeffrin-dev merged commit 039e275 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