* Security: Fix command substitution bypass and implement version 2 policy schema
- Hard-ban all command substitution ($(), backticks, $((())) to prevent policy bypasses
- Implement version 2 policy schema with simple_binaries and structured rules
- Remove legacy commands fnmatch patterns (breaking change)
- Add shlex-based argument parsing for argument-aware rule matching
- Block path-based binaries by default for security
- Update config/policy.yml and examples/example-policy.yml to version 2 schema
- Add comprehensive tests for command substitution blocking and version 2 schema
- Update documentation to reflect version 2 schema only
- Update CHANGELOG with security fix and breaking changes
Fixes: Command substitution bypass vulnerabilities (15+ bypasses blocked)
Breaking: Legacy commands patterns removed, version 2 schema only
* Add comprehensive test coverage and improve policy validation
- Add new test files for comprehensive coverage:
- test_ssh_coverage.py: SSH client edge cases and error handling
- test_ssh_integration.py: SSH integration scenarios
- test_utilities_coverage.py: Async task management and progress callbacks
- test_mcp_server_coverage.py: MCP server coverage (notification handlers, context logging, resources)
- Expand test_ssh.py with extensive test cases (1000+ lines added)
- Improve policy.py structured rule matching:
- Fix validation to require binary field for structured rules
- Add validation to ensure structured rules have at least one restriction
- Improve allow_extra_args logic with path_args support
- Fix edge cases in argument matching
- Add type annotations for mypy compliance
- Update documentation:
- Update CHANGELOG.md with test coverage details
- Update README.md, SECURITY.md, and wiki documentation
- Update example-policy.yml with version 2 schema
- Update CONTRIBUTING.md with script documentation
- Fix markdownlint issues in SECURITY.md
- Script maintenance:
- Add scripts/README.md documenting all scripts
- Add scripts/test-mcp-automated.py for automated testing
- Remove obsolete scripts (fix-markdownlint.py, fix-markdownlint.sh, test-annotations.sh)
- Enhance scripts/validate-mcp-schema.py with improved type checking
- Update pyproject.toml configuration
- Clean up .cursor/commands/issues.md (no longer needed)
- Fix code quality issues:
- Fix ruff UP038: Use X | Y instead of (X, Y) in isinstance
- Add missing type annotations for mypy compliance
- Fix unreachable code warnings
* Add .cursor/ to .gitignore and remove from tracking
* fix: Add pytest-asyncio dependency to fix async test failures
- Add pytest-asyncio>=0.21.0,<1.0.0 to test dependencies
- Configure asyncio_mode = 'auto' in pytest settings
- Fixes 10 failing async tests in test_mcp_server_coverage.py
* fix: Fix all broken code blocks and formatting issues in markdown files
- Fix unclosed code blocks in docs/CONTRIBUTING.md
- Fix broken code blocks in docs/wiki/12-Troubleshooting.md
- Fix broken code blocks in docs/wiki/13-Contributing.md
- Fix broken code blocks in docs/wiki/06-Configuration.md
- Fix broken code blocks in docs/wiki/11-Observability-Audit.md
- Wrap JSON examples in proper code blocks with json language specifier
- Fix code block language specifiers
- Ensure all code blocks are properly closed
Addresses PR review feedback from CodeBotD
- Fix SSH client exception handling to catch only KeyError/AttributeError (Issue #1)
- Fix DNS cache race condition with 1-second grace period (Issue #2)
- Fix cleanup thread to support graceful shutdown and log exceptions (Issue #3)
- Improve type hints for _ctx_log payload parameter (Issue #7)
- Increase command hash length from 12 to 16 characters for better collision resistance (Issue #11)
BREAKING CHANGE: Command hash length increased from 12 to 16 characters.
External tools parsing command hashes may need updates.
Added comprehensive unit tests for all fixes (11 new tests).
All 280 tests pass.
* feat: Improve SSH error handling with specific messages and per-host exception handling
- Enhanced SSH error messages with specific failure reasons:
* Authentication failures, timeouts, connection refused
* DNS resolution failures, host key verification errors
* Key file errors (not found, permission denied, format invalid, passphrase required)
* Network unreachable errors
- Added per-host exception handling in ssh_run_on_tag:
* Individual host failures no longer stop entire operation
* Each host's result included in results array with exit_code: -1 for failures
* Proper task cleanup on failure
- Improved async task error handling with sanitized error messages
- Comprehensive test coverage:
* 12 new unit tests for SSH error scenarios
* 5 new integration tests for per-host handling
* 7 new MCP compliance tests
- Added MCP Inspector test script for error handling validation
- Updated documentation:
* Troubleshooting guide with detailed error message explanations
* Tools reference with error handling documentation
* CHANGELOG with all improvements
All error messages are sanitized for security (no IPs, hostnames, or file paths exposed).
Follows MCP specification requirements for error handling patterns.
* fix: Replace socket.timeout with TimeoutError per ruff UP041 rule
- Changed socket.timeout to TimeoutError in test_ssh_client_connection_timeout
- Fixes ruff linting error UP041
- Test still passes (TimeoutError is handled by existing exception handler)
**Security Enhancement:** Prevent DNS-based DoS attacks and reduce load.
**Implementation:**
- Added in-memory rate limiter: max 10 resolutions/second per hostname
- Added DNS result caching with 60-second TTL
- Added 5-second timeout for DNS resolution
- Thread-safe implementation for concurrent access
- Rate limit violations logged as security events
**Rate Limiting Features:**
- Per-hostname tracking (separate limits for different hostnames)
- Time-window based (sliding 1-second window)
- Returns empty list when rate limited (fails closed)
**Caching Features:**
- Caches successful and failed resolutions
- Prevents repeated lookups for invalid hostnames
- Reduces load on DNS servers
**Tests Added:**
- 9 comprehensive tests for DNS rate limiting and caching
- Tests for normal resolution, rate limiting, caching, time windows
- Tests for per-hostname isolation and cache expiration
- Tests for empty hostname and timeout handling
**Documentation:**
- Updated SECURITY.md with DNS rate limiting section
- Updated Security-Model.md with DNS rate limiting details
- Updated CHANGELOG.md with PR8 entry
**Security Impact:** Prevents DNS-based DoS attacks by limiting
resolution frequency and caching results, reducing load on DNS
infrastructure.
Fixes security vulnerability from CodeQL analysis.