mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-14 23:44:15 +00:00
fix(cloudfront): handle empty objects in checks (#1962)
This commit is contained in:
1 parent
c01ff74c73
commit
17eb74842a
3 files changed
+13
-7
No files matched your search
+4
-1
@@ -12,7 +12,10 @@ class cloudfront_distributions_field_level_encryption_enabled(Check):
|
||||
report.region = distribution.region
|
||||
report.resource_arn = distribution.arn
|
||||
report.resource_id = distribution.id
|
||||
if distribution.default_cache_config.field_level_encryption_id:
|
||||
if (
|
||||
distribution.default_cache_config
|
||||
and distribution.default_cache_config.field_level_encryption_id
|
||||
):
|
||||
report.status = "PASS"
|
||||
report.status_extended = f"CloudFront Distribution {distribution.id} has Field Level Encryption enabled"
|
||||
else:
|
||||
|
||||
+6
-3
@@ -16,13 +16,15 @@ class cloudfront_distributions_https_enabled(Check):
|
||||
report.resource_arn = distribution.arn
|
||||
report.resource_id = distribution.id
|
||||
if (
|
||||
distribution.default_cache_config.viewer_protocol_policy
|
||||
distribution.default_cache_config
|
||||
and distribution.default_cache_config.viewer_protocol_policy
|
||||
== ViewerProtocolPolicy.allow_all
|
||||
):
|
||||
report.status = "FAIL"
|
||||
report.status_extended = f"CloudFront Distribution {distribution.id} viewers can use HTTP or HTTPS"
|
||||
elif (
|
||||
distribution.default_cache_config.viewer_protocol_policy
|
||||
distribution.default_cache_config
|
||||
and distribution.default_cache_config.viewer_protocol_policy
|
||||
== ViewerProtocolPolicy.redirect_to_https
|
||||
):
|
||||
report.status = "PASS"
|
||||
@@ -30,7 +32,8 @@ class cloudfront_distributions_https_enabled(Check):
|
||||
f"CloudFront Distribution {distribution.id} has redirect to HTTPS"
|
||||
)
|
||||
elif (
|
||||
distribution.default_cache_config.viewer_protocol_policy
|
||||
distribution.default_cache_config
|
||||
and distribution.default_cache_config.viewer_protocol_policy
|
||||
== ViewerProtocolPolicy.https_only
|
||||
):
|
||||
report.status = "PASS"
|
||||
|
||||
+3
-3
@@ -12,9 +12,9 @@ class cloudfront_distributions_logging_enabled(Check):
|
||||
report.region = distribution.region
|
||||
report.resource_arn = distribution.arn
|
||||
report.resource_id = distribution.id
|
||||
if (
|
||||
distribution.logging_enabled
|
||||
or distribution.default_cache_config.realtime_log_config_arn
|
||||
if distribution.logging_enabled or (
|
||||
distribution.default_cache_config
|
||||
and distribution.default_cache_config.realtime_log_config_arn
|
||||
):
|
||||
report.status = "PASS"
|
||||
report.status_extended = (
|
||||
|
||||
Reference in new issue
Block a user