runbooks 1.1.4__py3-none-any.whl → 1.1.6__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.
Files changed (273) hide show
  1. runbooks/__init__.py +31 -2
  2. runbooks/__init___optimized.py +18 -4
  3. runbooks/_platform/__init__.py +1 -5
  4. runbooks/_platform/core/runbooks_wrapper.py +141 -138
  5. runbooks/aws2/accuracy_validator.py +812 -0
  6. runbooks/base.py +7 -0
  7. runbooks/cfat/assessment/compliance.py +1 -1
  8. runbooks/cfat/assessment/runner.py +1 -0
  9. runbooks/cfat/cloud_foundations_assessment.py +227 -239
  10. runbooks/cli/__init__.py +1 -1
  11. runbooks/cli/commands/cfat.py +64 -23
  12. runbooks/cli/commands/finops.py +1005 -54
  13. runbooks/cli/commands/inventory.py +135 -91
  14. runbooks/cli/commands/operate.py +9 -36
  15. runbooks/cli/commands/security.py +42 -18
  16. runbooks/cli/commands/validation.py +432 -18
  17. runbooks/cli/commands/vpc.py +81 -17
  18. runbooks/cli/registry.py +22 -10
  19. runbooks/cloudops/__init__.py +20 -27
  20. runbooks/cloudops/base.py +96 -107
  21. runbooks/cloudops/cost_optimizer.py +544 -542
  22. runbooks/cloudops/infrastructure_optimizer.py +5 -4
  23. runbooks/cloudops/interfaces.py +224 -225
  24. runbooks/cloudops/lifecycle_manager.py +5 -4
  25. runbooks/cloudops/mcp_cost_validation.py +252 -235
  26. runbooks/cloudops/models.py +78 -53
  27. runbooks/cloudops/monitoring_automation.py +5 -4
  28. runbooks/cloudops/notebook_framework.py +177 -213
  29. runbooks/cloudops/security_enforcer.py +125 -159
  30. runbooks/common/accuracy_validator.py +17 -12
  31. runbooks/common/aws_pricing.py +349 -326
  32. runbooks/common/aws_pricing_api.py +211 -212
  33. runbooks/common/aws_profile_manager.py +40 -36
  34. runbooks/common/aws_utils.py +74 -79
  35. runbooks/common/business_logic.py +126 -104
  36. runbooks/common/cli_decorators.py +36 -60
  37. runbooks/common/comprehensive_cost_explorer_integration.py +455 -463
  38. runbooks/common/cross_account_manager.py +197 -204
  39. runbooks/common/date_utils.py +27 -39
  40. runbooks/common/decorators.py +29 -19
  41. runbooks/common/dry_run_examples.py +173 -208
  42. runbooks/common/dry_run_framework.py +157 -155
  43. runbooks/common/enhanced_exception_handler.py +15 -4
  44. runbooks/common/enhanced_logging_example.py +50 -64
  45. runbooks/common/enhanced_logging_integration_example.py +65 -37
  46. runbooks/common/env_utils.py +16 -16
  47. runbooks/common/error_handling.py +40 -38
  48. runbooks/common/lazy_loader.py +41 -23
  49. runbooks/common/logging_integration_helper.py +79 -86
  50. runbooks/common/mcp_cost_explorer_integration.py +476 -493
  51. runbooks/common/mcp_integration.py +99 -79
  52. runbooks/common/memory_optimization.py +140 -118
  53. runbooks/common/module_cli_base.py +37 -58
  54. runbooks/common/organizations_client.py +175 -193
  55. runbooks/common/patterns.py +23 -25
  56. runbooks/common/performance_monitoring.py +67 -71
  57. runbooks/common/performance_optimization_engine.py +283 -274
  58. runbooks/common/profile_utils.py +111 -37
  59. runbooks/common/rich_utils.py +315 -141
  60. runbooks/common/sre_performance_suite.py +177 -186
  61. runbooks/enterprise/__init__.py +1 -1
  62. runbooks/enterprise/logging.py +144 -106
  63. runbooks/enterprise/security.py +187 -204
  64. runbooks/enterprise/validation.py +43 -56
  65. runbooks/finops/__init__.py +26 -30
  66. runbooks/finops/account_resolver.py +1 -1
  67. runbooks/finops/advanced_optimization_engine.py +980 -0
  68. runbooks/finops/automation_core.py +268 -231
  69. runbooks/finops/business_case_config.py +184 -179
  70. runbooks/finops/cli.py +660 -139
  71. runbooks/finops/commvault_ec2_analysis.py +157 -164
  72. runbooks/finops/compute_cost_optimizer.py +336 -320
  73. runbooks/finops/config.py +20 -20
  74. runbooks/finops/cost_optimizer.py +484 -618
  75. runbooks/finops/cost_processor.py +332 -214
  76. runbooks/finops/dashboard_runner.py +1006 -172
  77. runbooks/finops/ebs_cost_optimizer.py +991 -657
  78. runbooks/finops/elastic_ip_optimizer.py +317 -257
  79. runbooks/finops/enhanced_mcp_integration.py +340 -0
  80. runbooks/finops/enhanced_progress.py +32 -29
  81. runbooks/finops/enhanced_trend_visualization.py +3 -2
  82. runbooks/finops/enterprise_wrappers.py +223 -285
  83. runbooks/finops/executive_export.py +203 -160
  84. runbooks/finops/helpers.py +130 -288
  85. runbooks/finops/iam_guidance.py +1 -1
  86. runbooks/finops/infrastructure/__init__.py +80 -0
  87. runbooks/finops/infrastructure/commands.py +506 -0
  88. runbooks/finops/infrastructure/load_balancer_optimizer.py +866 -0
  89. runbooks/finops/infrastructure/vpc_endpoint_optimizer.py +832 -0
  90. runbooks/finops/markdown_exporter.py +337 -174
  91. runbooks/finops/mcp_validator.py +1952 -0
  92. runbooks/finops/nat_gateway_optimizer.py +1512 -481
  93. runbooks/finops/network_cost_optimizer.py +657 -587
  94. runbooks/finops/notebook_utils.py +226 -188
  95. runbooks/finops/optimization_engine.py +1136 -0
  96. runbooks/finops/optimizer.py +19 -23
  97. runbooks/finops/rds_snapshot_optimizer.py +367 -411
  98. runbooks/finops/reservation_optimizer.py +427 -363
  99. runbooks/finops/scenario_cli_integration.py +64 -65
  100. runbooks/finops/scenarios.py +1277 -438
  101. runbooks/finops/schemas.py +218 -182
  102. runbooks/finops/snapshot_manager.py +2289 -0
  103. runbooks/finops/types.py +3 -3
  104. runbooks/finops/validation_framework.py +259 -265
  105. runbooks/finops/vpc_cleanup_exporter.py +189 -144
  106. runbooks/finops/vpc_cleanup_optimizer.py +591 -573
  107. runbooks/finops/workspaces_analyzer.py +171 -182
  108. runbooks/integration/__init__.py +89 -0
  109. runbooks/integration/mcp_integration.py +1920 -0
  110. runbooks/inventory/CLAUDE.md +816 -0
  111. runbooks/inventory/__init__.py +2 -2
  112. runbooks/inventory/aws_decorators.py +2 -3
  113. runbooks/inventory/check_cloudtrail_compliance.py +2 -4
  114. runbooks/inventory/check_controltower_readiness.py +152 -151
  115. runbooks/inventory/check_landingzone_readiness.py +85 -84
  116. runbooks/inventory/cloud_foundations_integration.py +144 -149
  117. runbooks/inventory/collectors/aws_comprehensive.py +1 -1
  118. runbooks/inventory/collectors/aws_networking.py +109 -99
  119. runbooks/inventory/collectors/base.py +4 -0
  120. runbooks/inventory/core/collector.py +495 -313
  121. runbooks/inventory/core/formatter.py +11 -0
  122. runbooks/inventory/draw_org_structure.py +8 -9
  123. runbooks/inventory/drift_detection_cli.py +69 -96
  124. runbooks/inventory/ec2_vpc_utils.py +2 -2
  125. runbooks/inventory/find_cfn_drift_detection.py +5 -7
  126. runbooks/inventory/find_cfn_orphaned_stacks.py +7 -9
  127. runbooks/inventory/find_cfn_stackset_drift.py +5 -6
  128. runbooks/inventory/find_ec2_security_groups.py +48 -42
  129. runbooks/inventory/find_landingzone_versions.py +4 -6
  130. runbooks/inventory/find_vpc_flow_logs.py +7 -9
  131. runbooks/inventory/inventory_mcp_cli.py +48 -46
  132. runbooks/inventory/inventory_modules.py +103 -91
  133. runbooks/inventory/list_cfn_stacks.py +9 -10
  134. runbooks/inventory/list_cfn_stackset_operation_results.py +1 -3
  135. runbooks/inventory/list_cfn_stackset_operations.py +79 -57
  136. runbooks/inventory/list_cfn_stacksets.py +8 -10
  137. runbooks/inventory/list_config_recorders_delivery_channels.py +49 -39
  138. runbooks/inventory/list_ds_directories.py +65 -53
  139. runbooks/inventory/list_ec2_availability_zones.py +2 -4
  140. runbooks/inventory/list_ec2_ebs_volumes.py +32 -35
  141. runbooks/inventory/list_ec2_instances.py +23 -28
  142. runbooks/inventory/list_ecs_clusters_and_tasks.py +26 -34
  143. runbooks/inventory/list_elbs_load_balancers.py +22 -20
  144. runbooks/inventory/list_enis_network_interfaces.py +26 -33
  145. runbooks/inventory/list_guardduty_detectors.py +2 -4
  146. runbooks/inventory/list_iam_policies.py +2 -4
  147. runbooks/inventory/list_iam_roles.py +5 -7
  148. runbooks/inventory/list_iam_saml_providers.py +4 -6
  149. runbooks/inventory/list_lambda_functions.py +38 -38
  150. runbooks/inventory/list_org_accounts.py +6 -8
  151. runbooks/inventory/list_org_accounts_users.py +55 -44
  152. runbooks/inventory/list_rds_db_instances.py +31 -33
  153. runbooks/inventory/list_rds_snapshots_aggregator.py +192 -208
  154. runbooks/inventory/list_route53_hosted_zones.py +3 -5
  155. runbooks/inventory/list_servicecatalog_provisioned_products.py +37 -41
  156. runbooks/inventory/list_sns_topics.py +2 -4
  157. runbooks/inventory/list_ssm_parameters.py +4 -7
  158. runbooks/inventory/list_vpc_subnets.py +2 -4
  159. runbooks/inventory/list_vpcs.py +7 -10
  160. runbooks/inventory/mcp_inventory_validator.py +554 -468
  161. runbooks/inventory/mcp_vpc_validator.py +359 -442
  162. runbooks/inventory/organizations_discovery.py +63 -55
  163. runbooks/inventory/recover_cfn_stack_ids.py +7 -8
  164. runbooks/inventory/requirements.txt +0 -1
  165. runbooks/inventory/rich_inventory_display.py +35 -34
  166. runbooks/inventory/run_on_multi_accounts.py +3 -5
  167. runbooks/inventory/unified_validation_engine.py +281 -253
  168. runbooks/inventory/verify_ec2_security_groups.py +1 -1
  169. runbooks/inventory/vpc_analyzer.py +735 -697
  170. runbooks/inventory/vpc_architecture_validator.py +293 -348
  171. runbooks/inventory/vpc_dependency_analyzer.py +384 -380
  172. runbooks/inventory/vpc_flow_analyzer.py +1 -1
  173. runbooks/main.py +49 -34
  174. runbooks/main_final.py +91 -60
  175. runbooks/main_minimal.py +22 -10
  176. runbooks/main_optimized.py +131 -100
  177. runbooks/main_ultra_minimal.py +7 -2
  178. runbooks/mcp/__init__.py +36 -0
  179. runbooks/mcp/integration.py +679 -0
  180. runbooks/monitoring/performance_monitor.py +9 -4
  181. runbooks/operate/dynamodb_operations.py +3 -1
  182. runbooks/operate/ec2_operations.py +145 -137
  183. runbooks/operate/iam_operations.py +146 -152
  184. runbooks/operate/networking_cost_heatmap.py +29 -8
  185. runbooks/operate/rds_operations.py +223 -254
  186. runbooks/operate/s3_operations.py +107 -118
  187. runbooks/operate/vpc_operations.py +646 -616
  188. runbooks/remediation/base.py +1 -1
  189. runbooks/remediation/commons.py +10 -7
  190. runbooks/remediation/commvault_ec2_analysis.py +70 -66
  191. runbooks/remediation/ec2_unattached_ebs_volumes.py +1 -0
  192. runbooks/remediation/multi_account.py +24 -21
  193. runbooks/remediation/rds_snapshot_list.py +86 -60
  194. runbooks/remediation/remediation_cli.py +92 -146
  195. runbooks/remediation/universal_account_discovery.py +83 -79
  196. runbooks/remediation/workspaces_list.py +46 -41
  197. runbooks/security/__init__.py +19 -0
  198. runbooks/security/assessment_runner.py +1150 -0
  199. runbooks/security/baseline_checker.py +812 -0
  200. runbooks/security/cloudops_automation_security_validator.py +509 -535
  201. runbooks/security/compliance_automation_engine.py +17 -17
  202. runbooks/security/config/__init__.py +2 -2
  203. runbooks/security/config/compliance_config.py +50 -50
  204. runbooks/security/config_template_generator.py +63 -76
  205. runbooks/security/enterprise_security_framework.py +1 -1
  206. runbooks/security/executive_security_dashboard.py +519 -508
  207. runbooks/security/multi_account_security_controls.py +959 -1210
  208. runbooks/security/real_time_security_monitor.py +422 -444
  209. runbooks/security/security_baseline_tester.py +1 -1
  210. runbooks/security/security_cli.py +143 -112
  211. runbooks/security/test_2way_validation.py +439 -0
  212. runbooks/security/two_way_validation_framework.py +852 -0
  213. runbooks/sre/production_monitoring_framework.py +167 -177
  214. runbooks/tdd/__init__.py +15 -0
  215. runbooks/tdd/cli.py +1071 -0
  216. runbooks/utils/__init__.py +14 -17
  217. runbooks/utils/logger.py +7 -2
  218. runbooks/utils/version_validator.py +50 -47
  219. runbooks/validation/__init__.py +6 -6
  220. runbooks/validation/cli.py +9 -3
  221. runbooks/validation/comprehensive_2way_validator.py +745 -704
  222. runbooks/validation/mcp_validator.py +906 -228
  223. runbooks/validation/terraform_citations_validator.py +104 -115
  224. runbooks/validation/terraform_drift_detector.py +461 -454
  225. runbooks/vpc/README.md +617 -0
  226. runbooks/vpc/__init__.py +8 -1
  227. runbooks/vpc/analyzer.py +577 -0
  228. runbooks/vpc/cleanup_wrapper.py +476 -413
  229. runbooks/vpc/cli_cloudtrail_commands.py +339 -0
  230. runbooks/vpc/cli_mcp_validation_commands.py +480 -0
  231. runbooks/vpc/cloudtrail_audit_integration.py +717 -0
  232. runbooks/vpc/config.py +92 -97
  233. runbooks/vpc/cost_engine.py +411 -148
  234. runbooks/vpc/cost_explorer_integration.py +553 -0
  235. runbooks/vpc/cross_account_session.py +101 -106
  236. runbooks/vpc/enhanced_mcp_validation.py +917 -0
  237. runbooks/vpc/eni_gate_validator.py +961 -0
  238. runbooks/vpc/heatmap_engine.py +185 -160
  239. runbooks/vpc/mcp_no_eni_validator.py +680 -639
  240. runbooks/vpc/nat_gateway_optimizer.py +358 -0
  241. runbooks/vpc/networking_wrapper.py +15 -8
  242. runbooks/vpc/pdca_remediation_planner.py +528 -0
  243. runbooks/vpc/performance_optimized_analyzer.py +219 -231
  244. runbooks/vpc/runbooks_adapter.py +1167 -241
  245. runbooks/vpc/tdd_red_phase_stubs.py +601 -0
  246. runbooks/vpc/test_data_loader.py +358 -0
  247. runbooks/vpc/tests/conftest.py +314 -4
  248. runbooks/vpc/tests/test_cleanup_framework.py +1022 -0
  249. runbooks/vpc/tests/test_cost_engine.py +0 -2
  250. runbooks/vpc/topology_generator.py +326 -0
  251. runbooks/vpc/unified_scenarios.py +1297 -1124
  252. runbooks/vpc/vpc_cleanup_integration.py +1943 -1115
  253. runbooks-1.1.6.dist-info/METADATA +327 -0
  254. runbooks-1.1.6.dist-info/RECORD +489 -0
  255. runbooks/finops/README.md +0 -414
  256. runbooks/finops/accuracy_cross_validator.py +0 -647
  257. runbooks/finops/business_cases.py +0 -950
  258. runbooks/finops/dashboard_router.py +0 -922
  259. runbooks/finops/ebs_optimizer.py +0 -973
  260. runbooks/finops/embedded_mcp_validator.py +0 -1629
  261. runbooks/finops/enhanced_dashboard_runner.py +0 -527
  262. runbooks/finops/finops_dashboard.py +0 -584
  263. runbooks/finops/finops_scenarios.py +0 -1218
  264. runbooks/finops/legacy_migration.py +0 -730
  265. runbooks/finops/multi_dashboard.py +0 -1519
  266. runbooks/finops/single_dashboard.py +0 -1113
  267. runbooks/finops/unlimited_scenarios.py +0 -393
  268. runbooks-1.1.4.dist-info/METADATA +0 -800
  269. runbooks-1.1.4.dist-info/RECORD +0 -468
  270. {runbooks-1.1.4.dist-info → runbooks-1.1.6.dist-info}/WHEEL +0 -0
  271. {runbooks-1.1.4.dist-info → runbooks-1.1.6.dist-info}/entry_points.txt +0 -0
  272. {runbooks-1.1.4.dist-info → runbooks-1.1.6.dist-info}/licenses/LICENSE +0 -0
  273. {runbooks-1.1.4.dist-info → runbooks-1.1.6.dist-info}/top_level.txt +0 -0
@@ -144,7 +144,7 @@ class ComplianceAutomationEngine:
144
144
  self.profile = profile
145
145
  self.output_dir = Path(output_dir)
146
146
  self.output_dir.mkdir(parents=True, exist_ok=True)
147
-
147
+
148
148
  # Initialize universal compliance configuration
149
149
  self.compliance_config = get_universal_compliance_config()
150
150
 
@@ -173,30 +173,30 @@ class ComplianceAutomationEngine:
173
173
  def _create_session(self) -> boto3.Session:
174
174
  """Create secure AWS session using enterprise profile management."""
175
175
  # Use management profile for compliance operations requiring cross-account access
176
- return create_management_session(profile=self.profile)
177
-
176
+ return create_management_session(profile_name=self.profile)
177
+
178
178
  def _get_compliance_weight(self, control_id: str, default_weight: float) -> float:
179
179
  """
180
180
  Get compliance weight for control using universal configuration system.
181
-
181
+
182
182
  Uses the universal compliance configuration with priority:
183
183
  1. Environment variables: COMPLIANCE_WEIGHT_<CONTROL_ID>
184
184
  2. Configuration file: COMPLIANCE_CONFIG_PATH
185
185
  3. Framework-specific defaults
186
-
186
+
187
187
  Args:
188
188
  control_id: Control identifier
189
189
  default_weight: Framework-specific default weight
190
-
190
+
191
191
  Returns:
192
192
  float: Compliance weight for the control
193
193
  """
194
194
  return self.compliance_config.get_control_weight(control_id, default_weight)
195
-
195
+
196
196
  def _get_compliance_threshold(self, framework: ComplianceFramework) -> float:
197
197
  """
198
198
  Get compliance threshold for framework using universal configuration system.
199
-
199
+
200
200
  Uses the universal compliance configuration with framework-specific defaults:
201
201
  - PCI DSS: 100.0% (requires perfect compliance)
202
202
  - HIPAA: 95.0% (healthcare requires high compliance)
@@ -205,10 +205,10 @@ class ComplianceAutomationEngine:
205
205
  - ISO 27001: 90.0% (information security management)
206
206
  - NIST Cybersecurity: 85.0% (cybersecurity framework)
207
207
  - CIS Benchmarks: 85.0% (security benchmarks)
208
-
208
+
209
209
  Args:
210
210
  framework: Compliance framework
211
-
211
+
212
212
  Returns:
213
213
  float: Compliance threshold for the framework
214
214
  """
@@ -222,11 +222,11 @@ class ComplianceAutomationEngine:
222
222
  ComplianceFramework.NIST_CYBERSECURITY: 85.0,
223
223
  ComplianceFramework.CIS_BENCHMARKS: 85.0,
224
224
  }
225
-
225
+
226
226
  # Get framework name for configuration lookup
227
- framework_name = framework.value.lower().replace(' ', '-').replace('_', '-')
227
+ framework_name = framework.value.lower().replace(" ", "-").replace("_", "-")
228
228
  default_threshold = framework_defaults.get(framework, 90.0)
229
-
229
+
230
230
  return self.compliance_config.get_framework_threshold(framework_name, default_threshold)
231
231
 
232
232
  def _load_framework_controls(self) -> Dict[ComplianceFramework, List[ComplianceControl]]:
@@ -661,7 +661,7 @@ class ComplianceAutomationEngine:
661
661
  async def _discover_target_accounts(self) -> List[str]:
662
662
  """
663
663
  Discover target accounts for compliance assessment using configuration-driven approach.
664
-
664
+
665
665
  Priority:
666
666
  1. Environment variable: COMPLIANCE_TARGET_ACCOUNTS (comma-separated)
667
667
  2. Configuration file: COMPLIANCE_ACCOUNTS_CONFIG
@@ -674,12 +674,12 @@ class ComplianceAutomationEngine:
674
674
  account_ids = [acc.strip() for acc in env_accounts.split(",")]
675
675
  print_info(f"Using {len(account_ids)} accounts from COMPLIANCE_TARGET_ACCOUNTS environment variable")
676
676
  return account_ids
677
-
677
+
678
678
  # Try configuration file
679
679
  config_path = os.getenv("COMPLIANCE_ACCOUNTS_CONFIG")
680
680
  if config_path and os.path.exists(config_path):
681
681
  try:
682
- with open(config_path, 'r') as f:
682
+ with open(config_path, "r") as f:
683
683
  config = json.load(f)
684
684
  account_ids = config.get("target_accounts", [])
685
685
  if account_ids:
@@ -687,7 +687,7 @@ class ComplianceAutomationEngine:
687
687
  return account_ids
688
688
  except Exception as e:
689
689
  print_warning(f"Failed to load account configuration from {config_path}: {e}")
690
-
690
+
691
691
  # Fall back to Organizations API discovery
692
692
  try:
693
693
  print_info("Discovering accounts via AWS Organizations API...")
@@ -18,7 +18,7 @@ from .compliance_config import (
18
18
 
19
19
  __all__ = [
20
20
  "ComplianceConfiguration",
21
- "UniversalComplianceConfig",
21
+ "UniversalComplianceConfig",
22
22
  "get_universal_compliance_config",
23
23
  "reset_compliance_config",
24
- ]
24
+ ]
@@ -3,13 +3,13 @@
3
3
  Universal Compliance Configuration Management
4
4
  ============================================
5
5
 
6
- This module provides enterprise-grade compliance configuration management
7
- that eliminates hardcoded values and supports dynamic configuration across
6
+ This module provides enterprise-grade compliance configuration management
7
+ that eliminates hardcoded values and supports dynamic configuration across
8
8
  all compliance frameworks.
9
9
 
10
10
  Features:
11
11
  - Environment variable configuration
12
- - Configuration file support
12
+ - Configuration file support
13
13
  - Framework-specific defaults
14
14
  - Universal profile compatibility
15
15
  - No hardcoded compliance weights or thresholds
@@ -29,7 +29,7 @@ from runbooks.common.rich_utils import console
29
29
  @dataclass
30
30
  class ComplianceConfiguration:
31
31
  """Universal compliance configuration container."""
32
-
32
+
33
33
  control_weights: Dict[str, float] = field(default_factory=dict)
34
34
  framework_thresholds: Dict[str, float] = field(default_factory=dict)
35
35
  assessment_frequencies: Dict[str, str] = field(default_factory=dict)
@@ -39,48 +39,48 @@ class ComplianceConfiguration:
39
39
  class UniversalComplianceConfig:
40
40
  """
41
41
  Universal compliance configuration manager that works with ANY AWS setup.
42
-
42
+
43
43
  Configuration Priority Order:
44
44
  1. Environment variables (highest priority)
45
45
  2. Configuration file (COMPLIANCE_CONFIG_PATH)
46
46
  3. Framework defaults (fallback)
47
-
47
+
48
48
  No hardcoded values - fully configurable for any enterprise environment.
49
49
  """
50
-
50
+
51
51
  def __init__(self, config_path: Optional[str] = None):
52
52
  """Initialize universal compliance configuration."""
53
53
  self.config_path = config_path or os.getenv("COMPLIANCE_CONFIG_PATH")
54
54
  self.config = self._load_configuration()
55
-
55
+
56
56
  def _load_configuration(self) -> ComplianceConfiguration:
57
57
  """Load compliance configuration from all sources."""
58
58
  config = ComplianceConfiguration()
59
-
59
+
60
60
  # Load from configuration file if available
61
61
  if self.config_path and os.path.exists(self.config_path):
62
62
  try:
63
- with open(self.config_path, 'r') as f:
63
+ with open(self.config_path, "r") as f:
64
64
  file_config = json.load(f)
65
-
65
+
66
66
  config.control_weights.update(file_config.get("control_weights", {}))
67
67
  config.framework_thresholds.update(file_config.get("framework_thresholds", {}))
68
68
  config.assessment_frequencies.update(file_config.get("assessment_frequencies", {}))
69
69
  config.remediation_priorities.update(file_config.get("remediation_priorities", {}))
70
-
70
+
71
71
  console.log(f"[green]Loaded compliance configuration from: {self.config_path}[/]")
72
-
72
+
73
73
  except Exception as e:
74
74
  console.log(f"[yellow]Warning: Failed to load compliance config from {self.config_path}: {e}[/]")
75
-
75
+
76
76
  # Override with environment variables (highest priority)
77
77
  self._load_environment_overrides(config)
78
-
78
+
79
79
  return config
80
-
80
+
81
81
  def _load_environment_overrides(self, config: ComplianceConfiguration) -> None:
82
82
  """Load configuration overrides from environment variables."""
83
-
83
+
84
84
  # Load control weights from environment
85
85
  for env_var in os.environ:
86
86
  if env_var.startswith("COMPLIANCE_WEIGHT_"):
@@ -91,7 +91,7 @@ class UniversalComplianceConfig:
91
91
  console.log(f"[dim cyan]Environment override: {control_id} weight = {weight}[/]")
92
92
  except ValueError:
93
93
  console.log(f"[yellow]Warning: Invalid weight in {env_var}: {os.environ[env_var]}[/]")
94
-
94
+
95
95
  # Load framework thresholds from environment
96
96
  for env_var in os.environ:
97
97
  if env_var.startswith("COMPLIANCE_THRESHOLD_"):
@@ -102,89 +102,89 @@ class UniversalComplianceConfig:
102
102
  console.log(f"[dim cyan]Environment override: {framework} threshold = {threshold}[/]")
103
103
  except ValueError:
104
104
  console.log(f"[yellow]Warning: Invalid threshold in {env_var}: {os.environ[env_var]}[/]")
105
-
105
+
106
106
  def get_control_weight(self, control_id: str, framework_default: float = 1.0) -> float:
107
107
  """
108
108
  Get compliance weight for control with universal fallback.
109
-
109
+
110
110
  Args:
111
111
  control_id: Control identifier (e.g., "SEC-1", "CC6.1")
112
112
  framework_default: Framework-specific default weight
113
-
113
+
114
114
  Returns:
115
115
  float: Compliance weight for the control
116
116
  """
117
117
  # Normalize control ID for lookup
118
118
  normalized_id = control_id.lower().replace(".", "-")
119
-
119
+
120
120
  # Check configuration sources in priority order
121
121
  if normalized_id in self.config.control_weights:
122
122
  return self.config.control_weights[normalized_id]
123
-
123
+
124
124
  # Use framework default
125
125
  return framework_default
126
-
126
+
127
127
  def get_framework_threshold(self, framework: str, default_threshold: float = 90.0) -> float:
128
128
  """
129
129
  Get compliance threshold for framework with universal fallback.
130
-
130
+
131
131
  Args:
132
132
  framework: Framework identifier (e.g., "aws-well-architected", "soc2-type-ii")
133
133
  default_threshold: Default threshold if not configured
134
-
134
+
135
135
  Returns:
136
136
  float: Compliance threshold for the framework
137
137
  """
138
138
  # Normalize framework name for lookup
139
139
  normalized_framework = framework.lower().replace("_", "-")
140
-
140
+
141
141
  # Check configuration sources in priority order
142
142
  if normalized_framework in self.config.framework_thresholds:
143
143
  return self.config.framework_thresholds[normalized_framework]
144
-
144
+
145
145
  # Use default threshold
146
146
  return default_threshold
147
-
147
+
148
148
  def get_assessment_frequency(self, control_id: str, default_frequency: str = "monthly") -> str:
149
149
  """
150
150
  Get assessment frequency for control with universal fallback.
151
-
151
+
152
152
  Args:
153
153
  control_id: Control identifier
154
154
  default_frequency: Default frequency if not configured
155
-
155
+
156
156
  Returns:
157
157
  str: Assessment frequency for the control
158
158
  """
159
159
  normalized_id = control_id.lower().replace(".", "-")
160
-
160
+
161
161
  if normalized_id in self.config.assessment_frequencies:
162
162
  return self.config.assessment_frequencies[normalized_id]
163
-
163
+
164
164
  return default_frequency
165
-
165
+
166
166
  def get_remediation_priority(self, control_id: str, default_priority: int = 3) -> int:
167
167
  """
168
168
  Get remediation priority for control with universal fallback.
169
-
169
+
170
170
  Args:
171
171
  control_id: Control identifier
172
172
  default_priority: Default priority if not configured (1=highest, 5=lowest)
173
-
173
+
174
174
  Returns:
175
175
  int: Remediation priority for the control
176
176
  """
177
177
  normalized_id = control_id.lower().replace(".", "-")
178
-
178
+
179
179
  if normalized_id in self.config.remediation_priorities:
180
180
  return self.config.remediation_priorities[normalized_id]
181
-
181
+
182
182
  return default_priority
183
-
183
+
184
184
  def export_configuration_template(self, output_path: str) -> None:
185
185
  """
186
186
  Export a configuration template for enterprise customization.
187
-
187
+
188
188
  Args:
189
189
  output_path: Path to save the configuration template
190
190
  """
@@ -195,7 +195,7 @@ class UniversalComplianceConfig:
195
195
  "cc6-1": 3.0,
196
196
  "cc6-2": 2.5,
197
197
  "pci-1": 2.0,
198
- "hipaa-164-312-a-1": 2.5
198
+ "hipaa-164-312-a-1": 2.5,
199
199
  },
200
200
  "framework_thresholds": {
201
201
  "aws-well-architected": 90.0,
@@ -204,24 +204,24 @@ class UniversalComplianceConfig:
204
204
  "hipaa": 95.0,
205
205
  "nist-cybersecurity": 90.0,
206
206
  "iso-27001": 85.0,
207
- "cis-benchmarks": 88.0
207
+ "cis-benchmarks": 88.0,
208
208
  },
209
209
  "assessment_frequencies": {
210
210
  "critical-controls": "weekly",
211
- "high-controls": "monthly",
211
+ "high-controls": "monthly",
212
212
  "medium-controls": "quarterly",
213
- "low-controls": "annually"
213
+ "low-controls": "annually",
214
214
  },
215
215
  "remediation_priorities": {
216
216
  "critical-controls": 1,
217
217
  "high-controls": 2,
218
218
  "medium-controls": 3,
219
- "low-controls": 4
220
- }
219
+ "low-controls": 4,
220
+ },
221
221
  }
222
-
222
+
223
223
  try:
224
- with open(output_path, 'w') as f:
224
+ with open(output_path, "w") as f:
225
225
  json.dump(template, f, indent=2)
226
226
  console.log(f"[green]Configuration template exported to: {output_path}[/]")
227
227
  except Exception as e:
@@ -249,7 +249,7 @@ def reset_compliance_config() -> None:
249
249
  # Export public interface
250
250
  __all__ = [
251
251
  "ComplianceConfiguration",
252
- "UniversalComplianceConfig",
252
+ "UniversalComplianceConfig",
253
253
  "get_universal_compliance_config",
254
254
  "reset_compliance_config",
255
- ]
255
+ ]
@@ -3,12 +3,12 @@
3
3
  Configuration Template Generator for Security and Remediation Modules
4
4
  ====================================================================
5
5
 
6
- This utility generates configuration templates for enterprise security and
6
+ This utility generates configuration templates for enterprise security and
7
7
  remediation operations, eliminating the need for hardcoded values.
8
8
 
9
9
  Features:
10
10
  - Compliance weight configuration templates
11
- - Account discovery configuration templates
11
+ - Account discovery configuration templates
12
12
  - Framework threshold configuration templates
13
13
  - Environment variable examples
14
14
  - Complete setup documentation
@@ -29,91 +29,79 @@ from runbooks.common.rich_utils import console, create_panel, print_info, print_
29
29
 
30
30
  class SecurityConfigTemplateGenerator:
31
31
  """Generate configuration templates for security and remediation modules."""
32
-
32
+
33
33
  def __init__(self, output_dir: str = "./artifacts/security/config"):
34
34
  """Initialize template generator."""
35
35
  self.output_dir = Path(output_dir)
36
36
  self.output_dir.mkdir(parents=True, exist_ok=True)
37
-
37
+
38
38
  def generate_compliance_config_template(self) -> Dict:
39
39
  """Generate compliance configuration template."""
40
40
  return {
41
41
  "_description": "Universal Compliance Configuration Template",
42
42
  "_usage": "Set COMPLIANCE_CONFIG_PATH environment variable to point to this file",
43
-
44
43
  "control_weights": {
45
44
  "_description": "Control weights for compliance scoring (1.0 = normal, 2.0 = double weight)",
46
-
47
45
  "aws_well_architected": {
48
46
  "sec-1": 2.0, # Identity Foundation
49
47
  "sec-2": 1.5, # Security at All Layers
50
48
  "sec-3": 2.5, # Data Protection
51
49
  "sec-4": 1.8, # Incident Response
52
- "sec-5": 1.2 # Network Security
50
+ "sec-5": 1.2, # Network Security
53
51
  },
54
-
55
52
  "soc2_type_ii": {
56
53
  "cc6-1": 3.0, # Access Controls (Critical)
57
54
  "cc6-2": 2.5, # Authentication
58
55
  "cc6-3": 2.0, # Authorization
59
56
  "cc7-1": 2.2, # System Operations
60
- "cc8-1": 1.8 # Change Management
57
+ "cc8-1": 1.8, # Change Management
61
58
  },
62
-
63
59
  "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
60
+ "pci-1": 2.0, # Network Security
61
+ "pci-2": 2.5, # System Security
62
+ "pci-3": 3.0, # Data Protection (Critical)
63
+ "pci-4": 2.0, # Transmission Security
64
+ "pci-6": 1.5, # Secure Systems
69
65
  },
70
-
71
66
  "hipaa": {
72
67
  "hipaa-164-312-a-1": 2.5, # Access Control
73
68
  "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
- }
69
+ "hipaa-164-312-b": 3.0, # Audit Controls (Critical)
70
+ "hipaa-164-312-c": 2.8, # Integrity
71
+ "hipaa-164-312-d": 1.5, # Person Authentication
72
+ },
78
73
  },
79
-
80
74
  "framework_thresholds": {
81
75
  "_description": "Minimum compliance scores required for each framework (percentage)",
82
-
83
76
  "aws-well-architected": 90.0,
84
77
  "soc2-type-ii": 95.0,
85
- "pci-dss": 100.0, # PCI DSS requires perfect compliance
78
+ "pci-dss": 100.0, # PCI DSS requires perfect compliance
86
79
  "hipaa": 95.0,
87
80
  "nist-cybersecurity": 90.0,
88
81
  "iso-27001": 90.0,
89
- "cis-benchmarks": 88.0
82
+ "cis-benchmarks": 88.0,
90
83
  },
91
-
92
84
  "assessment_frequencies": {
93
85
  "_description": "How often to assess each control type",
94
-
95
86
  "critical-controls": "weekly",
96
87
  "high-controls": "monthly",
97
- "medium-controls": "quarterly",
98
- "low-controls": "annually"
88
+ "medium-controls": "quarterly",
89
+ "low-controls": "annually",
99
90
  },
100
-
101
91
  "remediation_priorities": {
102
92
  "_description": "Remediation priority levels (1=highest, 5=lowest)",
103
-
104
93
  "critical-controls": 1,
105
94
  "high-controls": 2,
106
95
  "medium-controls": 3,
107
- "low-controls": 4
108
- }
96
+ "low-controls": 4,
97
+ },
109
98
  }
110
-
99
+
111
100
  def generate_account_config_template(self) -> Dict:
112
101
  """Generate account discovery configuration template."""
113
102
  return {
114
103
  "_description": "Universal Account Discovery Configuration Template",
115
104
  "_usage": "Set REMEDIATION_ACCOUNT_CONFIG environment variable to point to this file",
116
-
117
105
  "target_accounts": [
118
106
  {
119
107
  "account_id": "111122223333",
@@ -122,43 +110,41 @@ class SecurityConfigTemplateGenerator:
122
110
  "email": "prod@company.com",
123
111
  "profile_name": "prod-profile",
124
112
  "environment": "production",
125
- "criticality": "high"
113
+ "criticality": "high",
126
114
  },
127
115
  {
128
116
  "account_id": "444455556666",
129
- "account_name": "Staging Environment",
117
+ "account_name": "Staging Environment",
130
118
  "status": "ACTIVE",
131
119
  "email": "staging@company.com",
132
120
  "profile_name": "staging-profile",
133
121
  "environment": "staging",
134
- "criticality": "medium"
122
+ "criticality": "medium",
135
123
  },
136
124
  {
137
125
  "account_id": "777788889999",
138
126
  "account_name": "Development Environment",
139
- "status": "ACTIVE",
127
+ "status": "ACTIVE",
140
128
  "email": "dev@company.com",
141
129
  "profile_name": "dev-profile",
142
130
  "environment": "development",
143
- "criticality": "low"
144
- }
131
+ "criticality": "low",
132
+ },
145
133
  ],
146
-
147
134
  "discovery_settings": {
148
135
  "max_concurrent_accounts": 10,
149
136
  "validation_timeout_seconds": 30,
150
137
  "include_suspended_accounts": False,
151
138
  "auto_discover_via_organizations": True,
152
- "fallback_to_current_account": True
139
+ "fallback_to_current_account": True,
153
140
  },
154
-
155
141
  "filtering_rules": {
156
142
  "include_patterns": ["prod-*", "staging-*"],
157
143
  "exclude_patterns": ["test-*", "sandbox-*"],
158
- "max_accounts": 50
159
- }
144
+ "max_accounts": 50,
145
+ },
160
146
  }
161
-
147
+
162
148
  def generate_environment_variables_template(self) -> str:
163
149
  """Generate environment variables template."""
164
150
  return """# Universal Security and Remediation Configuration
@@ -221,7 +207,7 @@ export COMPLIANCE_CACHE_TTL="3600"
221
207
  # Export compliance configuration template
222
208
  # runbooks security export-config-template --output-dir ./config
223
209
  """
224
-
210
+
225
211
  def generate_setup_documentation(self) -> str:
226
212
  """Generate complete setup documentation."""
227
213
  return """# Universal Security and Remediation Module Setup Guide
@@ -426,7 +412,7 @@ runbooks security export-metrics --output ./metrics/
426
412
 
427
413
  This configuration system eliminates ALL hardcoded values and provides universal compatibility with any AWS environment.
428
414
  """
429
-
415
+
430
416
  def generate_all_templates(self) -> None:
431
417
  """Generate all configuration templates."""
432
418
  console.print(
@@ -437,58 +423,59 @@ This configuration system eliminates ALL hardcoded values and provides universal
437
423
  border_style="cyan",
438
424
  )
439
425
  )
440
-
426
+
441
427
  # Generate compliance configuration
442
428
  compliance_config = self.generate_compliance_config_template()
443
429
  compliance_path = self.output_dir / "compliance_config.json"
444
- with open(compliance_path, 'w') as f:
430
+ with open(compliance_path, "w") as f:
445
431
  json.dump(compliance_config, f, indent=2)
446
432
  print_success(f"Generated compliance configuration: {compliance_path}")
447
-
433
+
448
434
  # Generate account configuration
449
435
  account_config = self.generate_account_config_template()
450
436
  account_path = self.output_dir / "account_config.json"
451
- with open(account_path, 'w') as f:
437
+ with open(account_path, "w") as f:
452
438
  json.dump(account_config, f, indent=2)
453
439
  print_success(f"Generated account configuration: {account_path}")
454
-
440
+
455
441
  # Generate environment variables template
456
442
  env_template = self.generate_environment_variables_template()
457
443
  env_path = self.output_dir / "environment_variables.sh"
458
- with open(env_path, 'w') as f:
444
+ with open(env_path, "w") as f:
459
445
  f.write(env_template)
460
446
  print_success(f"Generated environment variables template: {env_path}")
461
-
447
+
462
448
  # Generate setup documentation
463
449
  setup_docs = self.generate_setup_documentation()
464
450
  docs_path = self.output_dir / "SETUP_GUIDE.md"
465
- with open(docs_path, 'w') as f:
451
+ with open(docs_path, "w") as f:
466
452
  f.write(setup_docs)
467
453
  print_success(f"Generated setup documentation: {docs_path}")
468
-
454
+
469
455
  # 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
- ))
456
+ console.print(
457
+ "\n"
458
+ + create_panel(
459
+ f"[bold green]Configuration templates generated successfully![/bold green]\n\n"
460
+ f"[cyan]Files created in {self.output_dir}:[/cyan]\n"
461
+ f"• compliance_config.json - Compliance weights and thresholds\n"
462
+ f"• account_config.json - Account discovery configuration\n"
463
+ f" environment_variables.sh - Environment variable examples\n"
464
+ f"• SETUP_GUIDE.md - Complete setup documentation\n\n"
465
+ f"[yellow]Next steps:[/yellow]\n"
466
+ f"1. Review and customize the configuration files\n"
467
+ f"2. Set environment variables or use config files\n"
468
+ f"3. Run: runbooks security assess --help\n"
469
+ f"4. Run: runbooks remediation --help",
470
+ title="✅ Templates Ready",
471
+ border_style="green",
472
+ )
473
+ )
485
474
 
486
475
 
487
476
  @click.command()
488
477
  @click.option(
489
- "--output-dir",
490
- default="./artifacts/security/config",
491
- help="Output directory for configuration templates"
478
+ "--output-dir", default="./artifacts/security/config", help="Output directory for configuration templates"
492
479
  )
493
480
  def generate_config_templates(output_dir: str):
494
481
  """Generate universal configuration templates for security and remediation modules."""
@@ -497,4 +484,4 @@ def generate_config_templates(output_dir: str):
497
484
 
498
485
 
499
486
  if __name__ == "__main__":
500
- generate_config_templates()
487
+ generate_config_templates()