Test cloudfront distributions using deprecated ssl protocols#290
Open
Conversation
| ) | ||
| report = self.check.execute(self.mock_session) | ||
| assert report.status == CheckStatus.UNKNOWN | ||
| assert "Error retrieving CloudFront distributions." in report.resource_ids_status[0].summary No newline at end of file |
Contributor
There was a problem hiding this comment.
Summary of Improvements
-
Fix Logical Bug: ViewerCertificate is in the DistributionConfig, not the Distribution
-
Your current check uses:
security_policy = distribution.get('ViewerCertificate', {}).get('MinimumProtocolVersion', 'TLSv1.2')
✅ Fix: Fetch
ViewerCertificatefromget_distribution_config(distribution_id)instead, which is the correct source.
-
-
Correct and Align Test Cases
- Your test mocks call
get_distribution_config, but the check never calls it. That’s why even deprecated protocols get marked as secure in the test. - ✅ Update the check to call
client.get_distribution_config(Id=distribution_id)to fetchViewerCertificateaccurately.
- Your test mocks call
Enhancements
-
Improve Test Coverage
- Add test for mixed distributions (some secure, some deprecated).
- Validate ARN consistency in the test using
.endswith("distribution/dist-id").
-
Add Logging/Debug Info (Optional)
- Useful for troubleshooting real-world deployments.
aafaq-rashid-comprinno
approved these changes
Jul 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds the cloudfront_distributions_using_deprecated_ssl_protocols check, which verifies that CloudFront distributions are configured to use only modern and secure SSL/TLS protocols, such as TLSv1.2 or higher.
It includes:
A new test file (tests/test_cloudfront_distributions_using_deprecated_ssl_protocols.py) with comprehensive unit tests for the check.
Test cases cover:
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.