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,38 @@
1
+ {
2
+ "type": "module",
3
+ "devDependencies": {
4
+ "@types/node": "^20.17.47",
5
+ "typescript": "^5.3.3"
6
+ },
7
+ "scripts": {
8
+ "start": "node ./build/app.js",
9
+ "lint": "eslint '*.ts' --quiet --fix",
10
+ "build": "rm -rf ./build && tsc"
11
+ },
12
+ "dependencies": {
13
+ "@aws-sdk/client-cloudformation": "^3.645.0",
14
+ "@aws-sdk/client-cloudtrail": "^3.645.0",
15
+ "@aws-sdk/client-config-service": "^3.645.0",
16
+ "@aws-sdk/client-controltower": "^3.645.0",
17
+ "@aws-sdk/client-cost-and-usage-report-service": "^3.645.0",
18
+ "@aws-sdk/client-cost-explorer": "^3.645.0",
19
+ "@aws-sdk/client-ec2": "^3.645.0",
20
+ "@aws-sdk/client-iam": "^3.645.0",
21
+ "@aws-sdk/client-organizations": "^3.645.0",
22
+ "@aws-sdk/client-ram": "^3.645.0",
23
+ "@aws-sdk/client-sso-admin": "^3.645.0",
24
+ "@types/archiver": "^6.0.2",
25
+ "@typescript-eslint/parser": "^5.10.2",
26
+ "archiver": "^7.0.1",
27
+ "eslint": "^8.8.0",
28
+ "eslint-config-prettier": "^8.3.0",
29
+ "eslint-plugin-prettier": "^4.0.0",
30
+ "prettier": "^2.5.1",
31
+ "ts-loader": "^9.5.1",
32
+ "ts-node": "^10.9.1",
33
+ "typescript": "^4.8.4",
34
+ "webpack": "^5.94.0",
35
+ "webpack-cli": "^5.1.4",
36
+ "webpack-node-externals": "^3.0.0"
37
+ }
38
+ }
@@ -0,0 +1,496 @@
1
+ """
2
+ Report generation for Cloud Foundations Assessment Tool.
3
+
4
+ This module provides various report formats including HTML, CSV, and JSON
5
+ for assessment results.
6
+ """
7
+
8
+ from pathlib import Path
9
+ from typing import Union
10
+
11
+ from loguru import logger
12
+
13
+ from runbooks.cfat.models import AssessmentReport, CheckStatus, Severity
14
+
15
+
16
+ class HTMLReportGenerator:
17
+ """Generate HTML reports for CFAT assessments."""
18
+
19
+ def __init__(self, report: AssessmentReport):
20
+ """Initialize with assessment report."""
21
+ self.report = report
22
+
23
+ def generate(self, file_path: Union[str, Path]) -> None:
24
+ """Generate HTML report file."""
25
+ output_path = Path(file_path)
26
+ output_path.parent.mkdir(parents=True, exist_ok=True)
27
+
28
+ html_content = self._generate_html()
29
+
30
+ with open(output_path, "w", encoding="utf-8") as f:
31
+ f.write(html_content)
32
+
33
+ logger.info(f"HTML report generated: {output_path}")
34
+
35
+ def _generate_html(self) -> str:
36
+ """Generate the complete HTML content."""
37
+ return f"""
38
+ <!DOCTYPE html>
39
+ <html lang="en">
40
+ <head>
41
+ <meta charset="UTF-8">
42
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
43
+ <title>Cloud Foundations Assessment Report</title>
44
+ <style>
45
+ {self._get_css_styles()}
46
+ </style>
47
+ </head>
48
+ <body>
49
+ <div class="container">
50
+ {self._generate_header()}
51
+ {self._generate_summary()}
52
+ {self._generate_results_table()}
53
+ {self._generate_recommendations()}
54
+ {self._generate_footer()}
55
+ </div>
56
+ <script>
57
+ {self._get_javascript()}
58
+ </script>
59
+ </body>
60
+ </html>
61
+ """
62
+
63
+ def _get_css_styles(self) -> str:
64
+ """Get CSS styles for the HTML report."""
65
+ return """
66
+ body {
67
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
68
+ margin: 0;
69
+ padding: 20px;
70
+ background-color: #f5f5f5;
71
+ color: #333;
72
+ }
73
+
74
+ .container {
75
+ max-width: 1200px;
76
+ margin: 0 auto;
77
+ background-color: white;
78
+ border-radius: 8px;
79
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
80
+ overflow: hidden;
81
+ }
82
+
83
+ .header {
84
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
85
+ color: white;
86
+ padding: 30px;
87
+ text-align: center;
88
+ }
89
+
90
+ .header h1 {
91
+ margin: 0;
92
+ font-size: 2.5em;
93
+ font-weight: 300;
94
+ }
95
+
96
+ .header .subtitle {
97
+ margin-top: 10px;
98
+ opacity: 0.9;
99
+ font-size: 1.1em;
100
+ }
101
+
102
+ .summary {
103
+ padding: 30px;
104
+ background-color: #fafafa;
105
+ border-bottom: 1px solid #eee;
106
+ }
107
+
108
+ .summary-grid {
109
+ display: grid;
110
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
111
+ gap: 20px;
112
+ margin-top: 20px;
113
+ }
114
+
115
+ .summary-card {
116
+ background: white;
117
+ padding: 20px;
118
+ border-radius: 8px;
119
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
120
+ text-align: center;
121
+ }
122
+
123
+ .summary-card .number {
124
+ font-size: 2em;
125
+ font-weight: bold;
126
+ margin-bottom: 5px;
127
+ }
128
+
129
+ .summary-card .label {
130
+ color: #666;
131
+ font-size: 0.9em;
132
+ }
133
+
134
+ .pass { color: #4CAF50; }
135
+ .fail { color: #f44336; }
136
+ .warning { color: #ff9800; }
137
+ .critical { color: #d32f2f; }
138
+ .info { color: #2196F3; }
139
+
140
+ .results {
141
+ padding: 30px;
142
+ }
143
+
144
+ .filters {
145
+ margin-bottom: 20px;
146
+ display: flex;
147
+ gap: 10px;
148
+ flex-wrap: wrap;
149
+ }
150
+
151
+ .filter-btn {
152
+ padding: 8px 16px;
153
+ border: 1px solid #ddd;
154
+ background: white;
155
+ border-radius: 4px;
156
+ cursor: pointer;
157
+ transition: all 0.3s;
158
+ }
159
+
160
+ .filter-btn:hover {
161
+ background: #f0f0f0;
162
+ }
163
+
164
+ .filter-btn.active {
165
+ background: #2196F3;
166
+ color: white;
167
+ border-color: #2196F3;
168
+ }
169
+
170
+ .results-table {
171
+ width: 100%;
172
+ border-collapse: collapse;
173
+ margin-top: 20px;
174
+ }
175
+
176
+ .results-table th,
177
+ .results-table td {
178
+ padding: 12px;
179
+ text-align: left;
180
+ border-bottom: 1px solid #eee;
181
+ }
182
+
183
+ .results-table th {
184
+ background-color: #f8f9fa;
185
+ font-weight: 600;
186
+ color: #555;
187
+ }
188
+
189
+ .results-table tr:hover {
190
+ background-color: #f8f9fa;
191
+ }
192
+
193
+ .status-badge {
194
+ padding: 4px 8px;
195
+ border-radius: 4px;
196
+ font-size: 0.8em;
197
+ font-weight: bold;
198
+ text-transform: uppercase;
199
+ }
200
+
201
+ .status-pass {
202
+ background-color: #e8f5e8;
203
+ color: #2e7d32;
204
+ }
205
+
206
+ .status-fail {
207
+ background-color: #ffebee;
208
+ color: #c62828;
209
+ }
210
+
211
+ .status-error {
212
+ background-color: #fff3e0;
213
+ color: #ef6c00;
214
+ }
215
+
216
+ .severity-badge {
217
+ padding: 4px 8px;
218
+ border-radius: 4px;
219
+ font-size: 0.8em;
220
+ font-weight: bold;
221
+ }
222
+
223
+ .severity-info {
224
+ background-color: #e3f2fd;
225
+ color: #1976d2;
226
+ }
227
+
228
+ .severity-warning {
229
+ background-color: #fff8e1;
230
+ color: #f57c00;
231
+ }
232
+
233
+ .severity-critical {
234
+ background-color: #ffebee;
235
+ color: #d32f2f;
236
+ }
237
+
238
+ .recommendations {
239
+ padding: 30px;
240
+ background-color: #f8f9fa;
241
+ }
242
+
243
+ .footer {
244
+ padding: 20px 30px;
245
+ background-color: #666;
246
+ color: white;
247
+ text-align: center;
248
+ font-size: 0.9em;
249
+ }
250
+
251
+ .expandable {
252
+ cursor: pointer;
253
+ }
254
+
255
+ .details {
256
+ display: none;
257
+ margin-top: 10px;
258
+ padding: 10px;
259
+ background-color: #f8f9fa;
260
+ border-radius: 4px;
261
+ font-size: 0.9em;
262
+ }
263
+
264
+ @media (max-width: 768px) {
265
+ .container {
266
+ margin: 10px;
267
+ }
268
+
269
+ .header {
270
+ padding: 20px;
271
+ }
272
+
273
+ .header h1 {
274
+ font-size: 2em;
275
+ }
276
+
277
+ .summary,
278
+ .results {
279
+ padding: 20px;
280
+ }
281
+
282
+ .results-table {
283
+ font-size: 0.9em;
284
+ }
285
+ }
286
+ """
287
+
288
+ def _generate_header(self) -> str:
289
+ """Generate the report header."""
290
+ return f"""
291
+ <div class="header">
292
+ <h1>Cloud Foundations Assessment Report</h1>
293
+ <div class="subtitle">
294
+ Account: {self.report.account_id} |
295
+ Region: {self.report.region} |
296
+ Generated: {self.report.timestamp.strftime("%Y-%m-%d %H:%M:%S")}
297
+ </div>
298
+ </div>
299
+ """
300
+
301
+ def _generate_summary(self) -> str:
302
+ """Generate the summary section."""
303
+ summary = self.report.summary
304
+
305
+ return f"""
306
+ <div class="summary">
307
+ <h2>Assessment Summary</h2>
308
+ <div class="summary-grid">
309
+ <div class="summary-card">
310
+ <div class="number">{summary.total_checks}</div>
311
+ <div class="label">Total Checks</div>
312
+ </div>
313
+ <div class="summary-card">
314
+ <div class="number pass">{summary.passed_checks}</div>
315
+ <div class="label">Passed</div>
316
+ </div>
317
+ <div class="summary-card">
318
+ <div class="number fail">{summary.failed_checks}</div>
319
+ <div class="label">Failed</div>
320
+ </div>
321
+ <div class="summary-card">
322
+ <div class="number warning">{summary.warnings}</div>
323
+ <div class="label">Warnings</div>
324
+ </div>
325
+ <div class="summary-card">
326
+ <div class="number critical">{summary.critical_issues}</div>
327
+ <div class="label">Critical Issues</div>
328
+ </div>
329
+ <div class="summary-card">
330
+ <div class="number info">{summary.pass_rate:.1f}%</div>
331
+ <div class="label">Pass Rate</div>
332
+ </div>
333
+ </div>
334
+ </div>
335
+ """
336
+
337
+ def _generate_results_table(self) -> str:
338
+ """Generate the results table."""
339
+ table_rows = ""
340
+
341
+ for result in self.report.results:
342
+ status_class = f"status-{result.status.value.lower()}"
343
+ severity_class = f"severity-{result.severity.value.lower()}"
344
+
345
+ table_rows += f"""
346
+ <tr class="result-row expandable" onclick="toggleDetails(this)">
347
+ <td>{result.check_name}</td>
348
+ <td>{result.check_category}</td>
349
+ <td><span class="status-badge {status_class}">{result.status.value}</span></td>
350
+ <td><span class="severity-badge {severity_class}">{result.severity.value}</span></td>
351
+ <td>{result.message}</td>
352
+ <td>{result.execution_time:.2f}s</td>
353
+ </tr>
354
+ """
355
+
356
+ if result.recommendations:
357
+ recommendations_html = "<ul>" + "".join(f"<li>{rec}</li>" for rec in result.recommendations) + "</ul>"
358
+ table_rows += f"""
359
+ <tr class="details-row">
360
+ <td colspan="6">
361
+ <div class="details">
362
+ <strong>Recommendations:</strong>
363
+ {recommendations_html}
364
+ </div>
365
+ </td>
366
+ </tr>
367
+ """
368
+
369
+ return f"""
370
+ <div class="results">
371
+ <h2>Assessment Results</h2>
372
+ <div class="filters">
373
+ <button class="filter-btn active" onclick="filterResults('all')">All</button>
374
+ <button class="filter-btn" onclick="filterResults('fail')">Failed</button>
375
+ <button class="filter-btn" onclick="filterResults('pass')">Passed</button>
376
+ <button class="filter-btn" onclick="filterResults('critical')">Critical</button>
377
+ <button class="filter-btn" onclick="filterResults('warning')">Warning</button>
378
+ </div>
379
+
380
+ <table class="results-table">
381
+ <thead>
382
+ <tr>
383
+ <th>Check Name</th>
384
+ <th>Category</th>
385
+ <th>Status</th>
386
+ <th>Severity</th>
387
+ <th>Message</th>
388
+ <th>Execution Time</th>
389
+ </tr>
390
+ </thead>
391
+ <tbody>
392
+ {table_rows}
393
+ </tbody>
394
+ </table>
395
+ </div>
396
+ """
397
+
398
+ def _generate_recommendations(self) -> str:
399
+ """Generate recommendations section."""
400
+ failed_results = self.report.get_failed_results()
401
+
402
+ if not failed_results:
403
+ return """
404
+ <div class="recommendations">
405
+ <h2>Recommendations</h2>
406
+ <p>Congratulations! All assessment checks passed successfully.</p>
407
+ </div>
408
+ """
409
+
410
+ recommendations_html = ""
411
+ for result in failed_results:
412
+ if result.recommendations:
413
+ recommendations_html += f"""
414
+ <div class="recommendation-item">
415
+ <h4>{result.check_name}</h4>
416
+ <ul>
417
+ {"".join(f"<li>{rec}</li>" for rec in result.recommendations)}
418
+ </ul>
419
+ </div>
420
+ """
421
+
422
+ return f"""
423
+ <div class="recommendations">
424
+ <h2>Recommendations</h2>
425
+ <p>Based on the assessment results, here are the recommended actions to improve your AWS account security and compliance:</p>
426
+ {recommendations_html}
427
+ </div>
428
+ """
429
+
430
+ def _generate_footer(self) -> str:
431
+ """Generate the report footer."""
432
+ return f"""
433
+ <div class="footer">
434
+ Generated by CloudOps Runbooks v{self.report.version} |
435
+ Execution time: {self.report.summary.total_execution_time:.1f}s |
436
+ Profile: {self.report.profile}
437
+ </div>
438
+ """
439
+
440
+ def _get_javascript(self) -> str:
441
+ """Get JavaScript for interactive features."""
442
+ return """
443
+ function toggleDetails(row) {
444
+ const detailsRow = row.nextElementSibling;
445
+ if (detailsRow && detailsRow.classList.contains('details-row')) {
446
+ const details = detailsRow.querySelector('.details');
447
+ if (details.style.display === 'none' || details.style.display === '') {
448
+ details.style.display = 'block';
449
+ } else {
450
+ details.style.display = 'none';
451
+ }
452
+ }
453
+ }
454
+
455
+ function filterResults(filter) {
456
+ const rows = document.querySelectorAll('.result-row');
457
+ const buttons = document.querySelectorAll('.filter-btn');
458
+
459
+ // Update active button
460
+ buttons.forEach(btn => btn.classList.remove('active'));
461
+ event.target.classList.add('active');
462
+
463
+ rows.forEach(row => {
464
+ const statusBadge = row.querySelector('.status-badge');
465
+ const severityBadge = row.querySelector('.severity-badge');
466
+ const detailsRow = row.nextElementSibling;
467
+
468
+ let show = false;
469
+
470
+ if (filter === 'all') {
471
+ show = true;
472
+ } else if (filter === 'fail') {
473
+ show = statusBadge && statusBadge.textContent.toLowerCase() === 'fail';
474
+ } else if (filter === 'pass') {
475
+ show = statusBadge && statusBadge.textContent.toLowerCase() === 'pass';
476
+ } else if (filter === 'critical') {
477
+ show = severityBadge && severityBadge.textContent.toLowerCase() === 'critical';
478
+ } else if (filter === 'warning') {
479
+ show = severityBadge && severityBadge.textContent.toLowerCase() === 'warning';
480
+ }
481
+
482
+ row.style.display = show ? '' : 'none';
483
+ if (detailsRow && detailsRow.classList.contains('details-row')) {
484
+ detailsRow.style.display = show ? '' : 'none';
485
+ }
486
+ });
487
+ }
488
+
489
+ // Initialize details as hidden
490
+ document.addEventListener('DOMContentLoaded', function() {
491
+ const details = document.querySelectorAll('.details');
492
+ details.forEach(detail => {
493
+ detail.style.display = 'none';
494
+ });
495
+ });
496
+ """
@@ -0,0 +1,46 @@
1
+ """
2
+ Reporting Module for Cloud Foundations Assessment Tool.
3
+
4
+ This module provides comprehensive report generation capabilities
5
+ in multiple formats including:
6
+
7
+ - Interactive HTML reports with charts and filtering
8
+ - CSV exports for spreadsheet analysis
9
+ - JSON data for programmatic processing
10
+ - Markdown documentation format
11
+ - Executive summaries for management
12
+
13
+ The reporting system supports:
14
+ - Customizable templates and styling
15
+ - Real-time data visualization
16
+ - Multi-format export capabilities
17
+ - Project management tool integration
18
+ - Compliance framework reporting
19
+ """
20
+
21
+ from runbooks.cfat.reporting.exporters import (
22
+ AsanaExporter,
23
+ JiraExporter,
24
+ ServiceNowExporter,
25
+ )
26
+ from runbooks.cfat.reporting.formatters import (
27
+ HTMLReportGenerator,
28
+ )
29
+ from runbooks.cfat.reporting.templates import (
30
+ ComplianceTemplate,
31
+ ExecutiveTemplate,
32
+ TechnicalTemplate,
33
+ )
34
+
35
+ __all__ = [
36
+ # Report generators
37
+ "HTMLReportGenerator",
38
+ # Report templates
39
+ "ExecutiveTemplate",
40
+ "TechnicalTemplate",
41
+ "ComplianceTemplate",
42
+ # Export integrations
43
+ "JiraExporter",
44
+ "AsanaExporter",
45
+ "ServiceNowExporter",
46
+ ]