sraverify 0.1.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 (261) hide show
  1. sraverify/__init__.py +36 -0
  2. sraverify/checks/__init__.py +56 -0
  3. sraverify/checks/accessanalyzer/SRA_IAA_1.py +188 -0
  4. sraverify/checks/accessanalyzer/SRA_IAA_2.py +162 -0
  5. sraverify/checks/accessanalyzer/SRA_IAA_3.py +260 -0
  6. sraverify/checks/accessanalyzer/SRA_IAA_4.py +207 -0
  7. sraverify/checks/accessanalyzer/__init__.py +3 -0
  8. sraverify/checks/cloudtrail/SRA-CT-1.py +220 -0
  9. sraverify/checks/cloudtrail/SRA-CT-10.py +229 -0
  10. sraverify/checks/cloudtrail/SRA-CT-11.py +242 -0
  11. sraverify/checks/cloudtrail/SRA-CT-12.py +163 -0
  12. sraverify/checks/cloudtrail/SRA-CT-13.py +279 -0
  13. sraverify/checks/cloudtrail/SRA-CT-2.py +218 -0
  14. sraverify/checks/cloudtrail/SRA-CT-3.py +196 -0
  15. sraverify/checks/cloudtrail/SRA-CT-4.py +161 -0
  16. sraverify/checks/cloudtrail/SRA-CT-5.py +200 -0
  17. sraverify/checks/cloudtrail/SRA-CT-6.py +161 -0
  18. sraverify/checks/cloudtrail/SRA-CT-7.py +194 -0
  19. sraverify/checks/cloudtrail/SRA-CT-8.py +226 -0
  20. sraverify/checks/cloudtrail/SRA-CT-9.py +226 -0
  21. sraverify/checks/cloudtrail/__init__.py +3 -0
  22. sraverify/checks/config/SRA-CONFIG-1.py +197 -0
  23. sraverify/checks/config/__init__.py +3 -0
  24. sraverify/core/__init__.py +3 -0
  25. sraverify/core/check.py +227 -0
  26. sraverify/core/logging.py +37 -0
  27. sraverify/core/session.py +47 -0
  28. sraverify/lib/__init__.py +4 -0
  29. sraverify/lib/audit_info.py +37 -0
  30. sraverify/lib/banner.py +42 -0
  31. sraverify/lib/check_loader.py +80 -0
  32. sraverify/lib/org_mgmt_checker.py +86 -0
  33. sraverify/lib/outputs.py +46 -0
  34. sraverify/lib/progress.py +75 -0
  35. sraverify/lib/regions.py +27 -0
  36. sraverify/lib/session.py +23 -0
  37. sraverify/main.py +350 -0
  38. sraverify/services/__init__.py +3 -0
  39. sraverify/services/accessanalyzer/__init__.py +15 -0
  40. sraverify/services/accessanalyzer/base.py +123 -0
  41. sraverify/services/accessanalyzer/checks/__init__.py +3 -0
  42. sraverify/services/accessanalyzer/checks/sra_accessanalyzer_01.py +82 -0
  43. sraverify/services/accessanalyzer/checks/sra_accessanalyzer_02.py +82 -0
  44. sraverify/services/accessanalyzer/checks/sra_accessanalyzer_03.py +103 -0
  45. sraverify/services/accessanalyzer/checks/sra_accessanalyzer_04.py +139 -0
  46. sraverify/services/accessanalyzer/client.py +123 -0
  47. sraverify/services/account/__init__.py +9 -0
  48. sraverify/services/account/base.py +56 -0
  49. sraverify/services/account/checks/__init__.py +1 -0
  50. sraverify/services/account/checks/sra_account_01.py +65 -0
  51. sraverify/services/account/checks/sra_account_02.py +63 -0
  52. sraverify/services/account/checks/sra_account_03.py +63 -0
  53. sraverify/services/account/client.py +51 -0
  54. sraverify/services/auditmanager/__init__.py +10 -0
  55. sraverify/services/auditmanager/base.py +72 -0
  56. sraverify/services/auditmanager/checks/__init__.py +1 -0
  57. sraverify/services/auditmanager/checks/sra_auditmanager_01.py +58 -0
  58. sraverify/services/auditmanager/checks/sra_auditmanager_02.py +80 -0
  59. sraverify/services/auditmanager/client.py +58 -0
  60. sraverify/services/cloudtrail/__init__.py +33 -0
  61. sraverify/services/cloudtrail/base.py +167 -0
  62. sraverify/services/cloudtrail/checks/__init__.py +1 -0
  63. sraverify/services/cloudtrail/checks/sra_cloudtrail_01.py +83 -0
  64. sraverify/services/cloudtrail/checks/sra_cloudtrail_02.py +99 -0
  65. sraverify/services/cloudtrail/checks/sra_cloudtrail_03.py +94 -0
  66. sraverify/services/cloudtrail/checks/sra_cloudtrail_04.py +92 -0
  67. sraverify/services/cloudtrail/checks/sra_cloudtrail_05.py +106 -0
  68. sraverify/services/cloudtrail/checks/sra_cloudtrail_06.py +93 -0
  69. sraverify/services/cloudtrail/checks/sra_cloudtrail_07.py +96 -0
  70. sraverify/services/cloudtrail/checks/sra_cloudtrail_08.py +145 -0
  71. sraverify/services/cloudtrail/checks/sra_cloudtrail_09.py +167 -0
  72. sraverify/services/cloudtrail/checks/sra_cloudtrail_10.py +162 -0
  73. sraverify/services/cloudtrail/checks/sra_cloudtrail_11.py +178 -0
  74. sraverify/services/cloudtrail/checks/sra_cloudtrail_12.py +77 -0
  75. sraverify/services/cloudtrail/checks/sra_cloudtrail_13.py +120 -0
  76. sraverify/services/cloudtrail/client.py +118 -0
  77. sraverify/services/config/__init__.py +25 -0
  78. sraverify/services/config/base.py +249 -0
  79. sraverify/services/config/checks/__init__.py +1 -0
  80. sraverify/services/config/checks/sra_config_01.py +123 -0
  81. sraverify/services/config/checks/sra_config_02.py +156 -0
  82. sraverify/services/config/checks/sra_config_03.py +149 -0
  83. sraverify/services/config/checks/sra_config_04.py +104 -0
  84. sraverify/services/config/checks/sra_config_05.py +104 -0
  85. sraverify/services/config/checks/sra_config_06.py +194 -0
  86. sraverify/services/config/checks/sra_config_07.py +162 -0
  87. sraverify/services/config/checks/sra_config_08.py +185 -0
  88. sraverify/services/config/checks/sra_config_09.py +177 -0
  89. sraverify/services/config/client.py +264 -0
  90. sraverify/services/ec2/__init__.py +8 -0
  91. sraverify/services/ec2/base.py +75 -0
  92. sraverify/services/ec2/checks/__init__.py +1 -0
  93. sraverify/services/ec2/checks/sra_ec2_01.py +83 -0
  94. sraverify/services/ec2/client.py +63 -0
  95. sraverify/services/firewallmanager/__init__.py +23 -0
  96. sraverify/services/firewallmanager/base.py +48 -0
  97. sraverify/services/firewallmanager/checks/__init__.py +1 -0
  98. sraverify/services/firewallmanager/checks/sra_firewallmanager_01.py +75 -0
  99. sraverify/services/firewallmanager/checks/sra_firewallmanager_02.py +57 -0
  100. sraverify/services/firewallmanager/checks/sra_firewallmanager_03.py +51 -0
  101. sraverify/services/firewallmanager/checks/sra_firewallmanager_04.py +51 -0
  102. sraverify/services/firewallmanager/checks/sra_firewallmanager_05.py +51 -0
  103. sraverify/services/firewallmanager/checks/sra_firewallmanager_06.py +51 -0
  104. sraverify/services/firewallmanager/checks/sra_firewallmanager_07.py +51 -0
  105. sraverify/services/firewallmanager/checks/sra_firewallmanager_08.py +61 -0
  106. sraverify/services/firewallmanager/checks/sra_firewallmanager_09.py +61 -0
  107. sraverify/services/firewallmanager/checks/sra_firewallmanager_10.py +71 -0
  108. sraverify/services/firewallmanager/client.py +40 -0
  109. sraverify/services/guardduty/__init__.py +58 -0
  110. sraverify/services/guardduty/base.py +207 -0
  111. sraverify/services/guardduty/checks/__init__.py +3 -0
  112. sraverify/services/guardduty/checks/sra_guardduty_01.py +51 -0
  113. sraverify/services/guardduty/checks/sra_guardduty_02.py +80 -0
  114. sraverify/services/guardduty/checks/sra_guardduty_03.py +77 -0
  115. sraverify/services/guardduty/checks/sra_guardduty_04.py +84 -0
  116. sraverify/services/guardduty/checks/sra_guardduty_05.py +84 -0
  117. sraverify/services/guardduty/checks/sra_guardduty_06.py +84 -0
  118. sraverify/services/guardduty/checks/sra_guardduty_07.py +85 -0
  119. sraverify/services/guardduty/checks/sra_guardduty_08.py +83 -0
  120. sraverify/services/guardduty/checks/sra_guardduty_09.py +84 -0
  121. sraverify/services/guardduty/checks/sra_guardduty_10.py +83 -0
  122. sraverify/services/guardduty/checks/sra_guardduty_11.py +93 -0
  123. sraverify/services/guardduty/checks/sra_guardduty_12.py +83 -0
  124. sraverify/services/guardduty/checks/sra_guardduty_13.py +90 -0
  125. sraverify/services/guardduty/checks/sra_guardduty_14.py +136 -0
  126. sraverify/services/guardduty/checks/sra_guardduty_15.py +94 -0
  127. sraverify/services/guardduty/checks/sra_guardduty_16.py +94 -0
  128. sraverify/services/guardduty/checks/sra_guardduty_17.py +91 -0
  129. sraverify/services/guardduty/checks/sra_guardduty_18.py +91 -0
  130. sraverify/services/guardduty/checks/sra_guardduty_19.py +91 -0
  131. sraverify/services/guardduty/checks/sra_guardduty_20.py +111 -0
  132. sraverify/services/guardduty/checks/sra_guardduty_21.py +112 -0
  133. sraverify/services/guardduty/checks/sra_guardduty_22.py +111 -0
  134. sraverify/services/guardduty/checks/sra_guardduty_23.py +154 -0
  135. sraverify/services/guardduty/checks/sra_guardduty_24.py +111 -0
  136. sraverify/services/guardduty/checks/sra_guardduty_25.py +111 -0
  137. sraverify/services/guardduty/client.py +107 -0
  138. sraverify/services/inspector/__init__.py +29 -0
  139. sraverify/services/inspector/base.py +233 -0
  140. sraverify/services/inspector/checks/__init__.py +3 -0
  141. sraverify/services/inspector/checks/sra_inspector_01.py +69 -0
  142. sraverify/services/inspector/checks/sra_inspector_02.py +68 -0
  143. sraverify/services/inspector/checks/sra_inspector_03.py +68 -0
  144. sraverify/services/inspector/checks/sra_inspector_04.py +70 -0
  145. sraverify/services/inspector/checks/sra_inspector_05.py +69 -0
  146. sraverify/services/inspector/checks/sra_inspector_06.py +115 -0
  147. sraverify/services/inspector/checks/sra_inspector_07.py +109 -0
  148. sraverify/services/inspector/checks/sra_inspector_08.py +69 -0
  149. sraverify/services/inspector/checks/sra_inspector_09.py +69 -0
  150. sraverify/services/inspector/checks/sra_inspector_10.py +69 -0
  151. sraverify/services/inspector/checks/sra_inspector_11.py +69 -0
  152. sraverify/services/inspector/client.py +99 -0
  153. sraverify/services/macie/__init__.py +27 -0
  154. sraverify/services/macie/base.py +271 -0
  155. sraverify/services/macie/checks/__init__.py +1 -0
  156. sraverify/services/macie/checks/sra_macie_01.py +100 -0
  157. sraverify/services/macie/checks/sra_macie_02.py +102 -0
  158. sraverify/services/macie/checks/sra_macie_03.py +152 -0
  159. sraverify/services/macie/checks/sra_macie_04.py +120 -0
  160. sraverify/services/macie/checks/sra_macie_05.py +85 -0
  161. sraverify/services/macie/checks/sra_macie_06.py +124 -0
  162. sraverify/services/macie/checks/sra_macie_07.py +138 -0
  163. sraverify/services/macie/checks/sra_macie_08.py +82 -0
  164. sraverify/services/macie/checks/sra_macie_09.py +103 -0
  165. sraverify/services/macie/checks/sra_macie_10.py +81 -0
  166. sraverify/services/macie/client.py +220 -0
  167. sraverify/services/s3/__init__.py +16 -0
  168. sraverify/services/s3/base.py +69 -0
  169. sraverify/services/s3/checks/__init__.py +1 -0
  170. sraverify/services/s3/checks/sra_s3_01.py +89 -0
  171. sraverify/services/s3/checks/sra_s3_02.py +89 -0
  172. sraverify/services/s3/checks/sra_s3_03.py +88 -0
  173. sraverify/services/s3/checks/sra_s3_04.py +88 -0
  174. sraverify/services/s3/client.py +52 -0
  175. sraverify/services/securityhub/__init__.py +27 -0
  176. sraverify/services/securityhub/base.py +349 -0
  177. sraverify/services/securityhub/checks/__init__.py +1 -0
  178. sraverify/services/securityhub/checks/sra_securityhub_01.py +115 -0
  179. sraverify/services/securityhub/checks/sra_securityhub_02.py +114 -0
  180. sraverify/services/securityhub/checks/sra_securityhub_03.py +136 -0
  181. sraverify/services/securityhub/checks/sra_securityhub_04.py +75 -0
  182. sraverify/services/securityhub/checks/sra_securityhub_05.py +102 -0
  183. sraverify/services/securityhub/checks/sra_securityhub_06.py +113 -0
  184. sraverify/services/securityhub/checks/sra_securityhub_07.py +121 -0
  185. sraverify/services/securityhub/checks/sra_securityhub_08.py +113 -0
  186. sraverify/services/securityhub/checks/sra_securityhub_09.py +100 -0
  187. sraverify/services/securityhub/checks/sra_securityhub_10.py +94 -0
  188. sraverify/services/securityhub/checks/sra_securityhub_11.py +73 -0
  189. sraverify/services/securityhub/client.py +249 -0
  190. sraverify/services/securityincidentresponse/__init__.py +13 -0
  191. sraverify/services/securityincidentresponse/base.py +95 -0
  192. sraverify/services/securityincidentresponse/checks/__init__.py +1 -0
  193. sraverify/services/securityincidentresponse/checks/sra_securityincidentresponse_01.py +77 -0
  194. sraverify/services/securityincidentresponse/checks/sra_securityincidentresponse_02.py +72 -0
  195. sraverify/services/securityincidentresponse/checks/sra_securityincidentresponse_03.py +86 -0
  196. sraverify/services/securityincidentresponse/checks/sra_securityincidentresponse_04.py +117 -0
  197. sraverify/services/securityincidentresponse/checks/sra_securityincidentresponse_05.py +55 -0
  198. sraverify/services/securityincidentresponse/client.py +71 -0
  199. sraverify/services/securitylake/__init__.py +39 -0
  200. sraverify/services/securitylake/base.py +461 -0
  201. sraverify/services/securitylake/checks/__init__.py +1 -0
  202. sraverify/services/securitylake/checks/sra_securitylake_01.py +98 -0
  203. sraverify/services/securitylake/checks/sra_securitylake_02.py +133 -0
  204. sraverify/services/securitylake/checks/sra_securitylake_03.py +116 -0
  205. sraverify/services/securitylake/checks/sra_securitylake_04.py +72 -0
  206. sraverify/services/securitylake/checks/sra_securitylake_05.py +116 -0
  207. sraverify/services/securitylake/checks/sra_securitylake_06.py +104 -0
  208. sraverify/services/securitylake/checks/sra_securitylake_07.py +108 -0
  209. sraverify/services/securitylake/checks/sra_securitylake_08.py +107 -0
  210. sraverify/services/securitylake/checks/sra_securitylake_09.py +107 -0
  211. sraverify/services/securitylake/checks/sra_securitylake_10.py +106 -0
  212. sraverify/services/securitylake/checks/sra_securitylake_11.py +109 -0
  213. sraverify/services/securitylake/checks/sra_securitylake_12.py +108 -0
  214. sraverify/services/securitylake/checks/sra_securitylake_13.py +108 -0
  215. sraverify/services/securitylake/checks/sra_securitylake_14.py +72 -0
  216. sraverify/services/securitylake/checks/sra_securitylake_15.py +120 -0
  217. sraverify/services/securitylake/checks/sra_securitylake_16.py +104 -0
  218. sraverify/services/securitylake/checks/sra_securitylake_17.py +103 -0
  219. sraverify/services/securitylake/client.py +247 -0
  220. sraverify/services/shield/__init__.py +33 -0
  221. sraverify/services/shield/base.py +199 -0
  222. sraverify/services/shield/checks/__init__.py +1 -0
  223. sraverify/services/shield/checks/sra_shield_01.py +68 -0
  224. sraverify/services/shield/checks/sra_shield_02.py +77 -0
  225. sraverify/services/shield/checks/sra_shield_03.py +84 -0
  226. sraverify/services/shield/checks/sra_shield_04.py +84 -0
  227. sraverify/services/shield/checks/sra_shield_05.py +84 -0
  228. sraverify/services/shield/checks/sra_shield_06.py +84 -0
  229. sraverify/services/shield/checks/sra_shield_07.py +84 -0
  230. sraverify/services/shield/checks/sra_shield_08.py +69 -0
  231. sraverify/services/shield/checks/sra_shield_09.py +86 -0
  232. sraverify/services/shield/checks/sra_shield_10.py +100 -0
  233. sraverify/services/shield/checks/sra_shield_11.py +71 -0
  234. sraverify/services/shield/checks/sra_shield_12.py +130 -0
  235. sraverify/services/shield/checks/sra_shield_13.py +112 -0
  236. sraverify/services/shield/checks/sra_shield_14.py +111 -0
  237. sraverify/services/shield/client.py +214 -0
  238. sraverify/services/waf/__init__.py +21 -0
  239. sraverify/services/waf/base.py +100 -0
  240. sraverify/services/waf/checks/__init__.py +1 -0
  241. sraverify/services/waf/checks/sra_waf_01.py +63 -0
  242. sraverify/services/waf/checks/sra_waf_02.py +82 -0
  243. sraverify/services/waf/checks/sra_waf_03.py +123 -0
  244. sraverify/services/waf/checks/sra_waf_04.py +94 -0
  245. sraverify/services/waf/checks/sra_waf_05.py +94 -0
  246. sraverify/services/waf/checks/sra_waf_06.py +91 -0
  247. sraverify/services/waf/checks/sra_waf_07.py +94 -0
  248. sraverify/services/waf/checks/sra_waf_08.py +66 -0
  249. sraverify/services/waf/checks/sra_waf_09.py +95 -0
  250. sraverify/services/waf/client.py +109 -0
  251. sraverify/utils/__init__.py +3 -0
  252. sraverify/utils/banner.py +65 -0
  253. sraverify/utils/outputs.py +57 -0
  254. sraverify/utils/progress.py +97 -0
  255. sraverify-0.1.0.dist-info/LICENSE +175 -0
  256. sraverify-0.1.0.dist-info/METADATA +516 -0
  257. sraverify-0.1.0.dist-info/NOTICE +1 -0
  258. sraverify-0.1.0.dist-info/RECORD +261 -0
  259. sraverify-0.1.0.dist-info/WHEEL +5 -0
  260. sraverify-0.1.0.dist-info/entry_points.txt +2 -0
  261. sraverify-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,154 @@
1
+ """
2
+ Check if GuardDuty Runtime Monitoring is configured for auto-enablement.
3
+ """
4
+ from typing import Dict, List, Any
5
+ from sraverify.services.guardduty.base import GuardDutyCheck
6
+ from sraverify.core.logging import logger
7
+
8
+
9
+ class SRA_GUARDDUTY_23(GuardDutyCheck):
10
+ """Check if GuardDuty Runtime Monitoring is configured for auto-enablement."""
11
+
12
+ def __init__(self):
13
+ """Initialize GuardDuty Runtime Monitoring auto-enablement check."""
14
+ super().__init__()
15
+ self.check_id = "SRA-GUARDDUTY-23"
16
+ self.check_name = "GuardDuty Runtime Monitoring auto-enablement configured"
17
+ self.description = ("This check verifies whether Runtime Monitoring and its components (ECS Fargate Agent Management, "
18
+ "EC2 Agent Management, and EKS Addon Management) are configured for auto-enablement "
19
+ "in GuardDuty for all member accounts. Runtime Monitoring provides threat detection for "
20
+ "runtime behavior of resources, helping to identify malicious activities.")
21
+ self.severity = "HIGH"
22
+ self.check_logic = "Check if RUNTIME_MONITORING feature and its components are configured with AutoEnable set to ALL."
23
+ self.account_type = "audit"
24
+
25
+ def execute(self) -> List[Dict[str, Any]]:
26
+ """
27
+ Execute the check.
28
+
29
+ Returns:
30
+ List of findings
31
+ """
32
+ findings = []
33
+ # Check all regions
34
+ for region in self.regions:
35
+ detector_id = self.get_detector_id(region)
36
+
37
+ # Handle regions where we can't access GuardDuty
38
+ if not detector_id:
39
+ findings.append(self.create_finding(
40
+ status="ERROR",
41
+ region=region,
42
+ resource_id=f"guardduty:{region}",
43
+ actual_value="Unable to access GuardDuty in this region",
44
+ remediation="Check permissions or if GuardDuty is supported in this region"
45
+ ))
46
+ continue
47
+
48
+ # Get organization configuration for GuardDuty
49
+ org_config = self.get_organization_configuration(region)
50
+
51
+ # Check if there was an error in the response
52
+ if "Error" in org_config:
53
+ error_code = org_config["Error"].get("Code", "Unknown")
54
+ error_message = org_config["Error"].get("Message", "Unknown error")
55
+
56
+ # Handle BadRequestException specifically for non-management accounts
57
+ if error_code == "BadRequestException":
58
+ findings.append(self.create_finding(
59
+ status="FAIL",
60
+ region=region,
61
+ resource_id=f"guardduty:{region}:{detector_id}",
62
+ actual_value=f"{error_code} {error_message}",
63
+ remediation="Verify that GuardDuty is the delegated admin in this Region and run the check again."
64
+ ))
65
+ else:
66
+ findings.append(self.create_finding(
67
+ status="ERROR",
68
+ region=region,
69
+ resource_id=f"guardduty:{region}:{detector_id}",
70
+ actual_value=f"Error accessing GuardDuty organization configuration: {error_code}",
71
+ remediation="Check permissions and AWS Organizations configuration"
72
+ ))
73
+ continue
74
+
75
+ # Check if Runtime Monitoring is configured for auto-enablement
76
+ # Look for RUNTIME_MONITORING in Features
77
+ runtime_monitoring_found = False
78
+ runtime_monitoring_auto_enable = "NOT_CONFIGURED"
79
+ additional_config = {}
80
+ features = org_config.get('Features', [])
81
+
82
+ for feature in features:
83
+ if feature.get('Name') == 'RUNTIME_MONITORING':
84
+ runtime_monitoring_found = True
85
+ runtime_monitoring_auto_enable = feature.get('AutoEnable', 'NONE')
86
+
87
+ # Check additional configuration for the three components
88
+ additional_configuration = feature.get('AdditionalConfiguration', [])
89
+ for config in additional_configuration:
90
+ config_name = config.get('Name')
91
+ config_auto_enable = config.get('AutoEnable', 'NONE')
92
+ additional_config[config_name] = config_auto_enable
93
+
94
+ break
95
+
96
+ # Check if all required components are properly configured
97
+ required_components = {
98
+ 'ECS_FARGATE_AGENT_MANAGEMENT': 'ALL',
99
+ 'EC2_AGENT_MANAGEMENT': 'ALL',
100
+ 'EKS_ADDON_MANAGEMENT': 'ALL'
101
+ }
102
+
103
+ missing_components = []
104
+ misconfigured_components = []
105
+
106
+ for component, expected_value in required_components.items():
107
+ if component not in additional_config:
108
+ missing_components.append(component)
109
+ elif additional_config[component] != expected_value:
110
+ misconfigured_components.append(f"{component}={additional_config[component]}")
111
+
112
+ # Determine the status based on the findings
113
+ if runtime_monitoring_found and runtime_monitoring_auto_enable == 'ALL' and not missing_components and not misconfigured_components:
114
+ findings.append(self.create_finding(
115
+ status="PASS",
116
+ region=region,
117
+ resource_id=f"guardduty:{region}:{detector_id}",
118
+ actual_value="GuardDuty Runtime Monitoring and all its components are configured for auto-enablement for all accounts (AutoEnable=ALL)",
119
+ remediation=""
120
+ ))
121
+ elif not runtime_monitoring_found:
122
+ findings.append(self.create_finding(
123
+ status="FAIL",
124
+ region=region,
125
+ resource_id=f"guardduty:{region}:{detector_id}",
126
+ actual_value=f"GuardDuty Runtime Monitoring feature is not configured",
127
+ remediation=f"Enable Runtime Monitoring feature and configure auto-enablement for all accounts in {region}"
128
+ ))
129
+ elif runtime_monitoring_auto_enable != 'ALL':
130
+ findings.append(self.create_finding(
131
+ status="FAIL",
132
+ region=region,
133
+ resource_id=f"guardduty:{region}:{detector_id}",
134
+ actual_value=f"GuardDuty Runtime Monitoring is configured with AutoEnable={runtime_monitoring_auto_enable}, but should be ALL",
135
+ remediation=f"Configure Runtime Monitoring auto-enablement for all accounts in {region} by setting AutoEnable to ALL"
136
+ ))
137
+ elif missing_components:
138
+ findings.append(self.create_finding(
139
+ status="FAIL",
140
+ region=region,
141
+ resource_id=f"guardduty:{region}:{detector_id}",
142
+ actual_value=f"GuardDuty Runtime Monitoring is missing the following components: {', '.join(missing_components)}",
143
+ remediation=f"Configure all required Runtime Monitoring components in {region}"
144
+ ))
145
+ elif misconfigured_components:
146
+ findings.append(self.create_finding(
147
+ status="FAIL",
148
+ region=region,
149
+ resource_id=f"guardduty:{region}:{detector_id}",
150
+ actual_value=f"GuardDuty Runtime Monitoring has misconfigured components: {', '.join(misconfigured_components)}",
151
+ remediation=f"Set AutoEnable to ALL for all Runtime Monitoring components in {region}"
152
+ ))
153
+
154
+ return findings
@@ -0,0 +1,111 @@
1
+ """
2
+ Check if GuardDuty Lambda Network Logs are configured for auto-enablement.
3
+ """
4
+ from typing import Dict, List, Any
5
+ from sraverify.services.guardduty.base import GuardDutyCheck
6
+ from sraverify.core.logging import logger
7
+
8
+
9
+ class SRA_GUARDDUTY_24(GuardDutyCheck):
10
+ """Check if GuardDuty Lambda Network Logs are configured for auto-enablement."""
11
+
12
+ def __init__(self):
13
+ """Initialize GuardDuty Lambda Network Logs auto-enablement check."""
14
+ super().__init__()
15
+ self.check_id = "SRA-GUARDDUTY-24"
16
+ self.check_name = "GuardDuty Lambda Network Logs auto-enablement configured"
17
+ self.description = ("This check verifies whether Lambda Network Logs are configured for auto-enablement "
18
+ "in GuardDuty for all member accounts. Lambda Network Logs monitoring analyzes VPC flow logs "
19
+ "for Lambda functions to detect potentially suspicious network activity.")
20
+ self.severity = "HIGH"
21
+ self.check_logic = "Check if LAMBDA_NETWORK_LOGS feature is configured with AutoEnable set to ALL."
22
+ self.account_type = "audit"
23
+
24
+ def execute(self) -> List[Dict[str, Any]]:
25
+ """
26
+ Execute the check.
27
+
28
+ Returns:
29
+ List of findings
30
+ """
31
+ findings = []
32
+ # Check all regions
33
+ for region in self.regions:
34
+ detector_id = self.get_detector_id(region)
35
+
36
+ # Handle regions where we can't access GuardDuty
37
+ if not detector_id:
38
+ findings.append(self.create_finding(
39
+ status="ERROR",
40
+ region=region,
41
+ resource_id=f"guardduty:{region}",
42
+ actual_value="Unable to access GuardDuty in this region",
43
+ remediation="Check permissions or if GuardDuty is supported in this region"
44
+ ))
45
+ continue
46
+
47
+ # Get organization configuration for GuardDuty
48
+ org_config = self.get_organization_configuration(region)
49
+
50
+ # Check if there was an error in the response
51
+ if "Error" in org_config:
52
+ error_code = org_config["Error"].get("Code", "Unknown")
53
+ error_message = org_config["Error"].get("Message", "Unknown error")
54
+
55
+ # Handle BadRequestException specifically for non-management accounts
56
+ if error_code == "BadRequestException":
57
+ findings.append(self.create_finding(
58
+ status="FAIL",
59
+ region=region,
60
+ resource_id=f"guardduty:{region}:{detector_id}",
61
+ actual_value=f"{error_code} {error_message}",
62
+ remediation="Verify that GuardDuty is the delegated admin in this Region and run the check again."
63
+ ))
64
+ else:
65
+ findings.append(self.create_finding(
66
+ status="ERROR",
67
+ region=region,
68
+ resource_id=f"guardduty:{region}:{detector_id}",
69
+ actual_value=f"Error accessing GuardDuty organization configuration: {error_code}",
70
+ remediation="Check permissions and AWS Organizations configuration"
71
+ ))
72
+ continue
73
+
74
+ # Check if Lambda Network Logs are configured for auto-enablement
75
+ # Look for LAMBDA_NETWORK_LOGS in Features
76
+ lambda_network_logs_found = False
77
+ lambda_network_logs_auto_enable = "NOT_CONFIGURED"
78
+ features = org_config.get('Features', [])
79
+
80
+ for feature in features:
81
+ if feature.get('Name') == 'LAMBDA_NETWORK_LOGS':
82
+ lambda_network_logs_found = True
83
+ lambda_network_logs_auto_enable = feature.get('AutoEnable', 'NONE')
84
+ break
85
+
86
+ if lambda_network_logs_found and lambda_network_logs_auto_enable == 'ALL':
87
+ findings.append(self.create_finding(
88
+ status="PASS",
89
+ region=region,
90
+ resource_id=f"guardduty:{region}:{detector_id}",
91
+ actual_value="GuardDuty Lambda Network Logs are configured for auto-enablement for all accounts (AutoEnable=ALL)",
92
+ remediation=""
93
+ ))
94
+ elif lambda_network_logs_found:
95
+ findings.append(self.create_finding(
96
+ status="FAIL",
97
+ region=region,
98
+ resource_id=f"guardduty:{region}:{detector_id}",
99
+ actual_value=f"GuardDuty Lambda Network Logs are configured with AutoEnable={lambda_network_logs_auto_enable}, but should be ALL",
100
+ remediation=f"Configure Lambda Network Logs auto-enablement for all accounts in {region} by setting AutoEnable to ALL"
101
+ ))
102
+ else:
103
+ findings.append(self.create_finding(
104
+ status="FAIL",
105
+ region=region,
106
+ resource_id=f"guardduty:{region}:{detector_id}",
107
+ actual_value=f"GuardDuty Lambda Network Logs feature is not configured",
108
+ remediation=f"Enable Lambda Network Logs feature and configure auto-enablement for all accounts in {region}"
109
+ ))
110
+
111
+ return findings
@@ -0,0 +1,111 @@
1
+ """
2
+ Check if GuardDuty RDS Login Events are configured for auto-enablement.
3
+ """
4
+ from typing import Dict, List, Any
5
+ from sraverify.services.guardduty.base import GuardDutyCheck
6
+ from sraverify.core.logging import logger
7
+
8
+
9
+ class SRA_GUARDDUTY_25(GuardDutyCheck):
10
+ """Check if GuardDuty RDS Login Events are configured for auto-enablement."""
11
+
12
+ def __init__(self):
13
+ """Initialize GuardDuty RDS Login Events auto-enablement check."""
14
+ super().__init__()
15
+ self.check_id = "SRA-GUARDDUTY-25"
16
+ self.check_name = "GuardDuty RDS Login Events auto-enablement configured"
17
+ self.description = ("This check verifies whether RDS Login Events are configured for auto-enablement "
18
+ "in GuardDuty for all member accounts. RDS Login Events monitoring analyzes database "
19
+ "login activity to detect potentially suspicious login attempts to RDS databases.")
20
+ self.severity = "HIGH"
21
+ self.check_logic = "Check if RDS_LOGIN_EVENTS feature is configured with AutoEnable set to ALL."
22
+ self.account_type = "audit"
23
+
24
+ def execute(self) -> List[Dict[str, Any]]:
25
+ """
26
+ Execute the check.
27
+
28
+ Returns:
29
+ List of findings
30
+ """
31
+ findings = []
32
+ # Check all regions
33
+ for region in self.regions:
34
+ detector_id = self.get_detector_id(region)
35
+
36
+ # Handle regions where we can't access GuardDuty
37
+ if not detector_id:
38
+ findings.append(self.create_finding(
39
+ status="ERROR",
40
+ region=region,
41
+ resource_id=f"guardduty:{region}",
42
+ actual_value="Unable to access GuardDuty in this region",
43
+ remediation="Check permissions or if GuardDuty is supported in this region"
44
+ ))
45
+ continue
46
+
47
+ # Get organization configuration for GuardDuty
48
+ org_config = self.get_organization_configuration(region)
49
+
50
+ # Check if there was an error in the response
51
+ if "Error" in org_config:
52
+ error_code = org_config["Error"].get("Code", "Unknown")
53
+ error_message = org_config["Error"].get("Message", "Unknown error")
54
+
55
+ # Handle BadRequestException specifically for non-management accounts
56
+ if error_code == "BadRequestException":
57
+ findings.append(self.create_finding(
58
+ status="FAIL",
59
+ region=region,
60
+ resource_id=f"guardduty:{region}:{detector_id}",
61
+ actual_value=f"{error_code} {error_message}",
62
+ remediation="Verify that GuardDuty is the delegated admin in this Region and run the check again."
63
+ ))
64
+ else:
65
+ findings.append(self.create_finding(
66
+ status="ERROR",
67
+ region=region,
68
+ resource_id=f"guardduty:{region}:{detector_id}",
69
+ actual_value=f"Error accessing GuardDuty organization configuration: {error_code}",
70
+ remediation="Check permissions and AWS Organizations configuration"
71
+ ))
72
+ continue
73
+
74
+ # Check if RDS Login Events are configured for auto-enablement
75
+ # Look for RDS_LOGIN_EVENTS in Features
76
+ rds_login_events_found = False
77
+ rds_login_events_auto_enable = "NOT_CONFIGURED"
78
+ features = org_config.get('Features', [])
79
+
80
+ for feature in features:
81
+ if feature.get('Name') == 'RDS_LOGIN_EVENTS':
82
+ rds_login_events_found = True
83
+ rds_login_events_auto_enable = feature.get('AutoEnable', 'NONE')
84
+ break
85
+
86
+ if rds_login_events_found and rds_login_events_auto_enable == 'ALL':
87
+ findings.append(self.create_finding(
88
+ status="PASS",
89
+ region=region,
90
+ resource_id=f"guardduty:{region}:{detector_id}",
91
+ actual_value="GuardDuty RDS Login Events are configured for auto-enablement for all accounts (AutoEnable=ALL)",
92
+ remediation=""
93
+ ))
94
+ elif rds_login_events_found:
95
+ findings.append(self.create_finding(
96
+ status="FAIL",
97
+ region=region,
98
+ resource_id=f"guardduty:{region}:{detector_id}",
99
+ actual_value=f"GuardDuty RDS Login Events are configured with AutoEnable={rds_login_events_auto_enable}, but should be ALL",
100
+ remediation=f"Configure RDS Login Events auto-enablement for all accounts in {region} by setting AutoEnable to ALL"
101
+ ))
102
+ else:
103
+ findings.append(self.create_finding(
104
+ status="FAIL",
105
+ region=region,
106
+ resource_id=f"guardduty:{region}:{detector_id}",
107
+ actual_value=f"GuardDuty RDS Login Events feature is not configured",
108
+ remediation=f"Enable RDS Login Events feature and configure auto-enablement for all accounts in {region}"
109
+ ))
110
+
111
+ return findings
@@ -0,0 +1,107 @@
1
+ """
2
+ GuardDuty client for interacting with AWS GuardDuty service.
3
+ """
4
+ from typing import Dict, List, Optional, Any
5
+ import boto3
6
+ from botocore.exceptions import ClientError
7
+ from sraverify.core.logging import logger
8
+
9
+
10
+ class GuardDutyClient:
11
+ """Client for interacting with AWS GuardDuty service."""
12
+
13
+ def __init__(self, region: str, session: Optional[boto3.Session] = None):
14
+ """
15
+ Initialize GuardDuty client for a specific region.
16
+
17
+ Args:
18
+ region: AWS region name
19
+ session: AWS session to use (if None, a new session will be created)
20
+ """
21
+ self.region = region
22
+ self.session = session or boto3.Session()
23
+ self.client = self.session.client('guardduty', region_name=region)
24
+
25
+ def get_detector_id(self) -> Optional[str]:
26
+ """
27
+ Get the detector ID for the current region.
28
+
29
+ Returns:
30
+ Detector ID if GuardDuty is enabled, None otherwise
31
+ """
32
+ try:
33
+ response = self.client.list_detectors()
34
+ detector_ids = response.get('DetectorIds', [])
35
+ if detector_ids:
36
+ return detector_ids[0]
37
+ logger.debug(f"No detector found in {self.region}")
38
+ return None
39
+ except ClientError as e:
40
+ error_code = e.response.get('Error', {}).get('Code', '')
41
+ error_message = str(e)
42
+ logger.error(f"Error getting detector ID in {self.region}: {error_message}")
43
+ # Return a special error indicator instead of None
44
+ return f"ERROR:{error_code}:{error_message}"
45
+
46
+ def get_detector_details(self, detector_id: str) -> Dict[str, Any]:
47
+ """
48
+ Get details for a specific detector.
49
+
50
+ Args:
51
+ detector_id: GuardDuty detector ID
52
+
53
+ Returns:
54
+ Dictionary containing detector details
55
+ """
56
+ try:
57
+ return self.client.get_detector(DetectorId=detector_id)
58
+ except ClientError as e:
59
+ logger.error(f"Error getting detector details for {detector_id} in {self.region}: {e}")
60
+ return {}
61
+
62
+ def describe_organization_configuration(self, detector_id: str) -> Dict[str, Any]:
63
+ """
64
+ Get organization configuration for a specific detector.
65
+
66
+ Args:
67
+ detector_id: GuardDuty detector ID
68
+
69
+ Returns:
70
+ Dictionary containing organization configuration details or error information
71
+ """
72
+ try:
73
+ return self.client.describe_organization_configuration(DetectorId=detector_id)
74
+ except ClientError as e:
75
+ error_code = e.response.get('Error', {}).get('Code', '')
76
+ error_message = str(e)
77
+ logger.error(f"Error getting organization configuration for {detector_id} in {self.region}: {error_message}")
78
+
79
+ # Return a dictionary with error information
80
+ return {
81
+ "Error": {
82
+ "Code": error_code,
83
+ "Message": error_message
84
+ }
85
+ }
86
+
87
+ def list_organization_admin_accounts(self) -> Dict[str, Any]:
88
+ """
89
+ List organization admin accounts for GuardDuty.
90
+
91
+ Returns:
92
+ Dictionary containing organization admin accounts details or error information
93
+ """
94
+ try:
95
+ return self.client.list_organization_admin_accounts()
96
+ except ClientError as e:
97
+ error_code = e.response.get('Error', {}).get('Code', '')
98
+ error_message = str(e)
99
+ logger.error(f"Error listing organization admin accounts for GuardDuty in {self.region}: {error_message}")
100
+
101
+ # Return a dictionary with error information
102
+ return {
103
+ "Error": {
104
+ "Code": error_code,
105
+ "Message": error_message
106
+ }
107
+ }
@@ -0,0 +1,29 @@
1
+ """
2
+ Inspector security checks.
3
+ """
4
+ from sraverify.services.inspector.checks.sra_inspector_01 import SRA_INSPECTOR_01
5
+ from sraverify.services.inspector.checks.sra_inspector_02 import SRA_INSPECTOR_02
6
+ from sraverify.services.inspector.checks.sra_inspector_03 import SRA_INSPECTOR_03
7
+ from sraverify.services.inspector.checks.sra_inspector_04 import SRA_INSPECTOR_04
8
+ from sraverify.services.inspector.checks.sra_inspector_05 import SRA_INSPECTOR_05
9
+ from sraverify.services.inspector.checks.sra_inspector_06 import SRA_INSPECTOR_06
10
+ from sraverify.services.inspector.checks.sra_inspector_07 import SRA_INSPECTOR_07
11
+ from sraverify.services.inspector.checks.sra_inspector_08 import SRA_INSPECTOR_08
12
+ from sraverify.services.inspector.checks.sra_inspector_09 import SRA_INSPECTOR_09
13
+ from sraverify.services.inspector.checks.sra_inspector_10 import SRA_INSPECTOR_10
14
+ from sraverify.services.inspector.checks.sra_inspector_11 import SRA_INSPECTOR_11
15
+
16
+ # Register checks
17
+ CHECKS = {
18
+ "SRA-INSPECTOR-01": SRA_INSPECTOR_01,
19
+ "SRA-INSPECTOR-02": SRA_INSPECTOR_02,
20
+ "SRA-INSPECTOR-03": SRA_INSPECTOR_03,
21
+ "SRA-INSPECTOR-04": SRA_INSPECTOR_04,
22
+ "SRA-INSPECTOR-05": SRA_INSPECTOR_05,
23
+ "SRA-INSPECTOR-06": SRA_INSPECTOR_06,
24
+ "SRA-INSPECTOR-07": SRA_INSPECTOR_07,
25
+ "SRA-INSPECTOR-08": SRA_INSPECTOR_08,
26
+ "SRA-INSPECTOR-09": SRA_INSPECTOR_09,
27
+ "SRA-INSPECTOR-10": SRA_INSPECTOR_10,
28
+ "SRA-INSPECTOR-11": SRA_INSPECTOR_11,
29
+ }