Skip to content

Commit 3e82151

Browse files
authored
Merge pull request #415 from roficas/gensec-v1
Adding GenSEC solution
2 parents b6e9949 + 1737ad6 commit 3e82151

File tree

58 files changed

+39480
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+39480
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Q CLI Project Context Setup
2+
3+
This directory contains configuration files to provide automatic project context for Q CLI sessions.
4+
5+
## Files
6+
7+
- **`project-context.md`** - Comprehensive project overview, architecture, and development guidelines
8+
- **`config.json`** - Q CLI configuration to auto-load project context
9+
- **`README.md`** - This file
10+
11+
## How It Works
12+
13+
When you start a new Q CLI session in this project directory, the configuration will:
14+
15+
1. **Auto-load project context** from `project-context.md`
16+
2. **Set working directory** to the project root
17+
3. **Apply safety guidelines** - Q will not modify files unless explicitly requested
18+
4. **Provide architecture awareness** - Q understands the Step Functions workflow, Lambda functions, and infrastructure
19+
20+
## Usage
21+
22+
Simply run Q CLI from the project root:
23+
24+
```bash
25+
cd /Users/roficas/aws-infrastructure-reverse-engineering
26+
q chat
27+
```
28+
29+
Q will automatically have context about:
30+
- ✅ System architecture (Step Functions, Lambda, DynamoDB, S3)
31+
- ✅ Component relationships and dependencies
32+
- ✅ Development guidelines and best practices
33+
- ✅ Security considerations and IAM architecture
34+
- ✅ Branch strategy (main vs mcp-server)
35+
36+
## Safety Features
37+
38+
The configuration includes safety instructions:
39+
- 🛡️ **Read-only by default** - Q won't modify files without explicit permission
40+
- 🛡️ **Confirmation required** - Q will ask before making changes
41+
- 🛡️ **Impact explanation** - Q will explain consequences of proposed changes
42+
- 🛡️ **Security focus** - Maintains security best practices for this security system
43+
44+
## Project Overview Reminder
45+
46+
This is a **serverless AWS security configuration analysis system** that:
47+
- Processes security configurations via S3 uploads
48+
- Uses Step Functions to orchestrate AI-powered analysis
49+
- Generates security controls, IAM models, and IaC templates
50+
- Leverages Amazon Bedrock for intelligent recommendations
51+
- Maintains audit trails and compliance mappings
52+
53+
The system is production-ready on the `main` branch, with experimental MCP server integration available on the `mcp-server` branch.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "aws-security-agent",
3+
"description": "AWS Security Configuration System project assistant",
4+
"prompt": "You are working on the AWS Security Configuration System project. Before responding to any user query, read and understand the project context from .amazonq/project-context.md. This context contains critical information about the system architecture, components, and development guidelines. IMPORTANT: Do not apply any code changes unless explicitly requested by the user. Always ask for confirmation before modifying files and explain the impact of proposed changes. Do not deploy any code unless explicitly asked.",
5+
"resources": [
6+
"file://.amazonq/rules/project-context.md",
7+
"file://.amazonq/rules/security-system-guidelines.md"
8+
],
9+
"allowedTools": [
10+
"fs_read",
11+
"fs_write",
12+
"execute_bash",
13+
"use_aws"
14+
],
15+
"toolsSettings": {
16+
"fs_read": {
17+
"allowedPaths": ["./"]
18+
},
19+
"fs_write": {
20+
"allowedPaths": ["./"]
21+
}
22+
}
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"defaultAgent": "aws-security-agent"
3+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Security Configuration System Rules
2+
3+
## Working Environment
4+
- **Work locally only** - do not attempt AWS deployments or account changes, unless explicitly asked
5+
- Focus on code development, testing, and local validation
6+
- Use existing test outputs and local files for analysis
7+
8+
## Code Style & Implementation
9+
- Follow minimal implementation principle - write only essential code
10+
- Use existing Lambda layers and shared utilities
11+
- Maintain consistency with current CDK stack structure
12+
- Follow AWS security best practices with least privilege IAM
13+
14+
## Architecture Constraints
15+
- All Lambda functions must use Python 3.10 runtime
16+
- Use existing DynamoDB table naming convention: `gensec-{TableName}`
17+
- S3 buckets follow pattern: `gensec-{purpose}-{account}-{region}`
18+
- Lambda functions use prefix: `gensec-{FunctionName}`
19+
20+
## Development Guidelines
21+
- Test changes in decomposed architecture (current active system)
22+
- Use existing Lambda layers: common, bedrock, dynamodb-operations, validation, requests, web-scraping
23+
- Environment variables must reference CDK-managed resource names
24+
- All resources must include gensec tags
25+
26+
## Output and Testing Standards
27+
- All generated outputs must be saved to `tests/output` directory
28+
- All test files and test data must be placed in `tests/` directory
29+
- Scripts should default to `tests/output` for generated content
30+
- Maintain organized subdirectories within tests for different output types
31+
32+
## Bedrock Integration
33+
- Use Strands Agent (GenSecAgent) when USE_STRANDS_AGENT=true
34+
- Support both direct model calls and agent-based processing
35+
- Implement pagination for large parameter sets
36+
- Log all AI interactions for debugging
37+
38+
## Data Flow Requirements
39+
- Security profiles and service requests trigger Step Functions workflow
40+
- All outputs stored in S3 with structured paths
41+
- DynamoDB used for tracking, validation, and service documentation
42+
- Support both individual file processing and batch operations
43+
44+
## Current Development Priorities
45+
- Implement pagination for Bedrock calls with large parameter sets
46+
- Replace web scraping with MCP server integration
47+
- Develop AgentCore to centralize Bedrock interactions
48+
- Improve validation logic to reduce false positives
49+
- Add SQS integration: S3→SQS→StepFunctions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Security Configuration System Guidelines
2+
3+
## 🚨 CRITICAL: READ-ONLY BY DEFAULT
4+
- **DO NOT modify files** unless explicitly requested
5+
- **Ask confirmation** before any changes
6+
- **Explain impact** of proposed changes
7+
- **Preserve functionality** unless specifically changing it
8+
9+
## Project Context
10+
**Serverless security configuration analysis system** that automates AWS service security recommendations using AI. Processes service configurations and generates security controls, IAM models, and infrastructure templates through Step Functions workflow.
11+
12+
## Architecture Components
13+
- **Workflow**: gensec-SecurityConfigWorkflow (ValidateAndCollectServiceData → AnalyzeSecurityRequirements → GenerateSecurityControls → GenerateIaCTemplate → GenerateServiceProfile → GenerateIAMModel)
14+
- **Lambda Functions**: SecurityProfileProcessor, AWSServiceDocumentationManager, AnalyzeSecurityRequirements, GenerateSecurityControls, GenerateIaCTemplate, GenerateIAMModel, GenerateServiceProfile
15+
- **Storage**: DynamoDB (SecurityControlLibrary, ServiceRequestTracking, AWSService* tables), S3 (input/output/documentation)
16+
17+
## Development Rules
18+
- **scripts/**: Development utilities (gitignored, NOT deployed)
19+
- **tests/output/**: Downloaded S3 artifacts (gitignored)
20+
- **Production code**: lambda/, cdk/, config-example/
21+
- Use existing Lambda layers: common, bedrock, dynamodb-operations, validation, requests, web-scraping
22+
- All resources use gensec- prefix and tags
23+
- Python 3.9 runtime for all Lambda functions
24+
25+
## Security Requirements
26+
- Follow AWS security best practices with least privilege IAM
27+
- This system processes sensitive security data - prioritize security, auditability, and least-privilege
28+
- Environment variables must reference CDK-managed resource names
29+
- Support both Strands Agent and direct Bedrock model calls
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# CDK
2+
cdk/cdk.context.json
3+
cdk/npm-debug.log*
4+
cdk/yarn-debug.log*
5+
cdk/yarn-error.log*
6+
cdk/.nyc_output
7+
cdk/coverage/
8+
cdk/lib/*.js
9+
cdk/lib/*.d.ts
10+
cdk/test/*.js
11+
cdk/test/*.d.ts
12+
13+
# Lambda
14+
lambda/**/*.zip
15+
lambda/**/node_modules/
16+
lambda/**/__pycache__/
17+
lambda/**/*.pyc
18+
lambda/**/.env
19+
20+
# Lambda Layers - Ignore all dependencies, keep only our custom modules
21+
layers/**/python/boto3/
22+
layers/**/python/botocore/
23+
layers/**/python/dateutil/
24+
layers/**/python/urllib3/
25+
layers/**/python/requests/
26+
layers/**/python/beautifulsoup4/
27+
layers/**/python/bs4/
28+
layers/**/python/lxml/
29+
layers/**/python/html5lib/
30+
layers/**/python/certifi/
31+
layers/**/python/charset_normalizer/
32+
layers/**/python/idna/
33+
layers/**/python/jmespath/
34+
layers/**/python/s3transfer/
35+
layers/**/python/soupsieve/
36+
layers/**/python/webencodings/
37+
layers/**/python/six.py
38+
layers/**/python/typing_extensions.py
39+
layers/**/python/bin/
40+
layers/**/python/**/
41+
layers/**/__pycache__/
42+
layers/**/*.pyc
43+
layers/**/*.pyo
44+
layers/**/*.egg-info/
45+
layers/**/build/
46+
layers/**/dist/
47+
# Keep our custom layer modules
48+
!layers/**/python/dynamodb_operations.py
49+
!layers/**/python/json_processing.py
50+
!layers/**/python/s3_operations.py
51+
!layers/**/python/validation.py
52+
!layers/**/python/bedrock_client.py
53+
54+
# AWS
55+
.aws/
56+
*.pem
57+
*.key
58+
.kiro/
59+
60+
# IDE
61+
.vscode/
62+
.idea/
63+
*.swp
64+
*.swo
65+
*~
66+
67+
# OS
68+
.DS_Store
69+
Thumbs.db
70+
71+
# Logs
72+
*.log
73+
logs/
74+
75+
# Temporary files
76+
tmp/
77+
temp/
78+
*.tmp
79+
80+
# Sensitive data
81+
secrets/
82+
*.secret
83+
*.credentials
84+
85+
# compiled resources
86+
**/dist/
87+
cdk/cdk.out/
88+
**/node_modules/
89+
90+
# nodejs
91+
**/package-lock.json
92+
93+
# Working scripts (not part of solution)
94+
tests/output/
95+
lambda-legacy/

0 commit comments

Comments
 (0)