项目文件夹

文件
Gelei Deng e238d701f2 feat: 🎸 version 1.0 agentic workflow (#325)
* feat: 🎸 version 1.0 agentic workflow

Major rewrite of PentestGPT to use an agentic pipeline architecture:
Core Changes: - New event-driven architecture with EventBus for
TUI-agent decoupling - Implemented AgentController with 5-state
lifecycle (IDLE->RUNNING->PAUSED->COMPLETED->ERROR) - Added AgentBackend
interface with ClaudeCodeBackend implementation - Session management
with file-based persistence for resumable pentests - Langfuse
integration for observability and tracing Interface: - New Textual-based
TUI with real-time activity feed - Keyboard shortcuts: F1 help, Ctrl+P
pause, Ctrl+Q quit - Enhanced CLI with --target, --instruction,
--non-interactive, --debug flags Project Structure: - Moved legacy
multi-LLM version (v0.15) to legacy/ directory - New pentestgpt/core/
for agent, controller, events, session modules - New
pentestgpt/interface/ for TUI and CLI components - New
pentestgpt/benchmark/ for xbow benchmark integration - Comprehensive
test suite in tests/ with unit and integration tests DevOps: - Docker
support with Ubuntu 24.04 container - GitHub Actions CI/CD pipeline -
Makefile with dev commands (test, lint, format, typecheck) - Added
xbow-validation-benchmarks as submodule

* style: format code with Black

This commit fixes the style issues introduced in abe3be0 according to the output
from Black.

Details: https://github.com/GreyDGL/PentestGPT/pull/325

* fix: 🐛 fix test pipeline

* feat: 🎸 update format

* feat: 🎸 update

---------

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2025-12-13 01:57:24 +08:00

72 行
2.0 KiB
Python

"""Base classes for extensible tool framework."""
from abc import ABC, abstractmethod
from typing import Any
class BaseTool(ABC):
"""Base class for all tools in PentestGPT."""
def __init__(self, name: str, description: str) -> None:
"""
Initialize a tool.
Args:
name: Tool name (e.g., "terminal_execute")
description: Human-readable description
"""
self.name = name
self.description = description
@abstractmethod
async def execute(self, *args: Any, **kwargs: Any) -> dict[str, Any]:
"""
Execute the tool with given arguments.
Returns:
Dictionary with execution results including:
- success: bool
- result: Any
- error: Optional[str]
"""
pass
def to_dict(self) -> dict[str, Any]:
"""Convert tool execution info to dictionary for tracer."""
return {
"tool_name": self.name,
"description": self.description,
}
class TerminalTool(BaseTool):
"""Tool for executing terminal commands (via Claude Code)."""
def __init__(self) -> None:
"""Initialize terminal tool."""
super().__init__(
name="terminal_execute", description="Execute shell commands for penetration testing"
)
async def execute(self, command: str = "", **kwargs: Any) -> dict[str, Any]:
"""
Execute a terminal command.
Note: For MVP, this is handled by Claude Code's built-in Bash tool.
This class serves as a placeholder for future enhancements.
Args:
command: Shell command to execute
**kwargs: Additional arguments
Returns:
Execution results
"""
# In the MVP, Claude Code handles command execution
# This is a placeholder for future direct execution capability
return {
"success": True,
"command": command,
"result": "Executed via Claude Code",
}