Skip to content

Conversation

nzuresh
Copy link

@nzuresh nzuresh commented Oct 7, 2025

Fixes

Summary

Changes

This PR adds AWS documentation integration to the ECS security analysis tool, enriching security recommendations with contextual AWS best practices documentation.

Key additions:

  • Added include_aws_docs optional parameter to analyze_ecs_security tool
  • Implemented parallel AWS documentation fetching with semaphore limiting (max 5 concurrent requests)
  • Added aws_documentation field to security recommendation structure
  • Implemented caching and graceful degradation for documentation retrieval
  • Made SecurityAnalyzer.analyze method async to support parallel operations
  • Enhanced MCP client presentation guidelines for proper resource detail display

Technical implementation:

  • Uses existing aws_knowledge_proxy module for documentation fetching
  • Implements 10-second timeout per documentation fetch
  • Maintains full backward compatibility (defaults to include_aws_docs=false)
  • Comprehensive error handling with fallback to empty documentation on failures

Files changed:

  • awslabs/ecs_mcp_server/api/security_analysis.py: +175 lines
  • awslabs/ecs_mcp_server/modules/security_analysis.py: +123 lines
  • tests/unit/test_security_analysis.py: +800 lines (22 new test cases)

User experience

Before:
Users receive security recommendations with severity, description, and remediation steps, but no direct links to AWS documentation for additional context.

After:
When include_aws_docs=true is specified, users receive the same security recommendations enhanced with relevant AWS documentation snippets that provide:

  • Direct links to AWS best practices guides
  • Contextual information about the security concern
  • Additional remediation guidance from official AWS sources

The feature gracefully degrades if documentation fetching fails, ensuring the core security analysis always completes successfully.

Checklist

If your change doesn't seem to apply, please leave them unchecked.

  • I have reviewed the contributing guidelines
  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented

Is this a breaking change? (Y/N): 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.

Suresh Natarajan added 3 commits October 6, 2025 13:55
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
… 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>
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)
Copy link

codecov bot commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 82.35294% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.40%. Comparing base (c2d7bf8) to head (41ebd3f).

Files with missing lines Patch % Lines
...er/awslabs/ecs_mcp_server/api/security_analysis.py 83.27% 37 Missing and 8 partials ⚠️
...wslabs/ecs_mcp_server/modules/security_analysis.py 68.42% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1462      +/-   ##
==========================================
- Coverage   89.45%   89.40%   -0.05%     
==========================================
  Files         726      728       +2     
  Lines       50305    50594     +289     
  Branches     7942     7989      +47     
==========================================
+ Hits        44998    45236     +238     
- Misses       3452     3495      +43     
- Partials     1855     1863       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Add include_aws_docs parameter, implement parallel documentation fetching
with caching and graceful degradation, enhance MCP client presentation
guidelines, and add comprehensive test suite (22 new tests, 99 total).

Changes: 3 files, 1009 insertions, 89 deletions
@nzuresh nzuresh force-pushed the feature/pr4-aws-docs-integration branch from 107cfdf to 41ebd3f Compare October 7, 2025 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

1 participant