mirror of
https://github.com/GH05TCREW/MetasploitMCP.git
synced 2026-07-25 10:55:22 -04:00
1aec6127e6
- Add RPC_CALL_TIMEOUT (30s) constant for RPC operations - Wrap list_exploits and list_payloads with asyncio.wait_for to prevent hanging - Add timeout handling to list_active_sessions and list_listeners - Add timeout handling to health check endpoint - Improve error messages with specific timeout information - Add debug logging for RPC calls to help diagnose communication issues - Add check_msf_connection() helper function for connection status - Add comprehensive timeout error handling with user-friendly messages Fixes issue where list_exploits call would hang for 3+ minutes when Metasploit server is slow or unresponsive. Now fails fast with clear error message after 30 second timeout.
96 lines
2.4 KiB
Makefile
96 lines
2.4 KiB
Makefile
# Makefile for MetasploitMCP testing and development
|
|
|
|
.PHONY: help install-deps test test-unit test-integration test-options test-helpers test-tools coverage clean lint format
|
|
|
|
# Default target
|
|
help:
|
|
@echo "Available targets:"
|
|
@echo " help - Show this help message"
|
|
@echo " install-deps - Install test dependencies"
|
|
@echo " test - Run all tests"
|
|
@echo " test-unit - Run unit tests only"
|
|
@echo " test-integration - Run integration tests only"
|
|
@echo " test-options - Run options parsing tests only"
|
|
@echo " test-helpers - Run helper function tests only"
|
|
@echo " test-tools - Run MCP tools tests only"
|
|
@echo " coverage - Run tests with coverage report"
|
|
@echo " coverage-html - Run tests with HTML coverage report"
|
|
@echo " lint - Run linting checks"
|
|
@echo " format - Format code"
|
|
@echo " clean - Clean up generated files"
|
|
|
|
# Install test dependencies
|
|
install-deps:
|
|
python -m pip install -r requirements-test.txt
|
|
|
|
# Test targets
|
|
test:
|
|
python run_tests.py --all
|
|
|
|
test-unit:
|
|
python run_tests.py --unit
|
|
|
|
test-integration:
|
|
python run_tests.py --integration
|
|
|
|
test-options:
|
|
python run_tests.py --options
|
|
|
|
test-helpers:
|
|
python run_tests.py --helpers
|
|
|
|
test-tools:
|
|
python run_tests.py --tools
|
|
|
|
# Coverage targets
|
|
coverage:
|
|
python run_tests.py --all --coverage
|
|
|
|
coverage-html:
|
|
python run_tests.py --all --coverage --html
|
|
@echo "Coverage report: file://$(PWD)/htmlcov/index.html"
|
|
|
|
# Code quality targets
|
|
lint:
|
|
@echo "Running flake8..."
|
|
-python -m flake8 MetasploitMCP.py tests/ --max-line-length=120 --ignore=E203,W503
|
|
@echo "Running pylint..."
|
|
-python -m pylint MetasploitMCP.py --disable=C0301,C0103,R0903,R0913
|
|
|
|
format:
|
|
@echo "Running black code formatter..."
|
|
-python -m black MetasploitMCP.py tests/ --line-length=120
|
|
@echo "Running isort import formatter..."
|
|
-python -m isort MetasploitMCP.py tests/
|
|
|
|
# Cleanup
|
|
clean:
|
|
rm -rf __pycache__/
|
|
rm -rf tests/__pycache__/
|
|
rm -rf .pytest_cache/
|
|
rm -rf htmlcov/
|
|
rm -rf .coverage
|
|
rm -rf *.pyc
|
|
rm -rf tests/*.pyc
|
|
find . -name "*.pyc" -delete
|
|
find . -name "__pycache__" -type d -exec rm -rf {} +
|
|
|
|
# Development targets
|
|
dev-setup: install-deps
|
|
@echo "Development environment setup complete"
|
|
|
|
check: lint test
|
|
@echo "All checks passed!"
|
|
|
|
# CI/CD targets
|
|
ci-test:
|
|
python run_tests.py --all --coverage --verbose
|
|
|
|
# Quick test (no coverage)
|
|
quick-test:
|
|
pytest tests/ -x -v
|
|
|
|
# Test with failure details
|
|
test-debug:
|
|
pytest tests/ -v --tb=long --capture=no
|