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.
- sraverify/__init__.py +36 -0
- sraverify/checks/__init__.py +56 -0
- sraverify/checks/accessanalyzer/SRA_IAA_1.py +188 -0
- sraverify/checks/accessanalyzer/SRA_IAA_2.py +162 -0
- sraverify/checks/accessanalyzer/SRA_IAA_3.py +260 -0
- sraverify/checks/accessanalyzer/SRA_IAA_4.py +207 -0
- sraverify/checks/accessanalyzer/__init__.py +3 -0
- sraverify/checks/cloudtrail/SRA-CT-1.py +220 -0
- sraverify/checks/cloudtrail/SRA-CT-10.py +229 -0
- sraverify/checks/cloudtrail/SRA-CT-11.py +242 -0
- sraverify/checks/cloudtrail/SRA-CT-12.py +163 -0
- sraverify/checks/cloudtrail/SRA-CT-13.py +279 -0
- sraverify/checks/cloudtrail/SRA-CT-2.py +218 -0
- sraverify/checks/cloudtrail/SRA-CT-3.py +196 -0
- sraverify/checks/cloudtrail/SRA-CT-4.py +161 -0
- sraverify/checks/cloudtrail/SRA-CT-5.py +200 -0
- sraverify/checks/cloudtrail/SRA-CT-6.py +161 -0
- sraverify/checks/cloudtrail/SRA-CT-7.py +194 -0
- sraverify/checks/cloudtrail/SRA-CT-8.py +226 -0
- sraverify/checks/cloudtrail/SRA-CT-9.py +226 -0
- sraverify/checks/cloudtrail/__init__.py +3 -0
- sraverify/checks/config/SRA-CONFIG-1.py +197 -0
- sraverify/checks/config/__init__.py +3 -0
- sraverify/core/__init__.py +3 -0
- sraverify/core/check.py +227 -0
- sraverify/core/logging.py +37 -0
- sraverify/core/session.py +47 -0
- sraverify/lib/__init__.py +4 -0
- sraverify/lib/audit_info.py +37 -0
- sraverify/lib/banner.py +42 -0
- sraverify/lib/check_loader.py +80 -0
- sraverify/lib/org_mgmt_checker.py +86 -0
- sraverify/lib/outputs.py +46 -0
- sraverify/lib/progress.py +75 -0
- sraverify/lib/regions.py +27 -0
- sraverify/lib/session.py +23 -0
- sraverify/main.py +350 -0
- sraverify/services/__init__.py +3 -0
- sraverify/services/accessanalyzer/__init__.py +15 -0
- sraverify/services/accessanalyzer/base.py +123 -0
- sraverify/services/accessanalyzer/checks/__init__.py +3 -0
- sraverify/services/accessanalyzer/checks/sra_accessanalyzer_01.py +82 -0
- sraverify/services/accessanalyzer/checks/sra_accessanalyzer_02.py +82 -0
- sraverify/services/accessanalyzer/checks/sra_accessanalyzer_03.py +103 -0
- sraverify/services/accessanalyzer/checks/sra_accessanalyzer_04.py +139 -0
- sraverify/services/accessanalyzer/client.py +123 -0
- sraverify/services/account/__init__.py +9 -0
- sraverify/services/account/base.py +56 -0
- sraverify/services/account/checks/__init__.py +1 -0
- sraverify/services/account/checks/sra_account_01.py +65 -0
- sraverify/services/account/checks/sra_account_02.py +63 -0
- sraverify/services/account/checks/sra_account_03.py +63 -0
- sraverify/services/account/client.py +51 -0
- sraverify/services/auditmanager/__init__.py +10 -0
- sraverify/services/auditmanager/base.py +72 -0
- sraverify/services/auditmanager/checks/__init__.py +1 -0
- sraverify/services/auditmanager/checks/sra_auditmanager_01.py +58 -0
- sraverify/services/auditmanager/checks/sra_auditmanager_02.py +80 -0
- sraverify/services/auditmanager/client.py +58 -0
- sraverify/services/cloudtrail/__init__.py +33 -0
- sraverify/services/cloudtrail/base.py +167 -0
- sraverify/services/cloudtrail/checks/__init__.py +1 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_01.py +83 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_02.py +99 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_03.py +94 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_04.py +92 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_05.py +106 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_06.py +93 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_07.py +96 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_08.py +145 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_09.py +167 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_10.py +162 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_11.py +178 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_12.py +77 -0
- sraverify/services/cloudtrail/checks/sra_cloudtrail_13.py +120 -0
- sraverify/services/cloudtrail/client.py +118 -0
- sraverify/services/config/__init__.py +25 -0
- sraverify/services/config/base.py +249 -0
- sraverify/services/config/checks/__init__.py +1 -0
- sraverify/services/config/checks/sra_config_01.py +123 -0
- sraverify/services/config/checks/sra_config_02.py +156 -0
- sraverify/services/config/checks/sra_config_03.py +149 -0
- sraverify/services/config/checks/sra_config_04.py +104 -0
- sraverify/services/config/checks/sra_config_05.py +104 -0
- sraverify/services/config/checks/sra_config_06.py +194 -0
- sraverify/services/config/checks/sra_config_07.py +162 -0
- sraverify/services/config/checks/sra_config_08.py +185 -0
- sraverify/services/config/checks/sra_config_09.py +177 -0
- sraverify/services/config/client.py +264 -0
- sraverify/services/ec2/__init__.py +8 -0
- sraverify/services/ec2/base.py +75 -0
- sraverify/services/ec2/checks/__init__.py +1 -0
- sraverify/services/ec2/checks/sra_ec2_01.py +83 -0
- sraverify/services/ec2/client.py +63 -0
- sraverify/services/firewallmanager/__init__.py +23 -0
- sraverify/services/firewallmanager/base.py +48 -0
- sraverify/services/firewallmanager/checks/__init__.py +1 -0
- sraverify/services/firewallmanager/checks/sra_firewallmanager_01.py +75 -0
- sraverify/services/firewallmanager/checks/sra_firewallmanager_02.py +57 -0
- sraverify/services/firewallmanager/checks/sra_firewallmanager_03.py +51 -0
- sraverify/services/firewallmanager/checks/sra_firewallmanager_04.py +51 -0
- sraverify/services/firewallmanager/checks/sra_firewallmanager_05.py +51 -0
- sraverify/services/firewallmanager/checks/sra_firewallmanager_06.py +51 -0
- sraverify/services/firewallmanager/checks/sra_firewallmanager_07.py +51 -0
- sraverify/services/firewallmanager/checks/sra_firewallmanager_08.py +61 -0
- sraverify/services/firewallmanager/checks/sra_firewallmanager_09.py +61 -0
- sraverify/services/firewallmanager/checks/sra_firewallmanager_10.py +71 -0
- sraverify/services/firewallmanager/client.py +40 -0
- sraverify/services/guardduty/__init__.py +58 -0
- sraverify/services/guardduty/base.py +207 -0
- sraverify/services/guardduty/checks/__init__.py +3 -0
- sraverify/services/guardduty/checks/sra_guardduty_01.py +51 -0
- sraverify/services/guardduty/checks/sra_guardduty_02.py +80 -0
- sraverify/services/guardduty/checks/sra_guardduty_03.py +77 -0
- sraverify/services/guardduty/checks/sra_guardduty_04.py +84 -0
- sraverify/services/guardduty/checks/sra_guardduty_05.py +84 -0
- sraverify/services/guardduty/checks/sra_guardduty_06.py +84 -0
- sraverify/services/guardduty/checks/sra_guardduty_07.py +85 -0
- sraverify/services/guardduty/checks/sra_guardduty_08.py +83 -0
- sraverify/services/guardduty/checks/sra_guardduty_09.py +84 -0
- sraverify/services/guardduty/checks/sra_guardduty_10.py +83 -0
- sraverify/services/guardduty/checks/sra_guardduty_11.py +93 -0
- sraverify/services/guardduty/checks/sra_guardduty_12.py +83 -0
- sraverify/services/guardduty/checks/sra_guardduty_13.py +90 -0
- sraverify/services/guardduty/checks/sra_guardduty_14.py +136 -0
- sraverify/services/guardduty/checks/sra_guardduty_15.py +94 -0
- sraverify/services/guardduty/checks/sra_guardduty_16.py +94 -0
- sraverify/services/guardduty/checks/sra_guardduty_17.py +91 -0
- sraverify/services/guardduty/checks/sra_guardduty_18.py +91 -0
- sraverify/services/guardduty/checks/sra_guardduty_19.py +91 -0
- sraverify/services/guardduty/checks/sra_guardduty_20.py +111 -0
- sraverify/services/guardduty/checks/sra_guardduty_21.py +112 -0
- sraverify/services/guardduty/checks/sra_guardduty_22.py +111 -0
- sraverify/services/guardduty/checks/sra_guardduty_23.py +154 -0
- sraverify/services/guardduty/checks/sra_guardduty_24.py +111 -0
- sraverify/services/guardduty/checks/sra_guardduty_25.py +111 -0
- sraverify/services/guardduty/client.py +107 -0
- sraverify/services/inspector/__init__.py +29 -0
- sraverify/services/inspector/base.py +233 -0
- sraverify/services/inspector/checks/__init__.py +3 -0
- sraverify/services/inspector/checks/sra_inspector_01.py +69 -0
- sraverify/services/inspector/checks/sra_inspector_02.py +68 -0
- sraverify/services/inspector/checks/sra_inspector_03.py +68 -0
- sraverify/services/inspector/checks/sra_inspector_04.py +70 -0
- sraverify/services/inspector/checks/sra_inspector_05.py +69 -0
- sraverify/services/inspector/checks/sra_inspector_06.py +115 -0
- sraverify/services/inspector/checks/sra_inspector_07.py +109 -0
- sraverify/services/inspector/checks/sra_inspector_08.py +69 -0
- sraverify/services/inspector/checks/sra_inspector_09.py +69 -0
- sraverify/services/inspector/checks/sra_inspector_10.py +69 -0
- sraverify/services/inspector/checks/sra_inspector_11.py +69 -0
- sraverify/services/inspector/client.py +99 -0
- sraverify/services/macie/__init__.py +27 -0
- sraverify/services/macie/base.py +271 -0
- sraverify/services/macie/checks/__init__.py +1 -0
- sraverify/services/macie/checks/sra_macie_01.py +100 -0
- sraverify/services/macie/checks/sra_macie_02.py +102 -0
- sraverify/services/macie/checks/sra_macie_03.py +152 -0
- sraverify/services/macie/checks/sra_macie_04.py +120 -0
- sraverify/services/macie/checks/sra_macie_05.py +85 -0
- sraverify/services/macie/checks/sra_macie_06.py +124 -0
- sraverify/services/macie/checks/sra_macie_07.py +138 -0
- sraverify/services/macie/checks/sra_macie_08.py +82 -0
- sraverify/services/macie/checks/sra_macie_09.py +103 -0
- sraverify/services/macie/checks/sra_macie_10.py +81 -0
- sraverify/services/macie/client.py +220 -0
- sraverify/services/s3/__init__.py +16 -0
- sraverify/services/s3/base.py +69 -0
- sraverify/services/s3/checks/__init__.py +1 -0
- sraverify/services/s3/checks/sra_s3_01.py +89 -0
- sraverify/services/s3/checks/sra_s3_02.py +89 -0
- sraverify/services/s3/checks/sra_s3_03.py +88 -0
- sraverify/services/s3/checks/sra_s3_04.py +88 -0
- sraverify/services/s3/client.py +52 -0
- sraverify/services/securityhub/__init__.py +27 -0
- sraverify/services/securityhub/base.py +349 -0
- sraverify/services/securityhub/checks/__init__.py +1 -0
- sraverify/services/securityhub/checks/sra_securityhub_01.py +115 -0
- sraverify/services/securityhub/checks/sra_securityhub_02.py +114 -0
- sraverify/services/securityhub/checks/sra_securityhub_03.py +136 -0
- sraverify/services/securityhub/checks/sra_securityhub_04.py +75 -0
- sraverify/services/securityhub/checks/sra_securityhub_05.py +102 -0
- sraverify/services/securityhub/checks/sra_securityhub_06.py +113 -0
- sraverify/services/securityhub/checks/sra_securityhub_07.py +121 -0
- sraverify/services/securityhub/checks/sra_securityhub_08.py +113 -0
- sraverify/services/securityhub/checks/sra_securityhub_09.py +100 -0
- sraverify/services/securityhub/checks/sra_securityhub_10.py +94 -0
- sraverify/services/securityhub/checks/sra_securityhub_11.py +73 -0
- sraverify/services/securityhub/client.py +249 -0
- sraverify/services/securityincidentresponse/__init__.py +13 -0
- sraverify/services/securityincidentresponse/base.py +95 -0
- sraverify/services/securityincidentresponse/checks/__init__.py +1 -0
- sraverify/services/securityincidentresponse/checks/sra_securityincidentresponse_01.py +77 -0
- sraverify/services/securityincidentresponse/checks/sra_securityincidentresponse_02.py +72 -0
- sraverify/services/securityincidentresponse/checks/sra_securityincidentresponse_03.py +86 -0
- sraverify/services/securityincidentresponse/checks/sra_securityincidentresponse_04.py +117 -0
- sraverify/services/securityincidentresponse/checks/sra_securityincidentresponse_05.py +55 -0
- sraverify/services/securityincidentresponse/client.py +71 -0
- sraverify/services/securitylake/__init__.py +39 -0
- sraverify/services/securitylake/base.py +461 -0
- sraverify/services/securitylake/checks/__init__.py +1 -0
- sraverify/services/securitylake/checks/sra_securitylake_01.py +98 -0
- sraverify/services/securitylake/checks/sra_securitylake_02.py +133 -0
- sraverify/services/securitylake/checks/sra_securitylake_03.py +116 -0
- sraverify/services/securitylake/checks/sra_securitylake_04.py +72 -0
- sraverify/services/securitylake/checks/sra_securitylake_05.py +116 -0
- sraverify/services/securitylake/checks/sra_securitylake_06.py +104 -0
- sraverify/services/securitylake/checks/sra_securitylake_07.py +108 -0
- sraverify/services/securitylake/checks/sra_securitylake_08.py +107 -0
- sraverify/services/securitylake/checks/sra_securitylake_09.py +107 -0
- sraverify/services/securitylake/checks/sra_securitylake_10.py +106 -0
- sraverify/services/securitylake/checks/sra_securitylake_11.py +109 -0
- sraverify/services/securitylake/checks/sra_securitylake_12.py +108 -0
- sraverify/services/securitylake/checks/sra_securitylake_13.py +108 -0
- sraverify/services/securitylake/checks/sra_securitylake_14.py +72 -0
- sraverify/services/securitylake/checks/sra_securitylake_15.py +120 -0
- sraverify/services/securitylake/checks/sra_securitylake_16.py +104 -0
- sraverify/services/securitylake/checks/sra_securitylake_17.py +103 -0
- sraverify/services/securitylake/client.py +247 -0
- sraverify/services/shield/__init__.py +33 -0
- sraverify/services/shield/base.py +199 -0
- sraverify/services/shield/checks/__init__.py +1 -0
- sraverify/services/shield/checks/sra_shield_01.py +68 -0
- sraverify/services/shield/checks/sra_shield_02.py +77 -0
- sraverify/services/shield/checks/sra_shield_03.py +84 -0
- sraverify/services/shield/checks/sra_shield_04.py +84 -0
- sraverify/services/shield/checks/sra_shield_05.py +84 -0
- sraverify/services/shield/checks/sra_shield_06.py +84 -0
- sraverify/services/shield/checks/sra_shield_07.py +84 -0
- sraverify/services/shield/checks/sra_shield_08.py +69 -0
- sraverify/services/shield/checks/sra_shield_09.py +86 -0
- sraverify/services/shield/checks/sra_shield_10.py +100 -0
- sraverify/services/shield/checks/sra_shield_11.py +71 -0
- sraverify/services/shield/checks/sra_shield_12.py +130 -0
- sraverify/services/shield/checks/sra_shield_13.py +112 -0
- sraverify/services/shield/checks/sra_shield_14.py +111 -0
- sraverify/services/shield/client.py +214 -0
- sraverify/services/waf/__init__.py +21 -0
- sraverify/services/waf/base.py +100 -0
- sraverify/services/waf/checks/__init__.py +1 -0
- sraverify/services/waf/checks/sra_waf_01.py +63 -0
- sraverify/services/waf/checks/sra_waf_02.py +82 -0
- sraverify/services/waf/checks/sra_waf_03.py +123 -0
- sraverify/services/waf/checks/sra_waf_04.py +94 -0
- sraverify/services/waf/checks/sra_waf_05.py +94 -0
- sraverify/services/waf/checks/sra_waf_06.py +91 -0
- sraverify/services/waf/checks/sra_waf_07.py +94 -0
- sraverify/services/waf/checks/sra_waf_08.py +66 -0
- sraverify/services/waf/checks/sra_waf_09.py +95 -0
- sraverify/services/waf/client.py +109 -0
- sraverify/utils/__init__.py +3 -0
- sraverify/utils/banner.py +65 -0
- sraverify/utils/outputs.py +57 -0
- sraverify/utils/progress.py +97 -0
- sraverify-0.1.0.dist-info/LICENSE +175 -0
- sraverify-0.1.0.dist-info/METADATA +516 -0
- sraverify-0.1.0.dist-info/NOTICE +1 -0
- sraverify-0.1.0.dist-info/RECORD +261 -0
- sraverify-0.1.0.dist-info/WHEEL +5 -0
- sraverify-0.1.0.dist-info/entry_points.txt +2 -0
- sraverify-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sraverify
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AWS Security Reference Architecture Verification Tool
|
|
5
|
+
Home-page: https://github.com/awslabs/sra-verify
|
|
6
|
+
Author: SRA Verify team
|
|
7
|
+
Author-email: schiefj@amazon.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
License-File: NOTICE
|
|
15
|
+
Requires-Dist: boto3>=1.26.0
|
|
16
|
+
Requires-Dist: colorama>=0.4.4
|
|
17
|
+
|
|
18
|
+
# SRA Verify
|
|
19
|
+
|
|
20
|
+
SRA Verify is a Python-based security auditing tool designed to assess AWS infrastructure configurations against the AWS
|
|
21
|
+
Security Reference Architecture (SRA). It helps identify security gaps and provides remediation guidance.
|
|
22
|
+
|
|
23
|
+
## Project Structure
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
sra-verify/
|
|
27
|
+
├── README.md
|
|
28
|
+
├── 1-sraverify-member-roles.yaml # CloudFormation template for member roles
|
|
29
|
+
├── 2-sraverify-codebuild-deploy.yaml # CloudFormation template for CodeBuild
|
|
30
|
+
├── s3_sync_command.sh # Script to sync files to S3
|
|
31
|
+
├── sraverify/ # Main package directory
|
|
32
|
+
│ ├── setup.py # Package setup configuration
|
|
33
|
+
│ ├── requirements.txt # Dependencies
|
|
34
|
+
│ ├── sraverify/ # Core code
|
|
35
|
+
│ │ ├── main.py # Entry point
|
|
36
|
+
│ │ ├── core/ # Core functionality
|
|
37
|
+
│ │ │ ├── check.py # Base security check class
|
|
38
|
+
│ │ │ ├── session.py # AWS session management
|
|
39
|
+
│ │ │ └── logging.py # Logging configuration
|
|
40
|
+
│ │ ├── services/ # Service-specific modules
|
|
41
|
+
│ │ │ ├── guardduty/ # GuardDuty checks
|
|
42
|
+
│ │ │ │ ├── base.py # GuardDuty base check class
|
|
43
|
+
│ │ │ │ ├── client.py # GuardDuty API client
|
|
44
|
+
│ │ │ │ └── checks/ # Individual GuardDuty checks
|
|
45
|
+
│ │ │ └── cloudtrail/ # CloudTrail checks
|
|
46
|
+
│ │ └── utils/ # Utility functions
|
|
47
|
+
│ └── tests/ # Test cases
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Project architecture
|
|
51
|
+
|
|
52
|
+
SRA Verify is designed with an extensible framework that makes it easy to add new security checks.
|
|
53
|
+
|
|
54
|
+
```mermaid
|
|
55
|
+
classDiagram
|
|
56
|
+
class SecurityCheck {
|
|
57
|
+
+check_type: str
|
|
58
|
+
+service: str
|
|
59
|
+
+resource_type: str
|
|
60
|
+
+check_id: str
|
|
61
|
+
+check_name: str
|
|
62
|
+
+description: str
|
|
63
|
+
+rational: str
|
|
64
|
+
+remediation: str
|
|
65
|
+
+severity: str
|
|
66
|
+
+check_logic: str
|
|
67
|
+
+findings: list
|
|
68
|
+
+regions: list
|
|
69
|
+
+session: boto3.Session
|
|
70
|
+
+_clients: dict
|
|
71
|
+
|
|
72
|
+
+_get_enabled_regions()
|
|
73
|
+
+initialize(session, regions)
|
|
74
|
+
+get_client(region)
|
|
75
|
+
+create_finding(status, region, account_id, resource_id, actual_value, remediation)
|
|
76
|
+
+get_findings()
|
|
77
|
+
+get_session_accountId(session)
|
|
78
|
+
+get_management_accountId(session)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
class GuardDutyCheck {
|
|
82
|
+
+_detector_details_cache: dict
|
|
83
|
+
+_detector_ids_cache: dict
|
|
84
|
+
+_setup_clients()
|
|
85
|
+
+get_detector_id(region)
|
|
86
|
+
+get_detector_details(region)
|
|
87
|
+
+get_enabled_regions()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
class GuardDutyClient {
|
|
91
|
+
+region: str
|
|
92
|
+
+session: boto3.Session
|
|
93
|
+
+client: boto3.client
|
|
94
|
+
+get_detector_id()
|
|
95
|
+
+get_detector_details(detector_id)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
class SRA_GD_1 {
|
|
99
|
+
+check_id: str
|
|
100
|
+
+check_name: str
|
|
101
|
+
+description: str
|
|
102
|
+
+severity: str
|
|
103
|
+
+check_logic: str
|
|
104
|
+
+execute()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
class SRA_GD_2 {
|
|
108
|
+
+check_id: str
|
|
109
|
+
+check_name: str
|
|
110
|
+
+description: str
|
|
111
|
+
+severity: str
|
|
112
|
+
+check_logic: str
|
|
113
|
+
+execute()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
class SRA_GD_3 {
|
|
117
|
+
+check_id: str
|
|
118
|
+
+check_name: str
|
|
119
|
+
+description: str
|
|
120
|
+
+severity: str
|
|
121
|
+
+check_logic: str
|
|
122
|
+
+execute()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
SecurityCheck <|-- GuardDutyCheck : extends
|
|
126
|
+
GuardDutyCheck <|-- SRA_GD_1 : extends
|
|
127
|
+
GuardDutyCheck <|-- SRA_GD_2 : extends
|
|
128
|
+
GuardDutyCheck <|-- SRA_GD_3 : extends
|
|
129
|
+
|
|
130
|
+
GuardDutyCheck --> GuardDutyClient : uses
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Data Flow
|
|
134
|
+
SRA Verify performs security assessments by analyzing AWS service configurations and generating findings.
|
|
135
|
+
|
|
136
|
+
```ascii
|
|
137
|
+
[AWS Account] --> [SRAVerify Tool] --> [Security Checks] --> [Findings]
|
|
138
|
+
| | | |
|
|
139
|
+
| | | |
|
|
140
|
+
v v v v
|
|
141
|
+
[IAM Roles] --> [AWS Session] --> [Service Clients] --> [CSV Reports]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Component Interactions:
|
|
145
|
+
- SRAVerify assumes IAM roles in target accounts
|
|
146
|
+
- Executes service-specific security checks
|
|
147
|
+
- Generates findings with status and remediation steps
|
|
148
|
+
- Outputs results to CSV format
|
|
149
|
+
- Supports parallel execution across accounts
|
|
150
|
+
- Handles regional service availability
|
|
151
|
+
|
|
152
|
+
### Best Practices for Check Implementation
|
|
153
|
+
|
|
154
|
+
1. Meaningful IDs: Use a consistent naming scheme (SRA-XX-#) where XX is a service abbreviation
|
|
155
|
+
2. Clear Descriptions: Provide detailed descriptions of what the check verifies
|
|
156
|
+
3. Actionable Remediation: Include specific steps for remediation in failure cases
|
|
157
|
+
4. Caching: Use caching for expensive API calls that might be reused across checks
|
|
158
|
+
|
|
159
|
+
Follow these steps to implement your own checks:
|
|
160
|
+
|
|
161
|
+
### 1. Determine the AWS Service
|
|
162
|
+
|
|
163
|
+
First, decide which AWS service your check will target. If it's a service that already has checks (like GuardDuty or
|
|
164
|
+
CloudTrail), you can add to the existing module. Otherwise, you'll need to create a new service module.
|
|
165
|
+
|
|
166
|
+
### 2. Create Service Module (if needed)
|
|
167
|
+
|
|
168
|
+
If you're adding checks for a new service, create the following structure:
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
sraverify/sraverify/services/your_service/
|
|
172
|
+
├── __init__.py
|
|
173
|
+
├── base.py
|
|
174
|
+
├── client.py
|
|
175
|
+
└── checks/
|
|
176
|
+
├── __init__.py
|
|
177
|
+
└── sra_xx_1.py
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### 3. Implement Service Client
|
|
181
|
+
|
|
182
|
+
Create a client class to handle API interactions with the AWS service:
|
|
183
|
+
|
|
184
|
+
- Mirror AWS SDK method naming patterns when appropriate.
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
# sraverify/sraverify/services/your_service/client.py
|
|
188
|
+
from typing import Dict, Optional, Any
|
|
189
|
+
import boto3
|
|
190
|
+
from botocore.exceptions import ClientError
|
|
191
|
+
from sraverify.core.logging import logger
|
|
192
|
+
|
|
193
|
+
class YourServiceClient:
|
|
194
|
+
def __init__(self, region: str, session: Optional[boto3.Session] = None):
|
|
195
|
+
self.region = region
|
|
196
|
+
self.session = session or boto3.Session()
|
|
197
|
+
self.client = self.session.client('your_service', region_name=region)
|
|
198
|
+
|
|
199
|
+
def get_resource(self) -> Dict[str, Any]:
|
|
200
|
+
try:
|
|
201
|
+
return self.client.describe_resource()
|
|
202
|
+
except ClientError as e:
|
|
203
|
+
logger.error(f"Error getting resource in {self.region}: {e}")
|
|
204
|
+
return {}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### 4. Create Base Check Class
|
|
208
|
+
|
|
209
|
+
Implement a base class for your service that extends SecurityCheck.
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
# sraverify/sraverify/services/your_service/base.py
|
|
213
|
+
from typing import Dict, Any
|
|
214
|
+
from sraverify.core.check import SecurityCheck
|
|
215
|
+
from sraverify.services.your_service.client import YourServiceClient
|
|
216
|
+
|
|
217
|
+
class YourServiceCheck(SecurityCheck):
|
|
218
|
+
def __init__(self):
|
|
219
|
+
super().__init__(
|
|
220
|
+
check_type="account", # or "management" if appropriate
|
|
221
|
+
service="YourService",
|
|
222
|
+
resource_type="AWS::YourService::Resource"
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
def _setup_clients(self):
|
|
226
|
+
self._clients.clear()
|
|
227
|
+
if hasattr(self, 'regions') and self.regions:
|
|
228
|
+
for region in self.regions:
|
|
229
|
+
self._clients[region] = YourServiceClient(region, session=self.session)
|
|
230
|
+
|
|
231
|
+
# Add helper methods for common operations
|
|
232
|
+
def get_resource_details(self, region: str) -> Dict[str, Any]:
|
|
233
|
+
client = self.get_client(region)
|
|
234
|
+
if not client:
|
|
235
|
+
return {}
|
|
236
|
+
return client.get_resource()
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### 5. Implement Individual Checks
|
|
240
|
+
|
|
241
|
+
Create a new check class that extends your service's base check class:
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
# sraverify/sraverify/services/your_service/checks/sra_xx_1.py
|
|
245
|
+
from typing import Dict, List, Any
|
|
246
|
+
from sraverify.services.your_service.base import YourServiceCheck
|
|
247
|
+
|
|
248
|
+
class SRA_XX_1(YourServiceCheck):
|
|
249
|
+
def __init__(self):
|
|
250
|
+
super().__init__()
|
|
251
|
+
self.check_id = "SRA-XX-1"
|
|
252
|
+
self.check_name = "Your check name"
|
|
253
|
+
self.description = "Detailed description of what this check verifies"
|
|
254
|
+
self.severity = "HIGH" # or MEDIUM, LOW
|
|
255
|
+
self.check_logic = "Description of the logic used to perform the check"
|
|
256
|
+
|
|
257
|
+
def execute(self) -> List[Dict[str, Any]]:
|
|
258
|
+
account_id = self.get_session_accountId(self.session)
|
|
259
|
+
|
|
260
|
+
for region in self.regions:
|
|
261
|
+
resource = self.get_resource_details(region)
|
|
262
|
+
|
|
263
|
+
if not resource or not self._is_compliant(resource):
|
|
264
|
+
self.findings.append(self.create_finding(
|
|
265
|
+
status="FAIL",
|
|
266
|
+
region=region,
|
|
267
|
+
account_id=account_id,
|
|
268
|
+
resource_id=None,
|
|
269
|
+
actual_value="Current configuration",
|
|
270
|
+
remediation="Steps to remediate the issue"
|
|
271
|
+
))
|
|
272
|
+
else:
|
|
273
|
+
self.findings.append(self.create_finding(
|
|
274
|
+
status="PASS",
|
|
275
|
+
region=region,
|
|
276
|
+
account_id=account_id,
|
|
277
|
+
resource_id=f"resource-id",
|
|
278
|
+
actual_value="Compliant configuration",
|
|
279
|
+
remediation="No remediation needed"
|
|
280
|
+
))
|
|
281
|
+
|
|
282
|
+
return self.findings
|
|
283
|
+
|
|
284
|
+
def _is_compliant(self, resource: Dict[str, Any]) -> bool:
|
|
285
|
+
# Implement your compliance check logic here
|
|
286
|
+
return resource.get('SecureSetting') == True
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### 6. Register Your Check
|
|
290
|
+
|
|
291
|
+
Add your check to the __init__.py file in your service directory:
|
|
292
|
+
|
|
293
|
+
```python
|
|
294
|
+
# sraverify/sraverify/services/your_service/__init__.py
|
|
295
|
+
from sraverify.services.your_service.checks.sra_xx_1 import SRA_XX_1
|
|
296
|
+
|
|
297
|
+
CHECKS = {
|
|
298
|
+
"SRA-XX-1": SRA_XX_1,
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### 7. Import in Main Module
|
|
303
|
+
|
|
304
|
+
Finally, import your service's checks in the main module:
|
|
305
|
+
|
|
306
|
+
```python
|
|
307
|
+
# sraverify/sraverify/main.py
|
|
308
|
+
# Add to imports
|
|
309
|
+
from sraverify.services.your_service import CHECKS as your_service_checks
|
|
310
|
+
|
|
311
|
+
# Add to ALL_CHECKS dictionary
|
|
312
|
+
ALL_CHECKS = {
|
|
313
|
+
**guardduty_checks,
|
|
314
|
+
**cloudtrail_checks,
|
|
315
|
+
**your_service_checks, # Add your new checks
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### 8. Test Your Check
|
|
320
|
+
|
|
321
|
+
Test your new check by running:
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
sraverify --check SRA-XX-1 --debug
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## Caching
|
|
328
|
+
|
|
329
|
+
SRA Verify implements an efficient caching system to minimize redundant API calls when performing security checks across multiple AWS regions and services.
|
|
330
|
+
This improves performance and reduces the risk of hitting API rate limits.
|
|
331
|
+
|
|
332
|
+
```python
|
|
333
|
+
class ServiceCheck(SecurityCheck):
|
|
334
|
+
# Class-level caches shared across all instances
|
|
335
|
+
_resource_cache = {}
|
|
336
|
+
_configuration_cache = {}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
Refer the the GuardDuty base.py file for an implementation example.
|
|
340
|
+
|
|
341
|
+
## Check Types
|
|
342
|
+
|
|
343
|
+
SRA Verify categorizes security checks into different types based on their scope and the AWS account context they operate in. Understanding these check types
|
|
344
|
+
is essential for properly implementing and running checks across your AWS environment.
|
|
345
|
+
|
|
346
|
+
### Available Check Types
|
|
347
|
+
|
|
348
|
+
SRA Verify supports the following check types:
|
|
349
|
+
|
|
350
|
+
**Account Checks**
|
|
351
|
+
|
|
352
|
+
Account checks evaluate security configurations within a single AWS account. These checks focus on resources and settings that are account-specific and can
|
|
353
|
+
be assessed independently.
|
|
354
|
+
|
|
355
|
+
Examples:
|
|
356
|
+
- Verifying GuardDuty detector exists in each region
|
|
357
|
+
- Checking if CloudTrail logging is enabled
|
|
358
|
+
|
|
359
|
+
**Management Checks**
|
|
360
|
+
|
|
361
|
+
Management checks assess configurations that involve AWS Organizations management account or organization-wide settings. These checks typically require
|
|
362
|
+
access to the Organizations API and evaluate controls that affect multiple accounts.
|
|
363
|
+
|
|
364
|
+
Examples:
|
|
365
|
+
- Check for an organization CloudTrail
|
|
366
|
+
|
|
367
|
+
When SRA Verify is deployed and run via CodeBuild, management checks will be ran on the management account. Account checks will be ran on each member.
|
|
368
|
+
|
|
369
|
+
## Library Usage
|
|
370
|
+
### Installation as a Library
|
|
371
|
+
```bash
|
|
372
|
+
pip install git+https://github.com/yourusername/sraverify.git
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Code Examples
|
|
376
|
+
|
|
377
|
+
Here's a comprehensive example demonstrating all major features of the SRAVerify library:
|
|
378
|
+
|
|
379
|
+
```python
|
|
380
|
+
#!/usr/bin/env python3
|
|
381
|
+
"""
|
|
382
|
+
Comprehensive example of using SRA Verify as a library.
|
|
383
|
+
|
|
384
|
+
This example demonstrates all the major functionality provided by the SRAVerify library,
|
|
385
|
+
including initialization, listing available checks and services, and running checks with
|
|
386
|
+
various filtering options.
|
|
387
|
+
"""
|
|
388
|
+
|
|
389
|
+
import json
|
|
390
|
+
from typing import Dict, Any
|
|
391
|
+
from sraverify import SRAVerify
|
|
392
|
+
|
|
393
|
+
# Configuration
|
|
394
|
+
AWS_PROFILE = 'default' # Change this to your AWS profile if needed
|
|
395
|
+
AWS_REGIONS = ['us-east-1', 'us-west-2'] # Regions to check
|
|
396
|
+
AUDIT_ACCOUNTS = ['123456789012'] # Replace with your audit account IDs
|
|
397
|
+
LOG_ARCHIVE_ACCOUNTS = ['987654321098'] # Replace with your log archive account IDs
|
|
398
|
+
|
|
399
|
+
def print_section(title: str):
|
|
400
|
+
"""Print a section header."""
|
|
401
|
+
print("\n" + "=" * 80)
|
|
402
|
+
print(f" {title} ".center(80, "="))
|
|
403
|
+
print("=" * 80 + "\n")
|
|
404
|
+
|
|
405
|
+
def pretty_print(data: Dict[str, Any]):
|
|
406
|
+
"""Print data in a formatted way."""
|
|
407
|
+
print(json.dumps(data, indent=2))
|
|
408
|
+
|
|
409
|
+
def main():
|
|
410
|
+
"""Run the comprehensive example."""
|
|
411
|
+
print_section("SRAVerify Library Usage Example")
|
|
412
|
+
|
|
413
|
+
# Initialize SRAVerify with configuration
|
|
414
|
+
print("Initializing SRAVerify...")
|
|
415
|
+
sra = SRAVerify(
|
|
416
|
+
profile=AWS_PROFILE,
|
|
417
|
+
regions=AWS_REGIONS,
|
|
418
|
+
debug=True # Enable debug logging
|
|
419
|
+
)
|
|
420
|
+
print("✓ SRAVerify initialized\n")
|
|
421
|
+
|
|
422
|
+
# Example 1: List all available services
|
|
423
|
+
print_section("Available Services")
|
|
424
|
+
services = sra.get_available_services()
|
|
425
|
+
print("Services that can be checked:")
|
|
426
|
+
for service in services:
|
|
427
|
+
print(f" • {service}")
|
|
428
|
+
|
|
429
|
+
# Example 2: List all available checks
|
|
430
|
+
print_section("Available Checks")
|
|
431
|
+
all_checks = sra.get_available_checks()
|
|
432
|
+
print("All available security checks:")
|
|
433
|
+
for check_id, info in all_checks.items():
|
|
434
|
+
print(f"\n{check_id}:")
|
|
435
|
+
print(f" Name: {info['name']}")
|
|
436
|
+
print(f" Service: {info['service']}")
|
|
437
|
+
print(f" Account Type: {info['account_type']}")
|
|
438
|
+
print(f" Severity: {info['severity']}")
|
|
439
|
+
|
|
440
|
+
# Example 3: Get checks for specific account types
|
|
441
|
+
print_section("Account-Specific Checks")
|
|
442
|
+
account_types = ['management', 'audit', 'log-archive', 'application']
|
|
443
|
+
|
|
444
|
+
for acc_type in account_types:
|
|
445
|
+
checks = sra.get_available_checks(account_type=acc_type)
|
|
446
|
+
print(f"\nChecks for {acc_type} accounts:")
|
|
447
|
+
for check_id, info in checks.items():
|
|
448
|
+
print(f" • {check_id}: {info['name']}")
|
|
449
|
+
|
|
450
|
+
# Example 4: Run all checks
|
|
451
|
+
print_section("Running All Checks")
|
|
452
|
+
print("Running all security checks...")
|
|
453
|
+
findings = sra.run_checks(
|
|
454
|
+
account_type='all',
|
|
455
|
+
audit_accounts=AUDIT_ACCOUNTS,
|
|
456
|
+
log_archive_accounts=LOG_ARCHIVE_ACCOUNTS,
|
|
457
|
+
show_progress=True
|
|
458
|
+
)
|
|
459
|
+
|
|
460
|
+
# Process and display findings
|
|
461
|
+
pass_count = sum(1 for f in findings if f['Status'] == 'PASS')
|
|
462
|
+
fail_count = sum(1 for f in findings if f['Status'] == 'FAIL')
|
|
463
|
+
error_count = sum(1 for f in findings if f['Status'] == 'ERROR')
|
|
464
|
+
|
|
465
|
+
print("\nResults Summary:")
|
|
466
|
+
print(f" Total Findings: {len(findings)}")
|
|
467
|
+
print(f" Pass: {pass_count}")
|
|
468
|
+
print(f" Fail: {fail_count}")
|
|
469
|
+
print(f" Error: {error_count}")
|
|
470
|
+
|
|
471
|
+
# Example 5: Run checks for specific service
|
|
472
|
+
print_section("Service-Specific Checks")
|
|
473
|
+
print("Running GuardDuty checks...")
|
|
474
|
+
gd_findings = sra.run_checks(
|
|
475
|
+
service='GuardDuty',
|
|
476
|
+
show_progress=True
|
|
477
|
+
)
|
|
478
|
+
|
|
479
|
+
print(f"\nGuardDuty Findings: {len(gd_findings)}")
|
|
480
|
+
for finding in gd_findings:
|
|
481
|
+
print(f"\nCheck: {finding['CheckId']}")
|
|
482
|
+
print(f"Status: {finding['Status']}")
|
|
483
|
+
print(f"Title: {finding['Title']}")
|
|
484
|
+
if finding['Status'] == 'FAIL':
|
|
485
|
+
print(f"Remediation: {finding['Remediation']}")
|
|
486
|
+
|
|
487
|
+
# Example 6: Run specific check
|
|
488
|
+
print_section("Single Check Example")
|
|
489
|
+
print("Running specific CloudTrail check (SRA-CT-1)...")
|
|
490
|
+
ct_findings = sra.run_checks(
|
|
491
|
+
check_id='SRA-CT-1',
|
|
492
|
+
show_progress=True
|
|
493
|
+
)
|
|
494
|
+
|
|
495
|
+
print("\nCloudTrail Check Results:")
|
|
496
|
+
pretty_print(ct_findings)
|
|
497
|
+
|
|
498
|
+
if __name__ == "__main__":
|
|
499
|
+
main()
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
This example demonstrates:
|
|
503
|
+
1. Initializing SRA Verify with custom configuration
|
|
504
|
+
2. Listing available services
|
|
505
|
+
3. Listing all security checks
|
|
506
|
+
4. Getting account-specific checks
|
|
507
|
+
5. Running all security checks
|
|
508
|
+
6. Running service-specific checks
|
|
509
|
+
7. Running individual checks
|
|
510
|
+
|
|
511
|
+
To use this example:
|
|
512
|
+
1. Save it as `example_sraverify.py`
|
|
513
|
+
2. Update the AWS configuration variables at the top
|
|
514
|
+
3. Run with `python example_sraverify.py`
|
|
515
|
+
|
|
516
|
+
The example demonstrates all major features of the library with proper error handling and formatted output.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|