Introducing a new way to review your PRs.

Read the announcement

greydgl / pentestgpt

Automated Penetration Testing Agentic Framework Powered by Large Language Models

View on GitHub

13 documents · Updated Nov 16, 2026

docs / development-and-container-runtime

Development and container runtime

Overview

The repository has two development surfaces: the root compatibility/package layer and the nested maintained agent. The root project in pyproject.toml is named pentestgpt, requires Python >=3.12,<4.0, builds with Hatchling, and exports only pentestgpt_legacy plus the obsolete root unified_agent compatibility copy. Its console scripts are pentestgpt-legacy and pentestgpt-legacy-connection; the maintained autonomous CLI lives in the nested pentestgpt_agent/ project and is driven from root targets rather than from the root wheel. The root lockfile uv.lock pins the editable pentestgpt package and its runtime dependencies, including Pydantic, python-dotenv, Langfuse, prompt-toolkit/rich/loguru, OpenAI/Anthropic/Google SDKs, claude-agent-sdk, openai-codex, mcp, and PyYAML. Root dev tooling is Ruff, MyPy, pytest, pytest-asyncio, and pytest-cov.

Makefile is the supported entry point for local development. make install runs uv sync at the root and then uv sync --extra $(AGENT_EXTRA) inside pentestgpt_agent, defaulting AGENT_EXTRA=all. make test first runs the nested agent test suite and then root tests while ignoring tests/docker/; make test-all includes Docker contract tests. make check combines root Ruff/format checks over unified_agent/, pentestgpt_legacy/, and tests/ with the nested agent gate (ruff, format check, MyPy, pytest). make ci mirrors CI by running checks, root non-Docker tests, and both root and nested package builds. make run is the local maintained-agent runtime: it requires TARGET, enters pentestgpt_agent, and invokes uv run pentestgpt-agent --goal ... --target ... --backend ... with optional MODEL.

The GitHub workflow in .github/…/ci.yml has two jobs. The quality job installs uv/Python 3.12, syncs the root with uv sync --locked, syncs pentestgpt_agent with its own lockfile, runs make check, runs root non-Docker tests, and builds both packages. The Docker job validates docker compose config, builds pentestgpt:latest, syncs the root project, and runs tests/docker/ with marker docker.

The Docker image in Dockerfile is a disposable pentest tool and provider-CLI environment, not the maintained framework image. It starts from Ubuntu 24.04, installs Python 3.12, Node 20, uv, Claude Code, Claude Code Router (ccr), OpenAI Codex CLI, socat, and common pentest/network tools (nmap, gobuster, dirb, netcat, curl/wget, DNS/whois tools, OpenVPN, jq, ripgrep, tmux). It creates a non-root pentester user with passwordless sudo, prepares /workspace, /app, and provider config directories, copies pyproject.toml, README.md, root unified_agent/, pentestgpt_legacy/, and selected scripts/ files, then installs the root wheel into system Python with uv pip install --system /app. The image entrypoint is home/…/entrypoint.sh, default command is /bin/bash, and PYTHONPATH=/app. Comments in Dockerfile, docs/architecture.md, docs/docker-dev-plan.md, AGENT.md, and CLAUDE.md all state the current gap: pentestgpt_agent is not baked into this image, so make docker-run intentionally exits with a diagnostic instead of pretending the maintained CLI is available.

docker-compose.yml builds the same image as service pentestgpt, mounts ./workspace to /workspace, and persists provider state in named volumes: pentestgpt-claude to /home/pentester/.claude, pentestgpt-codex to /home/pentester/.codex, and ccr-config to /home/pentester/.claude-code-router. Compose keeps stdin/TTY open, grants NET_ADMIN plus /dev/net/tun for VPN use, adds host.docker.internal, and sets default auth-related environment variables (PENTESTGPT_AUTH_MODE, ANTHROPIC_API_KEY, OPENROUTER_API_KEY). .dockerignore excludes .env*, local provider credentials, workspace/run/log state, benchmark artifacts, and build/test caches so secrets and runtime data do not enter image layers.

Container authentication is split across scripts. scripts/entrypoint.sh reads PENTESTGPT_AUTH_MODE (manual by default). In manual mode it loads a persisted Claude OAuth token from $HOME/.claude/oauth_token when present and runs docker-auth-status.sh as a non-blocking preflight. In openrouter mode it requires OPENROUTER_API_KEY, templates scripts/ccr-config-template.json, starts ccr on port 3456, and activates the router in .bashrc; local mode does the same for a local LLM server at host.docker.internal:1234; anthropic mode checks for ANTHROPIC_API_KEY without starting CCR. scripts/docker-login.sh is the host-side idempotent login flow behind make docker-login: it creates the Claude/Codex volumes, live-checks both CLIs, runs in-container codex login with a socat callback forward for missing Codex auth, and stores a Claude setup-token in the Claude volume without passing it as an argument or environment variable. scripts/docker-auth-status.sh runs inside the image and reports success only when both Claude and Codex appear authenticated; --roundtrip spends minimal provider calls to verify live access.

There are older setup helpers that are useful but not the canonical runtime path. setup.sh checks Docker, creates/fixes ./workspace, builds pentestgpt:latest, and prints historical Docker usage that still mentions running pentestgpt-agent inside Compose. fix-workspace-permissions.sh creates or chowns ./workspace, rebuilds via Compose, and also prints the older in-container agent command. scripts/config.sh writes .env.auth for manual, OpenRouter, Anthropic, or local-LLM modes and refers to make connect, which is not a current Makefile target. Prefer the explicit Makefile Docker targets and scripts/docker-login.sh flow for current work.

The documentation files under this scope define the current architecture boundaries. docs/architecture.md says pentestgpt_agent/ is the maintained two-role Supervisor/Executor framework with SQLite canonical memory, deterministic compilers, fresh provider sessions, and external unified-agent dependency from the sibling UnifedAgentWrapper repository; the root unified_agent/ copy is retained only for root packaging, duplicate tests, and current tool-image health checks. docs/docker-dev-plan.md narrows the image responsibility to tools, provider CLIs, legacy code, and persisted auth, and lists framework-image wiring as an open deployment decision. PENTESTGPT_AGENT_NEW_MIGRATION_REPORT.md, PENTESTGPT_AGENT_NEW_PRODUCTION_HARDENING_REPORT.md, and docs/…/pentestgpt-redesign-decisions.html are historical records: they preserve why the project moved away from the old fixed-stage/Instructor-Judge designs toward the current two-role loop, but they are not operational instructions. README.md remains the public page and contains some stale examples (pentestgpt, Docker make docker-run) that should be checked against Makefile and docs/docker-dev-plan.md before being treated as runnable. AGENT.md and CLAUDE.md are the internal agent guides and explicitly say not to edit the public README unless requested.

Coupling

  • If root package contents change in pyproject.toml, also update Dockerfile and uv.lock; the image copies only pyproject.toml, README.md, unified_agent/, pentestgpt_legacy/, and selected scripts before installing /app, so adding a root package or removing unified_agent/ must be coordinated with image build and Docker contract tests.
  • If pentestgpt_agent becomes part of the image, update Dockerfile, Makefile docker-run, docs/docker-dev-plan.md, docs/architecture.md, and .github/…/ci.yml together. Today they intentionally encode the opposite contract: local make run is supported, in-image maintained-agent execution is pending.
  • If provider auth paths or volume names change, update docker-compose.yml, Makefile variables CLAUDE_VOL/CODEX_VOL, scripts/docker-login.sh, scripts/docker-auth-status.sh, and scripts/entrypoint.sh in one change. The login flow relies on matching mount points for .claude/oauth_token and .codex/auth.json.
  • If scripts/ccr-config-template.json changes provider names, model IDs, port, or host URLs, verify scripts/entrypoint.sh substitutions for __OPENROUTER_API_KEY__ and "__ROUTER_CONFIG__"; the script edits the JSON with sed and then expects ccr to listen on 127.0.0.1:3456.
  • If root test or lint paths move, adjust Makefile and .github/…/ci.yml together. CI delegates repository checks to make check but invokes root non-Docker tests and Docker tests directly.
  • If .dockerignore is relaxed, re-check the credential story in docs/docker-dev-plan.md; .env*, provider config directories, workspace, runs, logs, and benchmarks are deliberately excluded because auth and assessment artifacts are mounted or generated at runtime.

Risks

  • README.md, setup.sh, and fix-workspace-permissions.sh still advertise in-container pentestgpt-agent or make docker-run usage, while Makefile, Dockerfile, AGENT.md, CLAUDE.md, and docs/docker-dev-plan.md state the maintained framework is not baked into the image. If users follow the stale public/setup examples, Docker runs fail with an absent CLI or the Makefile's deliberate diagnostic.
  • scripts/config.sh writes .env.auth and points users to make connect, but Makefile does not define config or connect. If this script is presented as a supported path without adding those targets, auth setup appears to succeed and then dead-ends.
  • scripts/entrypoint.sh injects API keys and router JSON into scripts/ccr-config-template.json via sed. If an OpenRouter key contains characters significant to the sed replacement delimiter or replacement syntax, CCR config generation can produce invalid JSON and prevent OpenRouter mode from starting.
  • The Docker runtime grants pentester passwordless sudo plus NET_ADMIN and /dev/net/tun in docker-compose.yml. As documented in docs/docker-dev-plan.md, provider roles use full access and the container or attack box is the security boundary; mounting unrelated host paths, sockets, or secrets would expand the blast radius.