AI-powered pre-commit security scanner and memory leak detector for Python
Project description
SentinelCode AI
SentinelCode AI is a proactive developer tool that scans your code before it is committed to detect:
- Hardcoded secrets (API keys, tokens, credentials)
- Resource leaks (unclosed files, improper handling)
- Context-based vulnerabilities
It integrates with Git pre-commit hooks to block unsafe commits and improve code quality automatically.
Features
- Regex + entropy-based secret detection
- Context-aware detection (sensitive variable names)
- AST-based memory leak detection
- Git pre-commit hook integration
- Smart fix suggestions
- Clean and colorful CLI output (Rich UI)
- Supports both file and folder scanning
Setup
Option A โ Install as CLI tool (Recommended)
pip install -e .
Enables the global sentinel command.
Option B โ Without pip install
pip install -r requirements.txt
python install_hook.py
๐ Usage
Scan a single file
sentinel --path path/to/file.py
Scan an entire folder
sentinel --path path/to/folder/
Without pip install
python -m src.cli.main --path path/to/file_or_folder
Pre-commit Hook Workflow
Once installed, every Git commit is automatically intercepted:
git commit -m "my changes"
โ
SentinelCode AI scans staged files
โ
HIGH risk found โ Commit BLOCKED + report shown
No issues โ Commit allowed
Run Tests
python -m pytest tests/
Example Output
๐ Scanning: tests/test_secret.py
Secrets Found:
[HIGH] AWS Access Key โ AKIA1234567890ABCDEF
Fix:
Move secret to environment variable
Example:
import os
SECRET = os.getenv("SECRET_KEY")
Leaks Found:
- Possible unclosed file at line 7
Project Structure
SentinelCodeAI/
โ
โโโ src/
โ โโโ core/
โ โ โโโ secrets.py
โ โ โโโ leaks.py
โ โ โโโ severity.py
โ โ
โ โโโ ai/
โ โ โโโ fixer.py
โ โ
โ โโโ cli/
โ โ โโโ main.py
โ โ
โ โโโ git_hooks/
โ โโโ pre_commit.py
โ
โโโ tests/
โ โโโ test_secrets.py
โ
โโโ requirements.txt
โโโ setup.py
โโโ install_hook.py
โโโ README.md
Future Improvements
- Auto-fix engine (automatic code correction)
- Integration with security tools (Bandit, Semgrep)
- Web dashboard for scan history
- Multi-language support
Why SentinelCode AI?
- Prevents accidental exposure of secrets
- Improves code quality before commit
- Saves debugging time by catching issues early
- Acts as a lightweight local security layer
Author
A. Veda Sree
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sentineldetectai-0.2.0.tar.gz.
File metadata
- Download URL: sentineldetectai-0.2.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f78b6634f8d7c51037410029f54822418638c94b02f63d1d4115553723e420b0
|
|
| MD5 |
abd7c919e335873bac9b44259afaf28b
|
|
| BLAKE2b-256 |
b93cb9b954324845cc761dee2621a1efb937899d89d80b55c9998e036232ec48
|
File details
Details for the file sentineldetectai-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sentineldetectai-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
320db7b26b652d3bc9db3aeb27f879a59c1d0dbec299aa1239911e64d1087dfe
|
|
| MD5 |
f2f76f958b2a14b98a6317a777079dbb
|
|
| BLAKE2b-256 |
b057f6086befbc4171a336ad02c49e23e829c9e02a9b2feca1a786b2664facad
|