Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

class cloudsplainingCredentialsExposure(BaseCloudsplainingIAMCheck):
excluded_actions = { # noqa: CCE003 # a static attribute
"ecr:GetAuthorizationToken"
"ecr:GetAuthorizationToken",
"ecr-public:GetAuthorizationToken",
}

def __init__(self) -> None:
Expand Down
5 changes: 4 additions & 1 deletion checkov/terraform/checks/data/aws/IAMCredentialsExposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@


class CloudSplainingCredentialsExposure(BaseTerraformCloudsplainingDataIAMCheck):
excluded_actions = {"ecr:GetAuthorizationToken"} # noqa: CCE003 # a static attribute
excluded_actions = { # noqa: CCE003 # a static attribute
"ecr:GetAuthorizationToken",
"ecr-public:GetAuthorizationToken",
}

def __init__(self) -> None:
name = "Ensure IAM policies does not allow credentials exposure"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@


class CloudSplainingCredentialsExposure(BaseTerraformCloudsplainingResourceIAMCheck):
excluded_actions = {"ecr:GetAuthorizationToken"} # noqa: CCE003 # a static attribute
excluded_actions = { # noqa: CCE003 # a static attribute
"ecr:GetAuthorizationToken",
"ecr-public:GetAuthorizationToken",
}

def __init__(self) -> None:
name = "Ensure IAM policies does not allow credentials exposure"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ Resources:
Resource: '*'
Roles:
- example_role
ECRPublicGetAuthTokenPolicy:
Type: 'AWS::IAM::Policy'
Properties:
PolicyName: ECRPublicGetAuthTokenPolicy
PolicyDocument:
Statement:
- Action: 'ecr-public:GetAuthorizationToken'
Effect: Allow
Resource: '*'
Roles:
- example_role
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_summary(self):
report = runner.run(root_folder=test_files_dir,runner_filter=RunnerFilter(checks=[check.id]))
summary = report.get_summary()
self.assertEqual(report.failed_checks[0].check_id, check.id)
self.assertEqual(summary['passed'], 1)
self.assertEqual(summary['passed'], 2)
self.assertEqual(summary['failed'], 1)
self.assertEqual(summary['skipped'], 0)
self.assertEqual(summary['parsing_errors'], 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ data "aws_iam_policy_document" "allowed_action" {
}
}

data "aws_iam_policy_document" "allowed_action_ecr_public" {
version = "2012-10-17"

statement {
effect = "Allow"
actions = [
"ecr-public:GetAuthorizationToken",
]
resources = [
"*",
]
}
}

data "aws_iam_policy_document" "deny" {
version = "2012-10-17"

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

passing_resources = {
"aws_iam_policy_document.allowed_action",
"aws_iam_policy_document.allowed_action_ecr_public",
"aws_iam_policy_document.deny",
"aws_iam_policy_document.pass",
}
Expand All @@ -30,7 +31,7 @@ def test(self):
passed_check_resources = set([c.resource for c in report.passed_checks])
failed_check_resources = set([c.resource for c in report.failed_checks])

self.assertEqual(summary["passed"], 3)
self.assertEqual(summary["passed"], 4)
self.assertEqual(summary["failed"], 1)
self.assertEqual(summary["skipped"], 0)
self.assertEqual(summary["parsing_errors"], 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ resource "aws_iam_policy" "allowed_action" {
POLICY
}

resource "aws_iam_policy" "allowed_action_ecr_public" {
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecr-public:GetAuthorizationToken"
],
"Resource": "*"
}
]
}
POLICY
}

resource "aws_iam_policy" "deny" {
policy = <<POLICY
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test(self):

passing_resources = {
"aws_iam_policy.allowed_action",
"aws_iam_policy.allowed_action_ecr_public",
"aws_iam_policy.deny",
"aws_iam_policy.pass",
}
Expand All @@ -30,7 +31,7 @@ def test(self):
passed_check_resources = set([c.resource for c in report.passed_checks])
failed_check_resources = set([c.resource for c in report.failed_checks])

self.assertEqual(summary["passed"], 3)
self.assertEqual(summary["passed"], 4)
self.assertEqual(summary["failed"], 1)
self.assertEqual(summary["skipped"], 0)
self.assertEqual(summary["parsing_errors"], 0)
Expand Down