runbooks 1.0.0__py3-none-any.whl → 1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- runbooks/__init__.py +1 -1
- runbooks/cfat/WEIGHT_CONFIG_README.md +368 -0
- runbooks/cfat/app.ts +27 -19
- runbooks/cfat/assessment/runner.py +6 -5
- runbooks/cfat/tests/test_weight_configuration.ts +449 -0
- runbooks/cfat/weight_config.ts +574 -0
- runbooks/common/__init__.py +26 -9
- runbooks/common/aws_pricing.py +1070 -105
- runbooks/common/date_utils.py +115 -0
- runbooks/common/enhanced_exception_handler.py +10 -7
- runbooks/common/mcp_cost_explorer_integration.py +5 -4
- runbooks/common/profile_utils.py +76 -115
- runbooks/common/rich_utils.py +3 -3
- runbooks/finops/dashboard_runner.py +47 -28
- runbooks/finops/ebs_optimizer.py +56 -9
- runbooks/finops/enhanced_trend_visualization.py +7 -2
- runbooks/finops/finops_dashboard.py +6 -5
- runbooks/finops/iam_guidance.py +6 -1
- runbooks/finops/nat_gateway_optimizer.py +46 -27
- runbooks/finops/tests/test_integration.py +3 -1
- runbooks/finops/vpc_cleanup_optimizer.py +22 -29
- runbooks/inventory/core/collector.py +51 -28
- runbooks/inventory/discovery.md +197 -247
- runbooks/inventory/inventory_modules.py +2 -2
- runbooks/inventory/list_ec2_instances.py +3 -3
- runbooks/inventory/organizations_discovery.py +13 -8
- runbooks/inventory/unified_validation_engine.py +2 -15
- runbooks/main.py +74 -32
- runbooks/operate/base.py +9 -6
- runbooks/operate/deployment_framework.py +5 -4
- runbooks/operate/deployment_validator.py +6 -5
- runbooks/operate/mcp_integration.py +6 -5
- runbooks/operate/networking_cost_heatmap.py +17 -13
- runbooks/operate/vpc_operations.py +52 -12
- runbooks/remediation/base.py +3 -1
- runbooks/remediation/commons.py +5 -5
- runbooks/remediation/commvault_ec2_analysis.py +66 -18
- runbooks/remediation/config/accounts_example.json +31 -0
- runbooks/remediation/multi_account.py +120 -7
- runbooks/remediation/remediation_cli.py +710 -0
- runbooks/remediation/universal_account_discovery.py +377 -0
- runbooks/security/compliance_automation_engine.py +99 -20
- runbooks/security/config/__init__.py +24 -0
- runbooks/security/config/compliance_config.py +255 -0
- runbooks/security/config/compliance_weights_example.json +22 -0
- runbooks/security/config_template_generator.py +500 -0
- runbooks/security/security_cli.py +377 -0
- runbooks/validation/cli.py +8 -7
- runbooks/validation/comprehensive_2way_validator.py +26 -15
- runbooks/validation/mcp_validator.py +62 -8
- runbooks/vpc/config.py +32 -7
- runbooks/vpc/cross_account_session.py +5 -1
- runbooks/vpc/heatmap_engine.py +21 -14
- runbooks/vpc/mcp_no_eni_validator.py +115 -36
- runbooks/vpc/runbooks_adapter.py +33 -12
- runbooks/vpc/tests/conftest.py +4 -2
- runbooks/vpc/tests/test_cost_engine.py +3 -1
- {runbooks-1.0.0.dist-info → runbooks-1.0.1.dist-info}/METADATA +1 -1
- {runbooks-1.0.0.dist-info → runbooks-1.0.1.dist-info}/RECORD +63 -65
- runbooks/finops/runbooks.inventory.organizations_discovery.log +0 -0
- runbooks/finops/runbooks.security.report_generator.log +0 -0
- runbooks/finops/runbooks.security.run_script.log +0 -0
- runbooks/finops/runbooks.security.security_export.log +0 -0
- runbooks/finops/tests/results_test_finops_dashboard.xml +0 -1
- runbooks/inventory/artifacts/scale-optimize-status.txt +0 -12
- runbooks/inventory/runbooks.inventory.organizations_discovery.log +0 -0
- runbooks/inventory/runbooks.security.report_generator.log +0 -0
- runbooks/inventory/runbooks.security.run_script.log +0 -0
- runbooks/inventory/runbooks.security.security_export.log +0 -0
- runbooks/vpc/runbooks.inventory.organizations_discovery.log +0 -0
- runbooks/vpc/runbooks.security.report_generator.log +0 -0
- runbooks/vpc/runbooks.security.run_script.log +0 -0
- runbooks/vpc/runbooks.security.security_export.log +0 -0
- {runbooks-1.0.0.dist-info → runbooks-1.0.1.dist-info}/WHEEL +0 -0
- {runbooks-1.0.0.dist-info → runbooks-1.0.1.dist-info}/entry_points.txt +0 -0
- {runbooks-1.0.0.dist-info → runbooks-1.0.1.dist-info}/licenses/LICENSE +0 -0
- {runbooks-1.0.0.dist-info → runbooks-1.0.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,500 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
Configuration Template Generator for Security and Remediation Modules
|
4
|
+
====================================================================
|
5
|
+
|
6
|
+
This utility generates configuration templates for enterprise security and
|
7
|
+
remediation operations, eliminating the need for hardcoded values.
|
8
|
+
|
9
|
+
Features:
|
10
|
+
- Compliance weight configuration templates
|
11
|
+
- Account discovery configuration templates
|
12
|
+
- Framework threshold configuration templates
|
13
|
+
- Environment variable examples
|
14
|
+
- Complete setup documentation
|
15
|
+
|
16
|
+
Author: DevOps Security Engineer (Claude Code Enterprise Team)
|
17
|
+
Version: 1.0.0 - Universal Configuration Templates
|
18
|
+
"""
|
19
|
+
|
20
|
+
import json
|
21
|
+
import os
|
22
|
+
from pathlib import Path
|
23
|
+
from typing import Dict, List, Optional
|
24
|
+
|
25
|
+
import click
|
26
|
+
|
27
|
+
from runbooks.common.rich_utils import console, create_panel, print_info, print_success
|
28
|
+
|
29
|
+
|
30
|
+
class SecurityConfigTemplateGenerator:
|
31
|
+
"""Generate configuration templates for security and remediation modules."""
|
32
|
+
|
33
|
+
def __init__(self, output_dir: str = "./artifacts/security/config"):
|
34
|
+
"""Initialize template generator."""
|
35
|
+
self.output_dir = Path(output_dir)
|
36
|
+
self.output_dir.mkdir(parents=True, exist_ok=True)
|
37
|
+
|
38
|
+
def generate_compliance_config_template(self) -> Dict:
|
39
|
+
"""Generate compliance configuration template."""
|
40
|
+
return {
|
41
|
+
"_description": "Universal Compliance Configuration Template",
|
42
|
+
"_usage": "Set COMPLIANCE_CONFIG_PATH environment variable to point to this file",
|
43
|
+
|
44
|
+
"control_weights": {
|
45
|
+
"_description": "Control weights for compliance scoring (1.0 = normal, 2.0 = double weight)",
|
46
|
+
|
47
|
+
"aws_well_architected": {
|
48
|
+
"sec-1": 2.0, # Identity Foundation
|
49
|
+
"sec-2": 1.5, # Security at All Layers
|
50
|
+
"sec-3": 2.5, # Data Protection
|
51
|
+
"sec-4": 1.8, # Incident Response
|
52
|
+
"sec-5": 1.2 # Network Security
|
53
|
+
},
|
54
|
+
|
55
|
+
"soc2_type_ii": {
|
56
|
+
"cc6-1": 3.0, # Access Controls (Critical)
|
57
|
+
"cc6-2": 2.5, # Authentication
|
58
|
+
"cc6-3": 2.0, # Authorization
|
59
|
+
"cc7-1": 2.2, # System Operations
|
60
|
+
"cc8-1": 1.8 # Change Management
|
61
|
+
},
|
62
|
+
|
63
|
+
"pci_dss": {
|
64
|
+
"pci-1": 2.0, # Network Security
|
65
|
+
"pci-2": 2.5, # System Security
|
66
|
+
"pci-3": 3.0, # Data Protection (Critical)
|
67
|
+
"pci-4": 2.0, # Transmission Security
|
68
|
+
"pci-6": 1.5 # Secure Systems
|
69
|
+
},
|
70
|
+
|
71
|
+
"hipaa": {
|
72
|
+
"hipaa-164-312-a-1": 2.5, # Access Control
|
73
|
+
"hipaa-164-312-a-2": 2.0, # Assigned Security
|
74
|
+
"hipaa-164-312-b": 3.0, # Audit Controls (Critical)
|
75
|
+
"hipaa-164-312-c": 2.8, # Integrity
|
76
|
+
"hipaa-164-312-d": 1.5 # Person Authentication
|
77
|
+
}
|
78
|
+
},
|
79
|
+
|
80
|
+
"framework_thresholds": {
|
81
|
+
"_description": "Minimum compliance scores required for each framework (percentage)",
|
82
|
+
|
83
|
+
"aws-well-architected": 90.0,
|
84
|
+
"soc2-type-ii": 95.0,
|
85
|
+
"pci-dss": 100.0, # PCI DSS requires perfect compliance
|
86
|
+
"hipaa": 95.0,
|
87
|
+
"nist-cybersecurity": 90.0,
|
88
|
+
"iso-27001": 90.0,
|
89
|
+
"cis-benchmarks": 88.0
|
90
|
+
},
|
91
|
+
|
92
|
+
"assessment_frequencies": {
|
93
|
+
"_description": "How often to assess each control type",
|
94
|
+
|
95
|
+
"critical-controls": "weekly",
|
96
|
+
"high-controls": "monthly",
|
97
|
+
"medium-controls": "quarterly",
|
98
|
+
"low-controls": "annually"
|
99
|
+
},
|
100
|
+
|
101
|
+
"remediation_priorities": {
|
102
|
+
"_description": "Remediation priority levels (1=highest, 5=lowest)",
|
103
|
+
|
104
|
+
"critical-controls": 1,
|
105
|
+
"high-controls": 2,
|
106
|
+
"medium-controls": 3,
|
107
|
+
"low-controls": 4
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
def generate_account_config_template(self) -> Dict:
|
112
|
+
"""Generate account discovery configuration template."""
|
113
|
+
return {
|
114
|
+
"_description": "Universal Account Discovery Configuration Template",
|
115
|
+
"_usage": "Set REMEDIATION_ACCOUNT_CONFIG environment variable to point to this file",
|
116
|
+
|
117
|
+
"target_accounts": [
|
118
|
+
{
|
119
|
+
"account_id": "111122223333",
|
120
|
+
"account_name": "Production Environment",
|
121
|
+
"status": "ACTIVE",
|
122
|
+
"email": "prod@company.com",
|
123
|
+
"profile_name": "prod-profile",
|
124
|
+
"environment": "production",
|
125
|
+
"criticality": "high"
|
126
|
+
},
|
127
|
+
{
|
128
|
+
"account_id": "444455556666",
|
129
|
+
"account_name": "Staging Environment",
|
130
|
+
"status": "ACTIVE",
|
131
|
+
"email": "staging@company.com",
|
132
|
+
"profile_name": "staging-profile",
|
133
|
+
"environment": "staging",
|
134
|
+
"criticality": "medium"
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"account_id": "777788889999",
|
138
|
+
"account_name": "Development Environment",
|
139
|
+
"status": "ACTIVE",
|
140
|
+
"email": "dev@company.com",
|
141
|
+
"profile_name": "dev-profile",
|
142
|
+
"environment": "development",
|
143
|
+
"criticality": "low"
|
144
|
+
}
|
145
|
+
],
|
146
|
+
|
147
|
+
"discovery_settings": {
|
148
|
+
"max_concurrent_accounts": 10,
|
149
|
+
"validation_timeout_seconds": 30,
|
150
|
+
"include_suspended_accounts": False,
|
151
|
+
"auto_discover_via_organizations": True,
|
152
|
+
"fallback_to_current_account": True
|
153
|
+
},
|
154
|
+
|
155
|
+
"filtering_rules": {
|
156
|
+
"include_patterns": ["prod-*", "staging-*"],
|
157
|
+
"exclude_patterns": ["test-*", "sandbox-*"],
|
158
|
+
"max_accounts": 50
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
def generate_environment_variables_template(self) -> str:
|
163
|
+
"""Generate environment variables template."""
|
164
|
+
return """# Universal Security and Remediation Configuration
|
165
|
+
# ================================================
|
166
|
+
|
167
|
+
# Profile Configuration (Universal Profile Management)
|
168
|
+
# Use any AWS profile name - no hardcoded requirements
|
169
|
+
export AWS_PROFILE="your-aws-profile-name"
|
170
|
+
|
171
|
+
# Compliance Configuration
|
172
|
+
export COMPLIANCE_CONFIG_PATH="/path/to/compliance_config.json"
|
173
|
+
|
174
|
+
# Alternative: Individual compliance weight overrides
|
175
|
+
export COMPLIANCE_WEIGHT_SEC_1="2.0"
|
176
|
+
export COMPLIANCE_WEIGHT_CC6_1="3.0"
|
177
|
+
export COMPLIANCE_WEIGHT_PCI_3="3.0"
|
178
|
+
|
179
|
+
# Framework threshold overrides
|
180
|
+
export COMPLIANCE_THRESHOLD_PCI_DSS="100.0"
|
181
|
+
export COMPLIANCE_THRESHOLD_SOC2_TYPE_II="95.0"
|
182
|
+
export COMPLIANCE_THRESHOLD_AWS_WELL_ARCHITECTED="90.0"
|
183
|
+
|
184
|
+
# Account Discovery Configuration
|
185
|
+
export REMEDIATION_ACCOUNT_CONFIG="/path/to/account_config.json"
|
186
|
+
|
187
|
+
# Alternative: Simple comma-separated account list
|
188
|
+
export REMEDIATION_TARGET_ACCOUNTS="111122223333,444455556666,777788889999"
|
189
|
+
|
190
|
+
# Security Assessment Configuration
|
191
|
+
export SECURITY_OUTPUT_DIR="./artifacts/security"
|
192
|
+
export SECURITY_EXPORT_FORMATS="json,csv,html,pdf"
|
193
|
+
export SECURITY_ASSESSMENT_LANGUAGE="en"
|
194
|
+
|
195
|
+
# Remediation Configuration
|
196
|
+
export REMEDIATION_OUTPUT_DIR="./artifacts/remediation"
|
197
|
+
export REMEDIATION_MAX_CONCURRENT="10"
|
198
|
+
export REMEDIATION_DRY_RUN="true"
|
199
|
+
|
200
|
+
# Multi-Account Configuration
|
201
|
+
export ORGANIZATIONS_MANAGEMENT_ROLE="OrganizationAccountAccessRole"
|
202
|
+
export CROSS_ACCOUNT_ROLE="SecurityAuditRole"
|
203
|
+
|
204
|
+
# Performance Tuning
|
205
|
+
export SECURITY_MAX_WORKERS="10"
|
206
|
+
export REMEDIATION_TIMEOUT_SECONDS="300"
|
207
|
+
export COMPLIANCE_CACHE_TTL="3600"
|
208
|
+
|
209
|
+
# Example Usage Commands
|
210
|
+
# =====================
|
211
|
+
|
212
|
+
# Security baseline assessment with custom profile
|
213
|
+
# runbooks security assess --profile your-profile --frameworks aws-well-architected,soc2-type-ii
|
214
|
+
|
215
|
+
# Multi-account remediation with discovered accounts
|
216
|
+
# runbooks remediation s3-security --all --operations block_public_access,enforce_ssl
|
217
|
+
|
218
|
+
# Custom compliance assessment with specific accounts
|
219
|
+
# runbooks security assess --accounts 111122223333,444455556666 --scope critical
|
220
|
+
|
221
|
+
# Export compliance configuration template
|
222
|
+
# runbooks security export-config-template --output-dir ./config
|
223
|
+
"""
|
224
|
+
|
225
|
+
def generate_setup_documentation(self) -> str:
|
226
|
+
"""Generate complete setup documentation."""
|
227
|
+
return """# Universal Security and Remediation Module Setup Guide
|
228
|
+
======================================================
|
229
|
+
|
230
|
+
This guide helps you configure the security and remediation modules for ANY AWS environment without hardcoded values.
|
231
|
+
|
232
|
+
## Quick Start
|
233
|
+
|
234
|
+
1. **Basic Setup (Single Account)**
|
235
|
+
```bash
|
236
|
+
export AWS_PROFILE="your-aws-profile"
|
237
|
+
runbooks security assess
|
238
|
+
```
|
239
|
+
|
240
|
+
2. **Multi-Account Setup (Organizations)**
|
241
|
+
```bash
|
242
|
+
export AWS_PROFILE="your-management-account-profile"
|
243
|
+
runbooks security assess --all
|
244
|
+
```
|
245
|
+
|
246
|
+
3. **Custom Configuration**
|
247
|
+
```bash
|
248
|
+
export COMPLIANCE_CONFIG_PATH="./compliance_config.json"
|
249
|
+
export REMEDIATION_ACCOUNT_CONFIG="./account_config.json"
|
250
|
+
runbooks security assess --frameworks pci-dss,hipaa
|
251
|
+
```
|
252
|
+
|
253
|
+
## Configuration Methods
|
254
|
+
|
255
|
+
### Method 1: Environment Variables (Simple)
|
256
|
+
Best for: Quick setup, CI/CD pipelines, simple environments
|
257
|
+
|
258
|
+
```bash
|
259
|
+
export REMEDIATION_TARGET_ACCOUNTS="111122223333,444455556666"
|
260
|
+
export COMPLIANCE_THRESHOLD_PCI_DSS="100.0"
|
261
|
+
```
|
262
|
+
|
263
|
+
### Method 2: Configuration Files (Recommended)
|
264
|
+
Best for: Enterprise environments, complex setups, team collaboration
|
265
|
+
|
266
|
+
```bash
|
267
|
+
export COMPLIANCE_CONFIG_PATH="./config/compliance.json"
|
268
|
+
export REMEDIATION_ACCOUNT_CONFIG="./config/accounts.json"
|
269
|
+
```
|
270
|
+
|
271
|
+
### Method 3: AWS Organizations (Automatic)
|
272
|
+
Best for: Large organizations, dynamic account discovery
|
273
|
+
|
274
|
+
```bash
|
275
|
+
export AWS_PROFILE="management-account-profile"
|
276
|
+
# No additional configuration needed - automatic discovery
|
277
|
+
```
|
278
|
+
|
279
|
+
## Universal Profile Support
|
280
|
+
|
281
|
+
The modules work with ANY AWS profile configuration:
|
282
|
+
|
283
|
+
- **Single Account**: Use any profile name
|
284
|
+
- **Multi-Account**: Use management account profile
|
285
|
+
- **AWS SSO**: Full support for SSO profiles
|
286
|
+
- **Cross-Account Roles**: Automatic role assumption
|
287
|
+
- **Mixed Environments**: Supports any AWS setup
|
288
|
+
|
289
|
+
## Compliance Framework Configuration
|
290
|
+
|
291
|
+
### Supported Frameworks
|
292
|
+
- AWS Well-Architected Security Pillar
|
293
|
+
- SOC2 Type II
|
294
|
+
- PCI DSS (Payment Card Industry)
|
295
|
+
- HIPAA (Healthcare compliance)
|
296
|
+
- NIST Cybersecurity Framework
|
297
|
+
- ISO 27001 (Information Security)
|
298
|
+
- CIS Benchmarks (Security benchmarks)
|
299
|
+
|
300
|
+
### Custom Weights and Thresholds
|
301
|
+
Configure compliance scoring to match your requirements:
|
302
|
+
|
303
|
+
```json
|
304
|
+
{
|
305
|
+
"control_weights": {
|
306
|
+
"sec-1": 2.0, // Double weight for critical controls
|
307
|
+
"cc6-1": 3.0 // Triple weight for access controls
|
308
|
+
},
|
309
|
+
"framework_thresholds": {
|
310
|
+
"pci-dss": 100.0, // PCI requires perfect compliance
|
311
|
+
"hipaa": 95.0 // HIPAA requires high compliance
|
312
|
+
}
|
313
|
+
}
|
314
|
+
```
|
315
|
+
|
316
|
+
## Account Discovery Configuration
|
317
|
+
|
318
|
+
### Automatic Discovery (Recommended)
|
319
|
+
The system automatically discovers accounts using:
|
320
|
+
1. Environment variables (REMEDIATION_TARGET_ACCOUNTS)
|
321
|
+
2. Configuration files (REMEDIATION_ACCOUNT_CONFIG)
|
322
|
+
3. AWS Organizations API (if available)
|
323
|
+
4. Current account (single account fallback)
|
324
|
+
|
325
|
+
### Manual Configuration
|
326
|
+
For specific account targeting:
|
327
|
+
|
328
|
+
```json
|
329
|
+
{
|
330
|
+
"target_accounts": [
|
331
|
+
{
|
332
|
+
"account_id": "111122223333",
|
333
|
+
"account_name": "Production",
|
334
|
+
"profile_name": "prod-profile"
|
335
|
+
}
|
336
|
+
]
|
337
|
+
}
|
338
|
+
```
|
339
|
+
|
340
|
+
## Security Operations
|
341
|
+
|
342
|
+
### Assessment Commands
|
343
|
+
```bash
|
344
|
+
# Single framework assessment
|
345
|
+
runbooks security assess --frameworks aws-well-architected
|
346
|
+
|
347
|
+
# Multi-framework assessment
|
348
|
+
runbooks security assess --frameworks soc2-type-ii,pci-dss,hipaa
|
349
|
+
|
350
|
+
# All accounts assessment
|
351
|
+
runbooks security assess --all --scope full
|
352
|
+
|
353
|
+
# Specific accounts assessment
|
354
|
+
runbooks security assess --accounts 111122223333,444455556666
|
355
|
+
```
|
356
|
+
|
357
|
+
### Remediation Commands
|
358
|
+
```bash
|
359
|
+
# S3 security remediation
|
360
|
+
runbooks remediation s3-security --operations block_public_access,enforce_ssl
|
361
|
+
|
362
|
+
# Multi-account remediation
|
363
|
+
runbooks remediation s3-security --all --operations enable_encryption
|
364
|
+
|
365
|
+
# Specific account remediation
|
366
|
+
runbooks remediation s3-security --accounts 111122223333
|
367
|
+
```
|
368
|
+
|
369
|
+
## Troubleshooting
|
370
|
+
|
371
|
+
### Common Issues
|
372
|
+
|
373
|
+
1. **Profile Not Found**
|
374
|
+
```bash
|
375
|
+
aws configure list-profiles # Check available profiles
|
376
|
+
export AWS_PROFILE="correct-profile-name"
|
377
|
+
```
|
378
|
+
|
379
|
+
2. **Organizations Access Denied**
|
380
|
+
```bash
|
381
|
+
# Falls back to environment/config discovery automatically
|
382
|
+
export REMEDIATION_TARGET_ACCOUNTS="111122223333,444455556666"
|
383
|
+
```
|
384
|
+
|
385
|
+
3. **Compliance Threshold Too High**
|
386
|
+
```bash
|
387
|
+
export COMPLIANCE_THRESHOLD_AWS_WELL_ARCHITECTED="85.0"
|
388
|
+
```
|
389
|
+
|
390
|
+
### Validation Commands
|
391
|
+
```bash
|
392
|
+
# Validate profile access
|
393
|
+
runbooks security validate-profile --profile your-profile
|
394
|
+
|
395
|
+
# Test account discovery
|
396
|
+
runbooks security discover-accounts --profile your-profile
|
397
|
+
|
398
|
+
# Validate compliance configuration
|
399
|
+
runbooks security validate-config --config-path ./compliance.json
|
400
|
+
```
|
401
|
+
|
402
|
+
## Enterprise Integration
|
403
|
+
|
404
|
+
### CI/CD Pipeline Integration
|
405
|
+
```yaml
|
406
|
+
# Example GitHub Actions workflow
|
407
|
+
env:
|
408
|
+
AWS_PROFILE: "ci-cd-profile"
|
409
|
+
COMPLIANCE_CONFIG_PATH: "./config/compliance.json"
|
410
|
+
REMEDIATION_TARGET_ACCOUNTS: "111122223333,444455556666"
|
411
|
+
|
412
|
+
steps:
|
413
|
+
- name: Security Assessment
|
414
|
+
run: runbooks security assess --frameworks aws-well-architected,soc2-type-ii
|
415
|
+
|
416
|
+
- name: Automated Remediation
|
417
|
+
run: runbooks remediation s3-security --operations block_public_access
|
418
|
+
```
|
419
|
+
|
420
|
+
### Monitoring Integration
|
421
|
+
```bash
|
422
|
+
# Export compliance metrics for monitoring
|
423
|
+
runbooks security assess --export-formats json,csv
|
424
|
+
runbooks security export-metrics --output ./metrics/
|
425
|
+
```
|
426
|
+
|
427
|
+
This configuration system eliminates ALL hardcoded values and provides universal compatibility with any AWS environment.
|
428
|
+
"""
|
429
|
+
|
430
|
+
def generate_all_templates(self) -> None:
|
431
|
+
"""Generate all configuration templates."""
|
432
|
+
console.print(
|
433
|
+
create_panel(
|
434
|
+
"[bold cyan]Generating Universal Security Configuration Templates[/bold cyan]\n\n"
|
435
|
+
"[dim]Creating configuration templates for enterprise security operations...[/dim]",
|
436
|
+
title="🔧 Configuration Template Generator",
|
437
|
+
border_style="cyan",
|
438
|
+
)
|
439
|
+
)
|
440
|
+
|
441
|
+
# Generate compliance configuration
|
442
|
+
compliance_config = self.generate_compliance_config_template()
|
443
|
+
compliance_path = self.output_dir / "compliance_config.json"
|
444
|
+
with open(compliance_path, 'w') as f:
|
445
|
+
json.dump(compliance_config, f, indent=2)
|
446
|
+
print_success(f"Generated compliance configuration: {compliance_path}")
|
447
|
+
|
448
|
+
# Generate account configuration
|
449
|
+
account_config = self.generate_account_config_template()
|
450
|
+
account_path = self.output_dir / "account_config.json"
|
451
|
+
with open(account_path, 'w') as f:
|
452
|
+
json.dump(account_config, f, indent=2)
|
453
|
+
print_success(f"Generated account configuration: {account_path}")
|
454
|
+
|
455
|
+
# Generate environment variables template
|
456
|
+
env_template = self.generate_environment_variables_template()
|
457
|
+
env_path = self.output_dir / "environment_variables.sh"
|
458
|
+
with open(env_path, 'w') as f:
|
459
|
+
f.write(env_template)
|
460
|
+
print_success(f"Generated environment variables template: {env_path}")
|
461
|
+
|
462
|
+
# Generate setup documentation
|
463
|
+
setup_docs = self.generate_setup_documentation()
|
464
|
+
docs_path = self.output_dir / "SETUP_GUIDE.md"
|
465
|
+
with open(docs_path, 'w') as f:
|
466
|
+
f.write(setup_docs)
|
467
|
+
print_success(f"Generated setup documentation: {docs_path}")
|
468
|
+
|
469
|
+
# Generate summary
|
470
|
+
console.print("\n" + create_panel(
|
471
|
+
f"[bold green]Configuration templates generated successfully![/bold green]\n\n"
|
472
|
+
f"[cyan]Files created in {self.output_dir}:[/cyan]\n"
|
473
|
+
f"• compliance_config.json - Compliance weights and thresholds\n"
|
474
|
+
f"• account_config.json - Account discovery configuration\n"
|
475
|
+
f"• environment_variables.sh - Environment variable examples\n"
|
476
|
+
f"• SETUP_GUIDE.md - Complete setup documentation\n\n"
|
477
|
+
f"[yellow]Next steps:[/yellow]\n"
|
478
|
+
f"1. Review and customize the configuration files\n"
|
479
|
+
f"2. Set environment variables or use config files\n"
|
480
|
+
f"3. Run: runbooks security assess --help\n"
|
481
|
+
f"4. Run: runbooks remediation --help",
|
482
|
+
title="✅ Templates Ready",
|
483
|
+
border_style="green",
|
484
|
+
))
|
485
|
+
|
486
|
+
|
487
|
+
@click.command()
|
488
|
+
@click.option(
|
489
|
+
"--output-dir",
|
490
|
+
default="./artifacts/security/config",
|
491
|
+
help="Output directory for configuration templates"
|
492
|
+
)
|
493
|
+
def generate_config_templates(output_dir: str):
|
494
|
+
"""Generate universal configuration templates for security and remediation modules."""
|
495
|
+
generator = SecurityConfigTemplateGenerator(output_dir)
|
496
|
+
generator.generate_all_templates()
|
497
|
+
|
498
|
+
|
499
|
+
if __name__ == "__main__":
|
500
|
+
generate_config_templates()
|