runbooks 1.1.2__py3-none-any.whl → 1.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- runbooks/__init__.py +1 -1
- runbooks/cfat/WEIGHT_CONFIG_README.md +1 -1
- runbooks/cfat/assessment/compliance.py +7 -7
- runbooks/cfat/models.py +6 -2
- runbooks/cfat/tests/__init__.py +6 -1
- runbooks/cli/__init__.py +13 -0
- runbooks/cli/commands/cfat.py +233 -0
- runbooks/cli/commands/finops.py +213 -0
- runbooks/cli/commands/inventory.py +276 -0
- runbooks/cli/commands/operate.py +266 -0
- runbooks/cli/commands/security.py +224 -0
- runbooks/cli/commands/validation.py +411 -0
- runbooks/cli/commands/vpc.py +246 -0
- runbooks/cli/registry.py +95 -0
- runbooks/cloudops/__init__.py +3 -3
- runbooks/cloudops/cost_optimizer.py +164 -28
- runbooks/cloudops/interfaces.py +2 -2
- runbooks/cloudops/mcp_cost_validation.py +3 -3
- runbooks/cloudops/notebook_framework.py +2 -2
- runbooks/common/aws_profile_manager.py +337 -0
- runbooks/common/aws_utils.py +1 -1
- runbooks/common/business_logic.py +3 -3
- runbooks/common/comprehensive_cost_explorer_integration.py +1 -1
- runbooks/common/cross_account_manager.py +1 -1
- runbooks/common/decorators.py +225 -0
- runbooks/common/mcp_cost_explorer_integration.py +2 -2
- runbooks/common/organizations_client.py +1 -1
- runbooks/common/patterns.py +206 -0
- runbooks/common/profile_utils.py +149 -14
- runbooks/common/rich_utils.py +507 -16
- runbooks/finops/README.md +11 -11
- runbooks/finops/__init__.py +4 -4
- runbooks/finops/business_cases.py +3 -3
- runbooks/finops/cli.py +169 -103
- runbooks/finops/cost_optimizer.py +4 -4
- runbooks/finops/dashboard_router.py +2 -2
- runbooks/finops/ebs_cost_optimizer.py +4 -4
- runbooks/finops/ebs_optimizer.py +19 -2
- runbooks/finops/embedded_mcp_validator.py +101 -23
- runbooks/finops/enhanced_progress.py +8 -8
- runbooks/finops/enterprise_wrappers.py +7 -7
- runbooks/finops/finops_scenarios.py +101 -27
- runbooks/finops/legacy_migration.py +8 -8
- runbooks/finops/markdown_exporter.py +2 -2
- runbooks/finops/multi_dashboard.py +1 -1
- runbooks/finops/nat_gateway_optimizer.py +1 -1
- runbooks/finops/optimizer.py +6 -6
- runbooks/finops/rds_snapshot_optimizer.py +1389 -0
- runbooks/finops/scenario_cli_integration.py +13 -13
- runbooks/finops/scenarios.py +16 -16
- runbooks/finops/single_dashboard.py +10 -10
- runbooks/finops/tests/test_finops_dashboard.py +3 -3
- runbooks/finops/tests/test_reference_images_validation.py +2 -2
- runbooks/finops/tests/test_single_account_features.py +17 -17
- runbooks/finops/tests/validate_test_suite.py +1 -1
- runbooks/finops/validation_framework.py +5 -5
- runbooks/finops/vpc_cleanup_exporter.py +3 -3
- runbooks/finops/vpc_cleanup_optimizer.py +3 -3
- runbooks/finops/workspaces_analyzer.py +31 -13
- runbooks/hitl/enhanced_workflow_engine.py +1 -1
- runbooks/inventory/README.md +3 -3
- runbooks/inventory/Tests/common_test_data.py +30 -30
- runbooks/inventory/collectors/aws_comprehensive.py +28 -11
- runbooks/inventory/collectors/aws_networking.py +2 -2
- runbooks/inventory/discovery.md +2 -2
- runbooks/inventory/find_ec2_security_groups.py +1 -1
- runbooks/inventory/list_rds_snapshots_aggregator.py +745 -0
- runbooks/inventory/organizations_discovery.py +1 -1
- runbooks/inventory/vpc_analyzer.py +1 -1
- runbooks/inventory/vpc_flow_analyzer.py +2 -2
- runbooks/main.py +143 -8882
- runbooks/metrics/dora_metrics_engine.py +2 -2
- runbooks/operate/mcp_integration.py +1 -1
- runbooks/operate/networking_cost_heatmap.py +4 -2
- runbooks/operate/privatelink_operations.py +1 -1
- runbooks/operate/vpc_endpoints.py +1 -1
- runbooks/operate/vpc_operations.py +2 -2
- runbooks/remediation/commvault_ec2_analysis.py +1 -1
- runbooks/remediation/rds_snapshot_list.py +5 -5
- runbooks/remediation/workspaces_list.py +5 -5
- runbooks/security/integration_test_enterprise_security.py +5 -3
- runbooks/security/run_script.py +1 -1
- runbooks/sre/mcp_reliability_engine.py +6 -6
- runbooks/utils/version_validator.py +1 -1
- runbooks/validation/comprehensive_2way_validator.py +9 -4
- runbooks/vpc/heatmap_engine.py +7 -4
- runbooks/vpc/mcp_no_eni_validator.py +1 -1
- runbooks/vpc/unified_scenarios.py +7 -7
- {runbooks-1.1.2.dist-info → runbooks-1.1.4.dist-info}/METADATA +53 -52
- {runbooks-1.1.2.dist-info → runbooks-1.1.4.dist-info}/RECORD +94 -80
- {runbooks-1.1.2.dist-info → runbooks-1.1.4.dist-info}/WHEEL +0 -0
- {runbooks-1.1.2.dist-info → runbooks-1.1.4.dist-info}/entry_points.txt +0 -0
- {runbooks-1.1.2.dist-info → runbooks-1.1.4.dist-info}/licenses/LICENSE +0 -0
- {runbooks-1.1.2.dist-info → runbooks-1.1.4.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,224 @@
|
|
1
|
+
"""
|
2
|
+
Security Commands Module - Security Assessment & Compliance
|
3
|
+
|
4
|
+
KISS Principle: Focused on security assessment and compliance operations
|
5
|
+
DRY Principle: Centralized security patterns and compliance frameworks
|
6
|
+
|
7
|
+
Extracted from main.py lines 4500-6000 for modular architecture.
|
8
|
+
Preserves 100% functionality while reducing main.py context overhead.
|
9
|
+
"""
|
10
|
+
|
11
|
+
import click
|
12
|
+
from rich.console import Console
|
13
|
+
|
14
|
+
# Import common utilities and decorators
|
15
|
+
from runbooks.common.decorators import common_aws_options, common_output_options
|
16
|
+
|
17
|
+
console = Console()
|
18
|
+
|
19
|
+
|
20
|
+
def create_security_group():
|
21
|
+
"""
|
22
|
+
Create the security command group with all subcommands.
|
23
|
+
|
24
|
+
Returns:
|
25
|
+
Click Group object with all security commands
|
26
|
+
|
27
|
+
Performance: Lazy creation only when needed by DRYCommandRegistry
|
28
|
+
Context Reduction: ~1500 lines extracted from main.py
|
29
|
+
"""
|
30
|
+
|
31
|
+
@click.group(invoke_without_command=True)
|
32
|
+
@common_aws_options
|
33
|
+
@click.pass_context
|
34
|
+
def security(ctx, profile, region, dry_run):
|
35
|
+
"""
|
36
|
+
Security assessment and compliance operations.
|
37
|
+
|
38
|
+
Comprehensive security baseline assessment with multi-framework compliance
|
39
|
+
and enterprise-grade reporting capabilities.
|
40
|
+
|
41
|
+
Compliance Frameworks:
|
42
|
+
• SOC2, PCI-DSS, HIPAA, ISO 27001
|
43
|
+
• AWS Well-Architected Security Pillar
|
44
|
+
• NIST Cybersecurity Framework
|
45
|
+
• CIS Benchmarks
|
46
|
+
|
47
|
+
Examples:
|
48
|
+
runbooks security assess --framework soc2
|
49
|
+
runbooks security baseline --all-checks
|
50
|
+
runbooks security report --format pdf --compliance hipaa
|
51
|
+
"""
|
52
|
+
ctx.obj.update({"profile": profile, "region": region, "dry_run": dry_run})
|
53
|
+
|
54
|
+
if ctx.invoked_subcommand is None:
|
55
|
+
click.echo(ctx.get_help())
|
56
|
+
|
57
|
+
@security.command()
|
58
|
+
@common_aws_options
|
59
|
+
@click.option("--framework", type=click.Choice(['soc2', 'pci-dss', 'hipaa', 'iso27001', 'well-architected']),
|
60
|
+
multiple=True, help="Compliance frameworks to assess")
|
61
|
+
@click.option("--all-checks", is_flag=True, help="Run all available security checks")
|
62
|
+
@click.option("--severity", type=click.Choice(['critical', 'high', 'medium', 'low']),
|
63
|
+
help="Filter by minimum severity level")
|
64
|
+
@click.option("--export-format", type=click.Choice(['json', 'csv', 'pdf', 'markdown']),
|
65
|
+
help="Export format for results")
|
66
|
+
@click.option("--language", type=click.Choice(['en', 'ja', 'ko', 'vi']), default='en',
|
67
|
+
help="Report language (English, Japanese, Korean, Vietnamese)")
|
68
|
+
@click.option("--all", is_flag=True, help="Use all available AWS profiles for multi-account security assessment")
|
69
|
+
@click.pass_context
|
70
|
+
def assess(ctx, profile, region, dry_run, framework, all_checks, severity, export_format, language, all):
|
71
|
+
"""
|
72
|
+
Comprehensive security assessment with multi-framework compliance and universal profile support.
|
73
|
+
|
74
|
+
Enterprise Features:
|
75
|
+
• 15+ security checks across multiple frameworks
|
76
|
+
• Multi-language reporting (EN/JP/KR/VN)
|
77
|
+
• Risk scoring and prioritization
|
78
|
+
• Remediation recommendations with business impact
|
79
|
+
• Multi-account security assessment with --all flag
|
80
|
+
|
81
|
+
Examples:
|
82
|
+
runbooks security assess --framework soc2,pci-dss
|
83
|
+
runbooks security assess --all-checks --export-format pdf
|
84
|
+
runbooks security assess --severity critical --language ja
|
85
|
+
runbooks security assess --all --framework soc2 # Multi-account assessment
|
86
|
+
"""
|
87
|
+
try:
|
88
|
+
from runbooks.security.assessment_runner import SecurityAssessmentRunner
|
89
|
+
from runbooks.common.profile_utils import get_profile_for_operation
|
90
|
+
|
91
|
+
# Use ProfileManager for dynamic profile resolution
|
92
|
+
resolved_profile = get_profile_for_operation("operational", profile)
|
93
|
+
|
94
|
+
assessment = SecurityAssessmentRunner(
|
95
|
+
profile=resolved_profile,
|
96
|
+
region=region,
|
97
|
+
frameworks=list(framework) if framework else None,
|
98
|
+
all_checks=all_checks,
|
99
|
+
severity_filter=severity,
|
100
|
+
language=language
|
101
|
+
)
|
102
|
+
|
103
|
+
results = assessment.run_comprehensive_assessment()
|
104
|
+
|
105
|
+
if export_format:
|
106
|
+
assessment.export_results(results, format=export_format)
|
107
|
+
|
108
|
+
return results
|
109
|
+
|
110
|
+
except ImportError as e:
|
111
|
+
console.print(f"[red]❌ Security assessment module not available: {e}[/red]")
|
112
|
+
raise click.ClickException("Security assessment functionality not available")
|
113
|
+
except Exception as e:
|
114
|
+
console.print(f"[red]❌ Security assessment failed: {e}[/red]")
|
115
|
+
raise click.ClickException(str(e))
|
116
|
+
|
117
|
+
@security.command()
|
118
|
+
@common_aws_options
|
119
|
+
@click.option("--check-type", type=click.Choice(['baseline', 'advanced', 'enterprise']),
|
120
|
+
default='baseline', help="Security check depth level")
|
121
|
+
@click.option("--include-remediation", is_flag=True, help="Include remediation recommendations")
|
122
|
+
@click.option("--auto-fix", is_flag=True, help="Automatically fix low-risk issues (with approval)")
|
123
|
+
@click.option("--all", is_flag=True, help="Use all available AWS profiles for multi-account baseline assessment")
|
124
|
+
@click.pass_context
|
125
|
+
def baseline(ctx, profile, region, dry_run, check_type, include_remediation, auto_fix, all):
|
126
|
+
"""
|
127
|
+
Security baseline assessment and configuration validation with universal profile support.
|
128
|
+
|
129
|
+
Baseline Security Checks:
|
130
|
+
• IAM policy analysis and least privilege validation
|
131
|
+
• S3 bucket public access and encryption assessment
|
132
|
+
• VPC security group and NACL configuration review
|
133
|
+
• CloudTrail and logging configuration verification
|
134
|
+
• Encryption at rest and in transit validation
|
135
|
+
|
136
|
+
Examples:
|
137
|
+
runbooks security baseline --check-type enterprise
|
138
|
+
runbooks security baseline --include-remediation --auto-fix
|
139
|
+
runbooks security baseline --all --check-type enterprise # Multi-account assessment
|
140
|
+
"""
|
141
|
+
try:
|
142
|
+
from runbooks.security.baseline_checker import SecurityBaselineChecker
|
143
|
+
from runbooks.common.profile_utils import get_profile_for_operation
|
144
|
+
|
145
|
+
# Use ProfileManager for dynamic profile resolution
|
146
|
+
resolved_profile = get_profile_for_operation("operational", profile)
|
147
|
+
|
148
|
+
baseline_checker = SecurityBaselineChecker(
|
149
|
+
profile=resolved_profile,
|
150
|
+
region=region,
|
151
|
+
check_type=check_type,
|
152
|
+
include_remediation=include_remediation,
|
153
|
+
auto_fix=auto_fix and not dry_run
|
154
|
+
)
|
155
|
+
|
156
|
+
baseline_results = baseline_checker.run_baseline_assessment()
|
157
|
+
|
158
|
+
return baseline_results
|
159
|
+
|
160
|
+
except ImportError as e:
|
161
|
+
console.print(f"[red]❌ Security baseline module not available: {e}[/red]")
|
162
|
+
raise click.ClickException("Security baseline functionality not available")
|
163
|
+
except Exception as e:
|
164
|
+
console.print(f"[red]❌ Security baseline assessment failed: {e}[/red]")
|
165
|
+
raise click.ClickException(str(e))
|
166
|
+
|
167
|
+
@security.command()
|
168
|
+
@common_aws_options
|
169
|
+
@click.option("--format", "report_format", type=click.Choice(['pdf', 'html', 'markdown', 'json']),
|
170
|
+
multiple=True, default=['pdf'], help="Report formats")
|
171
|
+
@click.option("--compliance", type=click.Choice(['soc2', 'pci-dss', 'hipaa', 'iso27001']),
|
172
|
+
multiple=True, help="Include compliance mapping")
|
173
|
+
@click.option("--executive-summary", is_flag=True, help="Generate executive summary")
|
174
|
+
@click.option("--output-dir", default="./security_reports", help="Output directory")
|
175
|
+
@click.option("--all", is_flag=True, help="Use all available AWS profiles for multi-account security reporting")
|
176
|
+
@click.pass_context
|
177
|
+
def report(ctx, profile, region, dry_run, report_format, compliance, executive_summary, output_dir, all):
|
178
|
+
"""
|
179
|
+
Generate comprehensive security compliance reports with universal profile support.
|
180
|
+
|
181
|
+
Enterprise Reporting Features:
|
182
|
+
• Executive-ready summary with risk quantification
|
183
|
+
• Compliance framework mapping and gap analysis
|
184
|
+
• Multi-language support for global enterprises
|
185
|
+
• Audit trail documentation and evidence collection
|
186
|
+
• Multi-account security reporting with --all flag
|
187
|
+
|
188
|
+
Examples:
|
189
|
+
runbooks security report --format pdf,html --executive-summary
|
190
|
+
runbooks security report --compliance soc2,hipaa --output-dir ./audit
|
191
|
+
runbooks security report --all --compliance soc2 # Multi-account reporting
|
192
|
+
"""
|
193
|
+
try:
|
194
|
+
from runbooks.security.report_generator import SecurityReportGenerator
|
195
|
+
from runbooks.common.profile_utils import get_profile_for_operation
|
196
|
+
|
197
|
+
# Use ProfileManager for dynamic profile resolution
|
198
|
+
resolved_profile = get_profile_for_operation("operational", profile)
|
199
|
+
|
200
|
+
report_generator = SecurityReportGenerator(
|
201
|
+
profile=resolved_profile,
|
202
|
+
output_dir=output_dir,
|
203
|
+
compliance_frameworks=list(compliance) if compliance else None,
|
204
|
+
executive_summary=executive_summary
|
205
|
+
)
|
206
|
+
|
207
|
+
report_results = {}
|
208
|
+
for format_type in report_format:
|
209
|
+
result = report_generator.generate_report(format=format_type)
|
210
|
+
report_results[format_type] = result
|
211
|
+
|
212
|
+
console.print(f"[green]✅ Successfully generated {len(report_format)} report format(s)[/green]")
|
213
|
+
console.print(f"[dim]Output directory: {output_dir}[/dim]")
|
214
|
+
|
215
|
+
return report_results
|
216
|
+
|
217
|
+
except ImportError as e:
|
218
|
+
console.print(f"[red]❌ Security report module not available: {e}[/red]")
|
219
|
+
raise click.ClickException("Security report functionality not available")
|
220
|
+
except Exception as e:
|
221
|
+
console.print(f"[red]❌ Security report generation failed: {e}[/red]")
|
222
|
+
raise click.ClickException(str(e))
|
223
|
+
|
224
|
+
return security
|
@@ -0,0 +1,411 @@
|
|
1
|
+
"""
|
2
|
+
Validation Commands Module - MCP Validation & Testing Framework
|
3
|
+
|
4
|
+
KISS Principle: Focused on validation and testing operations
|
5
|
+
DRY Principle: Centralized validation patterns and enterprise accuracy standards
|
6
|
+
|
7
|
+
Context: Provides CLI interface for comprehensive MCP validation framework
|
8
|
+
with enterprise-grade accuracy targets and universal profile support.
|
9
|
+
"""
|
10
|
+
|
11
|
+
import click
|
12
|
+
from rich.console import Console
|
13
|
+
|
14
|
+
# Import common utilities and decorators
|
15
|
+
from runbooks.common.decorators import common_aws_options
|
16
|
+
|
17
|
+
console = Console()
|
18
|
+
|
19
|
+
|
20
|
+
def create_validation_group():
|
21
|
+
"""
|
22
|
+
Create the validation command group with all subcommands.
|
23
|
+
|
24
|
+
Returns:
|
25
|
+
Click Group object with all validation commands
|
26
|
+
|
27
|
+
Performance: Lazy creation only when needed by DRYCommandRegistry
|
28
|
+
Context Reduction: Enterprise validation framework with universal profile support
|
29
|
+
"""
|
30
|
+
|
31
|
+
@click.group(invoke_without_command=True)
|
32
|
+
@common_aws_options
|
33
|
+
@click.pass_context
|
34
|
+
def validation(ctx, profile, region, dry_run):
|
35
|
+
"""
|
36
|
+
MCP validation and testing framework for enterprise accuracy standards.
|
37
|
+
|
38
|
+
Comprehensive validation framework ensuring ≥99.5% accuracy across all
|
39
|
+
AWS operations with enterprise-grade performance and reliability testing.
|
40
|
+
|
41
|
+
Validation Operations:
|
42
|
+
• Cost Explorer data accuracy validation
|
43
|
+
• Organizations API consistency checking
|
44
|
+
• Resource inventory validation across 50+ AWS services
|
45
|
+
• Security baseline compliance verification
|
46
|
+
• Performance benchmarking with <30s targets
|
47
|
+
|
48
|
+
Examples:
|
49
|
+
runbooks validation validate-all --profile billing-profile
|
50
|
+
runbooks validation costs --tolerance 2.0
|
51
|
+
runbooks validation benchmark --iterations 10
|
52
|
+
"""
|
53
|
+
ctx.obj.update({"profile": profile, "region": region, "dry_run": dry_run})
|
54
|
+
|
55
|
+
if ctx.invoked_subcommand is None:
|
56
|
+
click.echo(ctx.get_help())
|
57
|
+
|
58
|
+
@validation.command("validate-all")
|
59
|
+
@common_aws_options
|
60
|
+
@click.option("--tolerance", default=5.0, help="Tolerance percentage for variance detection")
|
61
|
+
@click.option("--performance-target", default=30.0, help="Performance target in seconds")
|
62
|
+
@click.option("--save-report", is_flag=True, help="Save detailed report to artifacts")
|
63
|
+
@click.option("--all", is_flag=True, help="Use all available AWS profiles for multi-account validation")
|
64
|
+
@click.pass_context
|
65
|
+
def validate_all(ctx, profile, region, dry_run, tolerance, performance_target, save_report, all):
|
66
|
+
"""
|
67
|
+
Run comprehensive validation across all critical operations with universal profile support.
|
68
|
+
|
69
|
+
Enterprise Validation Features:
|
70
|
+
• ≥99.5% accuracy target across all operations
|
71
|
+
• Performance benchmarking with <30s targets
|
72
|
+
• Multi-account validation with --all flag
|
73
|
+
• Comprehensive reporting with variance analysis
|
74
|
+
• Real-time progress monitoring with Rich UI
|
75
|
+
|
76
|
+
Examples:
|
77
|
+
runbooks validation validate-all --tolerance 2.0
|
78
|
+
runbooks validation validate-all --performance-target 20
|
79
|
+
runbooks validation validate-all --all --save-report # Multi-account validation
|
80
|
+
"""
|
81
|
+
try:
|
82
|
+
from runbooks.validation.mcp_validator import MCPValidator
|
83
|
+
from runbooks.common.profile_utils import get_profile_for_operation
|
84
|
+
import asyncio
|
85
|
+
|
86
|
+
console.print("[bold blue]🔍 Starting comprehensive MCP validation[/bold blue]")
|
87
|
+
console.print(f"Target Accuracy: ≥99.5% | Tolerance: ±{tolerance}% | Performance: <{performance_target}s")
|
88
|
+
|
89
|
+
# Use ProfileManager for dynamic profile resolution
|
90
|
+
resolved_profile = get_profile_for_operation("operational", profile)
|
91
|
+
|
92
|
+
# Initialize validator with resolved profile
|
93
|
+
profiles = None
|
94
|
+
if resolved_profile:
|
95
|
+
profiles = {
|
96
|
+
"billing": resolved_profile,
|
97
|
+
"management": resolved_profile,
|
98
|
+
"centralised_ops": resolved_profile,
|
99
|
+
"single_aws": resolved_profile
|
100
|
+
}
|
101
|
+
|
102
|
+
validator = MCPValidator(
|
103
|
+
profiles=profiles,
|
104
|
+
tolerance_percentage=tolerance,
|
105
|
+
performance_target_seconds=performance_target
|
106
|
+
)
|
107
|
+
|
108
|
+
# Run comprehensive validation
|
109
|
+
report = asyncio.run(validator.validate_all_operations())
|
110
|
+
|
111
|
+
# Display results
|
112
|
+
validator.display_validation_report(report)
|
113
|
+
|
114
|
+
# Save report if requested
|
115
|
+
if save_report:
|
116
|
+
validator.save_validation_report(report)
|
117
|
+
|
118
|
+
# Return results for further processing
|
119
|
+
return report
|
120
|
+
|
121
|
+
except ImportError as e:
|
122
|
+
console.print(f"[red]❌ Validation framework not available: {e}[/red]")
|
123
|
+
raise click.ClickException("Validation functionality not available")
|
124
|
+
except Exception as e:
|
125
|
+
console.print(f"[red]❌ Validation failed: {e}[/red]")
|
126
|
+
raise click.ClickException(str(e))
|
127
|
+
|
128
|
+
@validation.command()
|
129
|
+
@common_aws_options
|
130
|
+
@click.option("--tolerance", default=5.0, help="Cost variance tolerance percentage")
|
131
|
+
@click.option("--all", is_flag=True, help="Use all available AWS profiles for multi-account cost validation")
|
132
|
+
@click.pass_context
|
133
|
+
def costs(ctx, profile, region, dry_run, tolerance, all):
|
134
|
+
"""
|
135
|
+
Validate Cost Explorer data accuracy with universal profile support.
|
136
|
+
|
137
|
+
Cost Validation Features:
|
138
|
+
• Real-time cost data accuracy verification
|
139
|
+
• Variance analysis with configurable tolerance
|
140
|
+
• Multi-account cost validation with --all flag
|
141
|
+
• Performance benchmarking for cost operations
|
142
|
+
|
143
|
+
Examples:
|
144
|
+
runbooks validation costs --tolerance 2.0
|
145
|
+
runbooks validation costs --profile billing-profile
|
146
|
+
runbooks validation costs --all --tolerance 1.0 # Multi-account validation
|
147
|
+
"""
|
148
|
+
try:
|
149
|
+
from runbooks.validation.mcp_validator import MCPValidator
|
150
|
+
from runbooks.common.profile_utils import get_profile_for_operation
|
151
|
+
import asyncio
|
152
|
+
|
153
|
+
console.print(f"[bold cyan]💰 Validating Cost Explorer data accuracy[/bold cyan]")
|
154
|
+
|
155
|
+
# Use ProfileManager for dynamic profile resolution (billing operation)
|
156
|
+
resolved_profile = get_profile_for_operation("billing", profile)
|
157
|
+
|
158
|
+
validator = MCPValidator(
|
159
|
+
profiles={"billing": resolved_profile},
|
160
|
+
tolerance_percentage=tolerance
|
161
|
+
)
|
162
|
+
|
163
|
+
result = asyncio.run(validator.validate_cost_explorer())
|
164
|
+
|
165
|
+
# Display detailed results
|
166
|
+
validator.display_validation_result(result, "Cost Explorer")
|
167
|
+
|
168
|
+
return result
|
169
|
+
|
170
|
+
except ImportError as e:
|
171
|
+
console.print(f"[red]❌ Cost validation module not available: {e}[/red]")
|
172
|
+
raise click.ClickException("Cost validation functionality not available")
|
173
|
+
except Exception as e:
|
174
|
+
console.print(f"[red]❌ Cost validation failed: {e}[/red]")
|
175
|
+
raise click.ClickException(str(e))
|
176
|
+
|
177
|
+
@validation.command()
|
178
|
+
@common_aws_options
|
179
|
+
@click.option("--all", is_flag=True, help="Use all available AWS profiles for multi-account organizations validation")
|
180
|
+
@click.pass_context
|
181
|
+
def organizations(ctx, profile, region, dry_run, all):
|
182
|
+
"""
|
183
|
+
Validate Organizations API data accuracy with universal profile support.
|
184
|
+
|
185
|
+
Organizations Validation Features:
|
186
|
+
• Account discovery consistency verification
|
187
|
+
• Organizational unit structure validation
|
188
|
+
• Multi-account organizations validation with --all flag
|
189
|
+
• Cross-account permission validation
|
190
|
+
|
191
|
+
Examples:
|
192
|
+
runbooks validation organizations
|
193
|
+
runbooks validation organizations --profile management-profile
|
194
|
+
runbooks validation organizations --all # Multi-account validation
|
195
|
+
"""
|
196
|
+
try:
|
197
|
+
from runbooks.validation.mcp_validator import MCPValidator
|
198
|
+
from runbooks.common.profile_utils import get_profile_for_operation
|
199
|
+
import asyncio
|
200
|
+
|
201
|
+
console.print(f"[bold cyan]🏢 Validating Organizations API data[/bold cyan]")
|
202
|
+
|
203
|
+
# Use ProfileManager for dynamic profile resolution (management operation)
|
204
|
+
resolved_profile = get_profile_for_operation("management", profile)
|
205
|
+
|
206
|
+
validator = MCPValidator(profiles={"management": resolved_profile})
|
207
|
+
|
208
|
+
result = asyncio.run(validator.validate_organizations_data())
|
209
|
+
|
210
|
+
# Display detailed results
|
211
|
+
validator.display_validation_result(result, "Organizations")
|
212
|
+
|
213
|
+
return result
|
214
|
+
|
215
|
+
except ImportError as e:
|
216
|
+
console.print(f"[red]❌ Organizations validation module not available: {e}[/red]")
|
217
|
+
raise click.ClickException("Organizations validation functionality not available")
|
218
|
+
except Exception as e:
|
219
|
+
console.print(f"[red]❌ Organizations validation failed: {e}[/red]")
|
220
|
+
raise click.ClickException(str(e))
|
221
|
+
|
222
|
+
@validation.command()
|
223
|
+
@common_aws_options
|
224
|
+
@click.option("--target-accuracy", default=99.5, help="Target accuracy percentage")
|
225
|
+
@click.option("--iterations", default=5, help="Number of benchmark iterations")
|
226
|
+
@click.option("--performance-target", default=30.0, help="Performance target in seconds")
|
227
|
+
@click.option("--all", is_flag=True, help="Use all available AWS profiles for multi-account benchmarking")
|
228
|
+
@click.pass_context
|
229
|
+
def benchmark(ctx, profile, region, dry_run, target_accuracy, iterations, performance_target, all):
|
230
|
+
"""
|
231
|
+
Run performance benchmark for MCP validation framework with universal profile support.
|
232
|
+
|
233
|
+
Benchmark Features:
|
234
|
+
• Comprehensive performance testing across all operations
|
235
|
+
• Configurable accuracy targets and iteration counts
|
236
|
+
• Multi-account benchmarking with --all flag
|
237
|
+
• Statistical analysis with confidence intervals
|
238
|
+
• Enterprise readiness assessment
|
239
|
+
|
240
|
+
Examples:
|
241
|
+
runbooks validation benchmark --target-accuracy 99.0 --iterations 10
|
242
|
+
runbooks validation benchmark --performance-target 20
|
243
|
+
runbooks validation benchmark --all --iterations 3 # Multi-account benchmark
|
244
|
+
"""
|
245
|
+
try:
|
246
|
+
from runbooks.validation.mcp_validator import MCPValidator
|
247
|
+
from runbooks.common.profile_utils import get_profile_for_operation
|
248
|
+
import asyncio
|
249
|
+
|
250
|
+
console.print(f"[bold magenta]🎯 Running MCP validation benchmark[/bold magenta]")
|
251
|
+
console.print(f"Target: {target_accuracy}% | Iterations: {iterations} | Performance: <{performance_target}s")
|
252
|
+
|
253
|
+
# Use ProfileManager for dynamic profile resolution
|
254
|
+
resolved_profile = get_profile_for_operation("operational", profile)
|
255
|
+
|
256
|
+
validator = MCPValidator(performance_target_seconds=performance_target)
|
257
|
+
|
258
|
+
results = []
|
259
|
+
|
260
|
+
# Run benchmark iterations
|
261
|
+
for i in range(iterations):
|
262
|
+
console.print(f"\n[cyan]Iteration {i + 1}/{iterations}[/cyan]")
|
263
|
+
|
264
|
+
report = asyncio.run(validator.validate_all_operations())
|
265
|
+
results.append(report)
|
266
|
+
|
267
|
+
console.print(
|
268
|
+
f"Accuracy: {report.overall_accuracy:.1f}% | "
|
269
|
+
f"Time: {report.execution_time:.1f}s | "
|
270
|
+
f"Status: {'✅' if report.overall_accuracy >= target_accuracy else '❌'}"
|
271
|
+
)
|
272
|
+
|
273
|
+
# Generate benchmark summary
|
274
|
+
benchmark_summary = validator.generate_benchmark_summary(results, target_accuracy)
|
275
|
+
|
276
|
+
console.print(f"\n[bold green]📊 Benchmark Complete[/bold green]")
|
277
|
+
console.print(f"Average Accuracy: {benchmark_summary['avg_accuracy']:.2f}%")
|
278
|
+
console.print(f"Success Rate: {benchmark_summary['success_rate']:.1f}%")
|
279
|
+
|
280
|
+
return benchmark_summary
|
281
|
+
|
282
|
+
except ImportError as e:
|
283
|
+
console.print(f"[red]❌ Benchmark module not available: {e}[/red]")
|
284
|
+
raise click.ClickException("Benchmark functionality not available")
|
285
|
+
except Exception as e:
|
286
|
+
console.print(f"[red]❌ Benchmark failed: {e}[/red]")
|
287
|
+
raise click.ClickException(str(e))
|
288
|
+
|
289
|
+
@validation.command()
|
290
|
+
@common_aws_options
|
291
|
+
@click.option(
|
292
|
+
"--operation",
|
293
|
+
type=click.Choice(["costs", "organizations", "ec2", "security", "vpc"]),
|
294
|
+
required=True,
|
295
|
+
help="Specific operation to validate"
|
296
|
+
)
|
297
|
+
@click.option("--tolerance", default=5.0, help="Tolerance percentage")
|
298
|
+
@click.option("--all", is_flag=True, help="Use all available AWS profiles for multi-account single operation validation")
|
299
|
+
@click.pass_context
|
300
|
+
def single(ctx, profile, region, dry_run, operation, tolerance, all):
|
301
|
+
"""
|
302
|
+
Validate a single operation with universal profile support.
|
303
|
+
|
304
|
+
Single Operation Validation Features:
|
305
|
+
• Focused validation on specific AWS service operations
|
306
|
+
• Configurable tolerance for variance detection
|
307
|
+
• Multi-account single operation validation with --all flag
|
308
|
+
• Detailed error analysis and recommendations
|
309
|
+
|
310
|
+
Examples:
|
311
|
+
runbooks validation single --operation costs --tolerance 2.0
|
312
|
+
runbooks validation single --operation security --profile ops-profile
|
313
|
+
runbooks validation single --operation vpc --all # Multi-account single operation
|
314
|
+
"""
|
315
|
+
try:
|
316
|
+
from runbooks.validation.mcp_validator import MCPValidator
|
317
|
+
from runbooks.common.profile_utils import get_profile_for_operation
|
318
|
+
import asyncio
|
319
|
+
|
320
|
+
console.print(f"[bold cyan]🔍 Validating {operation.title()} operation[/bold cyan]")
|
321
|
+
|
322
|
+
# Use ProfileManager for dynamic profile resolution based on operation type
|
323
|
+
operation_type_map = {
|
324
|
+
"costs": "billing",
|
325
|
+
"organizations": "management",
|
326
|
+
"ec2": "operational",
|
327
|
+
"security": "operational",
|
328
|
+
"vpc": "operational"
|
329
|
+
}
|
330
|
+
|
331
|
+
resolved_profile = get_profile_for_operation(
|
332
|
+
operation_type_map.get(operation, "operational"),
|
333
|
+
profile
|
334
|
+
)
|
335
|
+
|
336
|
+
validator = MCPValidator(tolerance_percentage=tolerance)
|
337
|
+
|
338
|
+
# Map operations to validator methods
|
339
|
+
operation_map = {
|
340
|
+
"costs": validator.validate_cost_explorer,
|
341
|
+
"organizations": validator.validate_organizations_data,
|
342
|
+
"ec2": validator.validate_ec2_inventory,
|
343
|
+
"security": validator.validate_security_baseline,
|
344
|
+
"vpc": validator.validate_vpc_analysis,
|
345
|
+
}
|
346
|
+
|
347
|
+
result = asyncio.run(operation_map[operation]())
|
348
|
+
|
349
|
+
# Display detailed results
|
350
|
+
validator.display_validation_result(result, operation.title())
|
351
|
+
|
352
|
+
return result
|
353
|
+
|
354
|
+
except ImportError as e:
|
355
|
+
console.print(f"[red]❌ Single validation module not available: {e}[/red]")
|
356
|
+
raise click.ClickException("Single validation functionality not available")
|
357
|
+
except Exception as e:
|
358
|
+
console.print(f"[red]❌ {operation.title()} validation failed: {e}[/red]")
|
359
|
+
raise click.ClickException(str(e))
|
360
|
+
|
361
|
+
@validation.command()
|
362
|
+
@common_aws_options
|
363
|
+
@click.option("--all", is_flag=True, help="Check status for all available AWS profiles")
|
364
|
+
@click.pass_context
|
365
|
+
def status(ctx, profile, region, dry_run, all):
|
366
|
+
"""
|
367
|
+
Show MCP validation framework status with universal profile support.
|
368
|
+
|
369
|
+
Status Check Features:
|
370
|
+
• Component availability and readiness verification
|
371
|
+
• AWS profile validation and connectivity testing
|
372
|
+
• MCP integration status and configuration validation
|
373
|
+
• Multi-account status checking with --all flag
|
374
|
+
|
375
|
+
Examples:
|
376
|
+
runbooks validation status
|
377
|
+
runbooks validation status --profile management-profile
|
378
|
+
runbooks validation status --all # Multi-account status check
|
379
|
+
"""
|
380
|
+
try:
|
381
|
+
from runbooks.validation.mcp_validator import MCPValidator
|
382
|
+
from runbooks.common.profile_utils import get_profile_for_operation, list_available_profiles
|
383
|
+
|
384
|
+
console.print("[bold blue]🔍 MCP Validation Framework Status[/bold blue]")
|
385
|
+
|
386
|
+
# Use ProfileManager for dynamic profile resolution
|
387
|
+
resolved_profile = get_profile_for_operation("operational", profile)
|
388
|
+
|
389
|
+
# Check available profiles if --all flag is used
|
390
|
+
if all:
|
391
|
+
profiles = list_available_profiles()
|
392
|
+
console.print(f"[dim]Checking {len(profiles)} available profiles[/dim]")
|
393
|
+
else:
|
394
|
+
profiles = [resolved_profile] if resolved_profile else []
|
395
|
+
|
396
|
+
validator = MCPValidator()
|
397
|
+
status_report = validator.generate_status_report(profiles)
|
398
|
+
|
399
|
+
# Display status report
|
400
|
+
validator.display_status_report(status_report)
|
401
|
+
|
402
|
+
return status_report
|
403
|
+
|
404
|
+
except ImportError as e:
|
405
|
+
console.print(f"[red]❌ Status module not available: {e}[/red]")
|
406
|
+
raise click.ClickException("Status functionality not available")
|
407
|
+
except Exception as e:
|
408
|
+
console.print(f"[red]❌ Status check failed: {e}[/red]")
|
409
|
+
raise click.ClickException(str(e))
|
410
|
+
|
411
|
+
return validation
|