Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(terraform): fix CKV_AWS_283 check #4005

Merged
merged 1 commit into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions checkov/terraform/checks/data/aws/IAMPublichActionsPolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def scan_data_conf(self, conf: Dict[str, List[Any]], entity_type: str) -> CheckR
for principal in principals:
if isinstance(principal, dict):
principal_type = principal.get('type', [''])[0]
principal_identifiers = principal.get('identifiers', [[]])[0]
if principal_type == 'AWS' and '*' in principal_identifiers:
principal_identifiers = principal.get('identifiers', [])
if principal_type == 'AWS' and principal_identifiers and '*' in principal_identifiers[0]:
return CheckResult.FAILED

return CheckResult.PASSED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ data "aws_iam_policy_document" "pass" {
}
}

data "aws_iam_policy_document" "pass1" {
statement {

actions = ["sns:Publish"]

principals {
type = "AWS"
identifiers = []
}
resources = [aws_sns_topic.some-topic.arn]
}
}

data "aws_iam_policy_document" "pass2" {
statement {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def test(self):

passing_resources = {
"aws_iam_policy_document.pass",
'aws_iam_policy_document.pass1',
"aws_iam_policy_document.pass2"
}
failing_resources = {
Expand Down