Skip to main content

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:

  1. Planner Agent โ€” decides which scanners to run
  2. Scanner Executor โ€” runs Gitleaks / Trivy via subprocess
  3. Result Parser โ€” normalises findings into a unified format
  4. Verifier Agent โ€” classifies True Positive vs False Positive (via Grok)
  5. Fixer Agent โ€” generates a secure patch (via Grok)
  6. Patch Applier โ€” safely edits the file with backup
  7. Validator Agent โ€” confirms fix correctness (via Grok)
  8. 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

  1. Create secagent/scanners/my_scanner.py inheriting from BaseScanner
  2. Create secagent/parsers/my_parser.py inheriting from BaseParser
  3. 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

secagent_ai-0.1.0.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secagent_ai-0.1.0-py3-none-any.whl (43.7 kB view details)

Uploaded Python 3

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

Hashes for secagent_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0da3d9383d1a0960d3433db65160b12c6ed840fcfde3eca13bbe87df33704d35
MD5 02ec225796dff7eec902830074288c77
BLAKE2b-256 42f7c3b1b4d97aebbf6009892ad7dccac082cf7cf5205a5104aec6aa7cbe39da

See more details on using hashes here.

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

Hashes for secagent_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6a51a142b71d59905d27d32012394cb300d1f26224c55b57c0bc20f721902f8
MD5 8558ab35462816934d597f21e5330e5c
BLAKE2b-256 89f0de9e955603b50501e214da85b09f1e18795cfc4a36f61a3fedbed51bca6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page