Overview
The LLM Analysis package provides true agentic security analysis using large language models. Unlike template-based tools, it reasons about vulnerabilities contextually, generates working exploits, and creates intelligent patches.Purpose
AI-powered autonomous security with:- LLM-powered analysis: No heuristics, genuine reasoning
- Context-aware exploits: Generated from actual code, not templates
- Intelligent patching: Understands security context
- Multi-model support: Claude, GPT-4, Ollama (DeepSeek/Qwen)
- Automatic fallback: Cost optimization and reliability
Architecture
Quick Start
Analyze Findings
Generate Exploits
Create Patches
Python API
Autonomous Security Agent
Analyze Single Vulnerability
LLM Client
Core Classes
AutonomousSecurityAgentV2
Main agent for vulnerability analysis.VulnerabilityContext
Complete context for vulnerability analysis.Dict[str, Any]
required
SARIF finding data
Path
required
Repository path for reading source code
bool
Whether vulnerability is exploitable
float
Score from 0.0 to 1.0
Optional[str]
Generated exploit code
Optional[str]
Generated patch code
Dict[str, Any]
Detailed LLM analysis
LLMClient
Multi-model LLM client with fallback.str
LLM response text
str
Model that generated response
float
Estimated cost in USD
Dict[str, int]
Token usage (prompt, completion, total)
LLMConfig
Configuration for multi-model setup.str
default:"claude-3-7-sonnet-20250219"
Primary model to use
str
default:"gpt-4o"
Fallback if primary fails
bool
default:"True"
Enable local model fallback (Ollama)
str
default:"deepseek-r1:14b"
Local model name for Ollama
int
default:"3"
Max retry attempts per model
Supported Models
Cloud Models
Local Models (Ollama)
Configuration
Environment Variables
Model Selection Strategy
- Try primary model (Claude 3.7 Sonnet)
- If fails, try fallback (GPT-4o)
- If both fail, try local (DeepSeek R1)
- Retry each model up to 3 times
Analysis Output
Vulnerability Analysis
Exploit Generation
Patch Generation
Dataflow Analysis
The agent supports advanced dataflow analysis from CodeQL:Integration
With Static Analysis
With CodeQL
Related Packages
- Static Analysis - Semgrep scanning
- CodeQL - Semantic analysis
- Exploitability Validation - Validate findings
- Autonomous - Multi-turn reasoning
Performance
Analysis Speed
- Per finding: 10-30 seconds (depends on model)
- Batch (10 findings): 3-5 minutes
- With exploits: +20-40 seconds per exploitable finding
Cost Estimates
- Claude 3.7 Sonnet: ~$0.05-0.15 per finding
- GPT-4o: ~$0.03-0.10 per finding
- Local (Ollama): $0.00 (free, but slower)
Best Practices
- Start with max_findings=10 for initial assessment
- Enable exploits for critical findings only
- Use local models for cost-free experimentation
- Review patches before applying (AI can make mistakes)
- Combine with dataflow analysis for best results