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.
Files changed (77) hide show
  1. runbooks/__init__.py +1 -1
  2. runbooks/cfat/WEIGHT_CONFIG_README.md +368 -0
  3. runbooks/cfat/app.ts +27 -19
  4. runbooks/cfat/assessment/runner.py +6 -5
  5. runbooks/cfat/tests/test_weight_configuration.ts +449 -0
  6. runbooks/cfat/weight_config.ts +574 -0
  7. runbooks/common/__init__.py +26 -9
  8. runbooks/common/aws_pricing.py +1070 -105
  9. runbooks/common/date_utils.py +115 -0
  10. runbooks/common/enhanced_exception_handler.py +10 -7
  11. runbooks/common/mcp_cost_explorer_integration.py +5 -4
  12. runbooks/common/profile_utils.py +76 -115
  13. runbooks/common/rich_utils.py +3 -3
  14. runbooks/finops/dashboard_runner.py +47 -28
  15. runbooks/finops/ebs_optimizer.py +56 -9
  16. runbooks/finops/enhanced_trend_visualization.py +7 -2
  17. runbooks/finops/finops_dashboard.py +6 -5
  18. runbooks/finops/iam_guidance.py +6 -1
  19. runbooks/finops/nat_gateway_optimizer.py +46 -27
  20. runbooks/finops/tests/test_integration.py +3 -1
  21. runbooks/finops/vpc_cleanup_optimizer.py +22 -29
  22. runbooks/inventory/core/collector.py +51 -28
  23. runbooks/inventory/discovery.md +197 -247
  24. runbooks/inventory/inventory_modules.py +2 -2
  25. runbooks/inventory/list_ec2_instances.py +3 -3
  26. runbooks/inventory/organizations_discovery.py +13 -8
  27. runbooks/inventory/unified_validation_engine.py +2 -15
  28. runbooks/main.py +74 -32
  29. runbooks/operate/base.py +9 -6
  30. runbooks/operate/deployment_framework.py +5 -4
  31. runbooks/operate/deployment_validator.py +6 -5
  32. runbooks/operate/mcp_integration.py +6 -5
  33. runbooks/operate/networking_cost_heatmap.py +17 -13
  34. runbooks/operate/vpc_operations.py +52 -12
  35. runbooks/remediation/base.py +3 -1
  36. runbooks/remediation/commons.py +5 -5
  37. runbooks/remediation/commvault_ec2_analysis.py +66 -18
  38. runbooks/remediation/config/accounts_example.json +31 -0
  39. runbooks/remediation/multi_account.py +120 -7
  40. runbooks/remediation/remediation_cli.py +710 -0
  41. runbooks/remediation/universal_account_discovery.py +377 -0
  42. runbooks/security/compliance_automation_engine.py +99 -20
  43. runbooks/security/config/__init__.py +24 -0
  44. runbooks/security/config/compliance_config.py +255 -0
  45. runbooks/security/config/compliance_weights_example.json +22 -0
  46. runbooks/security/config_template_generator.py +500 -0
  47. runbooks/security/security_cli.py +377 -0
  48. runbooks/validation/cli.py +8 -7
  49. runbooks/validation/comprehensive_2way_validator.py +26 -15
  50. runbooks/validation/mcp_validator.py +62 -8
  51. runbooks/vpc/config.py +32 -7
  52. runbooks/vpc/cross_account_session.py +5 -1
  53. runbooks/vpc/heatmap_engine.py +21 -14
  54. runbooks/vpc/mcp_no_eni_validator.py +115 -36
  55. runbooks/vpc/runbooks_adapter.py +33 -12
  56. runbooks/vpc/tests/conftest.py +4 -2
  57. runbooks/vpc/tests/test_cost_engine.py +3 -1
  58. {runbooks-1.0.0.dist-info → runbooks-1.0.1.dist-info}/METADATA +1 -1
  59. {runbooks-1.0.0.dist-info → runbooks-1.0.1.dist-info}/RECORD +63 -65
  60. runbooks/finops/runbooks.inventory.organizations_discovery.log +0 -0
  61. runbooks/finops/runbooks.security.report_generator.log +0 -0
  62. runbooks/finops/runbooks.security.run_script.log +0 -0
  63. runbooks/finops/runbooks.security.security_export.log +0 -0
  64. runbooks/finops/tests/results_test_finops_dashboard.xml +0 -1
  65. runbooks/inventory/artifacts/scale-optimize-status.txt +0 -12
  66. runbooks/inventory/runbooks.inventory.organizations_discovery.log +0 -0
  67. runbooks/inventory/runbooks.security.report_generator.log +0 -0
  68. runbooks/inventory/runbooks.security.run_script.log +0 -0
  69. runbooks/inventory/runbooks.security.security_export.log +0 -0
  70. runbooks/vpc/runbooks.inventory.organizations_discovery.log +0 -0
  71. runbooks/vpc/runbooks.security.report_generator.log +0 -0
  72. runbooks/vpc/runbooks.security.run_script.log +0 -0
  73. runbooks/vpc/runbooks.security.security_export.log +0 -0
  74. {runbooks-1.0.0.dist-info → runbooks-1.0.1.dist-info}/WHEEL +0 -0
  75. {runbooks-1.0.0.dist-info → runbooks-1.0.1.dist-info}/entry_points.txt +0 -0
  76. {runbooks-1.0.0.dist-info → runbooks-1.0.1.dist-info}/licenses/LICENSE +0 -0
  77. {runbooks-1.0.0.dist-info → runbooks-1.0.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,574 @@
1
+ /**
2
+ * Dynamic Weight Configuration System for CFAT Assessment
3
+ *
4
+ * Replaces 30+ hardcoded weight values with flexible, environment-aware
5
+ * configuration system supporting multiple compliance frameworks.
6
+ *
7
+ * Enterprise Features:
8
+ * - Framework-specific weight profiles (AWS Well-Architected, SOC2, etc.)
9
+ * - Environment-based weight adjustments (dev, staging, prod)
10
+ * - Dynamic weight calculation based on organization size
11
+ * - Override capabilities for specific requirements
12
+ */
13
+
14
+ export interface WeightConfig {
15
+ // Core organizational checks
16
+ organization_created: number;
17
+ management_account_created: number;
18
+
19
+ // Identity and access management
20
+ iam_users_removed: number;
21
+ iam_idc_org_service_enabled: number;
22
+ iam_idc_configured: number;
23
+
24
+ // Resource management (Security best practices)
25
+ ec2_instances_removed: number;
26
+ vpc_removed: number;
27
+
28
+ // Logging and monitoring (Critical for compliance)
29
+ cloudtrail_created: number;
30
+ cloudtrail_org_service_enabled: number;
31
+ cloudtrail_org_trail_deployed: number;
32
+ config_recorder_management: number;
33
+ config_delivery_channel_management: number;
34
+
35
+ // Service integrations (Operational excellence)
36
+ cloudformation_stacksets_activated: number;
37
+ cloudformation_org_service_enabled: number;
38
+ guardduty_org_service_enabled: number;
39
+ ram_org_service_enabled: number;
40
+ securityhub_org_service_enabled: number;
41
+ iam_access_analyzer_org_service_enabled: number;
42
+ config_org_service_enabled: number;
43
+ backup_org_service_enabled: number;
44
+
45
+ // Organizational structure
46
+ infrastructure_ou_deployed: number;
47
+ security_ou_deployed: number;
48
+ workloads_ou_deployed: number;
49
+
50
+ // Governance and policies
51
+ scp_enabled: number;
52
+ tag_policy_enabled: number;
53
+ backup_policy_enabled: number;
54
+
55
+ // Control Tower (Landing Zone foundation)
56
+ control_tower_deployed: number;
57
+ control_tower_latest_version: number;
58
+ control_tower_not_drifted: number;
59
+
60
+ // Core accounts
61
+ log_archive_account_deployed: number;
62
+ audit_account_deployed: number;
63
+
64
+ // Legacy compliance
65
+ legacy_cur_setup: number;
66
+ }
67
+
68
+ export enum ComplianceFramework {
69
+ AWS_WELL_ARCHITECTED = 'aws-well-architected',
70
+ SOC2 = 'soc2',
71
+ PCI_DSS = 'pci-dss',
72
+ HIPAA = 'hipaa',
73
+ NIST = 'nist',
74
+ ISO_27001 = 'iso-27001',
75
+ CIS_BENCHMARKS = 'cis',
76
+ CUSTOM = 'custom'
77
+ }
78
+
79
+ export enum EnvironmentType {
80
+ DEVELOPMENT = 'development',
81
+ STAGING = 'staging',
82
+ PRODUCTION = 'production',
83
+ SANDBOX = 'sandbox'
84
+ }
85
+
86
+ export enum OrganizationSize {
87
+ SMALL = 'small', // < 10 accounts
88
+ MEDIUM = 'medium', // 10-100 accounts
89
+ LARGE = 'large', // 100-1000 accounts
90
+ ENTERPRISE = 'enterprise' // > 1000 accounts
91
+ }
92
+
93
+ /**
94
+ * Default weight configurations for different compliance frameworks
95
+ */
96
+ export const FRAMEWORK_WEIGHTS: Record<ComplianceFramework, WeightConfig> = {
97
+ [ComplianceFramework.AWS_WELL_ARCHITECTED]: {
98
+ // Foundational requirements (Critical - Weight 6)
99
+ organization_created: 6,
100
+ management_account_created: 6,
101
+ cloudtrail_created: 6,
102
+ cloudtrail_org_service_enabled: 6,
103
+ cloudtrail_org_trail_deployed: 6,
104
+ config_recorder_management: 6,
105
+ config_delivery_channel_management: 6,
106
+ iam_idc_org_service_enabled: 6,
107
+ iam_idc_configured: 6,
108
+ scp_enabled: 6,
109
+ tag_policy_enabled: 6,
110
+ control_tower_deployed: 6,
111
+ control_tower_not_drifted: 6,
112
+ security_ou_deployed: 6,
113
+ log_archive_account_deployed: 6,
114
+ audit_account_deployed: 6,
115
+
116
+ // Important but not critical (Weight 5)
117
+ cloudformation_stacksets_activated: 5,
118
+ cloudformation_org_service_enabled: 5,
119
+ infrastructure_ou_deployed: 5,
120
+ workloads_ou_deployed: 5,
121
+ backup_policy_enabled: 5,
122
+ control_tower_latest_version: 5,
123
+
124
+ // Best practices (Weight 4)
125
+ iam_users_removed: 4,
126
+ ec2_instances_removed: 4,
127
+ vpc_removed: 4,
128
+ legacy_cur_setup: 4,
129
+ guardduty_org_service_enabled: 4,
130
+ ram_org_service_enabled: 4,
131
+ securityhub_org_service_enabled: 4,
132
+ iam_access_analyzer_org_service_enabled: 4,
133
+ config_org_service_enabled: 4,
134
+ backup_org_service_enabled: 4
135
+ },
136
+
137
+ [ComplianceFramework.SOC2]: {
138
+ // SOC2 emphasizes security and availability (Higher security weights)
139
+ organization_created: 6,
140
+ management_account_created: 6,
141
+ cloudtrail_created: 6,
142
+ cloudtrail_org_service_enabled: 6,
143
+ cloudtrail_org_trail_deployed: 6,
144
+ config_recorder_management: 6,
145
+ config_delivery_channel_management: 6,
146
+ iam_idc_org_service_enabled: 6,
147
+ iam_idc_configured: 6,
148
+ scp_enabled: 6,
149
+ tag_policy_enabled: 5,
150
+ control_tower_deployed: 6,
151
+ control_tower_not_drifted: 6,
152
+ security_ou_deployed: 6,
153
+ log_archive_account_deployed: 6,
154
+ audit_account_deployed: 6,
155
+ securityhub_org_service_enabled: 6, // Higher weight for SOC2
156
+ iam_access_analyzer_org_service_enabled: 6, // Higher weight for SOC2
157
+
158
+ // Enhanced security monitoring
159
+ cloudformation_stacksets_activated: 5,
160
+ cloudformation_org_service_enabled: 5,
161
+ infrastructure_ou_deployed: 5,
162
+ workloads_ou_deployed: 5,
163
+ backup_policy_enabled: 6, // Higher for data protection
164
+ control_tower_latest_version: 5,
165
+ guardduty_org_service_enabled: 6, // Higher for threat detection
166
+
167
+ // Management account hygiene (Important for SOC2)
168
+ iam_users_removed: 5, // Higher weight for SOC2
169
+ ec2_instances_removed: 5, // Higher weight for SOC2
170
+ vpc_removed: 5, // Higher weight for SOC2
171
+ legacy_cur_setup: 4,
172
+ ram_org_service_enabled: 4,
173
+ config_org_service_enabled: 5,
174
+ backup_org_service_enabled: 6
175
+ },
176
+
177
+ [ComplianceFramework.PCI_DSS]: {
178
+ // PCI-DSS focuses on data protection and network security
179
+ organization_created: 6,
180
+ management_account_created: 6,
181
+ cloudtrail_created: 6,
182
+ cloudtrail_org_service_enabled: 6,
183
+ cloudtrail_org_trail_deployed: 6,
184
+ config_recorder_management: 6,
185
+ config_delivery_channel_management: 6,
186
+ iam_idc_org_service_enabled: 6,
187
+ iam_idc_configured: 6,
188
+ scp_enabled: 6,
189
+ tag_policy_enabled: 6,
190
+ control_tower_deployed: 6,
191
+ control_tower_not_drifted: 6,
192
+ security_ou_deployed: 6,
193
+ log_archive_account_deployed: 6,
194
+ audit_account_deployed: 6,
195
+
196
+ // Enhanced for PCI-DSS network and data requirements
197
+ securityhub_org_service_enabled: 6,
198
+ iam_access_analyzer_org_service_enabled: 6,
199
+ guardduty_org_service_enabled: 6,
200
+ backup_policy_enabled: 6,
201
+ backup_org_service_enabled: 6,
202
+
203
+ // Network isolation requirements
204
+ iam_users_removed: 6, // Critical for PCI-DSS
205
+ ec2_instances_removed: 6, // Critical for network isolation
206
+ vpc_removed: 6, // Critical for network isolation
207
+
208
+ cloudformation_stacksets_activated: 5,
209
+ cloudformation_org_service_enabled: 5,
210
+ infrastructure_ou_deployed: 5,
211
+ workloads_ou_deployed: 5,
212
+ control_tower_latest_version: 5,
213
+ legacy_cur_setup: 4,
214
+ ram_org_service_enabled: 4,
215
+ config_org_service_enabled: 5
216
+ },
217
+
218
+ [ComplianceFramework.HIPAA]: {
219
+ // HIPAA emphasizes data protection and audit trails
220
+ organization_created: 6,
221
+ management_account_created: 6,
222
+ cloudtrail_created: 6,
223
+ cloudtrail_org_service_enabled: 6,
224
+ cloudtrail_org_trail_deployed: 6,
225
+ config_recorder_management: 6,
226
+ config_delivery_channel_management: 6,
227
+ iam_idc_org_service_enabled: 6,
228
+ iam_idc_configured: 6,
229
+ scp_enabled: 6,
230
+ tag_policy_enabled: 6,
231
+ control_tower_deployed: 6,
232
+ control_tower_not_drifted: 6,
233
+ security_ou_deployed: 6,
234
+ log_archive_account_deployed: 6,
235
+ audit_account_deployed: 6,
236
+
237
+ // Data protection and monitoring
238
+ securityhub_org_service_enabled: 6,
239
+ iam_access_analyzer_org_service_enabled: 6,
240
+ backup_policy_enabled: 6,
241
+ backup_org_service_enabled: 6,
242
+ config_org_service_enabled: 6,
243
+
244
+ // Audit and compliance
245
+ cloudformation_stacksets_activated: 5,
246
+ cloudformation_org_service_enabled: 5,
247
+ infrastructure_ou_deployed: 5,
248
+ workloads_ou_deployed: 5,
249
+ control_tower_latest_version: 5,
250
+ guardduty_org_service_enabled: 5,
251
+
252
+ // Access controls
253
+ iam_users_removed: 5,
254
+ ec2_instances_removed: 4,
255
+ vpc_removed: 4,
256
+ legacy_cur_setup: 4,
257
+ ram_org_service_enabled: 4
258
+ },
259
+
260
+ [ComplianceFramework.NIST]: {
261
+ // NIST Cybersecurity Framework alignment
262
+ organization_created: 6,
263
+ management_account_created: 6,
264
+ cloudtrail_created: 6,
265
+ cloudtrail_org_service_enabled: 6,
266
+ cloudtrail_org_trail_deployed: 6,
267
+ config_recorder_management: 6,
268
+ config_delivery_channel_management: 6,
269
+ iam_idc_org_service_enabled: 6,
270
+ iam_idc_configured: 6,
271
+ scp_enabled: 6,
272
+ tag_policy_enabled: 5,
273
+ control_tower_deployed: 6,
274
+ control_tower_not_drifted: 6,
275
+ security_ou_deployed: 6,
276
+ log_archive_account_deployed: 6,
277
+ audit_account_deployed: 6,
278
+
279
+ // Identify, Protect, Detect framework
280
+ securityhub_org_service_enabled: 6,
281
+ iam_access_analyzer_org_service_enabled: 6,
282
+ guardduty_org_service_enabled: 6,
283
+ backup_policy_enabled: 5,
284
+ backup_org_service_enabled: 5,
285
+
286
+ cloudformation_stacksets_activated: 5,
287
+ cloudformation_org_service_enabled: 5,
288
+ infrastructure_ou_deployed: 5,
289
+ workloads_ou_deployed: 5,
290
+ control_tower_latest_version: 5,
291
+ config_org_service_enabled: 5,
292
+
293
+ iam_users_removed: 4,
294
+ ec2_instances_removed: 4,
295
+ vpc_removed: 4,
296
+ legacy_cur_setup: 4,
297
+ ram_org_service_enabled: 4
298
+ },
299
+
300
+ [ComplianceFramework.ISO_27001]: {
301
+ // ISO 27001 Information Security Management
302
+ organization_created: 6,
303
+ management_account_created: 6,
304
+ cloudtrail_created: 6,
305
+ cloudtrail_org_service_enabled: 6,
306
+ cloudtrail_org_trail_deployed: 6,
307
+ config_recorder_management: 6,
308
+ config_delivery_channel_management: 6,
309
+ iam_idc_org_service_enabled: 6,
310
+ iam_idc_configured: 6,
311
+ scp_enabled: 6,
312
+ tag_policy_enabled: 6,
313
+ control_tower_deployed: 6,
314
+ control_tower_not_drifted: 6,
315
+ security_ou_deployed: 6,
316
+ log_archive_account_deployed: 6,
317
+ audit_account_deployed: 6,
318
+
319
+ // Information security controls
320
+ securityhub_org_service_enabled: 6,
321
+ iam_access_analyzer_org_service_enabled: 6,
322
+ backup_policy_enabled: 6,
323
+ backup_org_service_enabled: 6,
324
+ config_org_service_enabled: 6,
325
+ guardduty_org_service_enabled: 5,
326
+
327
+ cloudformation_stacksets_activated: 5,
328
+ cloudformation_org_service_enabled: 5,
329
+ infrastructure_ou_deployed: 5,
330
+ workloads_ou_deployed: 5,
331
+ control_tower_latest_version: 5,
332
+
333
+ iam_users_removed: 5,
334
+ ec2_instances_removed: 4,
335
+ vpc_removed: 4,
336
+ legacy_cur_setup: 4,
337
+ ram_org_service_enabled: 4
338
+ },
339
+
340
+ [ComplianceFramework.CIS_BENCHMARKS]: {
341
+ // CIS Controls alignment
342
+ organization_created: 6,
343
+ management_account_created: 6,
344
+ cloudtrail_created: 6,
345
+ cloudtrail_org_service_enabled: 6,
346
+ cloudtrail_org_trail_deployed: 6,
347
+ config_recorder_management: 6,
348
+ config_delivery_channel_management: 6,
349
+ iam_idc_org_service_enabled: 6,
350
+ iam_idc_configured: 6,
351
+ scp_enabled: 6,
352
+ tag_policy_enabled: 5,
353
+ control_tower_deployed: 6,
354
+ control_tower_not_drifted: 6,
355
+ security_ou_deployed: 6,
356
+ log_archive_account_deployed: 6,
357
+ audit_account_deployed: 6,
358
+
359
+ // CIS Controls emphasis
360
+ securityhub_org_service_enabled: 6,
361
+ iam_access_analyzer_org_service_enabled: 6,
362
+ guardduty_org_service_enabled: 6,
363
+ backup_policy_enabled: 5,
364
+ backup_org_service_enabled: 5,
365
+ config_org_service_enabled: 6,
366
+
367
+ cloudformation_stacksets_activated: 5,
368
+ cloudformation_org_service_enabled: 5,
369
+ infrastructure_ou_deployed: 5,
370
+ workloads_ou_deployed: 5,
371
+ control_tower_latest_version: 5,
372
+
373
+ // Asset and access management
374
+ iam_users_removed: 5,
375
+ ec2_instances_removed: 5,
376
+ vpc_removed: 5,
377
+ legacy_cur_setup: 4,
378
+ ram_org_service_enabled: 4
379
+ },
380
+
381
+ [ComplianceFramework.CUSTOM]: {
382
+ // Balanced default weights (original hardcoded values preserved)
383
+ organization_created: 6,
384
+ management_account_created: 6,
385
+ iam_users_removed: 4,
386
+ ec2_instances_removed: 4,
387
+ vpc_removed: 4,
388
+ legacy_cur_setup: 4,
389
+ cloudtrail_created: 6,
390
+ cloudtrail_org_service_enabled: 6,
391
+ cloudtrail_org_trail_deployed: 6,
392
+ config_recorder_management: 6,
393
+ config_delivery_channel_management: 6,
394
+ cloudformation_stacksets_activated: 5,
395
+ guardduty_org_service_enabled: 4,
396
+ ram_org_service_enabled: 4,
397
+ securityhub_org_service_enabled: 4,
398
+ iam_access_analyzer_org_service_enabled: 4,
399
+ config_org_service_enabled: 4,
400
+ cloudformation_org_service_enabled: 5,
401
+ backup_org_service_enabled: 4,
402
+ infrastructure_ou_deployed: 5,
403
+ security_ou_deployed: 6,
404
+ workloads_ou_deployed: 5,
405
+ iam_idc_org_service_enabled: 6,
406
+ iam_idc_configured: 6,
407
+ scp_enabled: 6,
408
+ tag_policy_enabled: 6,
409
+ backup_policy_enabled: 5,
410
+ control_tower_deployed: 6,
411
+ control_tower_latest_version: 5,
412
+ control_tower_not_drifted: 6,
413
+ log_archive_account_deployed: 6,
414
+ audit_account_deployed: 6
415
+ }
416
+ };
417
+
418
+ /**
419
+ * Environment-based weight modifiers
420
+ */
421
+ export const ENVIRONMENT_MODIFIERS: Record<EnvironmentType, number> = {
422
+ [EnvironmentType.DEVELOPMENT]: 0.8, // 20% reduction for dev environments
423
+ [EnvironmentType.STAGING]: 0.9, // 10% reduction for staging
424
+ [EnvironmentType.PRODUCTION]: 1.0, // Full weight for production
425
+ [EnvironmentType.SANDBOX]: 0.6 // 40% reduction for sandbox
426
+ };
427
+
428
+ /**
429
+ * Organization size-based weight adjustments
430
+ */
431
+ export const SIZE_MODIFIERS: Record<OrganizationSize, Partial<WeightConfig>> = {
432
+ [OrganizationSize.SMALL]: {
433
+ // Small orgs might not need all enterprise features
434
+ infrastructure_ou_deployed: -1,
435
+ workloads_ou_deployed: -1,
436
+ backup_policy_enabled: -1
437
+ },
438
+ [OrganizationSize.MEDIUM]: {
439
+ // Medium orgs benefit from all features
440
+ },
441
+ [OrganizationSize.LARGE]: {
442
+ // Large orgs need enhanced governance
443
+ scp_enabled: +1,
444
+ tag_policy_enabled: +1,
445
+ backup_policy_enabled: +1
446
+ },
447
+ [OrganizationSize.ENTERPRISE]: {
448
+ // Enterprise requires maximum governance
449
+ scp_enabled: +1,
450
+ tag_policy_enabled: +1,
451
+ backup_policy_enabled: +1,
452
+ control_tower_deployed: +1,
453
+ security_ou_deployed: +1
454
+ }
455
+ };
456
+
457
+ /**
458
+ * Get dynamic weight configuration based on environment context
459
+ */
460
+ export function getWeightConfig(
461
+ framework: ComplianceFramework = ComplianceFramework.AWS_WELL_ARCHITECTED,
462
+ environment: EnvironmentType = EnvironmentType.PRODUCTION,
463
+ orgSize: OrganizationSize = OrganizationSize.MEDIUM,
464
+ customOverrides: Partial<WeightConfig> = {}
465
+ ): WeightConfig {
466
+ // Start with framework-specific weights
467
+ const baseWeights = { ...FRAMEWORK_WEIGHTS[framework] };
468
+
469
+ // Apply environment modifier
470
+ const envModifier = ENVIRONMENT_MODIFIERS[environment];
471
+
472
+ // Apply size-based adjustments
473
+ const sizeAdjustments = SIZE_MODIFIERS[orgSize] || {};
474
+
475
+ // Calculate final weights
476
+ const finalWeights: WeightConfig = { ...baseWeights };
477
+
478
+ // Apply environment modifier (multiply by modifier, round to nearest integer)
479
+ Object.keys(finalWeights).forEach(key => {
480
+ const typedKey = key as keyof WeightConfig;
481
+ finalWeights[typedKey] = Math.round(baseWeights[typedKey] * envModifier);
482
+ });
483
+
484
+ // Apply size adjustments (add/subtract values)
485
+ Object.keys(sizeAdjustments).forEach(key => {
486
+ const typedKey = key as keyof WeightConfig;
487
+ if (finalWeights[typedKey] !== undefined && sizeAdjustments[typedKey] !== undefined) {
488
+ finalWeights[typedKey] = Math.max(1, finalWeights[typedKey] + sizeAdjustments[typedKey]!);
489
+ }
490
+ });
491
+
492
+ // Apply custom overrides
493
+ Object.keys(customOverrides).forEach(key => {
494
+ const typedKey = key as keyof WeightConfig;
495
+ if (customOverrides[typedKey] !== undefined) {
496
+ finalWeights[typedKey] = customOverrides[typedKey]!;
497
+ }
498
+ });
499
+
500
+ return finalWeights;
501
+ }
502
+
503
+ /**
504
+ * Validate weight configuration values
505
+ */
506
+ export function validateWeightConfig(config: WeightConfig): { valid: boolean; errors: string[] } {
507
+ const errors: string[] = [];
508
+
509
+ Object.entries(config).forEach(([key, value]) => {
510
+ if (typeof value !== 'number') {
511
+ errors.push(`Weight for ${key} must be a number, got ${typeof value}`);
512
+ } else if (value < 1 || value > 10) {
513
+ errors.push(`Weight for ${key} must be between 1 and 10, got ${value}`);
514
+ } else if (!Number.isInteger(value)) {
515
+ errors.push(`Weight for ${key} must be an integer, got ${value}`);
516
+ }
517
+ });
518
+
519
+ return {
520
+ valid: errors.length === 0,
521
+ errors
522
+ };
523
+ }
524
+
525
+ /**
526
+ * Load weight configuration from environment variables or defaults
527
+ */
528
+ export function loadWeightConfigFromEnv(): {
529
+ framework: ComplianceFramework;
530
+ environment: EnvironmentType;
531
+ orgSize: OrganizationSize;
532
+ customOverrides: Partial<WeightConfig>;
533
+ } {
534
+ // Load from environment variables with sensible defaults
535
+ const framework = (process.env.CFAT_COMPLIANCE_FRAMEWORK as ComplianceFramework)
536
+ || ComplianceFramework.AWS_WELL_ARCHITECTED;
537
+
538
+ const environment = (process.env.CFAT_ENVIRONMENT_TYPE as EnvironmentType)
539
+ || EnvironmentType.PRODUCTION;
540
+
541
+ const orgSize = (process.env.CFAT_ORG_SIZE as OrganizationSize)
542
+ || OrganizationSize.MEDIUM;
543
+
544
+ // Load custom overrides from environment (JSON format)
545
+ let customOverrides: Partial<WeightConfig> = {};
546
+ const customOverridesEnv = process.env.CFAT_WEIGHT_OVERRIDES;
547
+ if (customOverridesEnv) {
548
+ try {
549
+ customOverrides = JSON.parse(customOverridesEnv);
550
+ } catch (error) {
551
+ console.warn('Invalid JSON in CFAT_WEIGHT_OVERRIDES, using defaults:', error);
552
+ }
553
+ }
554
+
555
+ return {
556
+ framework,
557
+ environment,
558
+ orgSize,
559
+ customOverrides
560
+ };
561
+ }
562
+
563
+ /**
564
+ * Export default configuration for easy importing
565
+ */
566
+ export function getDefaultWeightConfig(): WeightConfig {
567
+ const envConfig = loadWeightConfigFromEnv();
568
+ return getWeightConfig(
569
+ envConfig.framework,
570
+ envConfig.environment,
571
+ envConfig.orgSize,
572
+ envConfig.customOverrides
573
+ );
574
+ }
@@ -1,23 +1,33 @@
1
1
  """
2
- CloudOps Runbooks Common Framework - Enterprise Foundation
2
+ CloudOps Runbooks Common Framework - Universal Foundation
3
3
 
4
- This module provides the foundational enterprise framework components
5
- extracted from proven FinOps success patterns achieving 99.9996% accuracy,
6
- 280% ROI, and $630K annual value creation.
4
+ This module provides the foundational universal framework components
5
+ that work with ANY AWS setup without hardcoded assumptions.
7
6
 
8
7
  Components:
9
8
  - rich_utils: Beautiful CLI formatting with CloudOps theme
10
- - profile_utils: Three-tier AWS profile management system
9
+ - profile_utils: Universal AWS profile management (User → AWS_PROFILE → default)
10
+ - date_utils: Dynamic date generation utilities (No hardcoded dates)
11
11
  - performance_monitor: Enterprise-grade performance benchmarking
12
12
  - context_logger: Context-aware logging for CLI and Jupyter
13
13
  - mcp_integration: Phase 4 MCP Integration Framework (NEW)
14
14
  - cross_module_integration: Phase 4 Cross-Module Data Flow (NEW)
15
15
  - enterprise_audit_integration: Phase 4 Enterprise Audit Framework (NEW)
16
16
 
17
- Version: 0.8.0 - Phase 4 Multi-Module Integration Complete
17
+ Version: 1.0.0 - Universal Compatibility Update
18
18
  """
19
19
 
20
20
  # Rich CLI utilities (CloudOps theme, console, formatting)
21
+ # Dynamic date utilities (No hardcoded dates)
22
+ from .date_utils import (
23
+ get_aws_cli_example_period,
24
+ get_collection_timestamp,
25
+ get_current_month_period,
26
+ get_current_year,
27
+ get_previous_month_period,
28
+ get_test_date_period,
29
+ )
30
+
21
31
  # Phase 4: Cross-Module Integration (Data Flow Architecture)
22
32
  from .cross_module_integration import (
23
33
  DataFlowContext,
@@ -51,12 +61,12 @@ from .performance_monitor import (
51
61
  get_performance_benchmark,
52
62
  )
53
63
 
54
- # Profile management utilities (Three-tier enterprise system)
64
+ # Profile management utilities (Universal AWS profile system)
55
65
  from .profile_utils import (
56
66
  create_cost_session,
57
67
  create_management_session,
58
68
  create_operational_session,
59
- get_enterprise_profile_mapping,
69
+ get_current_profile_info,
60
70
  get_profile_for_operation,
61
71
  resolve_profile_for_operation_silent,
62
72
  validate_profile_access,
@@ -120,13 +130,20 @@ __all__ = [
120
130
  "print_markdown",
121
131
  "confirm_action",
122
132
  "create_columns",
133
+ # Dynamic date utilities
134
+ "get_current_year",
135
+ "get_current_month_period",
136
+ "get_previous_month_period",
137
+ "get_test_date_period",
138
+ "get_aws_cli_example_period",
139
+ "get_collection_timestamp",
123
140
  # Profile management utilities
124
141
  "get_profile_for_operation",
125
142
  "resolve_profile_for_operation_silent",
126
143
  "create_cost_session",
127
144
  "create_management_session",
128
145
  "create_operational_session",
129
- "get_enterprise_profile_mapping",
146
+ "get_current_profile_info",
130
147
  "validate_profile_access",
131
148
  # Performance monitoring framework
132
149
  "PerformanceMetrics",