Skip to content

OpenAuditLabs/agent

OAL Agent - Smart Contract Security Analysis System

[![License: AGPL v3](https://img.shield3. Configure environment

cp .env.example .env
# Edit .env with your configuration

Key environment variables:

  • API_HOST / API_PORT: API server configuration
  • DATABASE_URL: Database connection string
  • QUEUE_URL: Redis connection string
  • LLM_PROVIDER: LLM provider (openai, anthropic, etc.)
  • LLM_API_KEY: API key for LLM provider
  • LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR)
  1. Install pre-commit hooksnse-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) Python 3.9+ Code style: black

A multi-agent system for comprehensive smart contract security analysis using static analysis, dynamic testing, and machine learning.

⚠️ Project Status

🚧 Under Active Development - This project is currently in early development. APIs and features are subject to change.

✨ Features

  • πŸ€– Multi-Agent Architecture: Specialized agents for different analysis types
  • πŸ” Static Analysis: Integration with Slither and other static analyzers
  • πŸ§ͺ Dynamic Analysis: Symbolic execution and fuzzing capabilities
  • 🧠 ML-Powered Detection: Machine learning models for vulnerability detection
  • πŸ”Œ REST API: Easy integration with existing workflows
  • πŸ“Š Comprehensive Reporting: Detailed vulnerability reports with severity classification
  • πŸ” Sandboxed Execution: Safe contract analysis in isolated environments
  • πŸ“ˆ Telemetry & Monitoring: Built-in logging, metrics, and tracing

πŸ—οΈ Project Structure

agent/
β”œβ”€β”€ .github/workflows/     # CI/CD workflows
β”œβ”€β”€ .vscode/              # VS Code settings
β”œβ”€β”€ scripts/              # Utility scripts (lint, test, format)
β”œβ”€β”€ docs/                 # Documentation
β”‚   β”œβ”€β”€ architecture.md   # System architecture
β”‚   β”œβ”€β”€ agents.md        # Agent documentation
β”‚   β”œβ”€β”€ api.md           # API documentation
β”‚   β”œβ”€β”€ pipelines.md     # Pipeline documentation
β”‚   └── research/        # Research papers and notes
β”œβ”€β”€ models/              # ML models
β”‚   β”œβ”€β”€ transformers/    # Transformer models
β”‚   └── gnn/            # Graph Neural Network models
β”œβ”€β”€ data/               # Data storage
β”‚   β”œβ”€β”€ contracts/      # Smart contract samples
β”‚   └── datasets/       # Training datasets
β”œβ”€β”€ tests/              # Test suites
β”‚   β”œβ”€β”€ unit/          # Unit tests
β”‚   β”œβ”€β”€ integration/   # Integration tests
β”‚   β”œβ”€β”€ e2e/           # End-to-end tests
β”‚   β”œβ”€β”€ load/          # Load tests
β”‚   └── fixtures/      # Test fixtures
β”œβ”€β”€ src/oal_agent/     # Main source code
β”‚   β”œβ”€β”€ app/           # FastAPI application
β”‚   β”œβ”€β”€ core/          # Core orchestration
β”‚   β”œβ”€β”€ agents/        # Analysis agents
β”‚   β”œβ”€β”€ tools/         # External tool integrations
β”‚   β”œβ”€β”€ services/      # Background services
β”‚   β”œβ”€β”€ llm/           # LLM integration
β”‚   β”œβ”€β”€ security/      # Security components
β”‚   β”œβ”€β”€ telemetry/     # Logging & metrics
β”‚   β”œβ”€β”€ utils/         # Utilities
β”‚   └── cli.py         # Command-line interface
└── Configuration files (pyproject.toml, requirements.txt, etc.)

πŸš€ Quick Start

Prerequisites

  • Python 3.9+ (3.11 recommended)
  • Redis (for job queue management)
  • PostgreSQL or SQLite (for result storage)
  • Solidity compiler (solc) for contract analysis
  • Optional: Docker for containerized deployment

Installation

  1. Clone the repository

    git clone https://github.com/OpenAuditLabs/agent.git
    cd agent
  2. Set up Python environment

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    pip install -r requirements.txt
    pip install -r requirements-dev.txt
  3. Configure environment

    cp .env.example .env
    # Edit .env with your configuration
    # For profile-specific settings, create .env.<profile_name> files (e.g., .env.dev, .env.prod)

    Key environment variables:

    • API_HOST / API_PORT: API server configuration
    • DATABASE_URL: Database connection string
    • QUEUE_URL: Redis connection string
    • LLM_PROVIDER: LLM provider (openai, anthropic, etc.)
    • LLM_API_KEY: API key for LLM provider
    • LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR)
  4. Install pre-commit hooks

    pre-commit install

For detailed setup instructions, see the Setup Guide.

Running the Application

Start the API server:

# Using module notation
python -m src.oal_agent.cli serve

# Or directly
python src/oal_agent/cli.py serve

# With custom host/port
python src/oal_agent/cli.py serve --host 0.0.0.0 --port 8080

# With a specific configuration file
python src/oal_agent/cli.py --config ~/.oal_agent.env serve

# With a profile-specific configuration (e.g., .env.dev)
python src/oal_agent/cli.py --profile dev serve

Analyze a contract:

python src/oal_agent/cli.py analyze path/to/contract.sol

Access the API:

API Usage Example

import httpx

# Submit a contract for analysis
async with httpx.AsyncClient() as client:
    response = await client.post(
        "http://localhost:8000/api/v1/analysis/",
        json={
            "contract_code": "pragma solidity ^0.8.0; contract Example { ... }",
            "pipeline": "standard"
        }
    )
    job = response.json()
    job_id = job["job_id"]

    # Check job status
    status_response = await client.get(f"http://localhost:8000/api/v1/analysis/{job_id}")
    print(status_response.json())

    # Get results when complete
    results_response = await client.get(f"http://localhost:8000/api/v1/analysis/{job_id}/results")
    print(results_response.json())

πŸ§ͺ Testing

Run all tests:

bash scripts/test.sh

Run specific test suites:

pytest tests/unit/ -v
pytest tests/integration/ -v
pytest tests/e2e/ -v

Run with coverage:

pytest tests/ --cov=src/oal_agent --cov-report=html

πŸ”§ Development

Format code:

bash scripts/format.sh
# Or manually:
black src/ tests/
isort src/ tests/

Run linters:

bash scripts/lint.sh
# Includes: black, isort, flake8, mypy

Check code quality:

# Run all checks
pre-commit run --all-files

# Run specific checks
black --check src/ tests/
flake8 src/ tests/
mypy src/

πŸ“¦ Project Components

Core Components

  • Orchestrator: Manages the overall analysis workflow
  • Pipeline: Defines analysis sequences
  • Config: Centralized configuration management

Agents

  • Coordinator Agent: Routes tasks to specialized agents
  • Static Agent: Static code analysis using Slither, etc.
  • Dynamic Agent: Symbolic execution and fuzzing
  • ML Agent: Machine learning-based vulnerability detection

Tools Integration

  • Slither: Static analysis
  • Mythril: Symbolic execution
  • Sandbox: Safe contract execution environment

Services

  • Queue Service: Job queue management
  • Results Sink: Collects and stores results
  • Storage Service: Persistent data storage

LLM Integration

  • Provider: LLM API integration
  • Prompts: Specialized prompts for analysis
  • Guards: Safety and validation guardrails

πŸ” Security

  • Input validation for all user inputs
  • Sandboxed execution environment
  • Security policies and permissions
  • See SECURITY.md for details

πŸ“– Documentation

❓ Troubleshooting

Common Issues

Import errors after installation:

# Make sure you're in the virtual environment
source .venv/bin/activate
# Reinstall dependencies
pip install -r requirements.txt

Redis connection errors:

# Check if Redis is running
redis-cli ping
# Start Redis if needed
redis-server

Permission errors on scripts:

# Make scripts executable
chmod +x scripts/*.sh

Module not found errors:

# Add src to PYTHONPATH
export PYTHONPATH="${PYTHONPATH}:${PWD}/src"

For more help, see GitHub Issues or contact the team.

🀝 Contributing

We welcome contributions! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and linters (bash scripts/test.sh && bash scripts/lint.sh)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

πŸ“Š Roadmap

  • Complete core agent implementations
  • Add support for more static analysis tools
  • Implement ML model training pipeline
  • Add support for multiple blockchain platforms
  • Create web dashboard for analysis results
  • Implement real-time analysis streaming
  • Add plugin system for custom analyzers

πŸ› Bug Reports & Feature Requests

Please use the GitHub Issues to report bugs or request features.

πŸ’¬ Community & Support

πŸ“„ License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the LICENSE file for details.

Key points:

  • βœ… You can use, modify, and distribute this software
  • βœ… You must disclose source code of any modifications
  • βœ… Network use counts as distribution (you must share your modifications)
  • βœ… You must license derivative works under AGPL-3.0

πŸ™ Acknowledgments

  • OpenAuditLabs team and contributors
  • Open source security tools community (Slither, Mythril, etc.)
  • Smart contract security researchers and auditors worldwide

Made with ❀️ by OpenAuditLabs

About

AI-powered smart contract analysis engine for automated vulnerability detection

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors 11