aws-cis-controls-assessment 1.1.4__py3-none-any.whl → 1.2.2__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 (45) hide show
  1. aws_cis_assessment/__init__.py +4 -4
  2. aws_cis_assessment/config/rules/cis_controls_ig1.yaml +365 -2
  3. aws_cis_assessment/controls/base_control.py +106 -24
  4. aws_cis_assessment/controls/ig1/__init__.py +144 -15
  5. aws_cis_assessment/controls/ig1/control_4_1.py +4 -4
  6. aws_cis_assessment/controls/ig1/control_access_analyzer.py +198 -0
  7. aws_cis_assessment/controls/ig1/control_access_asset_mgmt.py +360 -0
  8. aws_cis_assessment/controls/ig1/control_access_control.py +323 -0
  9. aws_cis_assessment/controls/ig1/control_backup_security.py +579 -0
  10. aws_cis_assessment/controls/ig1/control_cloudfront_logging.py +215 -0
  11. aws_cis_assessment/controls/ig1/control_configuration_mgmt.py +407 -0
  12. aws_cis_assessment/controls/ig1/control_data_classification.py +255 -0
  13. aws_cis_assessment/controls/ig1/control_dynamodb_encryption.py +279 -0
  14. aws_cis_assessment/controls/ig1/control_ebs_encryption.py +177 -0
  15. aws_cis_assessment/controls/ig1/control_efs_encryption.py +243 -0
  16. aws_cis_assessment/controls/ig1/control_elb_logging.py +195 -0
  17. aws_cis_assessment/controls/ig1/control_guardduty.py +156 -0
  18. aws_cis_assessment/controls/ig1/control_inspector.py +184 -0
  19. aws_cis_assessment/controls/ig1/control_inventory.py +511 -0
  20. aws_cis_assessment/controls/ig1/control_macie.py +165 -0
  21. aws_cis_assessment/controls/ig1/control_messaging_encryption.py +419 -0
  22. aws_cis_assessment/controls/ig1/control_mfa.py +485 -0
  23. aws_cis_assessment/controls/ig1/control_network_security.py +194 -619
  24. aws_cis_assessment/controls/ig1/control_patch_management.py +626 -0
  25. aws_cis_assessment/controls/ig1/control_rds_encryption.py +228 -0
  26. aws_cis_assessment/controls/ig1/control_s3_encryption.py +383 -0
  27. aws_cis_assessment/controls/ig1/control_tls_ssl.py +556 -0
  28. aws_cis_assessment/controls/ig1/control_version_mgmt.py +337 -0
  29. aws_cis_assessment/controls/ig1/control_vpc_flow_logs.py +205 -0
  30. aws_cis_assessment/controls/ig1/control_waf_logging.py +226 -0
  31. aws_cis_assessment/core/assessment_engine.py +160 -11
  32. aws_cis_assessment/core/aws_client_factory.py +17 -5
  33. aws_cis_assessment/core/models.py +20 -1
  34. aws_cis_assessment/core/scoring_engine.py +102 -1
  35. aws_cis_assessment/reporters/base_reporter.py +58 -13
  36. aws_cis_assessment/reporters/html_reporter.py +186 -9
  37. aws_cis_controls_assessment-1.2.2.dist-info/METADATA +320 -0
  38. {aws_cis_controls_assessment-1.1.4.dist-info → aws_cis_controls_assessment-1.2.2.dist-info}/RECORD +44 -20
  39. docs/developer-guide.md +204 -5
  40. docs/user-guide.md +137 -4
  41. aws_cis_controls_assessment-1.1.4.dist-info/METADATA +0 -404
  42. {aws_cis_controls_assessment-1.1.4.dist-info → aws_cis_controls_assessment-1.2.2.dist-info}/WHEEL +0 -0
  43. {aws_cis_controls_assessment-1.1.4.dist-info → aws_cis_controls_assessment-1.2.2.dist-info}/entry_points.txt +0 -0
  44. {aws_cis_controls_assessment-1.1.4.dist-info → aws_cis_controls_assessment-1.2.2.dist-info}/licenses/LICENSE +0 -0
  45. {aws_cis_controls_assessment-1.1.4.dist-info → aws_cis_controls_assessment-1.2.2.dist-info}/top_level.txt +0 -0
docs/developer-guide.md CHANGED
@@ -1,16 +1,17 @@
1
1
  # Developer Guide
2
2
 
3
- This guide covers extending and customizing the AWS CIS Controls Compliance Assessment Framework - a production-ready, enterprise-grade solution with 138 implemented rules (133 CIS Controls + 5 bonus security enhancements).
3
+ This guide covers extending and customizing the AWS CIS Controls Compliance Assessment Framework - a production-ready, enterprise-grade solution with **175 total rules** (125 IG1 + 38 IG2 + 12 IG3).
4
4
 
5
5
  ## Production Framework Status
6
6
 
7
- **✅ Complete Implementation**
8
- - 100% CIS Controls coverage across all Implementation Groups
9
- - 138 total rules implemented (133 CIS + 5 bonus)
7
+ **✅ Enhanced CIS Controls v8.1 Coverage**
8
+ - **125 IG1 rules** (75%+ coverage of CIS Controls v8.1 IG1 safeguards)
9
+ - **38 IG2 rules** and **12 IG3 rules** for enhanced and advanced security
10
+ - **50 new rules** added in v1.2.0 across 4 phases
10
11
  - Production-tested architecture with comprehensive error handling
11
12
  - Enterprise-grade performance and scalability
13
+ - Coverage metrics reporting for transparency
12
14
  - Ready for immediate deployment and customization
13
- - **NEW:** AWS Backup service controls for infrastructure assessment
14
15
 
15
16
  ## Table of Contents
16
17
 
@@ -122,6 +123,204 @@ mypy aws_cis_assessment/
122
123
  pre-commit run --all-files
123
124
  ```
124
125
 
126
+ ## Implementation Patterns from Phase 1-4 Rules
127
+
128
+ ### Overview
129
+
130
+ The 50 new rules added in v1.2.0 follow consistent implementation patterns that serve as excellent examples for adding new controls. These patterns ensure reliability, maintainability, and consistency across the framework.
131
+
132
+ ### Pattern 1: Service Enablement Checks
133
+
134
+ Used for validating AWS security service enablement (GuardDuty, Inspector, Macie, etc.).
135
+
136
+ **Key Characteristics:**
137
+ - Check if service is enabled in the account/region
138
+ - Handle service not available scenarios gracefully
139
+ - Return NOT_APPLICABLE if service doesn't exist in region
140
+
141
+ **Example: GuardDuty Enablement**
142
+ ```python
143
+ def _get_resources(self, aws_factory: AWSClientFactory, region: str) -> List[Dict[str, Any]]:
144
+ """List GuardDuty detectors."""
145
+ try:
146
+ guardduty_client = aws_factory.get_client('guardduty', region)
147
+ response = guardduty_client.list_detectors()
148
+
149
+ if not response.get('DetectorIds'):
150
+ # No detectors = service not enabled
151
+ return [{'DetectorId': 'NONE', 'Region': region, 'Status': 'NOT_ENABLED'}]
152
+
153
+ return [{'DetectorId': detector_id, 'Region': region}
154
+ for detector_id in response['DetectorIds']]
155
+ except Exception as e:
156
+ logger.error(f"Error listing GuardDuty detectors: {e}")
157
+ return []
158
+ ```
159
+
160
+ ### Pattern 2: Logging Enablement Checks
161
+
162
+ Used for validating logging configuration (VPC Flow Logs, ELB logging, CloudFront, WAF).
163
+
164
+ **Key Characteristics:**
165
+ - List primary resources (VPCs, load balancers, distributions)
166
+ - Check if logging is configured for each resource
167
+ - Provide specific remediation steps
168
+
169
+ **Example: VPC Flow Logs**
170
+ ```python
171
+ def _evaluate_resource_compliance(self, resource: Dict[str, Any],
172
+ aws_factory: AWSClientFactory) -> ComplianceResult:
173
+ """Check if VPC has Flow Logs enabled."""
174
+ vpc_id = resource['VpcId']
175
+ region = resource.get('Region', 'us-east-1')
176
+
177
+ ec2_client = aws_factory.get_client('ec2', region)
178
+
179
+ # Check for flow logs
180
+ response = ec2_client.describe_flow_logs(
181
+ Filters=[{'Name': 'resource-id', 'Values': [vpc_id]}]
182
+ )
183
+
184
+ if response.get('FlowLogs'):
185
+ return self._create_compliant_result(vpc_id, region,
186
+ "VPC has Flow Logs enabled")
187
+ else:
188
+ return self._create_non_compliant_result(vpc_id, region,
189
+ "VPC does not have Flow Logs enabled")
190
+ ```
191
+
192
+ ### Pattern 3: Encryption Validation
193
+
194
+ Used for checking encryption at rest (EBS, RDS, EFS, DynamoDB, S3).
195
+
196
+ **Key Characteristics:**
197
+ - Verify encryption is enabled
198
+ - Check for KMS encryption when required
199
+ - Handle different encryption types (default vs KMS)
200
+
201
+ **Example: RDS Storage Encryption**
202
+ ```python
203
+ def _evaluate_resource_compliance(self, resource: Dict[str, Any],
204
+ aws_factory: AWSClientFactory) -> ComplianceResult:
205
+ """Check if RDS instance has storage encryption enabled."""
206
+ db_instance_id = resource['DBInstanceIdentifier']
207
+ encrypted = resource.get('StorageEncrypted', False)
208
+
209
+ if encrypted:
210
+ return self._create_compliant_result(db_instance_id, region,
211
+ "RDS instance has storage encryption enabled")
212
+ else:
213
+ return self._create_non_compliant_result(db_instance_id, region,
214
+ "RDS instance does not have storage encryption")
215
+ ```
216
+
217
+ ### Pattern 4: Configuration Validation
218
+
219
+ Used for checking configuration settings (SSM Patch Manager, AWS Config, Security Hub).
220
+
221
+ **Key Characteristics:**
222
+ - Validate service configuration exists
223
+ - Check configuration meets requirements
224
+ - Handle multi-region scenarios
225
+
226
+ **Example: Config Multi-Region**
227
+ ```python
228
+ def _get_resources(self, aws_factory: AWSClientFactory, region: str) -> List[Dict[str, Any]]:
229
+ """Check Config in all regions."""
230
+ resources = []
231
+
232
+ for check_region in aws_factory.regions:
233
+ try:
234
+ config_client = aws_factory.get_client('config', check_region)
235
+ response = config_client.describe_configuration_recorders()
236
+
237
+ if response.get('ConfigurationRecorders'):
238
+ resources.append({
239
+ 'Region': check_region,
240
+ 'Status': 'ENABLED',
241
+ 'Recorders': response['ConfigurationRecorders']
242
+ })
243
+ else:
244
+ resources.append({
245
+ 'Region': check_region,
246
+ 'Status': 'NOT_ENABLED'
247
+ })
248
+ except Exception as e:
249
+ logger.error(f"Error checking Config in {check_region}: {e}")
250
+
251
+ return resources
252
+ ```
253
+
254
+ ### Pattern 5: Inventory Tracking
255
+
256
+ Used for asset inventory controls (AMI tracking, Lambda runtimes, IAM users).
257
+
258
+ **Key Characteristics:**
259
+ - List all resources of a type
260
+ - Check for required tags or metadata
261
+ - Track versions and configurations
262
+
263
+ **Example: Lambda Runtime Inventory**
264
+ ```python
265
+ def _evaluate_resource_compliance(self, resource: Dict[str, Any],
266
+ aws_factory: AWSClientFactory) -> ComplianceResult:
267
+ """Check Lambda function runtime."""
268
+ function_name = resource['FunctionName']
269
+ runtime = resource.get('Runtime', 'unknown')
270
+
271
+ # Check if runtime is supported
272
+ deprecated_runtimes = ['python2.7', 'nodejs10.x', 'dotnetcore2.1']
273
+
274
+ if runtime in deprecated_runtimes:
275
+ return self._create_non_compliant_result(function_name, region,
276
+ f"Function uses deprecated runtime: {runtime}")
277
+ else:
278
+ return self._create_compliant_result(function_name, region,
279
+ f"Function uses supported runtime: {runtime}")
280
+ ```
281
+
282
+ ### Best Practices from Phase 1-4
283
+
284
+ 1. **Error Handling**: Always wrap AWS API calls in try-except blocks
285
+ 2. **Graceful Degradation**: Return appropriate status when service unavailable
286
+ 3. **Detailed Remediation**: Include specific CLI commands and console steps
287
+ 4. **Resource Identification**: Use proper resource IDs for tracking
288
+ 5. **Region Awareness**: Handle multi-region scenarios correctly
289
+ 6. **Logging**: Log errors and important events for debugging
290
+ 7. **Type Safety**: Use type hints for better code quality
291
+ 8. **Documentation**: Include docstrings explaining the control
292
+
293
+ ### Common Helper Methods
294
+
295
+ ```python
296
+ def _create_compliant_result(self, resource_id: str, region: str,
297
+ reason: str) -> ComplianceResult:
298
+ """Helper to create compliant result."""
299
+ return ComplianceResult(
300
+ resource_id=resource_id,
301
+ resource_type=self.resource_types[0],
302
+ compliance_status=ComplianceStatus.COMPLIANT,
303
+ evaluation_reason=reason,
304
+ config_rule_name=self.rule_name,
305
+ region=region,
306
+ timestamp=datetime.now()
307
+ )
308
+
309
+ def _create_non_compliant_result(self, resource_id: str, region: str,
310
+ reason: str) -> ComplianceResult:
311
+ """Helper to create non-compliant result."""
312
+ return ComplianceResult(
313
+ resource_id=resource_id,
314
+ resource_type=self.resource_types[0],
315
+ compliance_status=ComplianceStatus.NON_COMPLIANT,
316
+ evaluation_reason=reason,
317
+ config_rule_name=self.rule_name,
318
+ region=region,
319
+ timestamp=datetime.now(),
320
+ remediation_guidance=self._get_rule_remediation_steps()
321
+ )
322
+ ```
323
+
125
324
  ## Adding New Controls
126
325
 
127
326
  ### Step 1: Define Control Configuration
docs/user-guide.md CHANGED
@@ -4,12 +4,13 @@ This comprehensive guide covers how to use the AWS CIS Controls Compliance Asses
4
4
 
5
5
  ## Production Framework Overview
6
6
 
7
- **✅ Complete Implementation**
8
- - 138 AWS Config rules implemented (133 CIS Controls + 5 bonus security rules)
9
- - 100% coverage across all Implementation Groups (IG1, IG2, IG3)
7
+ **✅ Enhanced CIS Controls v8.1 Coverage**
8
+ - **125 IG1 rules** implemented (75%+ coverage of CIS Controls v8.1 IG1 safeguards)
9
+ - **50 new rules** added across security services, logging, encryption, inventory, configuration management, and backup security
10
+ - **38 IG2 rules** and **12 IG3 rules** for enhanced and advanced security
10
11
  - Production-tested architecture with enterprise-grade error handling
11
12
  - Ready for immediate deployment in production environments
12
- - **NEW:** AWS Backup service controls for infrastructure assessment
13
+ - **NEW:** Coverage metrics reporting showing safeguard coverage percentages
13
14
 
14
15
  ## Table of Contents
15
16
 
@@ -486,6 +487,138 @@ Each non-compliant finding includes:
486
487
  - Priority level (HIGH, MEDIUM, LOW)
487
488
  - Estimated effort
488
489
 
490
+ ## CIS Controls v8.1 IG1 Expansion (New in v1.2.0)
491
+
492
+ ### Overview
493
+
494
+ Version 1.2.0 adds **50 new IG1 rules** across four phases, achieving **75%+ coverage** of CIS Controls v8.1 Implementation Group 1 safeguards. This expansion significantly enhances the framework's ability to assess essential cyber hygiene controls.
495
+
496
+ ### Coverage Metrics
497
+
498
+ The framework now reports coverage metrics showing how many CIS Controls safeguards are assessed:
499
+
500
+ - **IG1**: 42 of 56 safeguards covered (75%+) with 125 rules
501
+ - **IG2**: 30 of 74 safeguards covered (~40%) with 38 rules
502
+ - **IG3**: 15 of 153 safeguards covered (~10%) with 12 rules
503
+
504
+ Coverage metrics appear in:
505
+ - HTML reports (executive dashboard)
506
+ - JSON reports (executive_summary section)
507
+ - Assessment statistics
508
+
509
+ ### Phase 1 - Quick Wins (13 Rules)
510
+
511
+ **Security Services (4 rules)**
512
+ - GuardDuty enablement check
513
+ - Inspector v2 enablement and configuration
514
+ - Macie enablement for data discovery
515
+ - IAM Access Analyzer deployment
516
+
517
+ **Logging (4 rules)**
518
+ - VPC Flow Logs enablement
519
+ - ELB access logging
520
+ - CloudFront distribution logging
521
+ - WAF logging configuration
522
+
523
+ **Encryption (5 rules)**
524
+ - EBS encryption by default
525
+ - RDS storage encryption
526
+ - EFS file system encryption
527
+ - DynamoDB table encryption with KMS
528
+ - S3 bucket default encryption with KMS
529
+
530
+ ### Phase 2 - Core Security (15 Rules)
531
+
532
+ **Patch Management (3 rules)**
533
+ - SSM Patch Manager enablement
534
+ - Patch baseline configuration
535
+ - EC2 instance patch compliance
536
+
537
+ **Access Control (5 rules)**
538
+ - AWS SSO/Identity Center enablement
539
+ - Identity Center configuration
540
+ - Admin user MFA requirements
541
+ - Cognito user pool MFA
542
+ - VPN endpoint MFA
543
+
544
+ **TLS/SSL Enforcement (5 rules)**
545
+ - ALB HTTP to HTTPS redirection
546
+ - ELB HTTPS-only listeners
547
+ - RDS SSL connection requirements
548
+ - API Gateway SSL enforcement
549
+ - Redshift TLS requirements
550
+
551
+ **Additional Encryption (3 rules)**
552
+ - SNS topic KMS encryption
553
+ - SQS queue encryption
554
+ - CloudTrail S3 data events
555
+
556
+ ### Phase 3 - Advanced (15 Rules)
557
+
558
+ **Inventory Management (5 rules)**
559
+ - SSM Inventory enablement
560
+ - AWS Config multi-region deployment
561
+ - AMI inventory tracking
562
+ - Lambda runtime inventory
563
+ - IAM user inventory
564
+
565
+ **Configuration Management (4 rules)**
566
+ - Config conformance pack deployment
567
+ - Security Hub standards enablement
568
+ - Asset tagging compliance
569
+ - Inspector assessment enablement
570
+
571
+ **Version Management (3 rules)**
572
+ - EC2 OS version support validation
573
+ - RDS engine version support
574
+ - Lambda runtime support
575
+
576
+ **Access & Asset Management (3 rules)**
577
+ - IAM user last access tracking
578
+ - SSM Session Manager availability
579
+ - Unauthorized asset detection
580
+
581
+ ### Phase 4 - Enhanced (7 Rules)
582
+
583
+ **Data Classification (2 rules)**
584
+ - Data resource classification tagging
585
+ - S3 bucket classification tags
586
+
587
+ **Network Security (2 rules)**
588
+ - AWS Network Firewall deployment
589
+ - Route 53 DNS Firewall enablement
590
+
591
+ **Backup Security (5 rules)**
592
+ - Backup vault encryption
593
+ - Cross-region backup copy
594
+ - Backup vault lock
595
+ - Route 53 query logging
596
+ - RDS backup retention
597
+
598
+ ### Using the New Rules
599
+
600
+ All new rules are automatically included in IG1 assessments:
601
+
602
+ ```bash
603
+ # Run complete IG1 assessment with all 125 rules
604
+ aws-cis-assess assess --implementation-groups IG1
605
+
606
+ # View coverage metrics in HTML report
607
+ aws-cis-assess assess --implementation-groups IG1 --output-format html
608
+
609
+ # Check specific phase rules
610
+ aws-cis-assess list-controls --implementation-groups IG1
611
+ ```
612
+
613
+ ### Benefits
614
+
615
+ 1. **Comprehensive Coverage**: 75%+ of CIS Controls v8.1 IG1 safeguards
616
+ 2. **Security Services**: Validates enablement of AWS security services
617
+ 3. **Encryption**: Ensures encryption at rest and in transit
618
+ 4. **Inventory**: Tracks assets and software versions
619
+ 5. **Configuration**: Validates security configuration standards
620
+ 6. **Backup**: Assesses backup infrastructure security
621
+
489
622
  ## Next Steps
490
623
 
491
624
  - **Configuration Guide**: Learn about customizing assessments