complio 0.1.1__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 (79) hide show
  1. CHANGELOG.md +208 -0
  2. README.md +343 -0
  3. complio/__init__.py +48 -0
  4. complio/cli/__init__.py +0 -0
  5. complio/cli/banner.py +87 -0
  6. complio/cli/commands/__init__.py +0 -0
  7. complio/cli/commands/history.py +439 -0
  8. complio/cli/commands/scan.py +700 -0
  9. complio/cli/main.py +115 -0
  10. complio/cli/output.py +338 -0
  11. complio/config/__init__.py +17 -0
  12. complio/config/settings.py +333 -0
  13. complio/connectors/__init__.py +9 -0
  14. complio/connectors/aws/__init__.py +0 -0
  15. complio/connectors/aws/client.py +342 -0
  16. complio/connectors/base.py +135 -0
  17. complio/core/__init__.py +10 -0
  18. complio/core/registry.py +228 -0
  19. complio/core/runner.py +351 -0
  20. complio/py.typed +0 -0
  21. complio/reporters/__init__.py +7 -0
  22. complio/reporters/generator.py +417 -0
  23. complio/tests_library/__init__.py +0 -0
  24. complio/tests_library/base.py +492 -0
  25. complio/tests_library/identity/__init__.py +0 -0
  26. complio/tests_library/identity/access_key_rotation.py +302 -0
  27. complio/tests_library/identity/mfa_enforcement.py +327 -0
  28. complio/tests_library/identity/root_account_protection.py +470 -0
  29. complio/tests_library/infrastructure/__init__.py +0 -0
  30. complio/tests_library/infrastructure/cloudtrail_encryption.py +286 -0
  31. complio/tests_library/infrastructure/cloudtrail_log_validation.py +274 -0
  32. complio/tests_library/infrastructure/cloudtrail_logging.py +400 -0
  33. complio/tests_library/infrastructure/ebs_encryption.py +244 -0
  34. complio/tests_library/infrastructure/ec2_security_groups.py +321 -0
  35. complio/tests_library/infrastructure/iam_password_policy.py +460 -0
  36. complio/tests_library/infrastructure/nacl_security.py +356 -0
  37. complio/tests_library/infrastructure/rds_encryption.py +252 -0
  38. complio/tests_library/infrastructure/s3_encryption.py +301 -0
  39. complio/tests_library/infrastructure/s3_public_access.py +369 -0
  40. complio/tests_library/infrastructure/secrets_manager_encryption.py +248 -0
  41. complio/tests_library/infrastructure/vpc_flow_logs.py +287 -0
  42. complio/tests_library/logging/__init__.py +0 -0
  43. complio/tests_library/logging/cloudwatch_alarms.py +354 -0
  44. complio/tests_library/logging/cloudwatch_logs_encryption.py +281 -0
  45. complio/tests_library/logging/cloudwatch_retention.py +252 -0
  46. complio/tests_library/logging/config_enabled.py +393 -0
  47. complio/tests_library/logging/eventbridge_rules.py +460 -0
  48. complio/tests_library/logging/guardduty_enabled.py +436 -0
  49. complio/tests_library/logging/security_hub_enabled.py +416 -0
  50. complio/tests_library/logging/sns_encryption.py +273 -0
  51. complio/tests_library/network/__init__.py +0 -0
  52. complio/tests_library/network/alb_nlb_security.py +421 -0
  53. complio/tests_library/network/api_gateway_security.py +452 -0
  54. complio/tests_library/network/cloudfront_https.py +332 -0
  55. complio/tests_library/network/direct_connect_security.py +343 -0
  56. complio/tests_library/network/nacl_configuration.py +367 -0
  57. complio/tests_library/network/network_firewall.py +355 -0
  58. complio/tests_library/network/transit_gateway_security.py +318 -0
  59. complio/tests_library/network/vpc_endpoints_security.py +339 -0
  60. complio/tests_library/network/vpn_security.py +333 -0
  61. complio/tests_library/network/waf_configuration.py +428 -0
  62. complio/tests_library/security/__init__.py +0 -0
  63. complio/tests_library/security/kms_key_rotation.py +314 -0
  64. complio/tests_library/storage/__init__.py +0 -0
  65. complio/tests_library/storage/backup_encryption.py +288 -0
  66. complio/tests_library/storage/dynamodb_encryption.py +280 -0
  67. complio/tests_library/storage/efs_encryption.py +257 -0
  68. complio/tests_library/storage/elasticache_encryption.py +370 -0
  69. complio/tests_library/storage/redshift_encryption.py +252 -0
  70. complio/tests_library/storage/s3_versioning.py +264 -0
  71. complio/utils/__init__.py +26 -0
  72. complio/utils/errors.py +179 -0
  73. complio/utils/exceptions.py +151 -0
  74. complio/utils/history.py +243 -0
  75. complio/utils/logger.py +391 -0
  76. complio-0.1.1.dist-info/METADATA +385 -0
  77. complio-0.1.1.dist-info/RECORD +79 -0
  78. complio-0.1.1.dist-info/WHEEL +4 -0
  79. complio-0.1.1.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,135 @@
1
+ """
2
+ Base connector interface for cloud providers.
3
+
4
+ This module defines the abstract base class for cloud provider connectors.
5
+ All cloud connectors (AWS, Azure, GCP) should inherit from CloudConnector.
6
+
7
+ Example:
8
+ >>> from complio.connectors.aws.client import AWSConnector
9
+ >>> connector = AWSConnector(profile_name="production")
10
+ >>> connector.connect()
11
+ >>> connector.validate_credentials()
12
+ """
13
+
14
+ from abc import ABC, abstractmethod
15
+ from typing import Any, Dict, Optional
16
+
17
+
18
+ class CloudConnector(ABC):
19
+ """Abstract base class for cloud provider connectors.
20
+
21
+ All cloud provider implementations must inherit from this class
22
+ and implement the required methods.
23
+
24
+ Attributes:
25
+ profile_name: Name of the credential profile to use
26
+ region: Cloud provider region
27
+ connected: Whether connector is currently connected
28
+
29
+ Example:
30
+ >>> class MyCloudConnector(CloudConnector):
31
+ ... def connect(self) -> bool:
32
+ ... # Implementation
33
+ ... pass
34
+ ... def disconnect(self) -> None:
35
+ ... # Implementation
36
+ ... pass
37
+ """
38
+
39
+ def __init__(self, profile_name: str, region: str) -> None:
40
+ """Initialize cloud connector.
41
+
42
+ Args:
43
+ profile_name: Credential profile name
44
+ region: Cloud provider region
45
+
46
+ Example:
47
+ >>> connector = MyCloudConnector("production", "us-east-1")
48
+ """
49
+ self.profile_name = profile_name
50
+ self.region = region
51
+ self.connected = False
52
+
53
+ @abstractmethod
54
+ def connect(self) -> bool:
55
+ """Establish connection to cloud provider.
56
+
57
+ Returns:
58
+ True if connection successful, False otherwise
59
+
60
+ Raises:
61
+ ConnectionError: If connection fails
62
+
63
+ Example:
64
+ >>> connector.connect()
65
+ True
66
+ """
67
+ pass
68
+
69
+ @abstractmethod
70
+ def disconnect(self) -> None:
71
+ """Disconnect from cloud provider.
72
+
73
+ Closes any open connections and cleans up resources.
74
+
75
+ Example:
76
+ >>> connector.disconnect()
77
+ """
78
+ pass
79
+
80
+ @abstractmethod
81
+ def validate_credentials(self) -> Dict[str, Any]:
82
+ """Validate credentials with cloud provider.
83
+
84
+ Returns:
85
+ Dictionary with validation result:
86
+ {
87
+ "valid": True/False,
88
+ "account_id": "123456789012",
89
+ "user_arn": "arn:aws:iam::...",
90
+ "error": "..." (if validation failed)
91
+ }
92
+
93
+ Raises:
94
+ ValueError: If credentials are invalid
95
+
96
+ Example:
97
+ >>> result = connector.validate_credentials()
98
+ >>> print(result["account_id"])
99
+ '123456789012'
100
+ """
101
+ pass
102
+
103
+ @abstractmethod
104
+ def test_connection(self) -> bool:
105
+ """Test if connection is working.
106
+
107
+ Returns:
108
+ True if connection is healthy, False otherwise
109
+
110
+ Example:
111
+ >>> if connector.test_connection():
112
+ ... print("Connection is healthy")
113
+ """
114
+ pass
115
+
116
+ def __enter__(self) -> "CloudConnector":
117
+ """Context manager entry.
118
+
119
+ Example:
120
+ >>> with connector:
121
+ ... # Use connector
122
+ ... pass
123
+ """
124
+ self.connect()
125
+ return self
126
+
127
+ def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
128
+ """Context manager exit.
129
+
130
+ Args:
131
+ exc_type: Exception type
132
+ exc_val: Exception value
133
+ exc_tb: Exception traceback
134
+ """
135
+ self.disconnect()
@@ -0,0 +1,10 @@
1
+ """Core modules for test execution and reporting."""
2
+
3
+ from complio.core.registry import TestRegistry
4
+ from complio.core.runner import ScanResults, TestRunner
5
+
6
+ __all__ = [
7
+ "TestRegistry",
8
+ "TestRunner",
9
+ "ScanResults",
10
+ ]
@@ -0,0 +1,228 @@
1
+ """
2
+ Test registry for managing compliance tests.
3
+
4
+ This module provides a registry of all available compliance tests,
5
+ allowing for easy discovery and execution.
6
+
7
+ Example:
8
+ >>> from complio.core.registry import TestRegistry
9
+ >>> registry = TestRegistry()
10
+ >>> tests = registry.get_all_tests()
11
+ >>> print(f"Available tests: {len(tests)}")
12
+ """
13
+
14
+ from typing import Dict, List, Type
15
+
16
+ from complio.tests_library.base import ComplianceTest
17
+ from complio.tests_library.infrastructure.s3_encryption import S3EncryptionTest
18
+ from complio.tests_library.infrastructure.ec2_security_groups import EC2SecurityGroupTest
19
+ from complio.tests_library.infrastructure.iam_password_policy import IAMPasswordPolicyTest
20
+ from complio.tests_library.infrastructure.cloudtrail_logging import CloudTrailLoggingTest
21
+ from complio.tests_library.infrastructure.ebs_encryption import EBSEncryptionTest
22
+ from complio.tests_library.infrastructure.rds_encryption import RDSEncryptionTest
23
+ from complio.tests_library.infrastructure.secrets_manager_encryption import SecretsManagerEncryptionTest
24
+ from complio.tests_library.infrastructure.s3_public_access import S3PublicAccessBlockTest
25
+ from complio.tests_library.infrastructure.cloudtrail_log_validation import CloudTrailLogValidationTest
26
+ from complio.tests_library.infrastructure.cloudtrail_encryption import CloudTrailEncryptionTest
27
+ from complio.tests_library.infrastructure.vpc_flow_logs import VPCFlowLogsTest
28
+ from complio.tests_library.infrastructure.nacl_security import NACLSecurityTest
29
+
30
+ # Phase 2: Storage Tests
31
+ from complio.tests_library.storage.redshift_encryption import RedshiftEncryptionTest
32
+ from complio.tests_library.storage.efs_encryption import EFSEncryptionTest
33
+ from complio.tests_library.storage.dynamodb_encryption import DynamoDBEncryptionTest
34
+ from complio.tests_library.storage.elasticache_encryption import ElastiCacheEncryptionTest
35
+
36
+ # Phase 2: Security Tests
37
+ from complio.tests_library.security.kms_key_rotation import KMSKeyRotationTest
38
+
39
+ # Phase 2: Identity Tests
40
+ from complio.tests_library.identity.access_key_rotation import AccessKeyRotationTest
41
+ from complio.tests_library.identity.mfa_enforcement import MFAEnforcementTest
42
+ from complio.tests_library.identity.root_account_protection import RootAccountProtectionTest
43
+
44
+ # Phase 3 Week 1: Easy Tests (6 tests)
45
+ from complio.tests_library.storage.s3_versioning import S3VersioningTest
46
+ from complio.tests_library.storage.backup_encryption import BackupEncryptionTest
47
+ from complio.tests_library.logging.cloudwatch_retention import CloudWatchRetentionTest
48
+ from complio.tests_library.logging.sns_encryption import SNSEncryptionTest
49
+ from complio.tests_library.logging.cloudwatch_logs_encryption import CloudWatchLogsEncryptionTest
50
+ from complio.tests_library.network.vpn_security import VPNSecurityTest
51
+
52
+ # Phase 3 Week 2: Medium Tests (9 tests - complete)
53
+ from complio.tests_library.network.nacl_configuration import NACLConfigurationTest
54
+ from complio.tests_library.network.alb_nlb_security import ALBNLBSecurityTest
55
+ from complio.tests_library.network.cloudfront_https import CloudFrontHTTPSTest
56
+ from complio.tests_library.network.transit_gateway_security import TransitGatewaySecurityTest
57
+ from complio.tests_library.network.vpc_endpoints_security import VPCEndpointsSecurityTest
58
+ from complio.tests_library.network.network_firewall import NetworkFirewallTest
59
+ from complio.tests_library.network.direct_connect_security import DirectConnectSecurityTest
60
+ from complio.tests_library.logging.cloudwatch_alarms import CloudWatchAlarmsTest
61
+ from complio.tests_library.logging.config_enabled import ConfigEnabledTest
62
+
63
+ # Phase 3 Week 3: Hard Tests (5 tests - complete!)
64
+ from complio.tests_library.network.waf_configuration import WAFConfigurationTest
65
+ from complio.tests_library.network.api_gateway_security import APIGatewaySecurityTest
66
+ from complio.tests_library.logging.guardduty_enabled import GuardDutyEnabledTest
67
+ from complio.tests_library.logging.security_hub_enabled import SecurityHubEnabledTest
68
+ from complio.tests_library.logging.eventbridge_rules import EventBridgeRulesTest
69
+
70
+
71
+ class TestRegistry:
72
+ """Registry of all available compliance tests.
73
+
74
+ This class maintains a catalog of all compliance tests,
75
+ organized by category and ISO 27001 control.
76
+
77
+ Attributes:
78
+ tests: Dictionary of test_id -> test class mappings
79
+
80
+ Example:
81
+ >>> registry = TestRegistry()
82
+ >>> test_class = registry.get_test("s3_encryption")
83
+ >>> print(test_class.__name__)
84
+ 'S3EncryptionTest'
85
+ """
86
+
87
+ def __init__(self) -> None:
88
+ """Initialize the test registry."""
89
+ self._tests: Dict[str, Type[ComplianceTest]] = {}
90
+ self._register_tests()
91
+
92
+ def _register_tests(self) -> None:
93
+ """Register all available compliance tests."""
94
+ # Infrastructure Tests
95
+ self._tests["s3_encryption"] = S3EncryptionTest
96
+ self._tests["ec2_security_groups"] = EC2SecurityGroupTest
97
+ self._tests["iam_password_policy"] = IAMPasswordPolicyTest
98
+ self._tests["cloudtrail_logging"] = CloudTrailLoggingTest
99
+
100
+ # Phase 1: 8 New Tests
101
+ self._tests["ebs_encryption"] = EBSEncryptionTest
102
+ self._tests["rds_encryption"] = RDSEncryptionTest
103
+ self._tests["secrets_manager_encryption"] = SecretsManagerEncryptionTest
104
+ self._tests["s3_public_access_block"] = S3PublicAccessBlockTest
105
+ self._tests["cloudtrail_log_validation"] = CloudTrailLogValidationTest
106
+ self._tests["cloudtrail_encryption"] = CloudTrailEncryptionTest
107
+ self._tests["vpc_flow_logs"] = VPCFlowLogsTest
108
+ self._tests["nacl_security"] = NACLSecurityTest
109
+
110
+ # Phase 2: 8 New Tests (Storage, Security, Identity)
111
+ self._tests["redshift_encryption"] = RedshiftEncryptionTest
112
+ self._tests["efs_encryption"] = EFSEncryptionTest
113
+ self._tests["dynamodb_encryption"] = DynamoDBEncryptionTest
114
+ self._tests["elasticache_encryption"] = ElastiCacheEncryptionTest
115
+ self._tests["kms_key_rotation"] = KMSKeyRotationTest
116
+ self._tests["access_key_rotation"] = AccessKeyRotationTest
117
+ self._tests["mfa_enforcement"] = MFAEnforcementTest
118
+ self._tests["root_account_protection"] = RootAccountProtectionTest
119
+
120
+ # Phase 3 Week 1: 6 Easy Tests (Storage, Logging, Network)
121
+ self._tests["s3_versioning"] = S3VersioningTest
122
+ self._tests["backup_encryption"] = BackupEncryptionTest
123
+ self._tests["cloudwatch_retention"] = CloudWatchRetentionTest
124
+ self._tests["sns_encryption"] = SNSEncryptionTest
125
+ self._tests["cloudwatch_logs_encryption"] = CloudWatchLogsEncryptionTest
126
+ self._tests["vpn_security"] = VPNSecurityTest
127
+
128
+ # Phase 3 Week 2: 9 Medium Tests (Network + Logging - complete)
129
+ self._tests["nacl_configuration"] = NACLConfigurationTest
130
+ self._tests["alb_nlb_security"] = ALBNLBSecurityTest
131
+ self._tests["cloudfront_https"] = CloudFrontHTTPSTest
132
+ self._tests["transit_gateway_security"] = TransitGatewaySecurityTest
133
+ self._tests["vpc_endpoints_security"] = VPCEndpointsSecurityTest
134
+ self._tests["network_firewall"] = NetworkFirewallTest
135
+ self._tests["direct_connect_security"] = DirectConnectSecurityTest
136
+ self._tests["cloudwatch_alarms"] = CloudWatchAlarmsTest
137
+ self._tests["config_enabled"] = ConfigEnabledTest
138
+
139
+ # Phase 3 Week 3: 5 Hard Tests (Network + Logging - complete!)
140
+ self._tests["waf_configuration"] = WAFConfigurationTest
141
+ self._tests["api_gateway_security"] = APIGatewaySecurityTest
142
+ self._tests["guardduty_enabled"] = GuardDutyEnabledTest
143
+ self._tests["security_hub_enabled"] = SecurityHubEnabledTest
144
+ self._tests["eventbridge_rules"] = EventBridgeRulesTest
145
+
146
+ def get_test(self, test_id: str) -> Type[ComplianceTest]:
147
+ """Get a test class by ID.
148
+
149
+ Args:
150
+ test_id: Test identifier (e.g., "s3_encryption")
151
+
152
+ Returns:
153
+ Test class
154
+
155
+ Raises:
156
+ KeyError: If test_id not found
157
+
158
+ Example:
159
+ >>> registry = TestRegistry()
160
+ >>> test_class = registry.get_test("s3_encryption")
161
+ """
162
+ if test_id not in self._tests:
163
+ raise KeyError(f"Test '{test_id}' not found. Available tests: {list(self._tests.keys())}")
164
+ return self._tests[test_id]
165
+
166
+ def get_all_tests(self) -> Dict[str, Type[ComplianceTest]]:
167
+ """Get all registered tests.
168
+
169
+ Returns:
170
+ Dictionary of test_id -> test class mappings
171
+
172
+ Example:
173
+ >>> registry = TestRegistry()
174
+ >>> tests = registry.get_all_tests()
175
+ >>> print(f"Total tests: {len(tests)}")
176
+ """
177
+ return self._tests.copy()
178
+
179
+ def get_test_ids(self) -> List[str]:
180
+ """Get list of all test IDs.
181
+
182
+ Returns:
183
+ List of test identifiers
184
+
185
+ Example:
186
+ >>> registry = TestRegistry()
187
+ >>> test_ids = registry.get_test_ids()
188
+ >>> print(test_ids)
189
+ ['s3_encryption', 'ec2_security_groups', ...]
190
+ """
191
+ return list(self._tests.keys())
192
+
193
+ def get_tests_by_category(self, category: str) -> Dict[str, Type[ComplianceTest]]:
194
+ """Get tests filtered by category.
195
+
196
+ Args:
197
+ category: Category name (e.g., "infrastructure", "access_control")
198
+
199
+ Returns:
200
+ Dictionary of matching tests
201
+
202
+ Example:
203
+ >>> registry = TestRegistry()
204
+ >>> infra_tests = registry.get_tests_by_category("infrastructure")
205
+ """
206
+ # For now, all tests are in infrastructure category
207
+ # This can be extended when we have more categories
208
+ if category == "infrastructure":
209
+ return self._tests.copy()
210
+ return {}
211
+
212
+ def test_exists(self, test_id: str) -> bool:
213
+ """Check if a test exists in the registry.
214
+
215
+ Args:
216
+ test_id: Test identifier
217
+
218
+ Returns:
219
+ True if test exists, False otherwise
220
+
221
+ Example:
222
+ >>> registry = TestRegistry()
223
+ >>> registry.test_exists("s3_encryption")
224
+ True
225
+ >>> registry.test_exists("nonexistent_test")
226
+ False
227
+ """
228
+ return test_id in self._tests