sentry-find-bugs
Find bugs, security vulnerabilities, and code quality issues in local branch changes.
What it does
sentry-find-bugs performs a structured five-phase security review of all code changes on your current git branch. It gathers the full diff, maps the attack surface of every changed file, runs an 11-item OWASP-aligned security checklist, verifies each potential issue with additional context, and produces a pre-audited FindingsReport containing only confirmed, real issues with severity ratings, evidence, and concrete fix suggestions.
The pipeline skips stylistic issues and never invents findings — if nothing is found, it says so explicitly.
Quickstart
# From inside your git repository
sentry-find-bugs
# Or supply a diff directly
sentry-find-bugs --diff "$(git diff main...HEAD)"
# JSON output
sentry-find-bugs --output-format jsonOutput
Found 2 issue(s):
[Critical] api/views.py:18
Problem: Raw SQL string formatting with user-controlled input
Evidence: Line 18 uses f-string interpolation of request.GET parameter into SQL query
Fix: Replace with parameterized query: cursor.execute("SELECT ... WHERE username = %s", [username])
Refs: OWASP A03:2021 - Injection
[High] api/admin_actions.py:12
Problem: Authorization check absent — any authenticated user can delete any order
Evidence: login_required decorator confirms identity but does not verify ownership of order_id
Fix: Add ownership check: if order.user != request.user and not request.user.is_staff: return 403
Refs: OWASP A01:2021 - Broken Access Control
Reviewed files:
api/views.py
api/admin_actions.py
api/urls.pyPipeline phases
| Phase | Description | Mellea primitive |
|---|---|---|
| 1 | Gather diff + list modified files | main.py:gather_diff + @generative slot |
| 2 | Attack surface mapping | Two-step @generative + m.instruct(format=AttackSurfaceMap) |
| 3 | 11-item security checklist per file | m.instruct(format=SecurityChecklist) |
| 4 | Per-issue verification | m.instruct(format=IssueVerdict) |
| 5 | Pre-conclusion audit + final report | m.instruct(format=FindingsReport, requirements=[...]) |
Security checklist categories
Injection · XSS · Authentication · Authorization/IDOR · CSRF · Race conditions · Session · Cryptography · Information disclosure · DoS · Business logic
Requirements
- Python ≥ 3.11
- ollama running with
granite4.1:3Bpulled - git CLI on PATH
- gh CLI (GitHub CLI) authenticated (for automatic default-branch detection)
See SETUP.md for install and configuration instructions.
Injectable tool parameters
The pipeline accepts two optional callable parameters for deeper analysis:
| Parameter | Default | Purpose |
|---|---|---|
search_fn |
stub (NotImplementedError) | Searches repo for test files covering a scenario |
read_file_fn |
stub (NotImplementedError) | Reads surrounding file context for issue confirmation |
Both stubs are handled gracefully — the pipeline falls back to diff-only analysis when they raise NotImplementedError. See SETUP.md §8 for recommended implementations.
Package layout
sentry_find_bugs_mellea/
pipeline.py # run_pipeline() — main entry point
config.py # BACKEND, MODEL_ID, PREFIX_TEXT, constants
schemas.py # Pydantic models: FindingsReport, IssueReport, etc.
slots.py # @generative slots: extract_modified_files, extract_attack_surface_raw
requirements.py # Mellea Requirements: audit_completeness_req, no_invented_issues_req
constrained_slots.py # Stubs: search_fn, read_file_fn (implement before production use)
main.py # CLI entry point
fixtures/ # 6 test fixtures (run with pytest)
SETUP.md # Setup and stub implementation guide
melleafy.json # Package manifest
mapping_report.md # Full element-to-primitive mapping documentationGenerated by
melleafy 4.3.2 from spec.md (agent_skills_std runtime).