-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(ecs): add cluster validation and configuration collection (PR #2) #1592
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
base: main
Are you sure you want to change the base?
feat(ecs): add cluster validation and configuration collection (PR #2) #1592
Conversation
Add foundational security analysis tool with cluster listing functionality. This PR establishes the core infrastructure and module registration. Features: - Region validation and selection - ECS cluster listing with metadata - Interactive workflow for cluster selection - Comprehensive error handling - Module registration in main.py Files Added: - awslabs/ecs_mcp_server/api/security_analysis.py (223 lines) - awslabs/ecs_mcp_server/modules/security_analysis.py (155 lines) - tests/unit/test_security_analysis_api.py (168 lines) - tests/unit/test_security_analysis_module.py (147 lines) Files Modified: - awslabs/ecs_mcp_server/main.py (module registration) Testing: - 14 unit tests with 91% coverage (with branch coverage) - All tests pass - Follows all coding patterns from existing codebase Usage: analyze_ecs_security() # List clusters in default region analyze_ecs_security(region='us-west-2') # List in specific region Total: 693 lines (378 production + 315 tests)
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1592 +/- ##
==========================================
+ Coverage 89.45% 89.54% +0.08%
==========================================
Files 724 728 +4
Lines 50959 51585 +626
Branches 8144 8261 +117
==========================================
+ Hits 45585 46191 +606
- Misses 3465 3479 +14
- Partials 1909 1915 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
14d794c to
3e5ca26
Compare
3e5ca26 to
7552d2d
Compare
|
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. |
Summary
Changes
This PR adds cluster validation and comprehensive configuration collection capabilities to the ECS Security Analysis Tool. It extends PR #1 by enabling the tool to collect detailed cluster configurations for security analysis.
Commit: 7cce872
New Features:
Files Modified:
src/ecs-mcp-server/awslabs/ecs_mcp_server/api/security_analysis.py(+375 lines) - AddedClusterNotFoundError,validate_clusters()andcollect_cluster_configuration()functionssrc/ecs-mcp-server/awslabs/ecs_mcp_server/modules/security_analysis.py(+107 lines, -22 lines) - Updated tool to acceptcluster_namesparameter and handle both list and collect modessrc/ecs-mcp-server/tests/unit/test_security_analysis_api.py(+439 lines, -1 line) - Comprehensive tests for new functionssrc/ecs-mcp-server/tests/unit/test_security_analysis_module.py(+132 lines, -2 lines) - Tests for updated module functionalityTotal: 1,078 lines changed (1,053 additions, 25 deletions)
User experience
Before this change:
Users could only list available ECS clusters. No way to collect detailed configuration data for security analysis.
After this change:
Users can now:
Example Usage:
Example Output:
{ "analysis_type": "ecs_security_configuration", "region": "us-east-1", "clusters_analyzed": 1, "cluster_configurations": [ { "cluster_name": "prod-cluster", "region": "us-east-1", "cluster_metadata": { "status": "ACTIVE", "running_tasks_count": 25, "active_services_count": 8, "tags": {"Environment": "Production"} }, "services": [ { "service_name": "web-service", "desired_count": 3, "running_count": 3, "task_definition": "arn:aws:ecs:...", "security_groups": [...] } ], "task_definitions": [...], "security_groups": [...], "collection_errors": [] } ], "collection_timestamp": "2025-10-27T17:30:00Z" }Checklist
If your change doesn't seem to apply, please leave them unchecked.
Testing:
Code Quality:
CODING_PATTERNS.txtNew Functions:
validate_clusters()- Validates cluster existence and returns ARNscollect_cluster_configuration()- Collects comprehensive cluster configurationIs this a breaking change? N
RFC issue number: N/A
Checklist:
Architecture Notes
This PR implements the second phase of the multi-PR plan:
The configuration collection is designed to gather all security-relevant data in a single pass, minimizing API calls while providing comprehensive information for security analysis.
Implementation Details
New Exception:
ClusterNotFoundError- Raised when one or more clusters cannot be found during validationNew Functions:
validate_clusters(cluster_names: list[str], region: str) -> list[str]ClusterNotFoundErrorif any cluster is not foundcollect_cluster_configuration(region: str, cluster_name: str) -> Dict[str, Any]Module Updates:
The
analyze_ecs_securitytool now supports two modes:Returns JSON with:
analysis_type: "ecs_security_configuration"region: Target AWS regionclusters_analyzed: Number of clusters processedcluster_configurations: Array of cluster configuration objectscollection_timestamp: ISO 8601 timestampError Handling:
collection_errorsarrayDependencies
This PR builds on PR #1 and must be merged after PR #1 is approved.
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.