Some checks are pending
Build Ghidra Plugin / build (push) Waiting to run
- Rename src/ghydramcp → src/mcghidra - Rename GhydraMCPPlugin.java → MCGhidraPlugin.java - Update all imports, class names, and references - Update pyproject.toml package name and script entry - Update Docker image names and container prefixes - Update environment variables: GHYDRA_* → MCGHIDRA_* - Update all documentation references
172 lines
5.1 KiB
Makefile
172 lines
5.1 KiB
Makefile
# MCGhidra Makefile
|
|
# Convenient commands for Docker and development operations
|
|
|
|
.PHONY: help build build-dev up up-dev down down-dev logs logs-dev \
|
|
shell status clean analyze test health
|
|
|
|
# Default target
|
|
help:
|
|
@echo "MCGhidra Docker Management"
|
|
@echo "============================"
|
|
@echo ""
|
|
@echo "Build commands:"
|
|
@echo " make build Build production Docker image"
|
|
@echo " make build-dev Build development Docker image"
|
|
@echo " make build-all Build both images"
|
|
@echo ""
|
|
@echo "Run commands:"
|
|
@echo " make up Start production container"
|
|
@echo " make up-dev Start development container"
|
|
@echo " make down Stop production container"
|
|
@echo " make down-dev Stop development container"
|
|
@echo " make down-all Stop all containers"
|
|
@echo ""
|
|
@echo "Analysis commands:"
|
|
@echo " make analyze FILE=path/to/binary Analyze a binary"
|
|
@echo " make analyze-bg FILE=path/to/binary Analyze in background"
|
|
@echo ""
|
|
@echo "Utility commands:"
|
|
@echo " make shell Start interactive shell in container"
|
|
@echo " make logs View production container logs"
|
|
@echo " make logs-dev View development container logs"
|
|
@echo " make status Check container status"
|
|
@echo " make health Check API health"
|
|
@echo " make clean Remove containers and volumes"
|
|
@echo " make clean-all Remove everything including images"
|
|
@echo ""
|
|
@echo "MCP Server commands:"
|
|
@echo " make mcp Start the MCP server (Python)"
|
|
@echo " make mcp-dev Start MCP server in development mode"
|
|
@echo ""
|
|
|
|
# =============================================================================
|
|
# Build Commands
|
|
# =============================================================================
|
|
|
|
build:
|
|
docker compose build mcghidra
|
|
|
|
build-dev:
|
|
docker compose build mcghidra-dev
|
|
|
|
build-all: build build-dev
|
|
|
|
# =============================================================================
|
|
# Run Commands
|
|
# =============================================================================
|
|
|
|
up:
|
|
docker compose --profile prod up -d mcghidra
|
|
@echo "MCGhidra starting... checking health in 30 seconds"
|
|
@sleep 30
|
|
@$(MAKE) health || echo "Server may still be starting up..."
|
|
|
|
up-dev:
|
|
docker compose --profile dev up -d mcghidra-dev
|
|
@echo "MCGhidra (dev) starting..."
|
|
|
|
down:
|
|
docker compose --profile prod down
|
|
|
|
down-dev:
|
|
docker compose --profile dev down
|
|
|
|
down-all:
|
|
docker compose --profile prod --profile dev --profile debug down
|
|
|
|
restart: down up
|
|
|
|
restart-dev: down-dev up-dev
|
|
|
|
# =============================================================================
|
|
# Analysis Commands
|
|
# =============================================================================
|
|
|
|
# Analyze a binary file
|
|
# Usage: make analyze FILE=/path/to/binary
|
|
analyze:
|
|
ifndef FILE
|
|
@echo "Error: FILE is required. Usage: make analyze FILE=/path/to/binary"
|
|
@exit 1
|
|
endif
|
|
@echo "Analyzing: $(FILE)"
|
|
docker compose run --rm -v "$(dir $(FILE)):/binaries:ro" mcghidra /binaries/$(notdir $(FILE))
|
|
|
|
# Analyze in background (detached)
|
|
analyze-bg:
|
|
ifndef FILE
|
|
@echo "Error: FILE is required. Usage: make analyze-bg FILE=/path/to/binary"
|
|
@exit 1
|
|
endif
|
|
@echo "Starting background analysis of: $(FILE)"
|
|
docker compose run -d -v "$(dir $(FILE)):/binaries:ro" mcghidra /binaries/$(notdir $(FILE))
|
|
|
|
# =============================================================================
|
|
# Utility Commands
|
|
# =============================================================================
|
|
|
|
shell:
|
|
docker compose --profile debug run --rm mcghidra-shell
|
|
|
|
logs:
|
|
docker compose logs -f mcghidra
|
|
|
|
logs-dev:
|
|
docker compose logs -f mcghidra-dev
|
|
|
|
status:
|
|
@echo "=== Container Status ==="
|
|
@docker compose ps -a
|
|
@echo ""
|
|
@echo "=== Resource Usage ==="
|
|
@docker stats --no-stream $$(docker compose ps -q 2>/dev/null) 2>/dev/null || echo "No containers running"
|
|
|
|
health:
|
|
@echo "Checking MCGhidra API health..."
|
|
@curl -sf http://localhost:$${MCGHIDRA_PORT:-8192}/ | python3 -m json.tool 2>/dev/null \
|
|
|| echo "API not responding (server may be starting or binary being analyzed)"
|
|
|
|
# =============================================================================
|
|
# Cleanup Commands
|
|
# =============================================================================
|
|
|
|
clean:
|
|
docker compose --profile prod --profile dev --profile debug down -v
|
|
@echo "Containers and volumes removed"
|
|
|
|
clean-all: clean
|
|
docker rmi mcghidra:latest mcghidra:dev 2>/dev/null || true
|
|
@echo "Images removed"
|
|
|
|
prune:
|
|
docker system prune -f
|
|
@echo "Docker system pruned"
|
|
|
|
# =============================================================================
|
|
# MCP Server Commands
|
|
# =============================================================================
|
|
|
|
mcp:
|
|
uv run python -m mcghidra
|
|
|
|
mcp-dev:
|
|
uv run python -m mcghidra --verbose
|
|
|
|
# =============================================================================
|
|
# Development Commands
|
|
# =============================================================================
|
|
|
|
test:
|
|
uv run pytest tests/ -v
|
|
|
|
lint:
|
|
uv run ruff check src/
|
|
|
|
format:
|
|
uv run ruff format src/
|
|
|
|
# Check if binaries directory exists
|
|
check-binaries:
|
|
@mkdir -p binaries
|
|
@echo "Binaries directory ready at ./binaries/"
|