forked from awslabs/mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Add ECS Security Analysis feature #1
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add security_analysis API module with comprehensive security assessment capabilities - Add security_analysis module with cluster analysis, compliance checks, and reporting - Add integration tests for security analysis tools - Add LLM testing scenarios for security analysis - Add unit tests for security analysis API and modules - Update main.py to register security_analysis module - Add pre-commit dependency to pyproject.toml - Add security analysis documentation and manual test script
- Replace broad substring checks with exact count() validation - Add protocol validation to prevent URL confusion attacks - Use specific pattern matching instead of generic 'in' checks - Addresses CodeQL 'Incomplete URL substring sanitization' warnings Changes: - ECR image detection: Use startswith() + count() validation - Docker Hub detection: Use count() for exact pattern matching - Image tag validation: Use count() instead of 'in' operator - Maintain functionality while improving security posture
…ith secure regex validation - Replace insecure '.dkr.ecr.' and '.amazonaws.com/' substring checks with proper regex validation - Add _is_valid_ecr_image() method using strict ECR URI pattern matching - Prevent URL substring sanitization bypass vulnerabilities - Maintain backward compatibility with existing functionality
- Break long regex pattern into multiple lines to fix E501 line length error - Fix trailing whitespace and end-of-file issues across test files - All pre-commit hooks now pass successfully - CodeQL security issues remain fixed with proper ECR validation
- Replace vulnerable Docker Hub validation logic with secure regex patterns - Add _is_docker_hub_image() method with proper pattern matching - Prevent bypass attempts for Docker Hub image detection - Fix line length issues and ensure all pre-commit hooks pass - Comprehensive validation for both explicit and implicit Docker Hub formats
…tion vulnerabilities - Replace all vulnerable startswith() patterns with secure regex validation - Add secure helper methods: _is_https_url(), _is_latest_tag() - Fix Docker Hub validation to use only regex patterns (no startswith) - Secure ECR validation with comprehensive regex patterns - Replace vulnerable count() and endswith() patterns with regex - Secure ARN validation for AWS services (Secrets Manager, SSM, IGW) - All pre-commit hooks passing - Comprehensive protection against URL substring sanitization attacks
- Fixed all 54+ inconsistent f-string resource formatting patterns - Standardized all resource names to use _format_resource_name() method - Ensured uniform 'Resource Type: Resource Name' format throughout - Applied bulk fixes using sed for efficiency across resource types: * Services, Clusters, Task Definitions, Container Instances * VPCs, Security Groups, Load Balancers, Target Groups * EFS/FSx Volumes, ECR Repositories, Subnets, Route Tables - All pre-commit hooks passing ✅ - Python syntax validation passing ✅ - 96 consistent resource name calls now in place - Zero inconsistent patterns remaining - Provides uniform user experience for security analysis output
nzuresh
pushed a commit
that referenced
this pull request
Oct 1, 2025
This is PR #2 in the sequential security analysis implementation series. Features: - Complete service security analysis with analyze_service_security() method - Network security analysis: - Public IP assignment detection (High severity) - Security groups validation and excessive SG detection - Service Connect namespace configuration checks - Platform configuration analysis: - Fargate platform version pinning recommendations - Service Connect security validation - Tag security analysis: - Sensitive data detection in tag keys and values - Structured data identification in tags - Service health monitoring: - Unusual task count detection (potential DDoS indicators) - Zero running tasks detection (potential security incidents) - Bulk analysis support: - get_service_list() for service discovery - analyze_multiple_services() for batch analysis - Multi-framework compliance mapping (SOC2, HIPAA, PCI-DSS) - Consistent error handling and resource naming This PR adds ~325 lines of focused service analysis functionality, building on the core framework from PR #1. Each security check includes detailed recommendations and compliance framework mappings. Builds on: PR #1 (Core Infrastructure + Basic Cluster Analysis) Next: PR #3 (Task Definition Security Analysis)
nzuresh
pushed a commit
that referenced
this pull request
Oct 2, 2025
- Add SecurityAnalyzer class with basic ECS security analysis - Add analyze_ecs_security API endpoint with parameter validation - Add comprehensive unit tests with 100% coverage - Implement progressive PR approach (255 lines total) Files added/modified: - awslabs/ecs_mcp_server/modules/security_analysis.py (76 lines) - awslabs/ecs_mcp_server/api/security_analysis.py (88 lines) - tests/unit/test_security_analysis.py (91 lines) This is PR #1 of the progressive implementation approach. All validation checks pass: ruff format, ruff check, pytest.
nzuresh
pushed a commit
that referenced
this pull request
Oct 2, 2025
- Add SecurityAnalyzer class with basic ECS security analysis - Add analyze_ecs_security API endpoint with parameter validation - Add comprehensive unit tests with 100% coverage - Implement progressive PR approach (255 lines total) Files added/modified: - awslabs/ecs_mcp_server/modules/security_analysis.py (76 lines) - awslabs/ecs_mcp_server/api/security_analysis.py (88 lines) - tests/unit/test_security_analysis.py (91 lines) This is PR #1 of the progressive implementation approach. All validation checks pass: ruff format, ruff check, pytest.
nzuresh
pushed a commit
that referenced
this pull request
Oct 5, 2025
- Add 23 new comprehensive tests (35 total tests now) - Test multiple clusters and regions handling - Test partial success scenarios and complex error cases - Test edge cases: empty responses, malformed data, timeouts - Test summary structure and recommendation validation - Test logging behavior and duplicate handling - Maintain 100% code coverage This PR extends PR #1 with comprehensive test coverage as per the revised implementation plan (split implementation + comprehensive tests).
nzuresh
pushed a commit
that referenced
this pull request
Oct 5, 2025
Implements PR #1 of the security integration feature: - Foundation for ECS security analysis - Basic cluster security checks (Container Insights, execute command, cluster status) - IAM security validation (service-linked roles) - Logging security checks (CloudWatch logging) Components: - DataAdapter: Collects ECS cluster data using existing ecs_api_operation - SecurityAnalyzer: Analyzes security configurations and generates recommendations - FastMCP tool registration with comprehensive docstrings and prompt patterns Features: - Automatic cluster discovery when no cluster names provided - Detailed security recommendations with remediation steps - Summary statistics by severity and category - Comprehensive error handling and logging Testing: - 14 unit tests with 95% code coverage - Tests for data collection, security checks, error handling, and integration - All quality checks passing (ruff, pyright, pytest) Requirements: 7.1, 8.1
nzuresh
pushed a commit
that referenced
this pull request
Oct 5, 2025
- Add collect_task_definitions() method to DataAdapter using existing utilities - Enhance _analyze_cluster_iam_security() for service-linked role validation - Add _analyze_iam_security() for task IAM role and policy validation - Detects wildcard permissions (High severity) - Checks for custom execution roles (Medium severity) - Identifies cross-account role usage (Medium severity) - Add 16 comprehensive tests for IAM security (6 new test classes) - Enhance quality-check.sh with: - Comprehensive coding pattern validation (10 key patterns) - Pre-commit integration - Diff coverage validation (90%+ requirement) - 94% test coverage for security_analysis.py (exceeds 90% requirement) - All quality checks passing (ruff, pyright, pre-commit) This is a stacked PR on top of PR #1 (feature/pr1-basic-cluster-security) Requirements: 4.1, 8.1
nzuresh
pushed a commit
that referenced
this pull request
Oct 5, 2025
- Add collect_task_definitions() method to DataAdapter using existing utilities - Enhance _analyze_cluster_iam_security() for service-linked role validation - Add _analyze_iam_security() for task IAM role and policy validation - Detects wildcard permissions (High severity) - Checks for custom execution roles (Medium severity) - Identifies cross-account role usage (Medium severity) - Add 16 comprehensive tests for IAM security (6 new test classes) - 94% test coverage for security_analysis.py (exceeds 90% requirement) - All quality checks passing (ruff, pyright, pre-commit) This is a stacked PR on top of PR #1 (feature/pr1-basic-cluster-security) Requirements: 4.1, 8.1
nzuresh
pushed a commit
that referenced
this pull request
Oct 6, 2025
- Add collect_task_definitions() method to DataAdapter using existing utilities - Enhance _analyze_cluster_iam_security() for service-linked role validation - Add _analyze_iam_security() for task IAM role and policy validation - Detects wildcard permissions (High severity) - Checks for custom execution roles (Medium severity) - Identifies cross-account role usage (Medium severity) - Add 16 comprehensive tests for IAM security (6 new test classes) - 94% test coverage for security_analysis.py (exceeds 90% requirement) - All quality checks passing (ruff, pyright, pre-commit) This is a stacked PR on top of PR #1 (feature/pr1-basic-cluster-security) Requirements: 4.1, 8.1
nzuresh
pushed a commit
that referenced
this pull request
Oct 7, 2025
Add comprehensive IAM security checks for ECS clusters: - Service-linked role verification for ECS Exec operations - Service-linked role validation for capacity providers - General IAM configuration review recommendations Implementation details: - Added _analyze_cluster_iam_security() method (~145 lines) - Integrated IAM checks into security analysis workflow - Updated module documentation with IAM security features - Added 9 comprehensive test cases with 95%+ coverage Security checks: - Verifies AWSServiceRoleForECS exists for ECS Exec - Validates service-linked role for Auto Scaling integration - Provides IAM best practices and least privilege guidance - Includes remediation steps with AWS CLI commands Test coverage: - Parameterized tests for various IAM configurations - Service-linked role recommendation validation - IAM category summary verification - All required fields validation Closes: Requirement 1.2 (IAM Security Analysis) Related: PR #1 (Foundation), PR #2 (Enhanced Cluster Security)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔒 ECS Security Analysis Feature
Overview
This PR introduces comprehensive security analysis capabilities for ECS clusters, providing vulnerability assessment, compliance checking, and security recommendations.
✨ Features Added
Core Security Analysis
Security Coverage Areas
📁 Files Added/Modified
Core Implementation
awslabs/ecs_mcp_server/api/security_analysis.py
- Security analysis API endpointsawslabs/ecs_mcp_server/modules/security_analysis.py
- Security analysis logicawslabs/ecs_mcp_server/main.py
- Module registrationTesting & Validation
tests/unit/api/test_security_analysis_api.py
- API unit teststests/unit/modules/test_security_analysis_module.py
- Module unit teststests/integ/mcp-inspector/scenarios/03_security_analysis_tools/
- Integration teststests/llm_testing/scenarios/07_security_analysis_scenario/
- LLM testing scenariosDocumentation & Tools
SECURITY_ANALYSIS_CHECKS.md
- Security checks documentationtest_security_manual.py
- Manual testing scriptpyproject.toml
- Added pre-commit dependency🚀 Usage Examples