fix(terraform): make CKV_AWS_86 detect CloudFront v1 and v2 logging configurations#7530
Open
dbuaon wants to merge 2 commits intobridgecrewio:mainfrom
Open
fix(terraform): make CKV_AWS_86 detect CloudFront v1 and v2 logging configurations#7530dbuaon wants to merge 2 commits intobridgecrewio:mainfrom
dbuaon wants to merge 2 commits intobridgecrewio:mainfrom
Conversation
Author
|
Hi maintainers, just adding a note on the validation scope. This PR intentionally validates CKV_AWS_86 compliance when the CloudFront distribution is connected to a CloudWatch Logs delivery source, which fixes the current v2 false positive while preserving the existing v1 behavior. I documented the current limitation around validating the full delivery destination chain in the PR description. I can extend the graph policy further if you prefer CKV_AWS_86 to require the complete v2 source -> delivery -> destination chain. |
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.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Description
This PR fixes Terraform CKV_AWS_86 for CloudFront logging by migrating evaluation to graph-based logic so the same control supports both logging models:
Previously, v2-only configurations could still fail CKV_AWS_86.
After this change, CKV_AWS_86 passes for valid v1 and valid v2 configurations, and fails when logging is not configured.
Fixes #7385
New/Edited policies
Description
CKV_AWS_86 is now implemented as a Terraform graph policy in checkov/terraform/checks/graph_checks/aws/CloudfrontDistributionLogging.yaml. It evaluates a CloudFront distribution as compliant when either:
This preserves backward compatibility while resolving v2 false positives
Fix
To remediate violations, configure one of:
Validation
Local commands executed:
-python -m pytest -q -n0 tests/terraform/checks/resource/aws/test_CloudfrontDistributionLogging.py
Observed results:
Graph policy test: 1 passed
CKV_AWS_86 resource-side runner test: 1 passed, 1 skipped (pre-existing skip: test_null_var_651)
Terraform fixture scan:
Note:
fail_v2_incomplete_chaincurrently passes because the graph check validates that the CloudFront distribution is connected to a CloudWatch Logs delivery source. It does not enforce the full delivery destination chain.Checklist: