Skip to content

ayinedjimi/VulnScanner-LLM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VulnScanner-LLM πŸ›‘οΈ

License: MIT Python 3.11+ Code style: black HuggingFace

AI-Powered Vulnerability Scanner with LLM Explanations

VulnScanner-LLM is an advanced security scanning tool that combines traditional SAST (Static Application Security Testing) with AI-powered explanations and remediation suggestions.

🎯 Features

  • Multi-Scanner Support: Integrates Semgrep, Bandit, CodeQL, and Safety
  • AI Explanations: LLM-powered detailed vulnerability explanations
  • Smart Remediation: Automated fix suggestions with code examples
  • SARIF Format: Full SARIF 2.1.0 support for CI/CD integration
  • REST API: FastAPI-based API for integration
  • CLI Tool: Rich command-line interface
  • Async Architecture: High-performance async scanning
  • Type Safety: Full type hints and mypy compliance

πŸ“– About / Γ€ propos

Author: Ayi NEDJIMI Website: ayinedjimi-consultants.fr HuggingFace: AYI-NEDJIMI Contact: [email protected]

English

VulnScanner-LLM is a production-ready vulnerability scanner designed by cybersecurity expert Ayi NEDJIMI. It combines the power of multiple security tools with cutting-edge AI to provide comprehensive vulnerability assessment and remediation guidance.

FranΓ§ais

VulnScanner-LLM est un scanner de vulnérabilités production-ready conçu par l'expert en cybersécurité Ayi NEDJIMI. Il combine la puissance de plusieurs outils de sécurité avec l'IA de pointe pour fournir une évaluation complète des vulnérabilités et des conseils de remédiation.

πŸš€ Installation

# Clone the repository
git clone https://github.com/AYI-NEDJIMI/VulnScanner-LLM.git
cd VulnScanner-LLM

# Install dependencies
pip install -r requirements.txt

# Install the package
pip install -e .

# Install scanning tools
pip install semgrep bandit

πŸ“‹ Requirements

  • Python 3.11+
  • OpenAI API key (for LLM features)
  • Semgrep (optional)
  • Bandit (optional)
  • CodeQL (optional)

βš™οΈ Configuration

Create a .env file:

OPENAI_API_KEY=your_api_key_here
OPENAI_MODEL=gpt-4

πŸ’» Usage

Command Line Interface

# Basic scan
vulnscanner scan /path/to/code

# Scan with specific scanner
vulnscanner scan /path/to/code --scanner semgrep

# Scan with AI explanations
vulnscanner scan /path/to/code --explain --remediate

# Export to SARIF
vulnscanner scan /path/to/code --output results.sarif --format sarif

# Filter by severity
vulnscanner scan /path/to/code --severity high

Python API

from vulnscanner_llm import VulnerabilityScanner, ScanConfig, ScannerType

# Configure scan
config = ScanConfig(
    target_path="/path/to/code",
    scanners=[ScannerType.SEMGREP, ScannerType.BANDIT],
    severity_threshold="medium"
)

# Run scan
with VulnerabilityScanner(config) as scanner:
    results = scanner.scan()

# Display results
print(f"Found {len(results.vulnerabilities)} vulnerabilities")
for vuln in results.vulnerabilities:
    print(f"{vuln['severity']}: {vuln['title']} in {vuln['file']}")

REST API

# Start API server
uvicorn vulnscanner_llm.api:app --reload

# Use the API
curl -X POST http://localhost:8000/scan \
  -H "Content-Type: application/json" \
  -d '{"target_path": "/path/to/code"}'

πŸ—οΈ Architecture

VulnScanner-LLM/
β”œβ”€β”€ src/vulnscanner_llm/
β”‚   β”œβ”€β”€ scanner.py          # Core scanning engine
β”‚   β”œβ”€β”€ llm_explainer.py    # AI explanation generator
β”‚   β”œβ”€β”€ sarif_parser.py     # SARIF format handler
β”‚   β”œβ”€β”€ remediation.py      # Remediation engine
β”‚   β”œβ”€β”€ api.py              # FastAPI REST API
β”‚   └── cli.py              # Command-line interface
β”œβ”€β”€ tests/                  # Test suite
β”œβ”€β”€ examples/               # Usage examples
└── docs/                   # Documentation

πŸ” Supported Scanners

Scanner Language Support Features
Semgrep Multi-language Fast, customizable rules
Bandit Python Security-focused
CodeQL Multi-language Deep semantic analysis
Safety Python Dependency vulnerabilities

πŸŽ“ Examples

Example 1: Full Scan with AI Analysis

from vulnscanner_llm import VulnerabilityScanner, LLMExplainer, ScanConfig

# Scan code
config = ScanConfig(target_path="./myapp")
scanner = VulnerabilityScanner(config)
results = scanner.scan()

# Get AI explanations
explainer = LLMExplainer()
for vuln in results.vulnerabilities[:5]:  # First 5
    explanation = explainer.explain({
        "vulnerability_id": vuln["id"],
        "title": vuln["title"],
        "severity": vuln["severity"],
        "description": vuln["description"],
        "code_snippet": vuln.get("code", "")
    })
    print(f"\n=== {vuln['title']} ===")
    print(explanation.summary)
    print(f"\nImpact: {explanation.security_impact}")

Example 2: SARIF Integration

from vulnscanner_llm import SARIFParser

# Parse SARIF file
parser = SARIFParser()
parsed = parser.parse_file("results.sarif")

print(f"Found {parsed.result_count} results")
print(f"Errors: {parsed.error_count}")
print(f"Warnings: {parsed.warning_count}")

# Convert to vulnerabilities
vulnerabilities = parser.to_vulnerabilities(parsed)

πŸ§ͺ Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=vulnscanner_llm --cov-report=html

# Run specific test
pytest tests/test_scanner.py -v

πŸ“Š Performance

  • Scans 10,000+ files/minute
  • Async architecture for parallel scanning
  • Optimized SARIF parsing
  • Batch LLM processing for efficiency

🀝 Related Projects

πŸ“„ License

MIT License - see LICENSE file

Copyright (c) 2024 Ayi NEDJIMI

πŸ”— Links

πŸ“ž Contact

For professional inquiries, consulting, or support:

Ayi NEDJIMI Email: [email protected] Website: https://ayinedjimi-consultants.fr

πŸ™ Acknowledgments

Built with:

  • OpenAI GPT-4 for AI capabilities
  • Semgrep for security scanning
  • FastAPI for API framework
  • Rich for beautiful CLI output

Made with ❀️ by Ayi NEDJIMI | ayinedjimi-consultants.fr

About

AI-Powered Vulnerability Scanner with LLM Explanations - By Ayi NEDJIMI (ayinedjimi-consultants.fr)

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages