Skip to content

feat: deterministic secrets pre-scan before AI review (#204) - #217

Merged
ajianaz merged 2 commits into
developfrom
feat/secrets-prescan
Jun 7, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/secrets-prescan

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements #204 — deterministic secrets detection that runs before the AI review pass. Catches known secret patterns with zero false negatives.

Changes

New: src/engine/secrets_scanner.rs

12 built-in patterns:

Pattern Severity
AWS Access Key (AKIA...) Critical
AWS Secret Key assignment Critical
GitHub Token (ghp_/gho_/ghu_/ghs_/ghr_) Critical
OpenAI API Key (sk-*/sk-proj-*) Critical
Anthropic API Key (sk-ant-*) Critical
Groq API Key (gsk_*) Critical
xAI API Key (xai-*) Critical
Private Key Block (BEGIN RSA/EC/DSA/OPENSSH PRIVATE KEY) Critical
JWT Token (eyJ...) Major
Slack Token (xoxb/xoxp/xoxa/xoxr/xoxs) Critical
Stripe Key (sk_live/sk_test/pk_live/pk_test) Critical
Google API Key (AIza...) Major

Features

  • Masked output: AKIA****CDEF (first 4 + last 4 chars shown)
  • Auto-skip test/spec/fixture/mock/example directories
  • Only scans added lines (not removed context)
  • Integrated into review pipeline before LLM call
  • Findings preserved on LLM failure fallback

Integration

  • review.rs: secrets scan runs alongside rule engine, findings merged into response
  • 18 unit tests covering all patterns + edge cases

Test Plan

  • 18 unit tests pass
  • Pre-commit hook: no issues found
  • Clippy clean
  • Push protection bypass: test strings built programmatically

ajianaz added 2 commits June 7, 2026 22:49
New module src/engine/secrets_scanner.rs with 12 built-in patterns:
- AWS Access Key / Secret Key
- GitHub Token (ghp/gho/ghu/ghs/ghr)
- OpenAI API Key (sk-*/sk-proj-*)
- Anthropic API Key (sk-ant-*)
- Groq API Key (gsk_*)
- xAI API Key (xai-*)
- Slack Token (xoxb/xoxp/xoxa/xoxr/xoxs)
- Stripe Key (sk_live/sk_test/pk_live/pk_test)
- Google API Key (AIza*)
- JWT Token (eyJ.*.eyJ.*)
- Private Key Block (RSA/EC/DSA/OPENSSH)

Features:
- Masked output: AKIA****CDEF (first 4 + last 4)
- Auto-skip test/spec/fixture/mock/example files
- Only scans added lines (not removed)
- Integrated into review pipeline before LLM call
- 18 unit tests covering all patterns + edge cases
- Findings merged with rule findings on LLM failure fallback
1. Test-file skip regex: broaden to match test_*.py and *_test.py
2. Secrets findings now included in LLM prompt context
3. Fallback path derives should_block from findings severity
@ajianaz
ajianaz merged commit 69befa1 into develop Jun 7, 2026
11 checks passed
@ajianaz
ajianaz deleted the feat/secrets-prescan branch June 8, 2026 04:22
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.

1 participant