Skip to main content

🛡️ CodeSentinel

AI Code Review & Security Assistant — Powered by loopy-agent

Python License


✨ Features

Feature Description
🔒 Security Scanner Pattern-based detection for 12+ vulnerability types
🤖 AI Code Review Maker/checker verification for accurate reviews
📊 Risk Scoring Prioritized findings by severity
📁 Repo Scanning Batch scan entire repositories
🔗 GitHub Integration Auto-review PRs and post comments
🌐 MCP Server Expose as tool for AI assistants
📄 Report Export HTML, JSON, Markdown, SARIF formats
💾 Caching Reduces API costs on repeated reviews

🚀 Quick Start

# Install
pip install codesentin3l

# Or clone and install
git clone https://github.com/Dream-Pixels-Forge/codesentin3l
cd codesentinel
pip install -e .

📖 Usage

CLI Commands

# Security scan (no API key needed)
codesentin3l scan myfile.py

# AI-powered review
export OPENAI_API_KEY="sk-..."
codesentin3l review myfile.py

# Full scan + review
codesentin3l full myfile.py

# Scan entire repository
codesentin3l repo ./my-project

# Review a git diff
codesentin3l pr changes.diff

# Start MCP server
codesentin3l mcp

# Run demo
codesentin3l demo

CLI Options

--provider openai|anthropic    # LLM provider (default: openai)
--model gpt-4|claude-3-opus   # Model (default: gpt-4)
--output <dir>                 # Output directory for reports
--format html|markdown|json    # Report format

🐍 Python API

Quick Review

import asyncio
from src import CodeReviewer

async def main():
    reviewer = CodeReviewer(provider="openai", model="gpt-4")
    result = await reviewer.review_file("my_code.py")
    reviewer.print_report(result)
    await reviewer.close()

asyncio.run(main())

Security Scan

from src import SecurityScanner

scanner = SecurityScanner()
findings = scanner.scan_file("my_code.py")
scanner.print_findings(findings)

risk_score = scanner.get_risk_score(findings)

Repo Scanning

from src import RepoScanner

scanner = RepoScanner()
summary = scanner.scan_repo("./my-project")
scanner.print_summary(summary)

Report Generation

from src import ReportGenerator, ReportConfig, ReportFormat

config = ReportConfig(
    format=ReportFormat.HTML,
    output_dir="./reports",
)
generator = ReportGenerator(config)
content = generator.generate(review=result, security_findings=findings)
path = generator.save(content, "my-review")

🌐 MCP Server

Start the MCP server to expose CodeSentinel as tools:

codesentin3l mcp

Available Tools

Tool Description
codesentinel_scan Scan code for security issues
codesentinel_review AI-powered code review
codesentinel_full Full scan + review combined
codesentinel_scan_file Scan a file from disk

Using with Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "codesentin3l": {
      "command": "python",
      "args": ["-m", "src.mcp_server"],
      "cwd": "/path/to/codesentinel"
    }
  }
}

🔗 GitHub Integration

Review a PR

from src import GitHubIntegration

async def main():
    gh = GitHubIntegration(token="ghp_...")
    review = await gh.review_pr("owner", "repo", pr_number=123)
    print(review.summary)
    print(f"Approved: {review.approved}")

asyncio.run(main())

Post Review Comment

review = await gh.review_pr("owner", "repo", 123, post_comment=True)

🔒 Security Patterns Detected

Pattern Severity Description
SQL Injection 🔴 Critical String formatting in queries
Command Injection 🔴 Critical os.system, eval, exec
Hardcoded Secrets 🔴 Critical API keys, passwords in code
Private Keys 🔴 Critical Embedded private keys
Weak Hashing 🟠 High MD5, SHA1 for passwords
XSS Risk 🟠 High innerHTML, dangerouslySetInnerHTML
Path Traversal 🟠 High Unsanitized file paths
Insecure Random 🟡 Medium random module for security
Debug Enabled 🟡 Medium DEBUG=True in production
CORS Wildcard 🟡 Medium Access-Control-Allow-Origin: *
Weak Crypto 🟠 High ECB mode, DES, RC4

📊 Report Formats

Format Use Case
HTML Visual reports, CI dashboards
JSON Machine parsing, integrations
Markdown GitHub, documentation
SARIF GitHub Code Scanning

🏗️ Architecture

┌─────────────────────────────────────────────────────────┐
│                    CodeSentinel                         │
├─────────────────────────────────────────────────────────┤
│                                                         │
│  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐ │
│  │   Security  │    │     AI      │    │   GitHub    │ │
│  │   Scanner   │    │   Reviewer  │    │ Integration │ │
│  │  (patterns) │    │  (loopy)    │    │   (PRs)     │ │
│  └──────┬──────┘    └──────┬──────┘    └──────┬──────┘ │
│         │                  │                  │         │
│         └──────────────────┼──────────────────┘         │
│                            │                            │
│                    ┌───────▼───────┐                    │
│                    │    Reporter   │                    │
│                    │ HTML/JSON/MD  │                    │
│                    └───────────────┘                    │
│                                                         │
├─────────────────────────────────────────────────────────┤
│                   loopy-agent                           │
│  ┌──────────┬──────────┬──────────┬──────────┐         │
│  │   loop   │ gateway  │ verification│  cache  │         │
│  └──────────┴──────────┴──────────┴──────────┘         │
└─────────────────────────────────────────────────────────┘

🧪 Examples

See the examples/ directory:

  • vulnerable_app.py — Code with intentional security issues
  • clean_app.py — Secure coding best practices

📝 License

MIT


🤝 Contributing

Contributions welcome! See CONTRIBUTING.md.


Built with ❤️ using loopy-agent

Download files

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

Source Distribution

codesentin3l-3.2.0.tar.gz (42.2 kB view details)

Uploaded Source

Built Distribution

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

codesentin3l-3.2.0-py3-none-any.whl (46.4 kB view details)

Uploaded Python 3

File details

Details for the file codesentin3l-3.2.0.tar.gz.

File metadata

  • Download URL: codesentin3l-3.2.0.tar.gz
  • Upload date:
  • Size: 42.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for codesentin3l-3.2.0.tar.gz
Algorithm Hash digest
SHA256 57d391b66758996cb1ea6258a5c4c7ea58516766928a5f845b25adb394db3f3a
MD5 e449995722a197569081162bb9539b4c
BLAKE2b-256 728e231183f627d25d4c92586d5f42955a8e3b752593b33cf7a06af9dc07b3bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for codesentin3l-3.2.0.tar.gz:

Publisher: release.yml on Dream-Pixels-Forge/codesentin3l

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codesentin3l-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: codesentin3l-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 46.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for codesentin3l-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11d14cb216dd20ee017ae5385de0a9b4fddd2ff11343ff8399692bd6ac4ef55c
MD5 7e3cfa53af6411ad38e704754d261a88
BLAKE2b-256 425ca2412cc55f5aed25fd2a60ac6d70b476dab080de283fe971263e9926cb60

See more details on using hashes here.

Provenance

The following attestation bundles were made for codesentin3l-3.2.0-py3-none-any.whl:

Publisher: release.yml on Dream-Pixels-Forge/codesentin3l

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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