Skip to main content

Pre-commit security scanner and memory leak detector for Python projects

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


โญ Contribute

Contributions are welcome! Feel free to fork the repo and submit a pull request.


๐Ÿ“œ License

This project is open-source and available under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sentineldetectai-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sentineldetectai-0.1.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file sentineldetectai-0.1.0.tar.gz.

File metadata

  • Download URL: sentineldetectai-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for sentineldetectai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c330abcb1c86843df0e4ed16cb595a91c6a30a0c72309659fc6e00c5fe836c6b
MD5 d06c6eb46cdd8286e814cc3c2bc41843
BLAKE2b-256 2b7b687efff3730ed24c6a70772fdf032b20915097220610cc17e0dfbaa632b3

See more details on using hashes here.

File details

Details for the file sentineldetectai-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sentineldetectai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e878dab43790a239f21e076317d40d5f87c97444a6ca4d3fef09acc42227bb68
MD5 87b95332efefa1800ca86689d609b2f4
BLAKE2b-256 6840e5eac37eaf2f277857be8baf8f3a6a77f34dcc86218f4dd60d670475046b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page