Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xSteph Pentest ai RateLimiter

From Leeroopedia
Knowledge Sources
Domains Rate_Limiting, Scan_Intensity, Throttling
Last Updated 2026-10-23 00:00 GMT

Overview

Concrete tool for controlling scan intensity via per-intensity rate profiles with RPS, concurrency, and phase delays, provided by the pentest-ai engine.

Description

The rate_limiter module defines ScanProfile dataclass and RateLimiter class. ScanProfile.from_intensity maps intensity levels (stealth, safe, normal, aggressive) to rate profiles: requests_per_second, max_concurrent_tools, delay_between_phases, tool_timeout_seconds, and max_retries. The RateLimiter enforces the profile using asyncio semaphore and sleep.

Usage

Import this module when you need to throttle scan traffic or control tool concurrency. Used by the orchestrator and agent loop.

Code Reference

Source Location

Signature

@dataclass(frozen=True)
class ScanProfile:
    requests_per_second: float
    max_concurrent_tools: int
    delay_between_phases: float
    tool_timeout_seconds: int
    max_retries: int = 1

    @classmethod
    def from_intensity(cls, intensity: str) -> "ScanProfile": ...

class RateLimiter:
    def __init__(self, profile: ScanProfile) -> None: ...
    async def acquire(self) -> None: ...
    async def release(self) -> None: ...

Import

from engine.rate_limiter import ScanProfile, RateLimiter

I/O Contract

Inputs

Name Type Required Description
intensity str Yes "stealth", "safe", "normal", or "aggressive"

Outputs

Name Type Description
ScanProfile dataclass Frozen rate profile for the intensity level

Usage Examples

Apply Rate Limiting

import asyncio
from engine.rate_limiter import ScanProfile, RateLimiter

profile = ScanProfile.from_intensity("stealth")
# 2 RPS, 1 concurrent tool, 5s phase delay, 300s timeout, 0 retries

limiter = RateLimiter(profile)

async def scan():
    await limiter.acquire()
    try:
        # ... run scan tool ...
        pass
    finally:
        await limiter.release()

asyncio.run(scan())

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment