|
1 | | -# CodeShield 🛡️ |
| 1 | +# CodeShield |
2 | 2 |
|
3 | | -> **The Complete AI Coding Safety Net** |
4 | | -> *AI code that works, matches your style, and remembers where you left off* |
| 3 | +An intelligent security layer for AI-generated code. CodeShield validates, formats, and secures code before it enters your production environment, acting as a firewall for your development workflow. |
5 | 4 |
|
6 | | -[](https://devpost.com) |
7 | | -[](https://python.org) |
8 | | -[](https://modelcontextprotocol.io) |
| 5 | +[View Demo](https://codeshield-five.vercel.app/) |
9 | 6 |
|
10 | | -## The Problem |
| 7 | +## Capabilities |
11 | 8 |
|
12 | | -AI coding assistants give you **90% correct code** that wastes your time: |
| 9 | +### TrustGate |
| 10 | +Validates generated code in an isolated sandbox environment. It detects potential security vulnerabilities, resource exhaustion, and malicious patterns through static analysis and runtime execution. |
13 | 11 |
|
14 | | -- ❌ Missing imports (`requests`, `json` not imported) |
15 | | -- ❌ Wrong variable names (`userName` instead of `user_name`) |
16 | | -- ❌ Forgets your codebase conventions |
17 | | -- ❌ Syntax errors that look right |
18 | | -- ❌ You lose context when switching tasks |
| 12 | +### StyleForge |
| 13 | +Analyzes your existing codebase to detect and enforce naming conventions. It automatically adapts new code to match your project's snake_case, camelCase, or PascalCase patterns. |
19 | 14 |
|
20 | | -## The Solution: 3 Pillars |
| 15 | +### ContextVault |
| 16 | +Persists your development state including open files, cursor positions, and notes. Allows for instant context restoration when switching between tasks. |
21 | 17 |
|
22 | | -| Pillar | What It Does | |
23 | | -|--------|--------------| |
24 | | -| 🔒 **TrustGate** | Verifies code before you see it | |
25 | | -| 🎨 **StyleForge** | Enforces YOUR naming conventions | |
26 | | -| 🧠 **ContextVault** | Saves/restores your coding context | |
27 | | - |
28 | | -## Quick Start |
| 18 | +## Installation |
29 | 19 |
|
30 | 20 | ```bash |
31 | | -# Install |
32 | 21 | pip install -e . |
33 | | - |
34 | | -# Verify some code |
35 | | -python -c " |
36 | | -from codeshield.trustgate.checker import verify_code |
37 | | -result = verify_code(''' |
38 | | -def fetch(): |
39 | | - return requests.get(url) |
40 | | -''') |
41 | | -print(f'Valid: {result.is_valid}') |
42 | | -print(f'Issues: {[i.message for i in result.issues]}') |
43 | | -print(f'Fixed: {result.fixed_code}') |
44 | | -" |
45 | 22 | ``` |
46 | 23 |
|
47 | | -## Features |
48 | | - |
49 | | -### 🔒 TrustGate |
| 24 | +## Python API Usage |
50 | 25 |
|
| 26 | +### Security Verification |
51 | 27 | ```python |
52 | 28 | from codeshield.trustgate.checker import verify_code |
53 | | -from codeshield.trustgate.sandbox import full_verification |
54 | 29 |
|
55 | | -# Quick check (static analysis) |
56 | | -result = verify_code(code, auto_fix=True) |
| 30 | +code = """ |
| 31 | +def fetch_data(url): |
| 32 | + return requests.get(url) |
| 33 | +""" |
57 | 34 |
|
58 | | -# Full check (static + sandbox execution) |
59 | | -report = full_verification(code) |
60 | | -print(f"Confidence: {report['confidence_score']:.0%}") |
| 35 | +# Detects missing imports and potential errors |
| 36 | +result = verify_code(code, auto_fix=True) |
| 37 | +print(result.fixed_code) |
61 | 38 | ``` |
62 | 39 |
|
63 | | -**What it catches:** |
64 | | -- Missing imports → Auto-adds them |
65 | | -- Syntax errors → Reports exact line |
66 | | -- Runtime errors → Catches in sandbox |
67 | | - |
68 | | -### 🎨 StyleForge |
69 | | - |
| 40 | +### Style Enforcement |
70 | 41 | ```python |
71 | 42 | from codeshield.styleforge.corrector import check_style |
72 | 43 |
|
73 | | -# Check code against your codebase conventions |
74 | | -result = check_style(code, codebase_path="./src") |
75 | | - |
76 | | -# Fixes: userName → user_name |
77 | | -# Fixes: getUserData → get_user_data |
| 44 | +# Enforces project-specific conventions |
| 45 | +result = check_style( |
| 46 | + code="def GetUserData(): pass", |
| 47 | + codebase_path="./src" |
| 48 | +) |
| 49 | +# Output: def get_user_data(): pass |
78 | 50 | ``` |
79 | 51 |
|
80 | | -### 🧠 ContextVault |
81 | | - |
| 52 | +### Context Management |
82 | 53 | ```python |
83 | 54 | from codeshield.contextvault.capture import save_context |
84 | | -from codeshield.contextvault.restore import restore_context |
85 | 55 |
|
86 | | -# Save where you are |
87 | 56 | save_context( |
88 | | - name="debugging-auth", |
89 | | - files=["src/auth.py", "src/users.py"], |
90 | | - notes="Working on login flow" |
| 57 | + name="auth-refactor", |
| 58 | + files=["src/auth.py", "tests/test_auth.py"], |
| 59 | + notes="fixing token expiration logic" |
91 | 60 | ) |
| 61 | +``` |
92 | 62 |
|
93 | | -# Later, restore with AI briefing |
94 | | -result = restore_context("debugging-auth") |
95 | | -print(result["briefing"]) # "You were working on login flow..." |
| 63 | +## Model Context Protocol (MCP) |
| 64 | + |
| 65 | +CodeShield exposes its functionality to AI assistants via MCP. Add the following configuration to your MCP settings file: |
| 66 | + |
| 67 | +```json |
| 68 | +{ |
| 69 | + "mcpServers": { |
| 70 | + "codeshield": { |
| 71 | + "command": "python", |
| 72 | + "args": ["-m", "codeshield.mcp.server"] |
| 73 | + } |
| 74 | + } |
| 75 | +} |
96 | 76 | ``` |
97 | 77 |
|
98 | | -## MCP Integration |
| 78 | +## Development |
99 | 79 |
|
100 | | -CodeShield works as an MCP server with Claude, Cursor, etc: |
| 80 | +1. Clone the repository |
| 81 | +2. Install dependencies: `pip install -e .` |
| 82 | +3. Run tests: `pytest` |
| 83 | +4. Start frontend: `cd frontend && npm run dev` |
101 | 84 |
|
102 | 85 | ```json |
103 | 86 | { |
|
0 commit comments