Autonomous security agent that scans, verifies, fixes vulnerabilities and generates reports.
Project description
SecAgent ๐ก๏ธ
Autonomous Security Agent โ scan, verify, fix vulnerabilities, and generate reports.
SecAgent is a Python CLI tool that runs an 8-stage security pipeline:
- Planner Agent โ decides which scanners to run
- Scanner Executor โ runs Gitleaks / Trivy via subprocess
- Result Parser โ normalises findings into a unified format
- Verifier Agent โ classifies True Positive vs False Positive (via Grok)
- Fixer Agent โ generates a secure patch (via Grok)
- Patch Applier โ safely edits the file with backup
- Validator Agent โ confirms fix correctness (via Grok)
- Report Builder โ generates
fix.md
Quick Start
# Install
pip install -e .
# Set your Grok API key
export GROK_API_KEY="xai-..."
# Scan a file
secagent scan ./main.py
# Scan a directory
secagent scan ./project/
Prerequisites
| Tool | Purpose | Install |
|---|---|---|
| Python 3.11+ | Runtime | python.org |
| Gitleaks | Secret scanning | brew install gitleaks / GitHub releases |
| Trivy | Vulnerability scanning | brew install trivy / GitHub releases |
| Grok API key | LLM reasoning | x.ai |
SecAgent degrades gracefully โ scanners that aren't installed are skipped, and agents fall back to reasonable defaults when no API key is set.
Configuration
| Env Variable | Default | Description |
|---|---|---|
GROK_API_KEY |
โ | xAI API key for agent reasoning |
GROK_MODEL |
grok-4-1-fast-reasoning |
Model to use for chat completions |
Architecture
secagent/
โโโ cli.py # Typer CLI entry point
โโโ pipeline.py # 8-stage orchestrator
โโโ models.py # Shared dataclasses
โโโ llm/
โ โโโ grok_client.py # Grok API wrapper
โโโ agents/
โ โโโ planner_agent.py # Scanner selection
โ โโโ verifier_agent.py # TP / FP classification
โ โโโ fixer_agent.py # Patch generation
โ โโโ validator_agent.py # Fix validation
โโโ scanners/
โ โโโ base_scanner.py # Abstract plugin interface
โ โโโ gitleaks_scanner.py # Secret scanning
โ โโโ trivy_scanner.py # Filesystem vuln scanning
โโโ parsers/
โ โโโ base_parser.py # Abstract parser
โ โโโ gitleaks_parser.py # Gitleaks โ Vulnerability
โ โโโ trivy_parser.py # Trivy โ Vulnerability
โโโ context/
โ โโโ context_builder.py # Code-window extraction
โ โโโ dependency_resolver.py # Import analysis
โโโ utils/
โ โโโ file_loader.py # File I/O helpers
โ โโโ patch_applier.py # Safe file patching
โโโ report/
โโโ fix_report.py # Markdown report generator
Adding a new scanner
- Create
secagent/scanners/my_scanner.pyinheriting fromBaseScanner - Create
secagent/parsers/my_parser.pyinheriting fromBaseParser - Register in
pipeline.pyโ_SCANNER_MAP
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secagent_ai-0.1.0.tar.gz.
File metadata
- Download URL: secagent_ai-0.1.0.tar.gz
- Upload date:
- Size: 32.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0da3d9383d1a0960d3433db65160b12c6ed840fcfde3eca13bbe87df33704d35
|
|
| MD5 |
02ec225796dff7eec902830074288c77
|
|
| BLAKE2b-256 |
42f7c3b1b4d97aebbf6009892ad7dccac082cf7cf5205a5104aec6aa7cbe39da
|
File details
Details for the file secagent_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: secagent_ai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 43.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6a51a142b71d59905d27d32012394cb300d1f26224c55b57c0bc20f721902f8
|
|
| MD5 |
8558ab35462816934d597f21e5330e5c
|
|
| BLAKE2b-256 |
89f0de9e955603b50501e214da85b09f1e18795cfc4a36f61a3fedbed51bca6e
|