Skip to main content

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


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.2.0.tar.gz (11.3 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.2.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

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

Hashes for sentineldetectai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f78b6634f8d7c51037410029f54822418638c94b02f63d1d4115553723e420b0
MD5 abd7c919e335873bac9b44259afaf28b
BLAKE2b-256 b93cb9b954324845cc761dee2621a1efb937899d89d80b55c9998e036232ec48

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sentineldetectai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 320db7b26b652d3bc9db3aeb27f879a59c1d0dbec299aa1239911e64d1087dfe
MD5 f2f76f958b2a14b98a6317a777079dbb
BLAKE2b-256 b057f6086befbc4171a336ad02c49e23e829c9e02a9b2feca1a786b2664facad

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