Skip to content

Praptii21/Code-Sentinel-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ CodeSentinel

AI-powered code security platform β€” scan, detect, and auto-fix vulnerabilities using a multi-LLM intelligent routing pipeline built on AWS Bedrock.


✨ Why CodeSentinel?

Capability What we do
Intelligent Model Routing Nova Micro β†’ Lite β†’ Pro selected automatically by prompt complexity β€” cuts cost by up to 95% vs always using Pro
Three-Layer Security Scan AWS IAM Access Analyzer (deterministic) + RAG context + Bedrock LLM analysis, merged & deduplicated
Dynamic Auto-Fix Button applies the exact surgical fix directly into your editor. When snippets mismatch, falls back to a live /api/fix LLM call that locates & patches the vulnerable lines
Simulate Attack Demo Adversarial red-team animation scans your code in real time before handing off to the AI defender β€” designed for compelling live demos
AI Sentinel Chat In-app chatbot (powered by Nova middleware) explains any vulnerability and can generate remediation on demand
Monaco Code Editor Full syntax highlighting, real-time glyph annotations marking vulnerable (πŸ”΄) and fixed (🟒) lines
Downloadable Report One-click .txt security report with all findings, severities, CWEs, and remediation
Auth + S3 Persistence Email/password signup & login; user data and analysis logs stored in AWS S3
Analytics Dashboard Live cost savings, token usage, latency, model distribution, and PII detection panel
Rate Limiting & Health Guard SlowAPI rate limiter + prompt-injection detector preventing abuse and resource exhaustion

πŸ—οΈ Architecture

Browser (Next.js 14)
    β”‚
    β”œβ”€ POST /api/scan   β†’ Three-layer pipeline: Parser β†’ RAG β†’ IAM Analyzer + Bedrock LLM
    β”œβ”€ POST /api/fix    β†’ LLM generates original_snippet + fixed_snippet for any vuln
    └─ POST /process    β†’ Nova Middleware: classify β†’ route β†’ invoke β†’ return
                              ↓
                       Amazon Bedrock (Nova Micro / Lite / Pro)
                       AWS IAM Access Analyzer
                       AWS S3 (users + logs)

πŸš€ Setup

Prerequisites

  • Node.js 18+, Python 3.11+
  • AWS account with Bedrock access (Nova models) and an S3 bucket

1. Clone & configure

git clone https://github.com/staree14/code-sentinel
cd code-sentinel
cp .env.example .env          # fill in AWS keys + S3 bucket
cp backend/.env.example backend/.env

2. Frontend

npm install
npm run dev          # http://localhost:3000

3. Backend

cd backend
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload --port 8000

Environment variables (.env / backend/.env)

Key Description
AWS_ACCESS_KEY_ID AWS credentials
AWS_SECRET_ACCESS_KEY AWS credentials
AWS_REGION e.g. us-east-1
S3_BUCKET_NAME Bucket for user data & logs

πŸ“‚ Project Structure

codesentinel/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ dashboard/     # Main security dashboard (scan + auto-fix + chat)
β”‚   β”‚   β”œβ”€β”€ scanner/       # Standalone scanner page
β”‚   β”‚   β”œβ”€β”€ login/ signup/ # Auth pages
β”‚   β”‚   └── analytics/     # Usage & cost analytics
β”‚   └── components/        # Editor, Hero, Routing diagram, Nav
└── backend/
    β”œβ”€β”€ main.py            # FastAPI app β€” /api/scan, /api/fix, /process, /api/analytics
    β”œβ”€β”€ security_agent.py  # Three-layer scan pipeline
    β”œβ”€β”€ analyzer.py        # Local fallback pattern engine
    β”œβ”€β”€ services/
    β”‚   β”œβ”€β”€ bedrock.py     # Bedrock Nova invocation
    β”‚   β”œβ”€β”€ classifier.py  # Prompt complexity classifier
    β”‚   β”œβ”€β”€ router.py      # Model routing logic
    β”‚   β”œβ”€β”€ rag.py         # RAG context builder
    β”‚   β”œβ”€β”€ iam_analyzer.py# AWS IAM Access Analyzer integration
    β”‚   └── s3_service.py  # S3 read/write/log
    └── security_rules.json# CIS benchmark rules for RAG

πŸ”‘ Key API Endpoints

Method Endpoint Description
POST /api/scan Full three-layer vulnerability scan
POST /api/fix LLM-generated surgical fix for a specific vuln
POST /process Intelligent Nova middleware with routing analytics
GET /api/analytics Aggregate daily cost & usage stats
POST /api/signup User registration (S3-backed)
POST /api/login User authentication

Built with Next.js Β· FastAPI Β· Amazon Bedrock Β· AWS IAM Access Analyzer Β· AWS S3

About

πŸ›‘οΈ AI-powered code security platform that scans, detects, and auto-fixes vulnerabilities using an intelligent multi-LLM routing pipeline powered by Amazon Bedrock.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors