runbooks 0.2.5__py3-none-any.whl → 0.7.0__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 (249) hide show
  1. conftest.py +26 -0
  2. jupyter-agent/.env +2 -0
  3. jupyter-agent/.env.template +2 -0
  4. jupyter-agent/.gitattributes +35 -0
  5. jupyter-agent/.gradio/certificate.pem +31 -0
  6. jupyter-agent/README.md +16 -0
  7. jupyter-agent/__main__.log +8 -0
  8. jupyter-agent/app.py +256 -0
  9. jupyter-agent/cloudops-agent.png +0 -0
  10. jupyter-agent/ds-system-prompt.txt +154 -0
  11. jupyter-agent/jupyter-agent.png +0 -0
  12. jupyter-agent/llama3_template.jinja +123 -0
  13. jupyter-agent/requirements.txt +9 -0
  14. jupyter-agent/tmp/4ojbs8a02ir/jupyter-agent.ipynb +68 -0
  15. jupyter-agent/tmp/cm5iasgpm3p/jupyter-agent.ipynb +91 -0
  16. jupyter-agent/tmp/crqbsseag5/jupyter-agent.ipynb +91 -0
  17. jupyter-agent/tmp/hohanq1u097/jupyter-agent.ipynb +57 -0
  18. jupyter-agent/tmp/jns1sam29wm/jupyter-agent.ipynb +53 -0
  19. jupyter-agent/tmp/jupyter-agent.ipynb +27 -0
  20. jupyter-agent/utils.py +409 -0
  21. runbooks/__init__.py +71 -3
  22. runbooks/__main__.py +13 -0
  23. runbooks/aws/ec2_describe_instances.py +1 -1
  24. runbooks/aws/ec2_run_instances.py +8 -2
  25. runbooks/aws/ec2_start_stop_instances.py +17 -4
  26. runbooks/aws/ec2_unused_volumes.py +5 -1
  27. runbooks/aws/s3_create_bucket.py +4 -2
  28. runbooks/aws/s3_list_objects.py +6 -1
  29. runbooks/aws/tagging_lambda_handler.py +13 -2
  30. runbooks/aws/tags.json +12 -0
  31. runbooks/base.py +353 -0
  32. runbooks/cfat/README.md +49 -0
  33. runbooks/cfat/__init__.py +74 -0
  34. runbooks/cfat/app.ts +644 -0
  35. runbooks/cfat/assessment/__init__.py +40 -0
  36. runbooks/cfat/assessment/asana-import.csv +39 -0
  37. runbooks/cfat/assessment/cfat-checks.csv +31 -0
  38. runbooks/cfat/assessment/cfat.txt +520 -0
  39. runbooks/cfat/assessment/collectors.py +200 -0
  40. runbooks/cfat/assessment/jira-import.csv +39 -0
  41. runbooks/cfat/assessment/runner.py +387 -0
  42. runbooks/cfat/assessment/validators.py +290 -0
  43. runbooks/cfat/cli.py +103 -0
  44. runbooks/cfat/docs/asana-import.csv +24 -0
  45. runbooks/cfat/docs/cfat-checks.csv +31 -0
  46. runbooks/cfat/docs/cfat.txt +335 -0
  47. runbooks/cfat/docs/checks-output.png +0 -0
  48. runbooks/cfat/docs/cloudshell-console-run.png +0 -0
  49. runbooks/cfat/docs/cloudshell-download.png +0 -0
  50. runbooks/cfat/docs/cloudshell-output.png +0 -0
  51. runbooks/cfat/docs/downloadfile.png +0 -0
  52. runbooks/cfat/docs/jira-import.csv +24 -0
  53. runbooks/cfat/docs/open-cloudshell.png +0 -0
  54. runbooks/cfat/docs/report-header.png +0 -0
  55. runbooks/cfat/models.py +1026 -0
  56. runbooks/cfat/package-lock.json +5116 -0
  57. runbooks/cfat/package.json +38 -0
  58. runbooks/cfat/report.py +496 -0
  59. runbooks/cfat/reporting/__init__.py +46 -0
  60. runbooks/cfat/reporting/exporters.py +337 -0
  61. runbooks/cfat/reporting/formatters.py +496 -0
  62. runbooks/cfat/reporting/templates.py +135 -0
  63. runbooks/cfat/run-assessment.sh +23 -0
  64. runbooks/cfat/runner.py +69 -0
  65. runbooks/cfat/src/actions/check-cloudtrail-existence.ts +43 -0
  66. runbooks/cfat/src/actions/check-config-existence.ts +37 -0
  67. runbooks/cfat/src/actions/check-control-tower.ts +37 -0
  68. runbooks/cfat/src/actions/check-ec2-existence.ts +46 -0
  69. runbooks/cfat/src/actions/check-iam-users.ts +50 -0
  70. runbooks/cfat/src/actions/check-legacy-cur.ts +30 -0
  71. runbooks/cfat/src/actions/check-org-cloudformation.ts +30 -0
  72. runbooks/cfat/src/actions/check-vpc-existence.ts +43 -0
  73. runbooks/cfat/src/actions/create-asanaimport.ts +14 -0
  74. runbooks/cfat/src/actions/create-backlog.ts +372 -0
  75. runbooks/cfat/src/actions/create-jiraimport.ts +15 -0
  76. runbooks/cfat/src/actions/create-report.ts +616 -0
  77. runbooks/cfat/src/actions/define-account-type.ts +51 -0
  78. runbooks/cfat/src/actions/get-enabled-org-policy-types.ts +40 -0
  79. runbooks/cfat/src/actions/get-enabled-org-services.ts +26 -0
  80. runbooks/cfat/src/actions/get-idc-info.ts +34 -0
  81. runbooks/cfat/src/actions/get-org-da-accounts.ts +34 -0
  82. runbooks/cfat/src/actions/get-org-details.ts +35 -0
  83. runbooks/cfat/src/actions/get-org-member-accounts.ts +44 -0
  84. runbooks/cfat/src/actions/get-org-ous.ts +35 -0
  85. runbooks/cfat/src/actions/get-regions.ts +22 -0
  86. runbooks/cfat/src/actions/zip-assessment.ts +27 -0
  87. runbooks/cfat/src/types/index.d.ts +147 -0
  88. runbooks/cfat/tests/__init__.py +141 -0
  89. runbooks/cfat/tests/test_cli.py +340 -0
  90. runbooks/cfat/tests/test_integration.py +290 -0
  91. runbooks/cfat/tests/test_models.py +505 -0
  92. runbooks/cfat/tests/test_reporting.py +354 -0
  93. runbooks/cfat/tsconfig.json +16 -0
  94. runbooks/cfat/webpack.config.cjs +27 -0
  95. runbooks/config.py +260 -0
  96. runbooks/finops/README.md +337 -0
  97. runbooks/finops/__init__.py +86 -0
  98. runbooks/finops/aws_client.py +245 -0
  99. runbooks/finops/cli.py +151 -0
  100. runbooks/finops/cost_processor.py +410 -0
  101. runbooks/finops/dashboard_runner.py +448 -0
  102. runbooks/finops/helpers.py +355 -0
  103. runbooks/finops/main.py +14 -0
  104. runbooks/finops/profile_processor.py +174 -0
  105. runbooks/finops/types.py +66 -0
  106. runbooks/finops/visualisations.py +80 -0
  107. runbooks/inventory/.gitignore +354 -0
  108. runbooks/inventory/ArgumentsClass.py +261 -0
  109. runbooks/inventory/FAILED_SCRIPTS_TROUBLESHOOTING.md +619 -0
  110. runbooks/inventory/Inventory_Modules.py +6130 -0
  111. runbooks/inventory/LandingZone/delete_lz.py +1075 -0
  112. runbooks/inventory/PASSED_SCRIPTS_GUIDE.md +738 -0
  113. runbooks/inventory/README.md +1320 -0
  114. runbooks/inventory/__init__.py +62 -0
  115. runbooks/inventory/account_class.py +532 -0
  116. runbooks/inventory/all_my_instances_wrapper.py +123 -0
  117. runbooks/inventory/aws_decorators.py +201 -0
  118. runbooks/inventory/aws_organization.png +0 -0
  119. runbooks/inventory/cfn_move_stack_instances.py +1526 -0
  120. runbooks/inventory/check_cloudtrail_compliance.py +614 -0
  121. runbooks/inventory/check_controltower_readiness.py +1107 -0
  122. runbooks/inventory/check_landingzone_readiness.py +711 -0
  123. runbooks/inventory/cloudtrail.md +727 -0
  124. runbooks/inventory/collectors/__init__.py +20 -0
  125. runbooks/inventory/collectors/aws_compute.py +518 -0
  126. runbooks/inventory/collectors/aws_networking.py +275 -0
  127. runbooks/inventory/collectors/base.py +222 -0
  128. runbooks/inventory/core/__init__.py +19 -0
  129. runbooks/inventory/core/collector.py +303 -0
  130. runbooks/inventory/core/formatter.py +296 -0
  131. runbooks/inventory/delete_s3_buckets_objects.py +169 -0
  132. runbooks/inventory/discovery.md +81 -0
  133. runbooks/inventory/draw_org_structure.py +748 -0
  134. runbooks/inventory/ec2_vpc_utils.py +341 -0
  135. runbooks/inventory/find_cfn_drift_detection.py +272 -0
  136. runbooks/inventory/find_cfn_orphaned_stacks.py +719 -0
  137. runbooks/inventory/find_cfn_stackset_drift.py +733 -0
  138. runbooks/inventory/find_ec2_security_groups.py +669 -0
  139. runbooks/inventory/find_landingzone_versions.py +201 -0
  140. runbooks/inventory/find_vpc_flow_logs.py +1221 -0
  141. runbooks/inventory/inventory.sh +659 -0
  142. runbooks/inventory/list_cfn_stacks.py +558 -0
  143. runbooks/inventory/list_cfn_stackset_operation_results.py +252 -0
  144. runbooks/inventory/list_cfn_stackset_operations.py +734 -0
  145. runbooks/inventory/list_cfn_stacksets.py +453 -0
  146. runbooks/inventory/list_config_recorders_delivery_channels.py +681 -0
  147. runbooks/inventory/list_ds_directories.py +354 -0
  148. runbooks/inventory/list_ec2_availability_zones.py +286 -0
  149. runbooks/inventory/list_ec2_ebs_volumes.py +244 -0
  150. runbooks/inventory/list_ec2_instances.py +425 -0
  151. runbooks/inventory/list_ecs_clusters_and_tasks.py +562 -0
  152. runbooks/inventory/list_elbs_load_balancers.py +411 -0
  153. runbooks/inventory/list_enis_network_interfaces.py +526 -0
  154. runbooks/inventory/list_guardduty_detectors.py +568 -0
  155. runbooks/inventory/list_iam_policies.py +404 -0
  156. runbooks/inventory/list_iam_roles.py +518 -0
  157. runbooks/inventory/list_iam_saml_providers.py +359 -0
  158. runbooks/inventory/list_lambda_functions.py +882 -0
  159. runbooks/inventory/list_org_accounts.py +446 -0
  160. runbooks/inventory/list_org_accounts_users.py +354 -0
  161. runbooks/inventory/list_rds_db_instances.py +406 -0
  162. runbooks/inventory/list_route53_hosted_zones.py +318 -0
  163. runbooks/inventory/list_servicecatalog_provisioned_products.py +575 -0
  164. runbooks/inventory/list_sns_topics.py +360 -0
  165. runbooks/inventory/list_ssm_parameters.py +402 -0
  166. runbooks/inventory/list_vpc_subnets.py +433 -0
  167. runbooks/inventory/list_vpcs.py +422 -0
  168. runbooks/inventory/lockdown_cfn_stackset_role.py +224 -0
  169. runbooks/inventory/models/__init__.py +24 -0
  170. runbooks/inventory/models/account.py +192 -0
  171. runbooks/inventory/models/inventory.py +309 -0
  172. runbooks/inventory/models/resource.py +247 -0
  173. runbooks/inventory/recover_cfn_stack_ids.py +205 -0
  174. runbooks/inventory/requirements.txt +12 -0
  175. runbooks/inventory/run_on_multi_accounts.py +211 -0
  176. runbooks/inventory/tests/common_test_data.py +3661 -0
  177. runbooks/inventory/tests/common_test_functions.py +204 -0
  178. runbooks/inventory/tests/setup.py +24 -0
  179. runbooks/inventory/tests/src.py +18 -0
  180. runbooks/inventory/tests/test_cfn_describe_stacks.py +208 -0
  181. runbooks/inventory/tests/test_ec2_describe_instances.py +162 -0
  182. runbooks/inventory/tests/test_inventory_modules.py +55 -0
  183. runbooks/inventory/tests/test_lambda_list_functions.py +86 -0
  184. runbooks/inventory/tests/test_moto_integration_example.py +273 -0
  185. runbooks/inventory/tests/test_org_list_accounts.py +49 -0
  186. runbooks/inventory/update_aws_actions.py +173 -0
  187. runbooks/inventory/update_cfn_stacksets.py +1215 -0
  188. runbooks/inventory/update_cloudwatch_logs_retention_policy.py +294 -0
  189. runbooks/inventory/update_iam_roles_cross_accounts.py +478 -0
  190. runbooks/inventory/update_s3_public_access_block.py +539 -0
  191. runbooks/inventory/utils/__init__.py +23 -0
  192. runbooks/inventory/utils/aws_helpers.py +510 -0
  193. runbooks/inventory/utils/threading_utils.py +493 -0
  194. runbooks/inventory/utils/validation.py +682 -0
  195. runbooks/inventory/verify_ec2_security_groups.py +1430 -0
  196. runbooks/main.py +1004 -0
  197. runbooks/organizations/__init__.py +12 -0
  198. runbooks/organizations/manager.py +374 -0
  199. runbooks/security/README.md +447 -0
  200. runbooks/security/__init__.py +71 -0
  201. runbooks/{security_baseline → security}/checklist/alternate_contacts.py +8 -1
  202. runbooks/{security_baseline → security}/checklist/bucket_public_access.py +4 -1
  203. runbooks/{security_baseline → security}/checklist/cloudwatch_alarm_configuration.py +9 -2
  204. runbooks/{security_baseline → security}/checklist/guardduty_enabled.py +9 -2
  205. runbooks/{security_baseline → security}/checklist/multi_region_instance_usage.py +5 -1
  206. runbooks/{security_baseline → security}/checklist/root_access_key.py +6 -1
  207. runbooks/{security_baseline → security}/config-origin.json +1 -1
  208. runbooks/{security_baseline → security}/config.json +1 -1
  209. runbooks/{security_baseline → security}/permission.json +1 -1
  210. runbooks/{security_baseline → security}/report_generator.py +10 -2
  211. runbooks/{security_baseline → security}/report_template_en.html +7 -7
  212. runbooks/{security_baseline → security}/report_template_jp.html +7 -7
  213. runbooks/{security_baseline → security}/report_template_kr.html +12 -12
  214. runbooks/{security_baseline → security}/report_template_vn.html +7 -7
  215. runbooks/{security_baseline → security}/run_script.py +8 -2
  216. runbooks/{security_baseline → security}/security_baseline_tester.py +12 -4
  217. runbooks/{security_baseline → security}/utils/common.py +5 -1
  218. runbooks/utils/__init__.py +204 -0
  219. runbooks-0.7.0.dist-info/METADATA +375 -0
  220. runbooks-0.7.0.dist-info/RECORD +249 -0
  221. {runbooks-0.2.5.dist-info → runbooks-0.7.0.dist-info}/WHEEL +1 -1
  222. runbooks-0.7.0.dist-info/entry_points.txt +7 -0
  223. runbooks-0.7.0.dist-info/licenses/LICENSE +201 -0
  224. runbooks-0.7.0.dist-info/top_level.txt +3 -0
  225. runbooks/python101/calculator.py +0 -34
  226. runbooks/python101/config.py +0 -1
  227. runbooks/python101/exceptions.py +0 -16
  228. runbooks/python101/file_manager.py +0 -218
  229. runbooks/python101/toolkit.py +0 -153
  230. runbooks-0.2.5.dist-info/METADATA +0 -439
  231. runbooks-0.2.5.dist-info/RECORD +0 -61
  232. runbooks-0.2.5.dist-info/entry_points.txt +0 -3
  233. runbooks-0.2.5.dist-info/top_level.txt +0 -1
  234. /runbooks/{security_baseline/__init__.py → inventory/tests/script_test_data.py} +0 -0
  235. /runbooks/{security_baseline → security}/checklist/__init__.py +0 -0
  236. /runbooks/{security_baseline → security}/checklist/account_level_bucket_public_access.py +0 -0
  237. /runbooks/{security_baseline → security}/checklist/direct_attached_policy.py +0 -0
  238. /runbooks/{security_baseline → security}/checklist/iam_password_policy.py +0 -0
  239. /runbooks/{security_baseline → security}/checklist/iam_user_mfa.py +0 -0
  240. /runbooks/{security_baseline → security}/checklist/multi_region_trail.py +0 -0
  241. /runbooks/{security_baseline → security}/checklist/root_mfa.py +0 -0
  242. /runbooks/{security_baseline → security}/checklist/root_usage.py +0 -0
  243. /runbooks/{security_baseline → security}/checklist/trail_enabled.py +0 -0
  244. /runbooks/{security_baseline → security}/checklist/trusted_advisor.py +0 -0
  245. /runbooks/{security_baseline → security}/utils/__init__.py +0 -0
  246. /runbooks/{security_baseline → security}/utils/enums.py +0 -0
  247. /runbooks/{security_baseline → security}/utils/language.py +0 -0
  248. /runbooks/{security_baseline → security}/utils/level_const.py +0 -0
  249. /runbooks/{security_baseline → security}/utils/permission_list.py +0 -0
@@ -0,0 +1,290 @@
1
+ """
2
+ Compliance Rule Validators for Cloud Foundations Assessment.
3
+
4
+ This module provides validation logic for different compliance frameworks
5
+ and security standards including:
6
+
7
+ - Security validation rules
8
+ - Compliance framework validation (SOC2, PCI-DSS, HIPAA)
9
+ - Operational best practices validation
10
+ - Custom validation rule support
11
+
12
+ Each validator implements specific validation logic and generates
13
+ assessment results with appropriate severity levels and remediation
14
+ guidance.
15
+ """
16
+
17
+ from abc import ABC, abstractmethod
18
+ from datetime import datetime
19
+ from typing import Any, Dict, List, Optional
20
+
21
+ from loguru import logger
22
+
23
+ from runbooks.cfat.models import (
24
+ AssessmentResult,
25
+ CheckStatus,
26
+ Severity,
27
+ )
28
+
29
+
30
+ class BaseValidator(ABC):
31
+ """Base class for compliance validators."""
32
+
33
+ def __init__(self, name: str, category: str, severity: Severity = Severity.WARNING):
34
+ """
35
+ Initialize validator.
36
+
37
+ Args:
38
+ name: Validator name
39
+ category: Assessment category
40
+ severity: Default severity level
41
+ """
42
+ self.name = name
43
+ self.category = category
44
+ self.severity = severity
45
+
46
+ @abstractmethod
47
+ def validate(self, resource_data: Dict[str, Any]) -> AssessmentResult:
48
+ """
49
+ Validate resource data against compliance rules.
50
+
51
+ Args:
52
+ resource_data: AWS resource data to validate
53
+
54
+ Returns:
55
+ Assessment result with validation outcome
56
+ """
57
+ pass
58
+
59
+ def _create_result(
60
+ self,
61
+ status: CheckStatus,
62
+ message: str,
63
+ finding_id: Optional[str] = None,
64
+ resource_arn: Optional[str] = None,
65
+ recommendations: Optional[List[str]] = None,
66
+ execution_time: float = 0.0,
67
+ ) -> AssessmentResult:
68
+ """
69
+ Create standardized assessment result.
70
+
71
+ Args:
72
+ status: Check status
73
+ message: Human-readable message
74
+ finding_id: Unique finding identifier
75
+ resource_arn: AWS resource ARN
76
+ recommendations: Remediation recommendations
77
+ execution_time: Validation execution time
78
+
79
+ Returns:
80
+ Formatted assessment result
81
+ """
82
+ return AssessmentResult(
83
+ finding_id=finding_id or f"{self.category.upper()}-{self.name.upper()}",
84
+ check_name=self.name,
85
+ check_category=self.category,
86
+ status=status,
87
+ severity=self.severity,
88
+ message=message,
89
+ resource_arn=resource_arn,
90
+ recommendations=recommendations or [],
91
+ execution_time=execution_time,
92
+ timestamp=datetime.utcnow(),
93
+ )
94
+
95
+
96
+ class SecurityValidator(BaseValidator):
97
+ """Security-focused validation rules."""
98
+
99
+ def __init__(self):
100
+ """Initialize security validator."""
101
+ super().__init__("security_validator", "security", Severity.CRITICAL)
102
+
103
+ def validate(self, resource_data: Dict[str, Any]) -> AssessmentResult:
104
+ """
105
+ Validate security configuration.
106
+
107
+ Args:
108
+ resource_data: Resource data to validate
109
+
110
+ Returns:
111
+ Security validation result
112
+ """
113
+ logger.debug(f"Running security validation: {self.name}")
114
+
115
+ # Example security validation logic
116
+ # TODO: Implement actual security validation rules
117
+
118
+ if self._check_root_mfa(resource_data):
119
+ return self._create_result(
120
+ status=CheckStatus.PASS,
121
+ message="Root account MFA is properly configured",
122
+ recommendations=["Continue monitoring root account access"],
123
+ )
124
+ else:
125
+ return self._create_result(
126
+ status=CheckStatus.FAIL,
127
+ message="Root account MFA is not enabled",
128
+ recommendations=[
129
+ "Enable MFA for the root account immediately",
130
+ "Use hardware MFA device for enhanced security",
131
+ "Restrict root account usage to emergency situations only",
132
+ ],
133
+ )
134
+
135
+ def _check_root_mfa(self, resource_data: Dict[str, Any]) -> bool:
136
+ """Check if root account MFA is enabled."""
137
+ # Placeholder implementation
138
+ iam_data = resource_data.get("iam", {})
139
+ return iam_data.get("root_account_mfa", False)
140
+
141
+
142
+ class ComplianceValidator(BaseValidator):
143
+ """Compliance framework validation rules."""
144
+
145
+ def __init__(self, framework: str = "SOC2"):
146
+ """
147
+ Initialize compliance validator.
148
+
149
+ Args:
150
+ framework: Target compliance framework
151
+ """
152
+ super().__init__(f"compliance_{framework.lower()}", "compliance", Severity.WARNING)
153
+ self.framework = framework
154
+
155
+ def validate(self, resource_data: Dict[str, Any]) -> AssessmentResult:
156
+ """
157
+ Validate compliance requirements.
158
+
159
+ Args:
160
+ resource_data: Resource data to validate
161
+
162
+ Returns:
163
+ Compliance validation result
164
+ """
165
+ logger.debug(f"Running {self.framework} compliance validation")
166
+
167
+ # Framework-specific validation logic
168
+ if self.framework.upper() == "SOC2":
169
+ return self._validate_soc2(resource_data)
170
+ elif self.framework.upper() == "PCI-DSS":
171
+ return self._validate_pci_dss(resource_data)
172
+ elif self.framework.upper() == "HIPAA":
173
+ return self._validate_hipaa(resource_data)
174
+ else:
175
+ return self._create_result(
176
+ status=CheckStatus.SKIP, message=f"Unknown compliance framework: {self.framework}"
177
+ )
178
+
179
+ def _validate_soc2(self, resource_data: Dict[str, Any]) -> AssessmentResult:
180
+ """Validate SOC2 compliance requirements."""
181
+ # Placeholder SOC2 validation
182
+ cloudtrail_data = resource_data.get("cloudtrail", {})
183
+ trails = cloudtrail_data.get("trails", [])
184
+
185
+ if trails:
186
+ return self._create_result(
187
+ status=CheckStatus.PASS,
188
+ message="SOC2: CloudTrail logging is enabled for audit trail",
189
+ recommendations=["Ensure CloudTrail logs are protected and monitored"],
190
+ )
191
+ else:
192
+ return self._create_result(
193
+ status=CheckStatus.FAIL,
194
+ message="SOC2: CloudTrail logging is not enabled",
195
+ recommendations=[
196
+ "Enable CloudTrail in all regions",
197
+ "Configure log file validation",
198
+ "Set up CloudTrail log monitoring and alerting",
199
+ ],
200
+ )
201
+
202
+ def _validate_pci_dss(self, resource_data: Dict[str, Any]) -> AssessmentResult:
203
+ """Validate PCI-DSS compliance requirements."""
204
+ # Placeholder PCI-DSS validation
205
+ return self._create_result(status=CheckStatus.SKIP, message="PCI-DSS validation not yet implemented")
206
+
207
+ def _validate_hipaa(self, resource_data: Dict[str, Any]) -> AssessmentResult:
208
+ """Validate HIPAA compliance requirements."""
209
+ # Placeholder HIPAA validation
210
+ return self._create_result(status=CheckStatus.SKIP, message="HIPAA validation not yet implemented")
211
+
212
+
213
+ class OperationalValidator(BaseValidator):
214
+ """Operational best practices validation."""
215
+
216
+ def __init__(self):
217
+ """Initialize operational validator."""
218
+ super().__init__("operational_validator", "operational", Severity.INFO)
219
+
220
+ def validate(self, resource_data: Dict[str, Any]) -> AssessmentResult:
221
+ """
222
+ Validate operational best practices.
223
+
224
+ Args:
225
+ resource_data: Resource data to validate
226
+
227
+ Returns:
228
+ Operational validation result
229
+ """
230
+ logger.debug("Running operational best practices validation")
231
+
232
+ # Example operational validation
233
+ # TODO: Implement actual operational validation rules
234
+
235
+ config_data = resource_data.get("config", {})
236
+ recorders = config_data.get("configuration_recorders", [])
237
+
238
+ if recorders:
239
+ return self._create_result(
240
+ status=CheckStatus.PASS,
241
+ message="AWS Config is enabled for configuration tracking",
242
+ recommendations=["Ensure Config rules are defined for compliance monitoring"],
243
+ )
244
+ else:
245
+ return self._create_result(
246
+ status=CheckStatus.FAIL,
247
+ message="AWS Config is not enabled",
248
+ severity=Severity.WARNING,
249
+ recommendations=[
250
+ "Enable AWS Config to track configuration changes",
251
+ "Configure Config rules for automated compliance checking",
252
+ "Set up Config remediation for automatic fixes",
253
+ ],
254
+ )
255
+
256
+
257
+ # Validation rule registry
258
+ VALIDATION_RULES = {
259
+ "security": SecurityValidator,
260
+ "compliance_soc2": lambda: ComplianceValidator("SOC2"),
261
+ "compliance_pci_dss": lambda: ComplianceValidator("PCI-DSS"),
262
+ "compliance_hipaa": lambda: ComplianceValidator("HIPAA"),
263
+ "operational": OperationalValidator,
264
+ }
265
+
266
+
267
+ def get_validator(rule_name: str) -> Optional[BaseValidator]:
268
+ """
269
+ Get validator instance by rule name.
270
+
271
+ Args:
272
+ rule_name: Name of the validation rule
273
+
274
+ Returns:
275
+ Validator instance or None if not found
276
+ """
277
+ validator_class = VALIDATION_RULES.get(rule_name)
278
+ if validator_class:
279
+ return validator_class()
280
+ return None
281
+
282
+
283
+ def list_available_validators() -> List[str]:
284
+ """
285
+ Get list of available validation rules.
286
+
287
+ Returns:
288
+ List of available validator names
289
+ """
290
+ return list(VALIDATION_RULES.keys())
runbooks/cfat/cli.py ADDED
@@ -0,0 +1,103 @@
1
+ """
2
+ Direct CLI interface for Cloud Foundations Assessment Tool (CFAT).
3
+
4
+ This module provides a standalone CLI entry point for CFAT that can be
5
+ accessed directly via 'cfat' or 'runbooks-cfat' commands.
6
+
7
+ This provides a focused interface for users who primarily use CFAT
8
+ and want direct access without the broader runbooks CLI structure.
9
+ """
10
+
11
+ import sys
12
+
13
+ import click
14
+ from loguru import logger
15
+
16
+ from runbooks.cfat import __version__ as cfat_version
17
+ from runbooks.main import assess as main_assess
18
+
19
+
20
+ @click.group(invoke_without_command=True)
21
+ @click.version_option(version=cfat_version)
22
+ @click.option("--debug", is_flag=True, help="Enable debug logging")
23
+ @click.option("--profile", default="default", help="AWS profile to use")
24
+ @click.option("--region", help="AWS region (overrides profile region)")
25
+ @click.pass_context
26
+ def main(ctx, debug, profile, region):
27
+ """
28
+ Cloud Foundations Assessment Tool (CFAT) - Direct CLI Access.
29
+
30
+ Enterprise-grade AWS Cloud Foundations assessment with comprehensive
31
+ reporting, parallel execution, and compliance framework alignment.
32
+
33
+ This tool evaluates AWS accounts against Cloud Foundations best practices
34
+ and generates actionable findings with remediation guidance.
35
+
36
+ Examples:
37
+ cfat assess --output html --severity CRITICAL
38
+ cfat assess --compliance-framework SOC2 --export-jira findings.csv
39
+ cfat assess --serve-web --web-port 8080
40
+
41
+ For full documentation: https://cloudops.oceansoft.io/runbooks/cfat/
42
+ """
43
+ # Initialize context for subcommands
44
+ ctx.ensure_object(dict)
45
+ ctx.obj["debug"] = debug
46
+ ctx.obj["profile"] = profile
47
+ ctx.obj["region"] = region
48
+
49
+ # Setup logging
50
+ if debug:
51
+ logger.remove()
52
+ logger.add(sys.stderr, level="DEBUG")
53
+
54
+ # Show help if no command provided
55
+ if ctx.invoked_subcommand is None:
56
+ click.echo(ctx.get_help())
57
+
58
+
59
+ # Import and register the assess command from main CLI
60
+ # This reuses the enhanced assess command with all its features
61
+ main.add_command(main_assess, name="assess")
62
+
63
+
64
+ @main.command()
65
+ @click.pass_context
66
+ def version(ctx):
67
+ """Show CFAT version information."""
68
+ click.echo(f"Cloud Foundations Assessment Tool (CFAT) version {cfat_version}")
69
+ click.echo("Part of CloudOps Runbooks - Enterprise CloudOps Automation")
70
+ click.echo("Documentation: https://cloudops.oceansoft.io/runbooks/cfat/")
71
+
72
+
73
+ @main.command()
74
+ @click.pass_context
75
+ def status(ctx):
76
+ """Show CFAT status and configuration."""
77
+ click.echo("šŸ” Cloud Foundations Assessment Tool Status")
78
+ click.echo(f"Version: {cfat_version}")
79
+ click.echo(f"Profile: {ctx.obj['profile']}")
80
+ click.echo(f"Region: {ctx.obj['region'] or 'Default from profile'}")
81
+ click.echo(f"Debug: {ctx.obj['debug']}")
82
+
83
+ # Show available assessment categories
84
+ click.echo("\nšŸ“‹ Available Assessment Categories:")
85
+ categories = ["iam", "vpc", "ec2", "cloudtrail", "config", "organizations", "cloudformation"]
86
+ for category in categories:
87
+ click.echo(f" • {category}")
88
+
89
+ # Show available output formats
90
+ click.echo("\nšŸ“„ Available Output Formats:")
91
+ formats = ["console", "html", "csv", "json", "markdown", "all"]
92
+ for fmt in formats:
93
+ click.echo(f" • {fmt}")
94
+
95
+ # Show available exporters
96
+ click.echo("\nšŸ”— Available Export Integrations:")
97
+ exporters = ["jira", "asana", "servicenow"]
98
+ for exporter in exporters:
99
+ click.echo(f" • {exporter}")
100
+
101
+
102
+ if __name__ == "__main__":
103
+ main()
@@ -0,0 +1,24 @@
1
+ "Task", "Description", "Status"
2
+ "cfat - Delete VPC in ap-south-1", "Delete any unnecessary VPC in ap-south-1 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
3
+ "cfat - Delete VPC in eu-north-1", "Delete any unnecessary VPC in eu-north-1 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
4
+ "cfat - Delete VPC in eu-west-3", "Delete any unnecessary VPC in eu-west-3 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
5
+ "cfat - Delete VPC in eu-west-2", "Delete any unnecessary VPC in eu-west-2 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
6
+ "cfat - Delete VPC in eu-west-1", "Delete any unnecessary VPC in eu-west-1 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
7
+ "cfat - Delete VPC in ap-northeast-3", "Delete any unnecessary VPC in ap-northeast-3 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
8
+ "cfat - Delete VPC in ap-northeast-2", "Delete any unnecessary VPC in ap-northeast-2 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
9
+ "cfat - Delete VPC in ap-northeast-1", "Delete any unnecessary VPC in ap-northeast-1 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
10
+ "cfat - Delete VPC in ca-central-1", "Delete any unnecessary VPC in ca-central-1 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
11
+ "cfat - Delete VPC in sa-east-1", "Delete any unnecessary VPC in sa-east-1 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
12
+ "cfat - Delete VPC in ap-southeast-1", "Delete any unnecessary VPC in ap-southeast-1 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
13
+ "cfat - Delete VPC in ap-southeast-2", "Delete any unnecessary VPC in ap-southeast-2 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
14
+ "cfat - Delete VPC in eu-central-1", "Delete any unnecessary VPC in eu-central-1 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
15
+ "cfat - Delete VPC in us-east-1", "Delete any unnecessary VPC in us-east-1 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
16
+ "cfat - Delete VPC in us-east-2", "Delete any unnecessary VPC in us-east-2 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
17
+ "cfat - Delete VPC in us-west-1", "Delete any unnecessary VPC in us-west-1 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
18
+ "cfat - Delete VPC in us-west-2", "Delete any unnecessary VPC in us-west-2 to include the default VPC. - Remediation Link: https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md", "Not Started"
19
+ "cfat - Setup legacy CUR", "Setup legacy CUR in AWS Organization - Remediation Link: https://docs.aws.amazon.com/cur/latest/userguide/dataexports-create-legacy.html", "Not Started"
20
+ "cfat - Review account email addresses", "Review Account Email Addresses in AWS Organization - Remediation Link: https://docs.aws.amazon.com/IAM/latest/UserGuide/root-user-best-practices.html#ru-bp-group", "Not Started"
21
+ "cfat - Delegate administration of AWS Config", "Delegate administration to AWS Config - Remediation Link: https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-config.html", "Not Started"
22
+ "cfat - Delegate administration of AWS Account management", "Delegate administration to AWS Account contact management - Remediation Link: https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-account.html#integrate-enable-da-account", "Not Started"
23
+ "cfat - Enable AWS Backup", "Enable AWS Backup in AWS Organization - Remediation Link: https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-backup.html#integrate-enable-ta-backup", "Not Started"
24
+ "cfat - Delegate administration of AWS Backup", "Delegate administration to AWS Backup - Remediation Link: https://docs.aws.amazon.com/aws-backup/latest/devguide/manage-cross-account.html#backup-delegatedadmin", "Not Started"
@@ -0,0 +1,31 @@
1
+ check,description,status,required,weight,loe,remediationLink
2
+ "AWS Organization created","AWS Organization is enabled.","complete",true,6,1,"https://aws.amazon.com/organizations/getting-started/"
3
+ "Management Account created","AWS Management account exists.","complete",true,6,1,"https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-creating.html"
4
+ "Management Account IAM users removed","IAM Users should not exist in Management Account.","complete",false,4,1,"https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_manage.html#id_users_deleting"
5
+ "Management Account EC2 instances removed","EC2 Instances should not exist in Management Account.","incomplete",false,4,1,"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/terminating-instances.html"
6
+ "Management Account VPCs removed","Management Account should not have any VPCs.","incomplete",false,4,1,"https://github.com/cloud-foundations-on-aws/cloud-foundations-templates/blob/main/network/network-default-vpc-deletion/README.md"
7
+ "CloudTrail Trail created","CloudTrail should be enabled within the account.","complete",true,6,3,"https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-trail-organization.html"
8
+ "CloudTrail Organization Service enabled","CloudTrail should be enabled on the Organization.","complete",true,6,1,"https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-cloudtrail.html"
9
+ "CloudTrail Org Trail deployed","At least one CloudTrail Organization Trail should be enabled.","complete",true,6,1,"https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-trail-organization.html"
10
+ "Config Recorder in Management Account configured","Config Recorder in the Management Account should be enabled.","incomplete",true,6,2,"https://aws.amazon.com/blogs/mt/managing-aws-organizations-accounts-using-aws-config-and-aws-cloudformation-stacksets/"
11
+ "Config Delivery Channel in Management Account configured","Config Delivery Channel in Management Account should be enabled.","incomplete",true,6,2,"https://aws.amazon.com/blogs/mt/managing-aws-organizations-accounts-using-aws-config-and-aws-cloudformation-stacksets/"
12
+ "CloudFormation StackSets activated","CloudFormation StackSets should be activated in the CloudFormation console.","incomplete",false,5,1,"https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-cloudformation.html#integrate-enable-ta-cloudformation"
13
+ "GuardDuty Organization service enabled","GuardDuty Organization services should be enabled.","complete",false,4,1,"https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-guardduty.html#integrate-enable-ta-guardduty"
14
+ "RAM Organization service enabled","Resource Access Manager (RAM) trusted access should be enabled in the AWS Organization.","complete",false,4,1,"https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-ram.html#integrate-enable-ta-ram"
15
+ "Security Hub Organization service enabled","Security Hub trusted access should be enabled in the AWS Organization.","complete",false,4,1,"https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-securityhub.html#integrate-enable-ta-securityhub"
16
+ "IAM Access Analyzer Organization service enabled","IAM Access Analyzer trusted access should be enabled in the AWS Organization.","complete",false,4,1,"https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#access-analyzer-enabling"
17
+ "Config Organization service enabled","AWS Config trusted access should be enabled in the AWS Organization.","complete",false,4,1,"https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-config.html#integrate-enable-ta-config"
18
+ "CloudFormation Organization service enabled","CloudFormation trusted access should be enabled in the AWS Organization.","complete",false,5,1,"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-activate-trusted-access.html"
19
+ "Top-level Infrastructure OU deployed","Top-level Infrastructure OU should exist.","complete",false,5,2,"https://catalog.workshops.aws/control-tower/en-US/introduction/manage-ou"
20
+ "Top-level Security OU deployed","Top-level Security OU should exist.","complete",true,6,2,"https://catalog.workshops.aws/control-tower/en-US/introduction/manage-ou"
21
+ "Top-level Workloads OU deployed","Top-level Workloads OU should exist.","complete",false,5,2,"https://catalog.workshops.aws/control-tower/en-US/introduction/manage-ou"
22
+ "IAM IdC Organization service enabled","IAM Identity Center trusted access should be enabled in the AWS Organization","complete",true,6,1,"https://docs.aws.amazon.com/singlesignon/latest/userguide/get-set-up-for-idc.html"
23
+ "IAM IdC configured","IAM Identity Center should be configured.","complete",true,6,3,"https://docs.aws.amazon.com/singlesignon/latest/userguide/tutorials.html"
24
+ "Service Control Policies enabled","Service Control Policy should be enabled within the AWS Organization.","complete",true,6,1,"https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_enable-disable.html"
25
+ "Organization Tag Policy enabled","Tag Policy should be enabled within the AWS Organization.","complete",true,6,1,"https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_enable-disable.html"
26
+ "Organization Backup Policy enabled","Backup Policy should be enabled within the AWS Organization.","complete",false,5,1,"https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_enable-disable.html"
27
+ "Control Tower deployed","Control Tower should be deployed.","complete",true,6,6,"https://catalog.workshops.aws/control-tower/en-US/prerequisites/deploying"
28
+ "Control Tower latest version","Control Tower should be the latest version.","complete",false,5,2,"https://docs.aws.amazon.com/controltower/latest/userguide/update-controltower.html"
29
+ "Control Tower not drifted","Control Tower should not be drifted.","complete",true,6,2,"https://docs.aws.amazon.com/controltower/latest/userguide/resolve-drift.html"
30
+ "Log Archive account deployed","Log Archive account should exist.","complete",true,6,2,"https://docs.aws.amazon.com/controltower/latest/userguide/getting-started-from-console.html"
31
+ "Audit account deployed","Audit/Security Tooling account should exist.","complete",true,6,2,"https://docs.aws.amazon.com/controltower/latest/userguide/getting-started-from-console.html"