Validate AI-generated code for security vulnerabilities, hallucinations, and logic errors
Project description
๐ก๏ธ AI Code Trust Validator
Trust your AI-generated code before shipping to production.
The complete quality gate for AI-assisted development
Installation โข Quick Start โข Features โข CLI Reference โข Documentation
๐ฏ The Problem
84% of developers use AI coding tools. Only 29% trust the output. (Stack Overflow 2025)
AI writes code fast, but that code often contains:
- ๐ Security vulnerabilities โ SQL injection, hardcoded secrets, command injection
- ๐ญ Hallucinations โ Fake imports, invented functions, imaginary APIs
- ๐ Logic errors โ Unreachable code, infinite loops, dead branches
- ๐ Technical debt โ Missing docs, poor naming, deep nesting
- ๐ Dependency issues โ Circular imports, missing modules, unused code
You can't ship what you can't trust.
โจ Features
| Category | Features |
|---|---|
| ๐ Analysis | Security scanning, Hallucination detection, Logic validation, Best practices |
| ๐ Reports | JSON, HTML (beautiful dashboard), SARIF (GitHub Security), PDF |
| ๐ง Fixes | Auto-fix suggestions, Confidence scores, One-click apply |
| ๐งช Testing | Auto-generate pytest tests, Edge case detection, Coverage analysis |
| ๐ API | REST API server, OpenAPI docs, Batch validation, Webhook support |
| ๐ Monitoring | File watch mode, Live dashboard, Continuous validation |
| ๐ฆ Multi-file | Dependency analysis, Circular dependency detection, Import validation |
| โก Performance | Intelligent caching, Incremental analysis, ~10,000+ lines/sec |
| ๐ Extensible | Plugin system, Custom analyzers, Hook system |
| ๐ณ Deployment | Docker, Docker Compose, GitHub Action, Pre-commit hooks |
| ๐ป IDE Integration | VS Code extension, LSP server, JetBrains (coming soon) |
| ๐ Team Analytics | Dashboard, Leaderboards, Trend analysis, Project breakdown |
๐ฆ Installation
# From PyPI (recommended)
pip install ai-trust-validator
# With server support
pip install ai-trust-validator[server]
# With all extras
pip install ai-trust-validator[all]
# From source
git clone https://github.com/rudra496/ai-code-trust-validator.git
cd ai-code-trust-validator
pip install -e ".[all]"
# Docker
docker pull ghcr.io/rudra496/ai-code-trust-validator:latest
docker run -v ./code:/code ghcr.io/rudra496/ai-code-trust-validator validate /code
๐ Quick Start
CLI
# Validate a file
aitrust validate generated_code.py
# Validate directory with minimum score
aitrust validate src/ --min-score 75 --strict
# Generate HTML report
aitrust report src/ --format html --output report.html
# Get fix suggestions
aitrust suggest-fixes buggy_code.py
# Generate tests
aitrust generate-tests module.py --output tests/test_module.py
# Start API server
aitrust serve --port 8080
# Watch for changes with live dashboard
aitrust watch src/ --dashboard
# Analyze dependencies
aitrust analyze-deps src/
# Run benchmarks
aitrust benchmark --iterations 100
# View team analytics
aitrust analytics --days 30
# Start LSP server (for IDE integration)
aitrust lsp
Python API
from ai_trust_validator import Validator, Config
# Simple validation
validator = Validator()
result = validator.validate("generated_code.py")
print(f"Trust Score: {result.trust_score}/100")
print(f"Passed: {result.passed}")
for issue in result.critical_issues:
print(f"[CRITICAL] {issue.message}")
if issue.suggestion:
print(f" ๐ก {issue.suggestion}")
# With custom config
config = Config(min_score=80, strict_mode=True)
validator = Validator(config)
result = validator.validate_code(code_string)
# Multi-file analysis
from ai_trust_validator import MultiFileAnalyzer
analyzer = MultiFileAnalyzer(validator)
result = analyzer.analyze_directory("src/")
print(f"Circular deps: {result.circular_dependencies}")
# Team analytics
from ai_trust_validator import AnalyticsDB
db = AnalyticsDB()
db.record_validation("file.py", result, user="dev1", project="myapp")
stats = db.get_stats(days=30)
print(f"Team avg: {stats.average_score}")
REST API
# Start server
aitrust serve --port 8080
# Validate via API
curl -X POST http://localhost:8080/validate \
-H "Content-Type: application/json" \
-d '{"code": "def hello(): print(\"world\")"}'
# Batch validation
curl -X POST http://localhost:8080/validate/batch \
-H "Content-Type: application/json" \
-d '{"files": [{"name": "a.py", "code": "..."}]}'
Web Dashboard
# Start server with dashboard
aitrust serve --port 8080
# Open browser to http://localhost:8080
# Or serve the static dashboard
cd dashboard && python -m http.server 3000
๐ Example Output
๐ Analyzing: generated_code.py
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ TRUST SCORE: 67/100 โ ๏ธ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Category Score Issues โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Security 72 2 medium, 1 low โ
โ Hallucinations 45 3 critical โ
โ Logic 85 1 minor โ
โ Best Practices 70 2 warnings โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐จ Critical Issues:
[HALLUCINATION] Line 12: Import 'fancy_lib' does not exist
[HALLUCINATION] Line 18: Function 'quick_sort_v2' not defined
[SECURITY] Line 24: Potential SQL injection via f-string
๐ก AI Suggestions:
โ Replace 'fancy_lib' with 'numpy' or 'pandas'
โ Use built-in sorted() instead of 'quick_sort_v2'
โ Use parameterized queries: cursor.execute("... WHERE id = ?", (user_id,))
๐ง CLI Reference
| Command | Description |
|---|---|
aitrust validate <path> |
Validate code and show trust score |
aitrust report <path> |
Generate detailed report (JSON/HTML/SARIF) |
aitrust suggest-fixes <path> |
Show fix suggestions for issues |
aitrust generate-tests <path> |
Generate pytest tests |
aitrust serve |
Start REST API server |
aitrust watch <path> |
Watch files for changes |
aitrust benchmark |
Run performance benchmarks |
aitrust analyze-deps <path> |
Multi-file dependency analysis |
aitrust analytics |
View team analytics |
aitrust cache <action> |
Manage validation cache |
aitrust lsp |
Start LSP server for IDEs |
๐ณ Docker & Deployment
Docker Compose
version: '3.8'
services:
validator:
image: ghcr.io/rudra496/ai-code-trust-validator:latest
ports:
- "8080:8080"
command: serve --port 8080
volumes:
- ./code:/code:ro
- ./.aitrust_cache:/app/.aitrust_cache
GitHub Action
name: AI Code Trust Check
on: [pull_request]
jobs:
trust-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate AI Code
uses: rudra496/ai-code-trust-validator@v0.3.0
with:
path: 'src/'
min-score: '75'
format: 'sarif'
Pre-commit Hook
# .pre-commit-config.yaml
repos:
- repo: https://github.com/rudra496/ai-code-trust-validator
rev: v0.3.0
hooks:
- id: ai-trust-validator
args: ['--min-score', '70']
๐ป IDE Integration
VS Code
# Install from VS Code Marketplace
# Search for "AI Trust Validator"
# Or install manually
cd vscode-extension
npm install
npm run compile
Features:
- Real-time diagnostics
- Trust score in status bar
- Quick fix suggestions
- Hover information
- Auto-validate on save
LSP Server (Neovim, Emacs, etc.)
# Start LSP server
aitrust lsp
# Configure in your LSP client
# Command: aitrust lsp
# Language: python
๐ Plugin System
Create custom analyzers:
from ai_trust_validator import AnalyzerPlugin, PluginMetadata, Issue
class MyCustomAnalyzer(AnalyzerPlugin):
@property
def metadata(self):
return PluginMetadata(
name="my_custom",
version="1.0.0",
author="You",
description="Custom analyzer"
)
def analyze(self, tree, code, context):
issues = []
# Your analysis logic
return issues
# Register
from ai_trust_validator import PluginManager
manager = PluginManager()
manager.register(MyCustomAnalyzer())
๐ Performance
| Metric | Value |
|---|---|
| Throughput | 10,000+ lines/sec |
| Avg validation | 5-20ms per file |
| Memory | <50MB typical |
| Cache hit rate | 95%+ on re-runs |
Run your own benchmarks:
aitrust benchmark --iterations 1000
๐บ๏ธ Roadmap
Completed โ
- Core validation engine
- Security analyzer
- Hallucination detector
- Logic analyzer
- Best practices checker
- CLI with rich output
- JSON/HTML/SARIF reports
- Fix suggestions
- Test generation
- REST API server
- Docker support
- GitHub Action
- Pre-commit hooks
- Plugin system
- Multi-file analysis
- Watch mode
- Caching system
- LSP server
- VS Code extension
- Web dashboard
- Team analytics
Coming Soon ๐ง
- JavaScript/TypeScript support
- AI-powered auto-fix (LLM integration)
- JetBrains plugin (IntelliJ, PyCharm)
- Cloud hosted version
๐ Statistics
๐ค Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
Ways to help:
- ๐ Report bugs
- ๐ก Suggest features
- ๐ Improve documentation
- ๐ง Submit pull requests
- โญ Star the repo!
๐ License
MIT License โ use it freely. Just don't blame us if AI breaks production. ๐
๐ Connect with the Creator
Rudra Sarker โข Developer & Researcher
Built to close the AI trust gap.
If this helped you, consider giving it a โญ โ it helps others find it too!
Made with โค๏ธ by Rudra Sarker
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 ai_trust_validator-0.3.0.tar.gz.
File metadata
- Download URL: ai_trust_validator-0.3.0.tar.gz
- Upload date:
- Size: 57.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a101c294819d6152444e5f5e70b0a24637bb0ed27d00b69dc4d898378ceff73
|
|
| MD5 |
0772fd91a8793b7de4745bcdfc8fa77b
|
|
| BLAKE2b-256 |
1742d0e38d1b09fcb1a615b8510248deeee0aada13ea90e0fb25850738d9c457
|
Provenance
The following attestation bundles were made for ai_trust_validator-0.3.0.tar.gz:
Publisher:
publish.yml on rudra496/ai-code-trust-validator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_trust_validator-0.3.0.tar.gz -
Subject digest:
6a101c294819d6152444e5f5e70b0a24637bb0ed27d00b69dc4d898378ceff73 - Sigstore transparency entry: 1178776048
- Sigstore integration time:
-
Permalink:
rudra496/ai-code-trust-validator@1ed3c10ab4af9657f53a6551dcfa1b3d8f01726e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/rudra496
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1ed3c10ab4af9657f53a6551dcfa1b3d8f01726e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ai_trust_validator-0.3.0-py3-none-any.whl.
File metadata
- Download URL: ai_trust_validator-0.3.0-py3-none-any.whl
- Upload date:
- Size: 61.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da9b6d7c7dc94598aecd169ba56b123e609daed45f4a427bdd8dc6240ae761c1
|
|
| MD5 |
85afb373d3a71e925f14a863454ee691
|
|
| BLAKE2b-256 |
81deb8ad5e64737fd4b650cd8d078a56b00fed83a49342e1cd95020e825bc53b
|
Provenance
The following attestation bundles were made for ai_trust_validator-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on rudra496/ai-code-trust-validator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_trust_validator-0.3.0-py3-none-any.whl -
Subject digest:
da9b6d7c7dc94598aecd169ba56b123e609daed45f4a427bdd8dc6240ae761c1 - Sigstore transparency entry: 1178776103
- Sigstore integration time:
-
Permalink:
rudra496/ai-code-trust-validator@1ed3c10ab4af9657f53a6551dcfa1b3d8f01726e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/rudra496
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1ed3c10ab4af9657f53a6551dcfa1b3d8f01726e -
Trigger Event:
workflow_dispatch
-
Statement type: