-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: Add enhanced cluster security analysis with container instance and capacity provider checks (PR #2) #1458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add comprehensive security analysis functionality for ECS clusters with interactive user workflow and AWS Trusted Advisor-style recommendations. Features: - Interactive cluster selection workflow (prevents automatic analysis) - Security checks for Container Insights, exec logging, CloudWatch encryption - Color-coded recommendations (red/yellow/green) with severity levels - Two-section output: Critical/High priority + Medium/Low priority - Comprehensive error handling and user guidance Implementation: - Module layer: FastMCP tool registration with detailed documentation - API layer: DataAdapter and SecurityAnalyzer classes - Test suite: 75 tests with 97% coverage using parameterized tests Files: - awslabs/ecs_mcp_server/api/security_analysis.py (478 lines) - awslabs/ecs_mcp_server/modules/security_analysis.py (198 lines) - tests/unit/test_security_analysis.py (405 lines) - awslabs/ecs_mcp_server/main.py (2 lines added) All quality checks passed: formatting, linting, type checking, DRY principle
7988654 to
a471941
Compare
… instance and capacity provider checks - Add container instance security checks (agent version, connectivity, instance types) - Add capacity provider security checks (termination protection, scaling config) - Implement data collection methods for container instances and capacity providers - Add comprehensive test coverage (94%) with 60+ new tests - Follow color-coded severity pattern (🔴 High, 🟡 Medium, 🟢 Low) - Include actionable CLI remediation steps for all recommendations Closes #<issue-number>
a471941 to
20e77dc
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1458 +/- ##
========================================
Coverage 89.45% 89.45%
========================================
Files 726 728 +2
Lines 50305 50532 +227
Branches 7942 7980 +38
========================================
+ Hits 44998 45205 +207
- Misses 3452 3465 +13
- Partials 1855 1862 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This pull request is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label. |
|
This pull request is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label. |
|
Closing this pull request as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen. If you wish to exclude this issue from being marked as stale, add the "backlog" label. |
Fixes #
Summary
Changes
This PR adds deep infrastructure security analysis for ECS clusters by examining container instances and capacity providers. It extends the security analysis functionality introduced in PR #1 with comprehensive infrastructure-level checks.
New Security Checks Added:
🖥️ Container Instance Security (3 checks)
⚙️ Capacity Provider Security (3 checks)
Technical Implementation:
collect_container_instances()andcollect_capacity_providers()data collection methods_analyze_enhanced_cluster_security()(~150 lines) for container instance analysis_analyze_capacity_providers()(~100 lines) for capacity provider analysis_is_agent_version_outdated()helper for semantic version comparisonUser experience
Before this change:
Users could only analyze cluster-level configuration settings (Container Insights, execute command logging). No visibility into infrastructure security posture.
After this change:
Users get comprehensive infrastructure security analysis including:
Example Output:
{ "recommendations": [ { "title": "🔴 Outdated ECS Agent Version", "severity": "High", "category": "Container Instance", "resource": "abc123", "resource_type": "ContainerInstance", "issue": "Container instance abc123 is running ECS agent version 1.65.0, which is below the recommended minimum version 1.70.0. Outdated agents may have security vulnerabilities or lack important features.", "recommendation": "Update the ECS agent to the latest version to ensure security patches and feature improvements are applied", "remediation_steps": [ "# For Amazon Linux 2 AMI:", "# SSH into the instance (EC2 instance ID: i-1234567890abcdef0)", "sudo yum update -y ecs-init", "sudo systemctl restart ecs" ], "documentation_links": [ "https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-update.html" ] } ] } Consistency with PR #1: ✅ Color-coded severity indicators (🔴 High, 🟡 Medium, 🟢 Low) ✅ Detailed recommendation structure with actionable CLI commands ✅ Resource type categorization ✅ AWS documentation links ✅ DRY principle with helper methods Checklist If your change doesn't seem to apply, please leave them unchecked. [x] I have reviewed the contributing guidelines [x] I have performed a self-review of this change [x] Changes have been tested [x] Changes are documented Quality Checks Passed: ✅ Pattern checks passed (coding standards) ✅ Code formatting passed (ruff format) ✅ Linting passed (ruff check) ✅ Type checking passed (pyright) ✅ Pre-commit validation passed ✅ Tests passed: 130 tests, 94% coverage Is this a breaking change? N RFC issue number: N/A Checklist: [ ] Migration process documented [ ] Implement warnings (if it can live side by side) ## Acknowledgment By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the [project license](https://github.com/awslabs/mcp/blob/main/LICENSE).