Skip to main content

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

  1. Try primary model (Claude 3.7 Sonnet)
  2. If fails, try fallback (GPT-4o)
  3. If both fail, try local (DeepSeek R1)
  4. 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

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

  1. Start with max_findings=10 for initial assessment
  2. Enable exploits for critical findings only
  3. Use local models for cost-free experimentation
  4. Review patches before applying (AI can make mistakes)
  5. Combine with dataflow analysis for best results