runbooks 0.7.9__py3-none-any.whl → 0.9.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/README.md +12 -1
- runbooks/cfat/__init__.py +1 -1
- runbooks/cfat/assessment/compliance.py +4 -1
- runbooks/cfat/assessment/runner.py +42 -34
- runbooks/cfat/models.py +1 -1
- runbooks/cloudops/__init__.py +123 -0
- runbooks/cloudops/base.py +385 -0
- runbooks/cloudops/cost_optimizer.py +811 -0
- runbooks/cloudops/infrastructure_optimizer.py +29 -0
- runbooks/cloudops/interfaces.py +828 -0
- runbooks/cloudops/lifecycle_manager.py +29 -0
- runbooks/cloudops/mcp_cost_validation.py +678 -0
- runbooks/cloudops/models.py +251 -0
- runbooks/cloudops/monitoring_automation.py +29 -0
- runbooks/cloudops/notebook_framework.py +676 -0
- runbooks/cloudops/security_enforcer.py +449 -0
- runbooks/common/__init__.py +152 -0
- runbooks/common/accuracy_validator.py +1039 -0
- runbooks/common/context_logger.py +440 -0
- runbooks/common/cross_module_integration.py +594 -0
- runbooks/common/enhanced_exception_handler.py +1108 -0
- runbooks/common/enterprise_audit_integration.py +634 -0
- runbooks/common/mcp_cost_explorer_integration.py +900 -0
- runbooks/common/mcp_integration.py +548 -0
- runbooks/common/performance_monitor.py +387 -0
- runbooks/common/profile_utils.py +216 -0
- runbooks/common/rich_utils.py +172 -1
- runbooks/feedback/user_feedback_collector.py +440 -0
- runbooks/finops/README.md +377 -458
- runbooks/finops/__init__.py +4 -21
- runbooks/finops/account_resolver.py +279 -0
- runbooks/finops/accuracy_cross_validator.py +638 -0
- runbooks/finops/aws_client.py +721 -36
- runbooks/finops/budget_integration.py +313 -0
- runbooks/finops/cli.py +59 -5
- runbooks/finops/cost_optimizer.py +1340 -0
- runbooks/finops/cost_processor.py +211 -37
- runbooks/finops/dashboard_router.py +900 -0
- runbooks/finops/dashboard_runner.py +990 -232
- runbooks/finops/embedded_mcp_validator.py +288 -0
- runbooks/finops/enhanced_dashboard_runner.py +8 -7
- runbooks/finops/enhanced_progress.py +327 -0
- runbooks/finops/enhanced_trend_visualization.py +423 -0
- runbooks/finops/finops_dashboard.py +184 -1829
- runbooks/finops/helpers.py +509 -196
- runbooks/finops/iam_guidance.py +400 -0
- runbooks/finops/markdown_exporter.py +466 -0
- runbooks/finops/multi_dashboard.py +1502 -0
- runbooks/finops/optimizer.py +15 -15
- runbooks/finops/profile_processor.py +2 -2
- 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/schemas.py +589 -0
- runbooks/finops/service_mapping.py +195 -0
- runbooks/finops/single_dashboard.py +710 -0
- runbooks/finops/tests/test_reference_images_validation.py +1 -1
- runbooks/inventory/README.md +12 -1
- runbooks/inventory/core/collector.py +157 -29
- runbooks/inventory/list_ec2_instances.py +9 -6
- runbooks/inventory/list_ssm_parameters.py +10 -10
- runbooks/inventory/organizations_discovery.py +210 -164
- runbooks/inventory/rich_inventory_display.py +74 -107
- runbooks/inventory/run_on_multi_accounts.py +13 -13
- runbooks/inventory/runbooks.inventory.organizations_discovery.log +0 -0
- runbooks/inventory/runbooks.security.security_export.log +0 -0
- runbooks/main.py +1371 -240
- runbooks/metrics/dora_metrics_engine.py +711 -17
- runbooks/monitoring/performance_monitor.py +433 -0
- runbooks/operate/README.md +394 -0
- runbooks/operate/base.py +215 -47
- runbooks/operate/ec2_operations.py +435 -5
- runbooks/operate/iam_operations.py +598 -3
- runbooks/operate/privatelink_operations.py +1 -1
- runbooks/operate/rds_operations.py +508 -0
- runbooks/operate/s3_operations.py +508 -0
- runbooks/operate/vpc_endpoints.py +1 -1
- runbooks/remediation/README.md +489 -13
- runbooks/remediation/base.py +5 -3
- runbooks/remediation/commons.py +8 -4
- runbooks/security/ENTERPRISE_SECURITY_FRAMEWORK.md +506 -0
- runbooks/security/README.md +12 -1
- runbooks/security/__init__.py +265 -33
- runbooks/security/cloudops_automation_security_validator.py +1164 -0
- runbooks/security/compliance_automation.py +12 -10
- runbooks/security/compliance_automation_engine.py +1021 -0
- runbooks/security/enterprise_security_framework.py +930 -0
- runbooks/security/enterprise_security_policies.json +293 -0
- runbooks/security/executive_security_dashboard.py +1247 -0
- runbooks/security/integration_test_enterprise_security.py +879 -0
- runbooks/security/module_security_integrator.py +641 -0
- runbooks/security/multi_account_security_controls.py +2254 -0
- runbooks/security/real_time_security_monitor.py +1196 -0
- runbooks/security/report_generator.py +1 -1
- runbooks/security/run_script.py +4 -8
- runbooks/security/security_baseline_tester.py +39 -52
- runbooks/security/security_export.py +99 -120
- runbooks/sre/README.md +472 -0
- runbooks/sre/__init__.py +33 -0
- runbooks/sre/mcp_reliability_engine.py +1049 -0
- runbooks/sre/performance_optimization_engine.py +1032 -0
- runbooks/sre/production_monitoring_framework.py +584 -0
- runbooks/sre/reliability_monitoring_framework.py +1011 -0
- runbooks/validation/__init__.py +2 -2
- runbooks/validation/benchmark.py +154 -149
- runbooks/validation/cli.py +159 -147
- runbooks/validation/mcp_validator.py +291 -248
- runbooks/vpc/README.md +478 -0
- runbooks/vpc/__init__.py +2 -2
- runbooks/vpc/manager_interface.py +366 -351
- runbooks/vpc/networking_wrapper.py +68 -36
- runbooks/vpc/rich_formatters.py +22 -8
- runbooks-0.9.1.dist-info/METADATA +308 -0
- {runbooks-0.7.9.dist-info → runbooks-0.9.1.dist-info}/RECORD +120 -59
- {runbooks-0.7.9.dist-info → runbooks-0.9.1.dist-info}/entry_points.txt +1 -1
- runbooks/finops/cross_validation.py +0 -375
- runbooks-0.7.9.dist-info/METADATA +0 -636
- {runbooks-0.7.9.dist-info → runbooks-0.9.1.dist-info}/WHEEL +0 -0
- {runbooks-0.7.9.dist-info → runbooks-0.9.1.dist-info}/licenses/LICENSE +0 -0
- {runbooks-0.7.9.dist-info → runbooks-0.9.1.dist-info}/top_level.txt +0 -0
runbooks/remediation/README.md
CHANGED
@@ -1,26 +1,502 @@
|
|
1
|
-
#
|
1
|
+
# AWS Security Remediation Automation (CLI)
|
2
2
|
|
3
|
-
|
3
|
+
The AWS Security Remediation Automation module is an enterprise-grade command-line tool for automated security remediation and compliance enforcement. Built with the Rich library for beautiful terminal output, it provides comprehensive security issue remediation through AWS Lambda functions and automated workflows.
|
4
4
|
|
5
|
-
|
5
|
+
## 📈 *remediation-runbooks*.md Enterprise Rollout
|
6
|
+
|
7
|
+
Following proven **99/100 manager score** success patterns established in FinOps:
|
8
|
+
|
9
|
+
### **Rollout Strategy**: Progressive *-runbooks*.md standardization
|
10
|
+
- **Phase 5**: Remediation rollout with *remediation-runbooks*.md framework ✅
|
11
|
+
- **Integration**: AWS Config rules with automated remediation workflows
|
12
|
+
- **Enterprise Features**: Multi-account remediation with compliance tracking
|
13
|
+
|
14
|
+
## Why AWS Security Remediation Automation?
|
15
|
+
|
16
|
+
Security remediation in enterprise AWS environments requires automated, consistent, and auditable approaches. The Security Remediation CLI provides enterprise-grade automation for security issue detection and remediation, designed for security teams, compliance officers, and DevOps engineers managing large-scale AWS deployments.
|
17
|
+
|
18
|
+
Key capabilities include:
|
19
|
+
- **Automated Remediation**: AWS Config integration with Lambda-based remediation
|
20
|
+
- **Multi-Account Operations**: Cross-account security issue resolution
|
21
|
+
- **Compliance Enforcement**: Automated compliance policy enforcement
|
22
|
+
- **Rich Reporting**: Comprehensive remediation tracking and audit trails
|
23
|
+
- **Enterprise Integration**: Integration with security orchestration platforms
|
24
|
+
|
25
|
+
## Table of Contents
|
26
|
+
|
27
|
+
- [Features](#features)
|
28
|
+
- [Prerequisites](#prerequisites)
|
29
|
+
- [Installation](#installation)
|
30
|
+
- [AWS CLI Profile Setup](#aws-cli-profile-setup)
|
31
|
+
- [Command Line Usage](#command-line-usage)
|
32
|
+
- [Options](#command-line-options)
|
33
|
+
- [Examples](#examples)
|
34
|
+
- [Remediation Operations](#remediation-operations)
|
35
|
+
- [S3 Security Remediation](#s3-security-remediation)
|
36
|
+
- [API Gateway Security](#api-gateway-security)
|
37
|
+
- [IAM Security Enforcement](#iam-security-enforcement)
|
38
|
+
- [VPC Security Remediation](#vpc-security-remediation)
|
39
|
+
- [Configuration](#configuration)
|
40
|
+
- [Export Formats](#export-formats)
|
41
|
+
- [Contributing](#contributing)
|
42
|
+
- [License](#license)
|
43
|
+
|
44
|
+
---
|
45
|
+
|
46
|
+
## Features
|
47
|
+
|
48
|
+
- **S3 Security Remediation**:
|
49
|
+
- Automated public access blocking
|
50
|
+
- Bucket encryption enforcement
|
51
|
+
- Access logging configuration
|
52
|
+
- Lifecycle policy enforcement
|
53
|
+
- **API Gateway Security**:
|
54
|
+
- Resource policy enforcement
|
55
|
+
- Throttling configuration
|
56
|
+
- WAF integration automation
|
57
|
+
- Logging and monitoring setup
|
58
|
+
- **IAM Security Enforcement**:
|
59
|
+
- Password policy enforcement
|
60
|
+
- MFA requirement automation
|
61
|
+
- Privilege escalation prevention
|
62
|
+
- Access key rotation automation
|
63
|
+
- **VPC Security Remediation**:
|
64
|
+
- Security group rule optimization
|
65
|
+
- Network ACL compliance enforcement
|
66
|
+
- VPC Flow Logs configuration
|
67
|
+
- Public subnet security hardening
|
68
|
+
- **Multi-Account Operations**:
|
69
|
+
- AWS Organizations integration
|
70
|
+
- Cross-account role management
|
71
|
+
- Centralized policy enforcement
|
72
|
+
- Compliance reporting aggregation
|
73
|
+
- **Lambda-Based Automation**:
|
74
|
+
- Event-driven remediation workflows
|
75
|
+
- AWS Config integration
|
76
|
+
- CloudWatch Events triggering
|
77
|
+
- Serverless execution model
|
78
|
+
- **Rich Terminal UI**: Beautiful console output with remediation progress tracking
|
79
|
+
|
80
|
+
---
|
81
|
+
|
82
|
+
## Prerequisites
|
83
|
+
|
84
|
+
- **Python 3.8 or later**: Ensure you have the required Python version installed
|
85
|
+
- **AWS CLI configured with named profiles**: Set up your AWS CLI profiles for seamless integration
|
86
|
+
- **AWS credentials with permissions**:
|
87
|
+
- `config:*` (for AWS Config integration)
|
88
|
+
- `lambda:*` (for remediation function management)
|
89
|
+
- `iam:*` (for IAM security enforcement)
|
90
|
+
- `s3:*` (for S3 security remediation)
|
91
|
+
- `apigateway:*` (for API Gateway security)
|
92
|
+
- `ec2:*` (for VPC security remediation)
|
93
|
+
- `events:*` (for event-driven automation)
|
94
|
+
- `logs:*` (for CloudWatch Logs integration)
|
95
|
+
|
96
|
+
---
|
6
97
|
|
7
98
|
## Installation
|
8
99
|
|
9
|
-
###
|
10
|
-
|
100
|
+
### Option 1: Using uv (Fast Python Package Installer)
|
101
|
+
```bash
|
102
|
+
# Install runbooks with remediation automation
|
103
|
+
uv pip install runbooks
|
104
|
+
```
|
105
|
+
|
106
|
+
### Option 2: Using pip
|
107
|
+
```bash
|
108
|
+
# Install runbooks package
|
109
|
+
pip install runbooks
|
110
|
+
```
|
111
|
+
|
112
|
+
### Option 3: Development Installation
|
113
|
+
```bash
|
114
|
+
git clone https://github.com/1xOps/CloudOps-Runbooks.git
|
115
|
+
cd CloudOps-Runbooks
|
116
|
+
uv sync --all-extras
|
117
|
+
```
|
118
|
+
|
119
|
+
---
|
120
|
+
|
121
|
+
## AWS CLI Profile Setup
|
122
|
+
|
123
|
+
Configure your named profiles for remediation operations:
|
124
|
+
|
125
|
+
```bash
|
126
|
+
aws configure --profile remediation-prod
|
127
|
+
aws configure --profile remediation-dev
|
128
|
+
aws configure --profile security-admin
|
129
|
+
# ... etc ...
|
130
|
+
```
|
131
|
+
|
132
|
+
For multi-account remediation, ensure cross-account roles are properly configured.
|
133
|
+
|
134
|
+
---
|
135
|
+
|
136
|
+
## Command Line Usage
|
137
|
+
|
138
|
+
Run remediation operations using `runbooks remediation` followed by options:
|
139
|
+
|
140
|
+
```bash
|
141
|
+
runbooks remediation [service] [operation] [options]
|
142
|
+
```
|
143
|
+
|
144
|
+
### Command Line Options
|
145
|
+
|
146
|
+
| Flag | Description |
|
147
|
+
|---|---|
|
148
|
+
| `--profile`, `-p` | AWS profile to use for operations |
|
149
|
+
| `--region`, `-r` | AWS region to target (default: us-east-1) |
|
150
|
+
| `--all-regions` | Execute remediation across all regions |
|
151
|
+
| `--dry-run` | Execute in dry-run mode (default: enabled) |
|
152
|
+
| `--auto-remediate` | Enable automatic remediation without prompts |
|
153
|
+
| `--compliance-framework` | Target compliance framework: SOC2, PCI-DSS, HIPAA |
|
154
|
+
| `--output-format` | Output format: table, json, csv, html |
|
155
|
+
| `--notification-sns` | SNS topic for remediation notifications |
|
156
|
+
|
157
|
+
### Examples
|
158
|
+
|
159
|
+
```bash
|
160
|
+
# S3 security remediation
|
161
|
+
runbooks remediation s3 block-public-access --profile production --dry-run
|
162
|
+
runbooks remediation s3 enforce-encryption --all-regions --profile production
|
163
|
+
|
164
|
+
# API Gateway security
|
165
|
+
runbooks remediation apigateway configure-throttling --profile production
|
166
|
+
runbooks remediation apigateway enable-logging --profile production
|
167
|
+
|
168
|
+
# IAM security enforcement
|
169
|
+
runbooks remediation iam enforce-password-policy --profile production
|
170
|
+
runbooks remediation iam require-mfa --dry-run --profile production
|
171
|
+
|
172
|
+
# Multi-service security scan and remediation
|
173
|
+
runbooks remediation scan --auto-remediate --compliance-framework SOC2 --profile production
|
174
|
+
```
|
175
|
+
|
176
|
+
---
|
177
|
+
|
178
|
+
## Remediation Operations
|
179
|
+
|
180
|
+
### S3 Security Remediation
|
181
|
+
|
182
|
+
**Public Access Blocking**:
|
183
|
+
```bash
|
184
|
+
# Block public access on all S3 buckets
|
185
|
+
runbooks remediation s3 block-public-access --profile production
|
186
|
+
|
187
|
+
# Selective bucket remediation
|
188
|
+
runbooks remediation s3 block-public-access --bucket-names bucket1,bucket2 --profile production
|
189
|
+
|
190
|
+
# Organization-wide S3 security
|
191
|
+
runbooks remediation s3 block-public-access --organization-wide --profile management-account
|
192
|
+
```
|
193
|
+
|
194
|
+
**Expected S3 Remediation Output**:
|
195
|
+
```
|
196
|
+
╭─ S3 Security Remediation Results ─╮
|
197
|
+
│ │
|
198
|
+
│ 📊 Buckets Analyzed: 47 │
|
199
|
+
│ 🔒 Remediation Applied: 12 │
|
200
|
+
│ ✅ Already Compliant: 35 │
|
201
|
+
│ │
|
202
|
+
│ 🛡️ Security Improvements: │
|
203
|
+
│ • Public access blocked: 8 buckets │
|
204
|
+
│ • Encryption enabled: 4 buckets │
|
205
|
+
│ • Logging configured: 12 buckets │
|
206
|
+
│ │
|
207
|
+
│ ⏱️ Remediation Time: 2m 34s │
|
208
|
+
╰────────────────────────────────────╯
|
209
|
+
```
|
210
|
+
|
211
|
+
**Encryption Enforcement**:
|
212
|
+
```bash
|
213
|
+
# Enforce server-side encryption
|
214
|
+
runbooks remediation s3 enforce-encryption --kms-key default --profile production
|
215
|
+
|
216
|
+
# Custom KMS key encryption
|
217
|
+
runbooks remediation s3 enforce-encryption --kms-key arn:aws:kms:... --profile production
|
218
|
+
```
|
219
|
+
|
220
|
+
### API Gateway Security
|
221
|
+
|
222
|
+
**Throttling Configuration**:
|
223
|
+
```bash
|
224
|
+
# Configure API throttling limits
|
225
|
+
runbooks remediation apigateway configure-throttling --rate-limit 1000 --burst-limit 2000 --profile production
|
226
|
+
|
227
|
+
# Per-API throttling configuration
|
228
|
+
runbooks remediation apigateway configure-throttling --api-id abcd123 --profile production
|
229
|
+
```
|
230
|
+
|
231
|
+
**WAF Integration**:
|
232
|
+
```bash
|
233
|
+
# Enable WAF for API Gateway
|
234
|
+
runbooks remediation apigateway enable-waf --web-acl-name api-protection --profile production
|
235
|
+
|
236
|
+
# Configure WAF rules
|
237
|
+
runbooks remediation apigateway configure-waf-rules --ruleset owasp-top-10 --profile production
|
238
|
+
```
|
239
|
+
|
240
|
+
### IAM Security Enforcement
|
241
|
+
|
242
|
+
**Password Policy Enforcement**:
|
243
|
+
```bash
|
244
|
+
# Enforce strong password policy
|
245
|
+
runbooks remediation iam enforce-password-policy --min-length 12 --require-symbols --profile production
|
246
|
+
|
247
|
+
# Custom password policy
|
248
|
+
runbooks remediation iam enforce-password-policy --config password-policy.json --profile production
|
249
|
+
```
|
250
|
+
|
251
|
+
**MFA Requirement**:
|
252
|
+
```bash
|
253
|
+
# Require MFA for all users
|
254
|
+
runbooks remediation iam require-mfa --profile production
|
255
|
+
|
256
|
+
# MFA for privileged users only
|
257
|
+
runbooks remediation iam require-mfa --privileged-only --profile production
|
258
|
+
```
|
259
|
+
|
260
|
+
### VPC Security Remediation
|
261
|
+
|
262
|
+
**Security Group Optimization**:
|
263
|
+
```bash
|
264
|
+
# Remove overly permissive rules
|
265
|
+
runbooks remediation vpc optimize-security-groups --profile production
|
266
|
+
|
267
|
+
# Enforce specific security policies
|
268
|
+
runbooks remediation vpc enforce-security-policy --policy-file security-policy.json --profile production
|
269
|
+
```
|
270
|
+
|
271
|
+
**VPC Flow Logs Configuration**:
|
272
|
+
```bash
|
273
|
+
# Enable VPC Flow Logs
|
274
|
+
runbooks remediation vpc enable-flow-logs --destination cloudwatch --profile production
|
275
|
+
|
276
|
+
# Configure Flow Logs with S3 destination
|
277
|
+
runbooks remediation vpc enable-flow-logs --destination s3 --s3-bucket vpc-flow-logs --profile production
|
278
|
+
```
|
279
|
+
|
280
|
+
---
|
281
|
+
|
282
|
+
## Configuration
|
283
|
+
|
284
|
+
### Remediation Configuration File
|
285
|
+
|
286
|
+
Create a `remediation_config.toml` file:
|
287
|
+
|
288
|
+
```toml
|
289
|
+
# remediation_config.toml
|
290
|
+
[s3]
|
291
|
+
enforce_public_access_block = true
|
292
|
+
default_encryption = "AES256"
|
293
|
+
enable_access_logging = true
|
294
|
+
lifecycle_policy_days = 365
|
295
|
+
|
296
|
+
[apigateway]
|
297
|
+
default_throttle_rate = 1000
|
298
|
+
default_throttle_burst = 2000
|
299
|
+
enable_waf = true
|
300
|
+
enable_logging = true
|
301
|
+
|
302
|
+
[iam]
|
303
|
+
password_policy = {
|
304
|
+
min_length = 12,
|
305
|
+
require_symbols = true,
|
306
|
+
require_numbers = true,
|
307
|
+
require_uppercase = true,
|
308
|
+
require_lowercase = true,
|
309
|
+
max_age_days = 90
|
310
|
+
}
|
311
|
+
require_mfa = true
|
312
|
+
|
313
|
+
[vpc]
|
314
|
+
enable_flow_logs = true
|
315
|
+
flow_logs_destination = "cloudwatch"
|
316
|
+
security_group_max_ingress_rules = 10
|
317
|
+
|
318
|
+
[notifications]
|
319
|
+
sns_topic = "arn:aws:sns:us-east-1:123456789012:security-remediation"
|
320
|
+
email_notifications = true
|
321
|
+
slack_webhook = "${SLACK_WEBHOOK_URL}"
|
322
|
+
|
323
|
+
[compliance]
|
324
|
+
frameworks = ["SOC2", "PCI-DSS"]
|
325
|
+
auto_remediate = false
|
326
|
+
audit_trail = true
|
327
|
+
```
|
328
|
+
|
329
|
+
**Using Configuration File**:
|
330
|
+
```bash
|
331
|
+
runbooks remediation --config remediation_config.toml scan --profile production
|
332
|
+
```
|
333
|
+
|
334
|
+
---
|
335
|
+
|
336
|
+
## Lambda-Based Automation
|
337
|
+
|
338
|
+
### Deploy Remediation Functions
|
339
|
+
|
340
|
+
**Deploy Lambda Functions**:
|
341
|
+
```bash
|
342
|
+
# Deploy all remediation functions
|
343
|
+
runbooks remediation deploy-functions --profile production
|
344
|
+
|
345
|
+
# Deploy specific function
|
346
|
+
runbooks remediation deploy-function --function s3-public-access-remediation --profile production
|
347
|
+
|
348
|
+
# Update existing functions
|
349
|
+
runbooks remediation update-functions --profile production
|
350
|
+
```
|
351
|
+
|
352
|
+
### AWS Config Integration
|
353
|
+
|
354
|
+
**Configure Config Rules**:
|
355
|
+
```bash
|
356
|
+
# Enable AWS Config for remediation
|
357
|
+
runbooks remediation configure-aws-config --enable --profile production
|
358
|
+
|
359
|
+
# Deploy remediation Config rules
|
360
|
+
runbooks remediation deploy-config-rules --profile production
|
361
|
+
|
362
|
+
# Monitor Config compliance
|
363
|
+
runbooks remediation monitor-compliance --dashboard --profile production
|
364
|
+
```
|
365
|
+
|
366
|
+
### Event-Driven Remediation
|
367
|
+
|
368
|
+
**CloudWatch Events Integration**:
|
369
|
+
```bash
|
370
|
+
# Configure event-driven remediation
|
371
|
+
runbooks remediation configure-events --profile production
|
372
|
+
|
373
|
+
# Test event triggers
|
374
|
+
runbooks remediation test-event-trigger --event-type s3-public-bucket --profile production
|
375
|
+
```
|
376
|
+
|
377
|
+
---
|
378
|
+
|
379
|
+
## Export Formats
|
380
|
+
|
381
|
+
### JSON Output Format
|
382
|
+
|
383
|
+
```bash
|
384
|
+
runbooks remediation scan --output-format json --output-file remediation_report.json --profile production
|
385
|
+
```
|
386
|
+
|
387
|
+
```json
|
388
|
+
{
|
389
|
+
"remediation_summary": {
|
390
|
+
"timestamp": "2024-01-15T10:30:00Z",
|
391
|
+
"account_id": "123456789012",
|
392
|
+
"compliance_framework": "SOC2",
|
393
|
+
"services_scanned": ["s3", "iam", "apigateway", "vpc"],
|
394
|
+
"total_issues_found": 23,
|
395
|
+
"issues_remediated": 18,
|
396
|
+
"manual_review_required": 5,
|
397
|
+
"remediation_actions": [
|
398
|
+
{
|
399
|
+
"service": "s3",
|
400
|
+
"action": "block_public_access",
|
401
|
+
"resources_affected": 8,
|
402
|
+
"status": "completed"
|
403
|
+
}
|
404
|
+
]
|
405
|
+
}
|
406
|
+
}
|
407
|
+
```
|
11
408
|
|
12
|
-
###
|
409
|
+
### HTML Remediation Report
|
13
410
|
|
14
|
-
1. Install conda and create a new environment
|
15
|
-
2. Install the required packages using pip:
|
16
411
|
```bash
|
17
|
-
|
412
|
+
runbooks remediation scan --output-format html --output-file remediation_report.html --profile production
|
18
413
|
```
|
19
414
|
|
20
|
-
|
415
|
+
---
|
416
|
+
|
417
|
+
## Multi-Account Remediation
|
418
|
+
|
419
|
+
### Organization-Wide Operations
|
21
420
|
|
421
|
+
**Cross-Account Remediation**:
|
22
422
|
```bash
|
23
|
-
|
24
|
-
|
25
|
-
|
423
|
+
# Scan entire organization
|
424
|
+
runbooks remediation scan --organization-wide --profile management-account
|
425
|
+
|
426
|
+
# Remediate across multiple accounts
|
427
|
+
runbooks remediation execute --accounts prod,dev,staging --profile management-account
|
428
|
+
|
429
|
+
# Compliance reporting
|
430
|
+
runbooks remediation compliance-report --organization-wide --framework SOC2 --profile management-account
|
26
431
|
```
|
432
|
+
|
433
|
+
### Centralized Policy Management
|
434
|
+
|
435
|
+
**Deploy Organization Policies**:
|
436
|
+
```bash
|
437
|
+
# Deploy service control policies
|
438
|
+
runbooks remediation deploy-scp --policy-file security-scp.json --profile management-account
|
439
|
+
|
440
|
+
# Enforce compliance policies
|
441
|
+
runbooks remediation enforce-org-policies --profile management-account
|
442
|
+
```
|
443
|
+
|
444
|
+
---
|
445
|
+
|
446
|
+
## Integration with Security Tools
|
447
|
+
|
448
|
+
### SOAR Platform Integration
|
449
|
+
|
450
|
+
```bash
|
451
|
+
# Configure SOAR integration
|
452
|
+
runbooks remediation configure --platform phantom --api-key $PHANTOM_API_KEY
|
453
|
+
|
454
|
+
# Send remediation playbooks to SOAR
|
455
|
+
runbooks remediation export-playbooks --platform phantom --profile production
|
456
|
+
```
|
457
|
+
|
458
|
+
### SIEM Integration
|
459
|
+
|
460
|
+
```bash
|
461
|
+
# Configure SIEM logging
|
462
|
+
runbooks remediation configure --siem splunk --hec-endpoint $SPLUNK_HEC_URL
|
463
|
+
|
464
|
+
# Send remediation logs to SIEM
|
465
|
+
runbooks remediation log-to-siem --profile production
|
466
|
+
```
|
467
|
+
|
468
|
+
---
|
469
|
+
|
470
|
+
## Contributing
|
471
|
+
|
472
|
+
We welcome contributions! Please see our [Contributing Guidelines](../../../CONTRIBUTING.md) for details.
|
473
|
+
|
474
|
+
### Development Setup
|
475
|
+
```bash
|
476
|
+
git clone https://github.com/1xOps/CloudOps-Runbooks.git
|
477
|
+
cd CloudOps-Runbooks
|
478
|
+
uv sync --all-extras
|
479
|
+
uv run python -m runbooks remediation --help
|
480
|
+
```
|
481
|
+
|
482
|
+
### Running Tests
|
483
|
+
```bash
|
484
|
+
uv run pytest tests/remediation/ -v
|
485
|
+
```
|
486
|
+
|
487
|
+
---
|
488
|
+
|
489
|
+
## License
|
490
|
+
|
491
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](../../../LICENSE) file for details.
|
492
|
+
|
493
|
+
---
|
494
|
+
|
495
|
+
## Enterprise Support
|
496
|
+
|
497
|
+
For enterprise support, professional services, and custom remediation integrations:
|
498
|
+
- **Email**: [info@oceansoft.io](mailto:info@oceansoft.io)
|
499
|
+
- **GitHub**: [CloudOps Runbooks Issues](https://github.com/1xOps/CloudOps-Runbooks/issues)
|
500
|
+
- **Documentation**: [Enterprise Remediation Documentation](https://docs.cloudops-runbooks.io/remediation)
|
501
|
+
|
502
|
+
Let's automate security remediation together. 🚀
|
runbooks/remediation/base.py
CHANGED
@@ -79,6 +79,7 @@ from botocore.exceptions import BotoCoreError, ClientError
|
|
79
79
|
from loguru import logger
|
80
80
|
from pydantic import BaseModel, Field
|
81
81
|
|
82
|
+
from runbooks.common.profile_utils import create_management_session
|
82
83
|
from runbooks.inventory.models.account import AWSAccount
|
83
84
|
|
84
85
|
|
@@ -385,13 +386,14 @@ class BaseRemediation(ABC):
|
|
385
386
|
|
386
387
|
@property
|
387
388
|
def session(self) -> boto3.Session:
|
388
|
-
"""Get or create AWS session with profile configuration."""
|
389
|
+
"""Get or create AWS session with profile configuration using enterprise profile management."""
|
389
390
|
if self._session is None:
|
390
391
|
try:
|
391
|
-
|
392
|
+
# Use management profile for remediation operations requiring cross-account access
|
393
|
+
self._session = create_management_session(profile=self.profile)
|
392
394
|
except Exception as e:
|
393
395
|
logger.warning(f"Failed to create session with profile {self.profile}: {e}")
|
394
|
-
self._session =
|
396
|
+
self._session = create_management_session() # Use default profile
|
395
397
|
return self._session
|
396
398
|
|
397
399
|
def get_client(self, service_name: str, region: str = None) -> Any:
|
runbooks/remediation/commons.py
CHANGED
@@ -13,6 +13,8 @@ import botocore.exceptions
|
|
13
13
|
import botocore.session
|
14
14
|
from botocore.exceptions import ClientError
|
15
15
|
|
16
|
+
from runbooks.common.rich_utils import console, print_error, print_info, print_warning
|
17
|
+
|
16
18
|
logger = logging.getLogger(__name__)
|
17
19
|
|
18
20
|
|
@@ -37,7 +39,9 @@ def get_all_available_aws_credentials(start_url: str = None, role_name="power-us
|
|
37
39
|
clientId=client_creds["clientId"], clientSecret=client_creds["clientSecret"], startUrl=start_url
|
38
40
|
)
|
39
41
|
|
40
|
-
print(
|
42
|
+
console.print(
|
43
|
+
f"[cyan]Please go to {device_auth['verificationUriComplete']} and enter the code: [bold]{device_auth['userCode']}[/bold][/cyan]"
|
44
|
+
)
|
41
45
|
webbrowser.open(device_auth["verificationUriComplete"])
|
42
46
|
|
43
47
|
# Wait for user to authorize
|
@@ -54,15 +58,15 @@ def get_all_available_aws_credentials(start_url: str = None, role_name="power-us
|
|
54
58
|
deviceCode=device_auth["deviceCode"],
|
55
59
|
)
|
56
60
|
except sso_oidc.exceptions.AuthorizationPendingException:
|
57
|
-
|
61
|
+
print_info("Waiting for authorization... Please complete the process in your browser.")
|
58
62
|
time.sleep(5) # Wait for 5 seconds before trying again
|
59
63
|
retry_count += 1
|
60
64
|
except Exception as e:
|
61
|
-
|
65
|
+
print_error(f"An error occurred: {e}")
|
62
66
|
break
|
63
67
|
|
64
68
|
if not token:
|
65
|
-
|
69
|
+
print_error("Authorization timed out or failed. Please try again.")
|
66
70
|
return credentials
|
67
71
|
|
68
72
|
# Create SSO client
|