How ghostsecurity/reaper works
Purpose and entry point
Reaper is a Go-based local HTTPS MITM proxy for application-security testing. It captures in-scope HTTP(S) traffic, persists requests/responses locally, and exposes CLI commands for proxy lifecycle and traffic inspection. The executable starts at cmd/reaper/main.go; version metadata is in version/version.go.
CLI control plane
The CLI is organized as command handlers under internal/cli/, with a root command coordinating subcommands. Lifecycle commands start, stop, and communicate with the background proxy process; query commands retrieve, search, format, tail, clear, and inspect stored traffic.
• internal/cli/root.go
• internal/cli/start.go
• internal/cli/get.go
• internal/cli/search.go
• internal/cli/logs.go
Platform-specific startup behavior is separated between internal/cli/start_unix.go and internal/cli/start_windows.go.
Daemon boundary
A local daemon separates short-lived CLI invocations from the long-running interception service. CLI-side connection logic and daemon-side serving communicate through an explicit protocol layer, allowing commands such as status, shutdown, and traffic queries to target the running process rather than directly owning proxy execution.
• internal/daemon/client.go
• internal/daemon/server.go
• internal/daemon/protocol.go
• internal/daemon/daemon.go
Interception and TLS handling
The proxy subsystem is the traffic-plane boundary between target applications and remote services. It handles proxying, certificate generation/management for HTTPS interception, and scope filtering so only configured in-scope traffic is captured.
• internal/proxy/proxy.go
• internal/proxy/cert.go
• internal/proxy/scope.go
Control flow is: client application → local MITM proxy → scope decision → upstream destination; eligible request/response exchanges are emitted for storage.
Persistence and query model
Captured traffic is represented by storage models and written to a local SQLite-backed store. This forms the durable boundary between live interception and later CLI inspection, enabling search and request/response retrieval after capture.
• internal/storage/models.go
• internal/storage/store.go
• internal/storage/sqlite.go
The main data flow is proxy capture → storage abstraction → SQLite database → daemon protocol → CLI rendering/output.
Runtime and distribution
The runtime is a compiled Go binary, primarily documented for Linux and macOS. Installation can use the repository script, while release packaging is driven by GoReleaser. GitHub Actions validates Go tests/linting and publishes releases.
• scripts/install.sh
• .goreleaser.yaml
• .github/workflows/release.yml
• go.mod
Main entry points: root.go Root command · proxy.go MITM proxy · client.go Daemon client · main.go Reaper binary
Components 24
CLI Control Plane
- Root command
internal/cli/root.go - Start lifecycle · Starts, stops, and manages the background service.
internal/cli/start.go - Traffic queries · Gets, searches, formats, tails, and inspects captured traffic.
internal/cli/get.go - Traffic search
internal/cli/search.go - Log output
internal/cli/logs.go - Platform startup · Uses Unix- or Windows-specific daemon startup behavior.
internal/cli/start_unix.go
Local Daemon
Separates CLI invocations from the long-running proxy.
- Daemon client
internal/daemon/client.go - Daemon server · Serves lifecycle and traffic-query requests from CLI processes.
internal/daemon/server.go - Daemon protocol · Defines status, shutdown, and traffic-query messages.
internal/daemon/protocol.go - Daemon runtime
internal/daemon/daemon.go
Traffic Plane
- MITM proxy · Intercepts in-scope HTTP(S) exchanges.
internal/proxy/proxy.go - TLS certificates
internal/proxy/cert.go - Scope filter · Determines whether an exchange is eligible for capture.
internal/proxy/scope.go
Traffic Storage
- Traffic models
internal/storage/models.go - Storage abstraction
internal/storage/store.go - Local SQLite · Durable captured request and response store.
internal/storage/sqlite.go
Build & Distribution
- Install script
scripts/install.sh - Release packaging
.goreleaser.yaml - Release workflow
.github/workflows/release.yml - Go module
go.mod
Other components
- Reaper binary
cmd/reaper/main.go - Version metadata
version/version.go - Client application
- Upstream destination
Connections 27
- Reaper binary → Root command: starts
- Version metadata → Reaper binary: versions
- Root command → Start lifecycle: routes
- Root command → Traffic queries: routes
- Root command → Traffic search: routes
- Root command → Log output: routes
- Start lifecycle → Platform startup: launches via
- Start lifecycle → Daemon client: controls
- Traffic queries → Daemon client: queries
- Traffic search → Daemon client: searches
- Log output → Daemon client: reads
- Daemon client → Daemon protocol: uses
- Daemon protocol → Daemon server: serves
- Daemon server → Daemon runtime: controls
- Daemon runtime → MITM proxy: runs
- Client application → MITM proxy: proxies through
- MITM proxy → TLS certificates: uses
- MITM proxy → Scope filter: evaluates
- MITM proxy → Upstream destination: forwards to
- Scope filter → Traffic models: eligible exchanges
- Traffic models → Storage abstraction: persists through
- Daemon server → Storage abstraction: retrieves traffic
- Storage abstraction → Local SQLite: stores in
- Go module → Reaper binary: builds
- Install script → Reaper binary: installs
- Release workflow → Release packaging: publishes with
- Release packaging → Reaper binary: packages