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,447 @@
1
+ # CloudOps Runbooks: Security Baseline Assessment
2
+
3
+ ## 📖 Overview
4
+
5
+ The **CloudOps Runbooks: Security Baseline Assessment** is a comprehensive tool designed to evaluate the security of AWS environments in accordance with basic security advisories. It provides a structured way to assess your account and workload configurations against **AWS security best practices** and the **AWS Startup Security Baseline (SSB)**.
6
+
7
+ **Fully integrated with the CloudOps Runbooks CLI**, this tool offers enterprise-grade security assessment capabilities with multilingual reporting, parallel execution, and comprehensive remediation guidance. The tool is designed for DevOps teams, SRE engineers, and security professionals who need automated, actionable security insights.
8
+
9
+ By automating **15+ critical AWS account security and workload security checks**, this solution empowers startups, enterprises, and DevOps teams to validate their cloud security posture, generate actionable reports, and align with AWS Well-Architected principles.
10
+
11
+ Key capabilities include:
12
+ - **Enterprise CLI Integration**: Seamlessly integrated with `runbooks security` commands
13
+ - **Multilingual Reports**: Generate reports in English, Japanese, Korean, and Vietnamese
14
+ - **Parallel Execution**: Fast assessment with configurable worker pools
15
+ - **Rich Console Output**: Beautiful terminal output with progress indicators
16
+ - **Multiple Output Formats**: HTML reports with actionable remediation steps
17
+
18
+ In the **Test Report**, we provide numerous techniques for successfully responding to security threats on AWS with minimal resources. This script is appropriate for usage by early-stage businesses that cannot afford to invest much in security. 
19
+
20
+
21
+ ## ✨ Features: Core Capabilities
22
+
23
+ 1. **🚀 Enterprise CLI Integration**:
24
+ - Seamlessly integrated with `runbooks security` commands for professional workflows
25
+ - Rich console output with progress indicators and beautiful terminal formatting
26
+ - Unified CLI interface with other CloudOps tools (CFAT, inventory, organizations)
27
+
28
+ 2. **🌍 Multilingual Reporting**:
29
+ - Generate reports in **4 languages**: English, Korean, Japanese, Vietnamese
30
+ - Localized error messages and remediation guidance
31
+ - Cultural context for international DevOps teams
32
+
33
+ 3. **⚡ Performance & Scalability**:
34
+ - Parallel execution with configurable worker pools for faster assessments
35
+ - Modern dependency management with UV (Rust-based package manager)
36
+ - Optimized AWS API calls to minimize execution time
37
+
38
+ 4. **📊 Comprehensive Security Coverage**:
39
+ - **15+ critical security checks** covering account, IAM, infrastructure, and operational security
40
+ - Validates IAM configurations, S3 bucket policies, VPC security groups, and CloudTrail settings
41
+ - Aligned with AWS Security Best Practices and Well-Architected Framework
42
+
43
+ 5. **🔧 Multiple Output Formats**:
44
+ - **HTML reports** with interactive elements and remediation links
45
+ - **JSON output** for programmatic processing and CI/CD integration
46
+ - **Console output** for immediate feedback and debugging
47
+
48
+ 6. **🛡️ Enterprise Security Features**:
49
+ - Support for multiple AWS authentication methods (IAM roles, SSO, CloudShell)
50
+ - Read-only permissions ensuring compliance with **least privilege principle**
51
+ - Audit trail and logging for compliance requirements
52
+
53
+ 7. **🔄 CI/CD Integration Ready**:
54
+ - Designed for automated security scanning in pipelines
55
+ - JSON output format for integration with security dashboards
56
+ - Exit codes and structured logging for automation scripts
57
+
58
+ ---
59
+
60
+ ## 📂 File Structure
61
+
62
+ This modular structure ensures maintainability and supports seamless integration into pipelines or ad hoc testing.
63
+
64
+ ```plaintext
65
+ src/runbooks/
66
+ ├── security/ # Integrated security module
67
+ │ ├── checklist/ # Security check modules
68
+ │ │ ├── iam_password_policy.py # Checks IAM password policy
69
+ │ │ ├── bucket_public_access.py # Validates S3 bucket policies
70
+ │ │ ├── root_mfa.py # Root account MFA validation
71
+ │ │ ├── cloudtrail_enabled.py # CloudTrail configuration checks
72
+ │ │ └── ... # More checks for IAM, S3, CloudTrail, etc.
73
+ │ ├── utils/ # Core utilities and constants
74
+ │ │ ├── common.py # Shared helper functions
75
+ │ │ ├── enums.py # Enumerations for reporting
76
+ │ │ ├── language.py # Multi-language support
77
+ │ │ └── permission_list.py # IAM permissions for checks
78
+ │ ├── config.json # Configurable parameters for checks
79
+ │ ├── permission.json # IAM policy for execution
80
+ │ ├── report_generator.py # HTML report generator
81
+ │ ├── security_baseline_tester.py # Core assessment engine
82
+ │ ├── run_script.py # Legacy script support
83
+ │ ├── __init__.py # Module exports and API
84
+ │ └── report_template_*.html # Multilingual report templates
85
+ ├── cfat/ # Cloud Foundations Assessment Tool
86
+ ├── inventory/ # Multi-account resource discovery
87
+ ├── organizations/ # AWS Organizations management
88
+ └── main.py # Central CLI entry point
89
+ ```
90
+
91
+ ---
92
+
93
+
94
+ ## 🚀 Deployment and Usage
95
+
96
+ The security baseline assessment is fully integrated into the CloudOps Runbooks CLI, providing enterprise-grade security assessment capabilities with a simple, intuitive interface.
97
+
98
+ > **⚡ Quick Start**: `pip install runbooks && runbooks security assess`
99
+
100
+ ### **Option 1: Install via PyPI (Recommended)**
101
+
102
+ 1. **Install the Package**:
103
+ ```bash
104
+ pip install runbooks
105
+ ```
106
+
107
+ 2. **Run Security Assessment**:
108
+ ```bash
109
+ # Basic security assessment
110
+ runbooks security assess
111
+
112
+ # Assessment with specific AWS profile and language
113
+ runbooks security assess --profile production --language EN
114
+
115
+ # Generate Korean language report
116
+ runbooks security assess --language KR --output ./security-reports
117
+ ```
118
+
119
+ 3. **List Available Security Checks**:
120
+ ```bash
121
+ runbooks security list-checks
122
+ ```
123
+
124
+ ---
125
+
126
+ ### **Option 2: Development Installation**
127
+
128
+ 1. **Clone the Repository**:
129
+ ```bash
130
+ git clone https://github.com/1xOps/CloudOps-Runbooks.git
131
+ cd CloudOps-Runbooks
132
+ ```
133
+
134
+ 2. **Install Dependencies using UV** (Rust-based package manager):
135
+ ```bash
136
+ # Install UV if not already installed
137
+ curl -LsSf https://astral.sh/uv/install.sh | sh
138
+
139
+ # Install dependencies and activate environment
140
+ uv sync --all-extras
141
+ ```
142
+
143
+ 3. **Run Security Assessment**:
144
+ ```bash
145
+ uv run python -m runbooks security assess --profile PROFILE_NAME --language EN
146
+ ```
147
+
148
+ ---
149
+
150
+ ### **Option 3: Using Task Automation**
151
+
152
+ 1. **Prerequisites Check**:
153
+ ```bash
154
+ task -d ~ check-tools
155
+ task -d ~ check-aws
156
+ ```
157
+
158
+ 2. **Install and Run**:
159
+ ```bash
160
+ task install
161
+ task security.assess
162
+ ```
163
+
164
+ ---
165
+
166
+ ### **CLI Command Reference**
167
+
168
+ ```bash
169
+ # Main security commands
170
+ runbooks security --help # Show security help
171
+ runbooks security assess # Run comprehensive assessment
172
+ runbooks security assess --profile prod # Use specific AWS profile
173
+ runbooks security assess --language KR # Generate Korean report
174
+ runbooks security assess --output /reports # Custom output directory
175
+
176
+ # Individual security checks
177
+ runbooks security check root_mfa # Check root MFA
178
+ runbooks security check iam_password_policy # Check IAM password policy
179
+ runbooks security list-checks # List all available checks
180
+
181
+ # Advanced usage
182
+ runbooks security assess --format html # HTML report (default)
183
+ runbooks security assess --format json # JSON output
184
+ runbooks security assess --format console # Console output only
185
+ ```
186
+
187
+ ---
188
+
189
+ ## 🛡️ Security Checks Included
190
+
191
+ The following checks are aligned with the [AWS Startup Security Baseline (SSB)](https://docs.aws.amazon.com/prescriptive-guidance/latest/aws-startup-security-baseline/welcome.html):
192
+
193
+ 1. **Account-Level Security**:
194
+ - Root account MFA enabled
195
+ - No root access keys
196
+ - Alternate contacts configured
197
+
198
+ 2. **IAM Best Practices**:
199
+ - Password policies enforced
200
+ - MFA for IAM users
201
+ - Attached policies preferred over inline policies
202
+
203
+ 3. **Monitoring and Logging**:
204
+ - CloudTrail enabled across all regions
205
+ - GuardDuty activated
206
+ - CloudWatch alarms configured for critical events
207
+
208
+ 4. **S3 Bucket Policies**:
209
+ - Public access block enabled
210
+ - Encryption enforced for bucket objects
211
+
212
+ 5. **VPC and Network Security**:
213
+ - Validates security group configurations
214
+ - Multi-region usage of resources (e.g., EC2 instances, S3 buckets)
215
+
216
+ ---
217
+
218
+ ## 📊 Reports and Insights
219
+
220
+ - **Format**: HTML reports generated in the `results/` directory.
221
+ - **Languages**: Supported in English, Korean, and Japanese.
222
+ - **Insights**:
223
+ - Passed, failed, and skipped checks with detailed descriptions.
224
+ - Direct remediation steps with links to AWS documentation.
225
+
226
+ Sample Report:
227
+
228
+ | Check ID | Description | Result | Remediation Steps |
229
+ |----------|-----------------------------|----------|------------------------------------|
230
+ | 01 | Root account MFA enabled | ✅ Pass | N/A |
231
+ | 02 | CloudTrail enabled | ❌ Fail | [Enable CloudTrail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html) |
232
+ | 03 | S3 bucket public access | ✅ Pass | N/A |
233
+
234
+ ---
235
+
236
+ ## 📋 Prerequisites
237
+
238
+ ### **IAM Permissions**
239
+
240
+ Attach the policy defined in `permission.json` to the IAM user or role executing the script. This policy ensures **read-only access**, except for specific actions like `iam:GenerateCredentialReport`.
241
+
242
+ ### **AWS CLI Configuration**
243
+ - Set up credentials in the `~/.aws/credentials` file or use AWS CloudShell.
244
+
245
+ ---
246
+
247
+ ## 🔮 Future Enhancements
248
+
249
+ 1. **Multi-Account Scans**:
250
+ - Expand to support AWS Organizations for enterprise-wide checks.
251
+ 2. **AI Integration**:
252
+ - Leverage machine learning for automated anomaly detection and remediation suggestions.
253
+ 3. **Visualization Dashboards**:
254
+ - Integrate with AWS QuickSight or Grafana for real-time security monitoring.
255
+
256
+ ---
257
+
258
+ ## 📢 Feedback and Contributions
259
+
260
+ We value your feedback! Share your ideas or report issues via:
261
+ - **GitHub**: [CloudOps Runbooks Repository](https://github.com/nnthanh101/cloudops-runbooks/issues)
262
+ - **Email**: [support@nnthanh101.com](mailto:support@nnthanh101.com)
263
+
264
+ Let’s work together to make cloud security accessible, effective, and scalable for everyone. 🚀
265
+
266
+ ---
267
+
268
+ ### **Create an IAM User with Permissions**
269
+
270
+ 1. **Navigate to IAM in the AWS Console**:
271
+ - Go to the **IAM service** on the AWS Management Console.
272
+
273
+ 2. **Add a New User**:
274
+ - Select **Users** from the navigation pane, then click **Add users**.
275
+ - Enter a username for the new user under **User name**.
276
+
277
+ 3. **Assign Permissions**:
278
+ - Choose **Attach policies directly** on the **Set permissions** page.
279
+ - Click **Create Policy**, then switch to the **JSON** tab and paste the following policy:
280
+
281
+ ```json
282
+ {
283
+ "Version": "2012-10-17",
284
+ "Statement": [
285
+ {
286
+ "Sid": "SSBUserPermission",
287
+ "Effect": "Allow",
288
+ "Action": [
289
+ "iam:GenerateCredentialReport",
290
+ "s3:GetBucketPublicAccessBlock",
291
+ "iam:GetAccountPasswordPolicy",
292
+ "cloudtrail:GetTrail",
293
+ "ec2:DescribeInstances",
294
+ "guardduty:ListDetectors",
295
+ "cloudtrail:GetTrailStatus",
296
+ "account:GetAlternateContact",
297
+ "ec2:DescribeRegions",
298
+ "s3:ListBucket",
299
+ "iam:ListUserPolicies",
300
+ "support:DescribeTrustedAdvisorChecks",
301
+ "guardduty:GetDetector",
302
+ "cloudtrail:DescribeTrails",
303
+ "s3:GetAccountPublicAccessBlock",
304
+ "s3:ListAllMyBuckets",
305
+ "ec2:DescribeNetworkInterfaces",
306
+ "ec2:DescribeVpcs",
307
+ "iam:ListAttachedUserPolicies",
308
+ "cloudwatch:DescribeAlarms",
309
+ "iam:ListUsers",
310
+ "sts:GetCallerIdentity",
311
+ "iam:GetCredentialReport",
312
+ "ec2:DescribeSubnets"
313
+ ],
314
+ "Resource": "*"
315
+ }
316
+ ]
317
+ }
318
+ ```
319
+
320
+ 4. **Additional Permissions for CloudShell** *(Optional)*:
321
+ - Add the **AWSCloudShellFullAccess** policy if you plan to use AWS CloudShell for assessments.
322
+
323
+ 5. **Complete User Creation**:
324
+ - Attach the policy to the user, then finish user creation by clicking **Next**.
325
+
326
+ 6. **Generate Access Key**:
327
+ - On the user’s **Security credentials** tab, click **Create access key** to generate the key. [Learn more about creating access keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey).
328
+
329
+ 7. **Configure AWS CLI**:
330
+ - Set up your AWS credentials by editing the `~/.aws/credentials` file or use AWS CloudShell directly. [AWS CLI configuration guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html).
331
+
332
+ ---
333
+
334
+ ### **Quick Start Examples**
335
+
336
+ 1. **Basic Security Assessment**:
337
+ ```bash
338
+ runbooks security assess
339
+ ```
340
+
341
+ 2. **Assessment with Custom Profile and Language**:
342
+ ```bash
343
+ runbooks security assess --profile production --language EN
344
+ ```
345
+ - Supported languages: **English (EN)**, **Korean (KR)**, **Japanese (JP)**, **Vietnamese (VN)**.
346
+
347
+ 3. **Generate Reports in Different Languages**:
348
+ ```bash
349
+ # English report
350
+ runbooks security assess --language EN --output ./reports/english
351
+
352
+ # Korean report
353
+ runbooks security assess --language KR --output ./reports/korean
354
+
355
+ # Japanese report
356
+ runbooks security assess --language JP --output ./reports/japanese
357
+
358
+ # Vietnamese report
359
+ runbooks security assess --language VN --output ./reports/vietnamese
360
+ ```
361
+
362
+ 4. **View Results**:
363
+ - Upon completion, an HTML report will be generated in the specified output directory (default: `./results/`)
364
+ - The CLI provides rich console output with immediate feedback on security findings
365
+ - Reports include actionable remediation steps with links to AWS documentation
366
+
367
+ 5. **List Available Security Checks**:
368
+ ```bash
369
+ runbooks security list-checks
370
+ ```
371
+
372
+ 6. **Run Individual Security Checks** *(Coming Soon)*:
373
+ ```bash
374
+ runbooks security check root_mfa
375
+ runbooks security check iam_password_policy
376
+ ```
377
+
378
+ > ![Sample Report](./images/report_sample_en.png)
379
+
380
+ > ![Sample Report](./images/report_sample_vn.png)
381
+
382
+ ---
383
+
384
+ ## FAQ: Frequently Asked Questions
385
+
386
+ ### **1. How can I test additional security items to enhance AWS account security?**
387
+
388
+ To test a broader range of security configurations, consider using [AWS Trusted Advisor](https://aws.amazon.com/blogs/aws/aws-trusted-advisor-new-priority-capability/).
389
+ This service regularly analyzes your AWS accounts and helps you implement AWS security best practices aligned with the AWS Well-Architected Framework. By managing your security settings through Trusted Advisor, you can systematically improve the security posture of your AWS environment.
390
+
391
+ ---
392
+
393
+ ### **2. Where can I find more information or guidelines to improve AWS security?**
394
+
395
+ AWS provides the [AWS Well-Architected Tool](https://docs.aws.amazon.com/wellarchitected/latest/userguide/intro.html), a comprehensive cloud service for evaluating and optimizing your architecture.
396
+ This tool includes a **Security Pillar**, which outlines detailed best practices for securing your AWS workloads. Use these guidelines to design, assess, and enhance your security strategy effectively.
397
+
398
+ ---
399
+
400
+ ### **3. Can I scan multiple AWS accounts within the same AWS Organization simultaneously?**
401
+
402
+ No, this script currently supports scanning a **single AWS account** at a time.
403
+ To scan additional AWS accounts in the same organization, you must:
404
+ - Create a separate IAM user with the required permissions in each account.
405
+ - Run the script individually for each account.
406
+
407
+ **Note**: Organization-level security settings cannot be assessed using this script. Consider AWS services like **AWS Organizations** for managing policies at scale.
408
+
409
+ ---
410
+
411
+ ### **4. Can I use this tool without an IAM Access Key?**
412
+
413
+ Yes, you can run the security assessment without an IAM Access Key by leveraging IAM roles.
414
+ The integrated `runbooks security` CLI fully supports IAM roles and various AWS authentication methods.
415
+
416
+ **Supported Authentication Methods**:
417
+ 1. **IAM Roles** (Recommended): Configure and use IAM roles instead of access keys
418
+ 2. **AWS SSO**: Use AWS Single Sign-On for centralized authentication
419
+ 3. **Environment Variables**: Set AWS credentials via environment variables
420
+ 4. **Instance Profiles**: Automatically use instance profiles when running on EC2
421
+ 5. **AWS CloudShell**: Run directly in AWS CloudShell without any setup
422
+
423
+ **Setup Examples**:
424
+
425
+ **Using IAM Roles**:
426
+ 1. Configure a role profile in AWS CLI: [IAM roles guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html#cli-role-overview)
427
+ 2. Run the assessment:
428
+ ```bash
429
+ runbooks security assess --profile ROLE_PROFILE_NAME --language EN
430
+ ```
431
+
432
+ **Using AWS SSO**:
433
+ 1. Configure SSO profile: `aws configure sso`
434
+ 2. Run the assessment:
435
+ ```bash
436
+ runbooks security assess --profile sso-profile --language EN
437
+ ```
438
+
439
+ **Using AWS CloudShell**:
440
+ ```bash
441
+ pip install runbooks
442
+ runbooks security assess --language EN
443
+ ```
444
+
445
+ This approach enhances security by reducing the dependency on long-term access keys and provides enterprise-grade authentication options.
446
+
447
+ ---
@@ -0,0 +1,71 @@
1
+ """
2
+ AWS Security Baseline Testing Module.
3
+
4
+ This module provides comprehensive AWS security baseline testing capabilities
5
+ with multilingual reporting and enterprise-grade assessment features.
6
+
7
+ The security module evaluates AWS accounts against security best practices
8
+ and generates detailed HTML reports with findings and remediation guidance.
9
+
10
+ Features:
11
+ - Comprehensive security checklist validation
12
+ - Multilingual report generation (EN, JP, KR, VN)
13
+ - Parallel execution for performance
14
+ - Enterprise-ready HTML reporting
15
+ - CLI integration with runbooks
16
+ - AWS Organizations and multi-account support
17
+
18
+ Example:
19
+ ```python
20
+ from runbooks.security import SecurityBaselineTester
21
+
22
+ # Initialize security tester
23
+ tester = SecurityBaselineTester(
24
+ profile="prod",
25
+ lang_code="EN",
26
+ output_dir="./security-reports"
27
+ )
28
+
29
+ # Run security assessment
30
+ tester.run()
31
+ ```
32
+
33
+ CLI Usage:
34
+ ```bash
35
+ # Run security assessment
36
+ runbooks security assess --profile prod --language EN
37
+
38
+ # Generate Korean language report
39
+ runbooks security assess --language KR --output /reports
40
+
41
+ # Run specific security checks
42
+ runbooks security check root-mfa --profile production
43
+ ```
44
+
45
+ Author: CloudOps Runbooks Team
46
+ Version: 1.1.0
47
+ """
48
+
49
+ from .report_generator import ReportGenerator, generate_html_report
50
+ from .run_script import main as run_security_script, parse_arguments
51
+ from .security_baseline_tester import SecurityBaselineTester
52
+
53
+ # Version info
54
+ __version__ = "1.1.0"
55
+ __author__ = "CloudOps Runbooks Team"
56
+
57
+ # Public API
58
+ __all__ = [
59
+ # Core functionality
60
+ "SecurityBaselineTester",
61
+ "ReportGenerator",
62
+ "generate_html_report",
63
+
64
+ # CLI functions
65
+ "run_security_script",
66
+ "parse_arguments",
67
+
68
+ # Metadata
69
+ "__version__",
70
+ "__author__",
71
+ ]
@@ -54,7 +54,14 @@ def check_alternate_contact_filling(session, translator) -> common.CheckResult:
54
54
  ret.error_message = f"Unexpected Exception: {str(e)}"
55
55
  logging.error(ret.error_message, exc_info=True)
56
56
  finally:
57
- ret.result_rows.append([contact_type, contact["Name"], contact["EmailAddress"], contact["PhoneNumber"]])
57
+ ret.result_rows.append(
58
+ [
59
+ contact_type,
60
+ contact["Name"],
61
+ contact["EmailAddress"],
62
+ contact["PhoneNumber"],
63
+ ]
64
+ )
58
65
 
59
66
  if ret.level == level.success:
60
67
  ret.msg = translator.translate("success")
@@ -16,7 +16,10 @@ def get_bucket_info(client, bucket_name) -> tuple:
16
16
  if e.response["Error"]["Code"] == "NoSuchPublicAccessBlockConfiguration":
17
17
  return level.danger, [bucket_name, "All Allowed"]
18
18
  else:
19
- logging.error(f"Error getting public access block for bucket {bucket_name}: {str(e)}", exc_info=True)
19
+ logging.error(
20
+ f"Error getting public access block for bucket {bucket_name}: {str(e)}",
21
+ exc_info=True,
22
+ )
20
23
  return level.error, [bucket_name, "ERR"]
21
24
 
22
25
  public_access_block_policy_counter = sum(
@@ -12,7 +12,10 @@ def get_cloudwatch_alarms(client, region):
12
12
  alarms = client.describe_alarms()["MetricAlarms"]
13
13
  return region, alarms
14
14
  except (client.exceptions.InvalidNextToken, botocore.exceptions.ClientError) as e:
15
- logging.error(f"Error getting CloudWatch alarms for region {region}: {str(e)}", exc_info=True)
15
+ logging.error(
16
+ f"Error getting CloudWatch alarms for region {region}: {str(e)}",
17
+ exc_info=True,
18
+ )
16
19
  return region, "ERR"
17
20
 
18
21
 
@@ -37,7 +40,11 @@ def check_cloudwatch_alarm_configuration(session, translator) -> common.CheckRes
37
40
 
38
41
  with ThreadPoolExecutor() as thread_executor:
39
42
  futures = [
40
- thread_executor.submit(get_cloudwatch_alarms, session.client("cloudwatch", region_name=region), region)
43
+ thread_executor.submit(
44
+ get_cloudwatch_alarms,
45
+ session.client("cloudwatch", region_name=region),
46
+ region,
47
+ )
41
48
  for region in regions
42
49
  ]
43
50
 
@@ -16,7 +16,10 @@ def get_guard_duty_configuration(client, region):
16
16
  client.exceptions.InternalServerErrorException,
17
17
  botocore.exceptions.ClientError,
18
18
  ) as e:
19
- logging.error(f"Error getting GuardDuty configuration for region {region}: {str(e)}", exc_info=True)
19
+ logging.error(
20
+ f"Error getting GuardDuty configuration for region {region}: {str(e)}",
21
+ exc_info=True,
22
+ )
20
23
  return region, "ERR"
21
24
 
22
25
 
@@ -41,7 +44,11 @@ def check_guard_duty_enabled(session, translator) -> common.CheckResult:
41
44
 
42
45
  with ThreadPoolExecutor() as executor:
43
46
  futures = [
44
- executor.submit(get_guard_duty_configuration, session.client("guardduty", region_name=region), region)
47
+ executor.submit(
48
+ get_guard_duty_configuration,
49
+ session.client("guardduty", region_name=region),
50
+ region,
51
+ )
45
52
  for region in regions
46
53
  ]
47
54
 
@@ -39,7 +39,11 @@ def check_multiregion_instance_usage(session, translator) -> common.CheckResult:
39
39
 
40
40
  with ThreadPoolExecutor() as executor:
41
41
  futures = [
42
- executor.submit(get_instance_usage_by_region, session.client("ec2", region_name=region), region)
42
+ executor.submit(
43
+ get_instance_usage_by_region,
44
+ session.client("ec2", region_name=region),
45
+ region,
46
+ )
43
47
  for region in regions
44
48
  ]
45
49
 
@@ -29,7 +29,12 @@ def check_access_key(root_credential_report, key_number):
29
29
 
30
30
  if key_active == "TRUE":
31
31
  last_used_days = get_last_used_days(key_last_used)
32
- return f"AccessKey{key_number}", "In Use", format_last_used(last_used_days), True
32
+ return (
33
+ f"AccessKey{key_number}",
34
+ "In Use",
35
+ format_last_used(last_used_days),
36
+ True,
37
+ )
33
38
  return f"AccessKey{key_number}", "Not In Use", "N/A", False
34
39
 
35
40
 
@@ -21,4 +21,4 @@
21
21
  "first_iam_user_row_index": 2,
22
22
  "root_row_index": 1
23
23
  }
24
- }
24
+ }
@@ -21,4 +21,4 @@
21
21
  "first_iam_user_row_index": 2,
22
22
  "root_row_index": 1
23
23
  }
24
- }
24
+ }
@@ -33,4 +33,4 @@
33
33
  "Resource": "*"
34
34
  }
35
35
  ]
36
- }
36
+ }
@@ -52,7 +52,12 @@ class ReportGenerator:
52
52
 
53
53
  ## Attempt to read the template file
54
54
  if not template_path.is_file():
55
- logger.error("Template file '%s' for language '%s' not found at %s", template_filename, lang, template_path)
55
+ logger.error(
56
+ "Template file '%s' for language '%s' not found at %s",
57
+ template_filename,
58
+ lang,
59
+ template_path,
60
+ )
56
61
  raise FileNotFoundError(f"Could not find the template '{template_filename}' for language '{lang}'.")
57
62
 
58
63
  with template_path.open("r", encoding="utf-8") as file:
@@ -131,7 +136,10 @@ class ReportGenerator:
131
136
  formatted_result = {
132
137
  "title": result_dict.get("title", "Unknown"),
133
138
  "message": result_dict.get("msg", "No message"),
134
- "table": self._format_table(result_dict.get("result_cols", []), result_dict.get("result_rows", [])),
139
+ "table": self._format_table(
140
+ result_dict.get("result_cols", []),
141
+ result_dict.get("result_rows", []),
142
+ ),
135
143
  }
136
144
  if level == level_const.error:
137
145
  formatted_result["error_message"] = result_dict.get("error_message", "Unknown error")