prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Scanning IAM policy only takes First SID in json rather than looping through
  **Describe the bug**
  It seems when specifying more than one SID in a json, the policies do not loop through each one rather it just looks at the first one and ends. 
  
  **To Reproduce**
  Steps to reproduce the behavior:
  1. Create policy with more than one SID
  `{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Sid": "SqsAllow",
        "Effect": "Allow",
        "Action": [
          "sqs:GetQueueAttributes",
          "sqs:GetQueueUrl",
          "sqs:ListDeadLetterSourceQueues",
          "sqs:ListQueues",
          "sqs:ReceiveMessage",
          "sqs:SendMessage",
          "sqs:SendMessageBatch"
        ],
        "Resource": "*"
            },
      {
        "Sid": "ALL",
        "Effect": "Allow",
        "Action": [ "*"
        ],
        "Resource": ["*"]
      },`
  2. Run Checkov against policy
  
  
  **Expected behavior**
  I would expect the scan to check each json within the policy rather than the first one
  
  
  
  **Desktop (please complete the following information):**
   - OS: Mac
   - Checkov Version: 1.0.442
  
  
  
  
  </issue>
  <code>
  [start of checkov/terraform/checks/resource/aws/IAMStarActionPolicyDocument.py]
  1 from checkov.common.models.enums import CheckResult, CheckCategories
  2 from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck
  3 import json
  4 
  5 
  6 class IAMStarActionPolicyDocument(BaseResourceCheck):
  7 
  8     def __init__(self):
  9         name = "Ensure no IAM policies documents allow \"*\" as a statement's actions"
  10         id = "CKV_AWS_63"
  11         supported_resources = ['aws_iam_role_policy', 'aws_iam_user_policy', 'aws_iam_group_policy', 'aws_iam_policy']
  12         categories = [CheckCategories.IAM]
  13         super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)
  14 
  15     def scan_resource_conf(self, conf):
  16         if 'policy' in conf.keys():
  17             try:
  18                 policy_block = json.loads(conf['policy'][0])
  19                 if 'Statement' in policy_block.keys():
  20                         if 'Action' in policy_block['Statement'][0] and \
  21                                 policy_block['Statement'][0].get('Effect', ['Allow']) == 'Allow' and \
  22                                 policy_block['Statement'][0]['Action'][0] == "*":
  23                             return CheckResult.FAILED
  24             except: # nosec
  25                 pass
  26         return CheckResult.PASSED
  27 
  28 
  29 check = IAMStarActionPolicyDocument()
  30
  [end of checkov/terraform/checks/resource/aws/IAMStarActionPolicyDocument.py]
  [start of checkov/terraform/checks/resource/aws/IAMAdminPolicyDocument.py]
  1 from checkov.common.models.enums import CheckResult, CheckCategories
  2 from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck
  3 import json
  4 
  5 
  6 class IAMAdminPolicyDocument(BaseResourceCheck):
  7 
  8     def __init__(self):
  9         name = "Ensure IAM policies that allow full \"*-*\" administrative privileges are not created"
  10         id = "CKV_AWS_62"
  11         supported_resources = ['aws_iam_role_policy', 'aws_iam_user_policy', 'aws_iam_group_policy', 'aws_iam_policy']
  12         categories = [CheckCategories.IAM]
  13         super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)
  14 
  15     def scan_resource_conf(self, conf):
  16         if 'policy' in conf.keys():
  17             try:
  18                 policy_block = json.loads(conf['policy'][0])
  19                 if 'Statement' in policy_block.keys():
  20                         if 'Action' in policy_block['Statement'][0] and \
  21                                 policy_block['Statement'][0].get('Effect', ['Allow']) == 'Allow' and \
  22                                 policy_block['Statement'][0]['Action'][0] == "*" and \
  23                                 'Resource' in policy_block['Statement'][0] and \
  24                                 policy_block['Statement'][0]['Resource'] == '*':
  25                             return CheckResult.FAILED
  26             except: # nosec
  27                 pass
  28         return CheckResult.PASSED
  29 
  30 
  31 check = IAMAdminPolicyDocument()
  32
  [end of checkov/terraform/checks/resource/aws/IAMAdminPolicyDocument.py]
  [start of checkov/terraform/checks/data/aws/StarActionPolicyDocument.py]
  1 from checkov.terraform.checks.data.base_check import BaseDataCheck
  2 from checkov.common.models.enums import CheckResult, CheckCategories
  3 
  4 
  5 class StarActionPolicyDocument(BaseDataCheck):
  6     def __init__(self):
  7         name = "Ensure no IAM policies documents allow \"*\" as a statement's actions"
  8         id = "CKV_AWS_49"
  9         supported_data = ['aws_iam_policy_document']
  10         categories = [CheckCategories.IAM]
  11         super().__init__(name=name, id=id, categories=categories, supported_data=supported_data)
  12 
  13     def scan_data_conf(self, conf):
  14         """
  15             validates iam policy document
  16             https://learn.hashicorp.com/terraform/aws/iam-policy
  17         :param conf: aws_kms_key configuration
  18         :return: <CheckResult>
  19         """
  20         key = 'statement'
  21         if key in conf.keys():
  22             for statement in conf['statement']:
  23                 if 'actions' in statement and '*' in statement['actions'][0] and statement.get('effect', ['Allow'])[0] == 'Allow':
  24                     return CheckResult.FAILED
  25         return CheckResult.PASSED
  26 
  27 
  28 check = StarActionPolicyDocument()
  29
  [end of checkov/terraform/checks/data/aws/StarActionPolicyDocument.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/checkov/terraform/checks/data/aws/StarActionPolicyDocument.py b/checkov/terraform/checks/data/aws/StarActionPolicyDocument.py
  --- a/checkov/terraform/checks/data/aws/StarActionPolicyDocument.py
  +++ b/checkov/terraform/checks/data/aws/StarActionPolicyDocument.py
  @@ -19,7 +19,7 @@
           """
           key = 'statement'
           if key in conf.keys():
  -            for statement in conf['statement']:
  +            for statement in conf[key]:
                   if 'actions' in statement and '*' in statement['actions'][0] and statement.get('effect', ['Allow'])[0] == 'Allow':
                       return CheckResult.FAILED
           return CheckResult.PASSED
  diff --git a/checkov/terraform/checks/resource/aws/IAMAdminPolicyDocument.py b/checkov/terraform/checks/resource/aws/IAMAdminPolicyDocument.py
  --- a/checkov/terraform/checks/resource/aws/IAMAdminPolicyDocument.py
  +++ b/checkov/terraform/checks/resource/aws/IAMAdminPolicyDocument.py
  @@ -17,13 +17,13 @@
               try:
                   policy_block = json.loads(conf['policy'][0])
                   if 'Statement' in policy_block.keys():
  -                        if 'Action' in policy_block['Statement'][0] and \
  -                                policy_block['Statement'][0].get('Effect', ['Allow']) == 'Allow' and \
  -                                policy_block['Statement'][0]['Action'][0] == "*" and \
  -                                'Resource' in policy_block['Statement'][0] and \
  -                                policy_block['Statement'][0]['Resource'] == '*':
  +                    for statement in policy_block['Statement']:
  +                        if 'Action' in statement and \
  +                                statement.get('Effect', ['Allow']) == 'Allow' and \
  +                                '*' in statement.get('Action', ['']) and \
  +                                '*' in statement.get('Resource', ['']):
                               return CheckResult.FAILED
  -            except: # nosec
  +            except:  # nosec
                   pass
           return CheckResult.PASSED
   
  diff --git a/checkov/terraform/checks/resource/aws/IAMStarActionPolicyDocument.py b/checkov/terraform/checks/resource/aws/IAMStarActionPolicyDocument.py
  --- a/checkov/terraform/checks/resource/aws/IAMStarActionPolicyDocument.py
  +++ b/checkov/terraform/checks/resource/aws/IAMStarActionPolicyDocument.py
  @@ -17,9 +17,10 @@
               try:
                   policy_block = json.loads(conf['policy'][0])
                   if 'Statement' in policy_block.keys():
  -                        if 'Action' in policy_block['Statement'][0] and \
  -                                policy_block['Statement'][0].get('Effect', ['Allow']) == 'Allow' and \
  -                                policy_block['Statement'][0]['Action'][0] == "*":
  +                    for statement in policy_block['Statement']:
  +                        if 'Action' in statement and \
  +                                statement.get('Effect', ['Allow']) == 'Allow' and \
  +                                '*' in statement.get('Action', ['']):
                               return CheckResult.FAILED
               except: # nosec
                   pass
  
verification_info: {"golden_diff": "diff --git a/checkov/terraform/checks/data/aws/StarActionPolicyDocument.py b/checkov/terraform/checks/data/aws/StarActionPolicyDocument.py\n--- a/checkov/terraform/checks/data/aws/StarActionPolicyDocument.py\n+++ b/checkov/terraform/checks/data/aws/StarActionPolicyDocument.py\n@@ -19,7 +19,7 @@\n         \"\"\"\n         key = 'statement'\n         if key in conf.keys():\n-            for statement in conf['statement']:\n+            for statement in conf[key]:\n                 if 'actions' in statement and '*' in statement['actions'][0] and statement.get('effect', ['Allow'])[0] == 'Allow':\n                     return CheckResult.FAILED\n         return CheckResult.PASSED\ndiff --git a/checkov/terraform/checks/resource/aws/IAMAdminPolicyDocument.py b/checkov/terraform/checks/resource/aws/IAMAdminPolicyDocument.py\n--- a/checkov/terraform/checks/resource/aws/IAMAdminPolicyDocument.py\n+++ b/checkov/terraform/checks/resource/aws/IAMAdminPolicyDocument.py\n@@ -17,13 +17,13 @@\n             try:\n                 policy_block = json.loads(conf['policy'][0])\n                 if 'Statement' in policy_block.keys():\n-                        if 'Action' in policy_block['Statement'][0] and \\\n-                                policy_block['Statement'][0].get('Effect', ['Allow']) == 'Allow' and \\\n-                                policy_block['Statement'][0]['Action'][0] == \"*\" and \\\n-                                'Resource' in policy_block['Statement'][0] and \\\n-                                policy_block['Statement'][0]['Resource'] == '*':\n+                    for statement in policy_block['Statement']:\n+                        if 'Action' in statement and \\\n+                                statement.get('Effect', ['Allow']) == 'Allow' and \\\n+                                '*' in statement.get('Action', ['']) and \\\n+                                '*' in statement.get('Resource', ['']):\n                             return CheckResult.FAILED\n-            except: # nosec\n+            except:  # nosec\n                 pass\n         return CheckResult.PASSED\n \ndiff --git a/checkov/terraform/checks/resource/aws/IAMStarActionPolicyDocument.py b/checkov/terraform/checks/resource/aws/IAMStarActionPolicyDocument.py\n--- a/checkov/terraform/checks/resource/aws/IAMStarActionPolicyDocument.py\n+++ b/checkov/terraform/checks/resource/aws/IAMStarActionPolicyDocument.py\n@@ -17,9 +17,10 @@\n             try:\n                 policy_block = json.loads(conf['policy'][0])\n                 if 'Statement' in policy_block.keys():\n-                        if 'Action' in policy_block['Statement'][0] and \\\n-                                policy_block['Statement'][0].get('Effect', ['Allow']) == 'Allow' and \\\n-                                policy_block['Statement'][0]['Action'][0] == \"*\":\n+                    for statement in policy_block['Statement']:\n+                        if 'Action' in statement and \\\n+                                statement.get('Effect', ['Allow']) == 'Allow' and \\\n+                                '*' in statement.get('Action', ['']):\n                             return CheckResult.FAILED\n             except: # nosec\n                 pass\n", "issue": "Scanning IAM policy only takes First SID in json rather than looping through\n**Describe the bug**\r\nIt seems when specifying more than one SID in a json, the policies do not loop through each one rather it just looks at the first one and ends. \r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n1. Create policy with more than one SID\r\n`{\r\n  \"Version\": \"2012-10-17\",\r\n  \"Statement\": [\r\n    {\r\n      \"Sid\": \"SqsAllow\",\r\n      \"Effect\": \"Allow\",\r\n      \"Action\": [\r\n        \"sqs:GetQueueAttributes\",\r\n        \"sqs:GetQueueUrl\",\r\n        \"sqs:ListDeadLetterSourceQueues\",\r\n        \"sqs:ListQueues\",\r\n        \"sqs:ReceiveMessage\",\r\n        \"sqs:SendMessage\",\r\n        \"sqs:SendMessageBatch\"\r\n      ],\r\n      \"Resource\": \"*\"\r\n          },\r\n    {\r\n      \"Sid\": \"ALL\",\r\n      \"Effect\": \"Allow\",\r\n      \"Action\": [ \"*\"\r\n      ],\r\n      \"Resource\": [\"*\"]\r\n    },`\r\n2. Run Checkov against policy\r\n\r\n\r\n**Expected behavior**\r\nI would expect the scan to check each json within the policy rather than the first one\r\n\r\n\r\n\r\n**Desktop (please complete the following information):**\r\n - OS: Mac\r\n - Checkov Version: 1.0.442\r\n\r\n\r\n\n", "before_files": [{"content": "from checkov.common.models.enums import CheckResult, CheckCategories\nfrom checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck\nimport json\n\n\nclass IAMStarActionPolicyDocument(BaseResourceCheck):\n\n    def __init__(self):\n        name = \"Ensure no IAM policies documents allow \\\"*\\\" as a statement's actions\"\n        id = \"CKV_AWS_63\"\n        supported_resources = ['aws_iam_role_policy', 'aws_iam_user_policy', 'aws_iam_group_policy', 'aws_iam_policy']\n        categories = [CheckCategories.IAM]\n        super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)\n\n    def scan_resource_conf(self, conf):\n        if 'policy' in conf.keys():\n            try:\n                policy_block = json.loads(conf['policy'][0])\n                if 'Statement' in policy_block.keys():\n                        if 'Action' in policy_block['Statement'][0] and \\\n                                policy_block['Statement'][0].get('Effect', ['Allow']) == 'Allow' and \\\n                                policy_block['Statement'][0]['Action'][0] == \"*\":\n                            return CheckResult.FAILED\n            except: # nosec\n                pass\n        return CheckResult.PASSED\n\n\ncheck = IAMStarActionPolicyDocument()\n", "path": "checkov/terraform/checks/resource/aws/IAMStarActionPolicyDocument.py"}, {"content": "from checkov.common.models.enums import CheckResult, CheckCategories\nfrom checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck\nimport json\n\n\nclass IAMAdminPolicyDocument(BaseResourceCheck):\n\n    def __init__(self):\n        name = \"Ensure IAM policies that allow full \\\"*-*\\\" administrative privileges are not created\"\n        id = \"CKV_AWS_62\"\n        supported_resources = ['aws_iam_role_policy', 'aws_iam_user_policy', 'aws_iam_group_policy', 'aws_iam_policy']\n        categories = [CheckCategories.IAM]\n        super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)\n\n    def scan_resource_conf(self, conf):\n        if 'policy' in conf.keys():\n            try:\n                policy_block = json.loads(conf['policy'][0])\n                if 'Statement' in policy_block.keys():\n                        if 'Action' in policy_block['Statement'][0] and \\\n                                policy_block['Statement'][0].get('Effect', ['Allow']) == 'Allow' and \\\n                                policy_block['Statement'][0]['Action'][0] == \"*\" and \\\n                                'Resource' in policy_block['Statement'][0] and \\\n                                policy_block['Statement'][0]['Resource'] == '*':\n                            return CheckResult.FAILED\n            except: # nosec\n                pass\n        return CheckResult.PASSED\n\n\ncheck = IAMAdminPolicyDocument()\n", "path": "checkov/terraform/checks/resource/aws/IAMAdminPolicyDocument.py"}, {"content": "from checkov.terraform.checks.data.base_check import BaseDataCheck\nfrom checkov.common.models.enums import CheckResult, CheckCategories\n\n\nclass StarActionPolicyDocument(BaseDataCheck):\n    def __init__(self):\n        name = \"Ensure no IAM policies documents allow \\\"*\\\" as a statement's actions\"\n        id = \"CKV_AWS_49\"\n        supported_data = ['aws_iam_policy_document']\n        categories = [CheckCategories.IAM]\n        super().__init__(name=name, id=id, categories=categories, supported_data=supported_data)\n\n    def scan_data_conf(self, conf):\n        \"\"\"\n            validates iam policy document\n            https://learn.hashicorp.com/terraform/aws/iam-policy\n        :param conf: aws_kms_key configuration\n        :return: <CheckResult>\n        \"\"\"\n        key = 'statement'\n        if key in conf.keys():\n            for statement in conf['statement']:\n                if 'actions' in statement and '*' in statement['actions'][0] and statement.get('effect', ['Allow'])[0] == 'Allow':\n                    return CheckResult.FAILED\n        return CheckResult.PASSED\n\n\ncheck = StarActionPolicyDocument()\n", "path": "checkov/terraform/checks/data/aws/StarActionPolicyDocument.py"}]}