prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [Bug]: Context name on conditions are case-insensitive
  ### Steps to Reproduce
  
  As yo can see here https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html, context name on conditions are case-insensitive. Some default aws policies are "AWS:xxxx" instead of "aws:xxxx", so prowler fails to detect it. Also can happen with manual policies, if someone put "aws:sourceaccount" inseat of "aws:SourceAccount". So is_account_only_allowed_in_condition must be case-insensitive to work.
  
  I found it on SNS default policy, which look like this:
  
  ```
  {
    "Version": "2008-10-17",
    "Id": "__default_policy_ID",
    "Statement": [
      {
        "Sid": "__default_statement_ID",
        "Effect": "Allow",
        "Principal": {
          "AWS": "*"
        },
        "Action": [
          "SNS:GetTopicAttributes",
          "SNS:SetTopicAttributes",
          "SNS:AddPermission",
          "SNS:RemovePermission",
          "SNS:DeleteTopic",
          "SNS:Subscribe",
          "SNS:ListSubscriptionsByTopic",
          "SNS:Publish",
          "SNS:Receive"
        ],
        "Resource": "arn:aws:sns:eu-west-1:XXXXXXXX:config-topic",
        "Condition": {
          "StringEquals": {
            "AWS:SourceOwner": "XXXXXXXX"
          }
        }
      }
    ]
  }
  ```
  
  
  
  ### Expected behavior
  
  It should pass when found a condition like "AWS:SourceOwner" with a valid value. 
  
  ### Actual Result with Screenshots or Logs
  
  It can't detect correctly the condition, so the test fails.
  ╭────────────┬───────────┬───────────┬────────────┬────────┬──────────┬───────╮
  │ Provider   │ Service   │ Status    │   Critical │   High │   Medium │   Low │
  ├────────────┼───────────┼───────────┼────────────┼────────┼──────────┼───────┤
  │ aws        │ sns       │ FAIL (13) │          0 │     13 │        0 │     0 │
  ╰────────────┴───────────┴───────────┴────────────┴────────┴──────────┴───────╯
  
  ### How did you install Prowler?
  
  Cloning the repository from github.com (git clone)
  
  ### Environment Resource
  
  8. SNS
  
  ### OS used
  
  5. Ubuntu
  
  ### Prowler version
  
  Prowler 3.8.2
  
  ### Pip version
  
  pip 23.2.1
  
  ### Context
  
  _No response_
  
  </issue>
  <code>
  [start of prowler/providers/aws/lib/policy_condition_parser/policy_condition_parser.py]
  1 # lista de cuentas y te devuelva las válidas
  2 def is_account_only_allowed_in_condition(
  3     condition_statement: dict, source_account: str
  4 ):
  5     is_condition_valid = False
  6     valid_condition_options = {
  7         "StringEquals": [
  8             "aws:SourceAccount",
  9             "aws:SourceOwner",
  10             "s3:ResourceAccount",
  11             "aws:PrincipalAccount",
  12             "aws:ResourceAccount",
  13         ],
  14         "StringLike": [
  15             "aws:SourceAccount",
  16             "aws:SourceOwner",
  17             "aws:SourceArn",
  18             "aws:PrincipalArn",
  19             "aws:ResourceAccount",
  20             "aws:PrincipalAccount",
  21         ],
  22         "ArnLike": ["aws:SourceArn", "aws:PrincipalArn"],
  23         "ArnEquals": ["aws:SourceArn", "aws:PrincipalArn"],
  24     }
  25 
  26     for condition_operator, condition_operator_key in valid_condition_options.items():
  27         if condition_operator in condition_statement:
  28             for value in condition_operator_key:
  29                 if value in condition_statement[condition_operator]:
  30                     # values are a list
  31                     if isinstance(
  32                         condition_statement[condition_operator][value],
  33                         list,
  34                     ):
  35                         # if there is an arn/account without the source account -> we do not consider it safe
  36                         # here by default we assume is true and look for false entries
  37                         is_condition_valid = True
  38                         for item in condition_statement[condition_operator][value]:
  39                             if source_account not in item:
  40                                 is_condition_valid = False
  41                                 break
  42 
  43                     # value is a string
  44                     elif isinstance(
  45                         condition_statement[condition_operator][value],
  46                         str,
  47                     ):
  48                         if (
  49                             source_account
  50                             in condition_statement[condition_operator][value]
  51                         ):
  52                             is_condition_valid = True
  53 
  54     return is_condition_valid
  55
  [end of prowler/providers/aws/lib/policy_condition_parser/policy_condition_parser.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/prowler/providers/aws/lib/policy_condition_parser/policy_condition_parser.py b/prowler/providers/aws/lib/policy_condition_parser/policy_condition_parser.py
  --- a/prowler/providers/aws/lib/policy_condition_parser/policy_condition_parser.py
  +++ b/prowler/providers/aws/lib/policy_condition_parser/policy_condition_parser.py
  @@ -1,31 +1,52 @@
  -# lista de cuentas y te devuelva las válidas
   def is_account_only_allowed_in_condition(
       condition_statement: dict, source_account: str
   ):
  +    """
  +    is_account_only_allowed_in_condition parses the IAM Condition policy block and returns True if the source_account passed as argument is within, False if not.
  +
  +    @param condition_statement: dict with an IAM Condition block, e.g.:
  +        {
  +            "StringLike": {
  +                "AWS:SourceAccount": 111122223333
  +            }
  +        }
  +
  +    @param source_account: str with a 12-digit AWS Account number, e.g.: 111122223333
  +    """
       is_condition_valid = False
  +
  +    # The conditions must be defined in lowercase since the context key names are not case-sensitive.
  +    # For example, including the aws:SourceAccount context key is equivalent to testing for AWS:SourceAccount
  +    # https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html
       valid_condition_options = {
           "StringEquals": [
  -            "aws:SourceAccount",
  -            "aws:SourceOwner",
  -            "s3:ResourceAccount",
  -            "aws:PrincipalAccount",
  -            "aws:ResourceAccount",
  +            "aws:sourceaccount",
  +            "aws:sourceowner",
  +            "s3:resourceaccount",
  +            "aws:principalaccount",
  +            "aws:resourceaccount",
           ],
           "StringLike": [
  -            "aws:SourceAccount",
  -            "aws:SourceOwner",
  -            "aws:SourceArn",
  -            "aws:PrincipalArn",
  -            "aws:ResourceAccount",
  -            "aws:PrincipalAccount",
  +            "aws:sourceaccount",
  +            "aws:sourceowner",
  +            "aws:sourcearn",
  +            "aws:principalarn",
  +            "aws:resourceaccount",
  +            "aws:principalaccount",
           ],
  -        "ArnLike": ["aws:SourceArn", "aws:PrincipalArn"],
  -        "ArnEquals": ["aws:SourceArn", "aws:PrincipalArn"],
  +        "ArnLike": ["aws:sourcearn", "aws:principalarn"],
  +        "ArnEquals": ["aws:sourcearn", "aws:principalarn"],
       }
   
       for condition_operator, condition_operator_key in valid_condition_options.items():
           if condition_operator in condition_statement:
               for value in condition_operator_key:
  +                # We need to transform the condition_statement into lowercase
  +                condition_statement[condition_operator] = {
  +                    k.lower(): v
  +                    for k, v in condition_statement[condition_operator].items()
  +                }
  +
                   if value in condition_statement[condition_operator]:
                       # values are a list
                       if isinstance(
  
verification_info: {"golden_diff": "diff --git a/prowler/providers/aws/lib/policy_condition_parser/policy_condition_parser.py b/prowler/providers/aws/lib/policy_condition_parser/policy_condition_parser.py\n--- a/prowler/providers/aws/lib/policy_condition_parser/policy_condition_parser.py\n+++ b/prowler/providers/aws/lib/policy_condition_parser/policy_condition_parser.py\n@@ -1,31 +1,52 @@\n-# lista de cuentas y te devuelva las v\u00e1lidas\n def is_account_only_allowed_in_condition(\n     condition_statement: dict, source_account: str\n ):\n+    \"\"\"\n+    is_account_only_allowed_in_condition parses the IAM Condition policy block and returns True if the source_account passed as argument is within, False if not.\n+\n+    @param condition_statement: dict with an IAM Condition block, e.g.:\n+        {\n+            \"StringLike\": {\n+                \"AWS:SourceAccount\": 111122223333\n+            }\n+        }\n+\n+    @param source_account: str with a 12-digit AWS Account number, e.g.: 111122223333\n+    \"\"\"\n     is_condition_valid = False\n+\n+    # The conditions must be defined in lowercase since the context key names are not case-sensitive.\n+    # For example, including the aws:SourceAccount context key is equivalent to testing for AWS:SourceAccount\n+    # https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html\n     valid_condition_options = {\n         \"StringEquals\": [\n-            \"aws:SourceAccount\",\n-            \"aws:SourceOwner\",\n-            \"s3:ResourceAccount\",\n-            \"aws:PrincipalAccount\",\n-            \"aws:ResourceAccount\",\n+            \"aws:sourceaccount\",\n+            \"aws:sourceowner\",\n+            \"s3:resourceaccount\",\n+            \"aws:principalaccount\",\n+            \"aws:resourceaccount\",\n         ],\n         \"StringLike\": [\n-            \"aws:SourceAccount\",\n-            \"aws:SourceOwner\",\n-            \"aws:SourceArn\",\n-            \"aws:PrincipalArn\",\n-            \"aws:ResourceAccount\",\n-            \"aws:PrincipalAccount\",\n+            \"aws:sourceaccount\",\n+            \"aws:sourceowner\",\n+            \"aws:sourcearn\",\n+            \"aws:principalarn\",\n+            \"aws:resourceaccount\",\n+            \"aws:principalaccount\",\n         ],\n-        \"ArnLike\": [\"aws:SourceArn\", \"aws:PrincipalArn\"],\n-        \"ArnEquals\": [\"aws:SourceArn\", \"aws:PrincipalArn\"],\n+        \"ArnLike\": [\"aws:sourcearn\", \"aws:principalarn\"],\n+        \"ArnEquals\": [\"aws:sourcearn\", \"aws:principalarn\"],\n     }\n \n     for condition_operator, condition_operator_key in valid_condition_options.items():\n         if condition_operator in condition_statement:\n             for value in condition_operator_key:\n+                # We need to transform the condition_statement into lowercase\n+                condition_statement[condition_operator] = {\n+                    k.lower(): v\n+                    for k, v in condition_statement[condition_operator].items()\n+                }\n+\n                 if value in condition_statement[condition_operator]:\n                     # values are a list\n                     if isinstance(\n", "issue": "[Bug]: Context name on conditions are case-insensitive\n### Steps to Reproduce\n\nAs yo can see here https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html, context name on conditions are case-insensitive. Some default aws policies are \"AWS:xxxx\" instead of \"aws:xxxx\", so prowler fails to detect it. Also can happen with manual policies, if someone put \"aws:sourceaccount\" inseat of \"aws:SourceAccount\". So is_account_only_allowed_in_condition must be case-insensitive to work.\r\n\r\nI found it on SNS default policy, which look like this:\r\n\r\n```\r\n{\r\n  \"Version\": \"2008-10-17\",\r\n  \"Id\": \"__default_policy_ID\",\r\n  \"Statement\": [\r\n    {\r\n      \"Sid\": \"__default_statement_ID\",\r\n      \"Effect\": \"Allow\",\r\n      \"Principal\": {\r\n        \"AWS\": \"*\"\r\n      },\r\n      \"Action\": [\r\n        \"SNS:GetTopicAttributes\",\r\n        \"SNS:SetTopicAttributes\",\r\n        \"SNS:AddPermission\",\r\n        \"SNS:RemovePermission\",\r\n        \"SNS:DeleteTopic\",\r\n        \"SNS:Subscribe\",\r\n        \"SNS:ListSubscriptionsByTopic\",\r\n        \"SNS:Publish\",\r\n        \"SNS:Receive\"\r\n      ],\r\n      \"Resource\": \"arn:aws:sns:eu-west-1:XXXXXXXX:config-topic\",\r\n      \"Condition\": {\r\n        \"StringEquals\": {\r\n          \"AWS:SourceOwner\": \"XXXXXXXX\"\r\n        }\r\n      }\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\n\n\n### Expected behavior\n\nIt should pass when found a condition like \"AWS:SourceOwner\" with a valid value. \n\n### Actual Result with Screenshots or Logs\n\nIt can't detect correctly the condition, so the test fails.\r\n\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\r\n\u2502 Provider   \u2502 Service   \u2502 Status    \u2502   Critical \u2502   High \u2502   Medium \u2502   Low \u2502\r\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\r\n\u2502 aws        \u2502 sns       \u2502 FAIL (13) \u2502          0 \u2502     13 \u2502        0 \u2502     0 \u2502\r\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\n### How did you install Prowler?\n\nCloning the repository from github.com (git clone)\n\n### Environment Resource\n\n8. SNS\n\n### OS used\n\n5. Ubuntu\n\n### Prowler version\n\nProwler 3.8.2\n\n### Pip version\n\npip 23.2.1\n\n### Context\n\n_No response_\n", "before_files": [{"content": "# lista de cuentas y te devuelva las v\u00e1lidas\ndef is_account_only_allowed_in_condition(\n    condition_statement: dict, source_account: str\n):\n    is_condition_valid = False\n    valid_condition_options = {\n        \"StringEquals\": [\n            \"aws:SourceAccount\",\n            \"aws:SourceOwner\",\n            \"s3:ResourceAccount\",\n            \"aws:PrincipalAccount\",\n            \"aws:ResourceAccount\",\n        ],\n        \"StringLike\": [\n            \"aws:SourceAccount\",\n            \"aws:SourceOwner\",\n            \"aws:SourceArn\",\n            \"aws:PrincipalArn\",\n            \"aws:ResourceAccount\",\n            \"aws:PrincipalAccount\",\n        ],\n        \"ArnLike\": [\"aws:SourceArn\", \"aws:PrincipalArn\"],\n        \"ArnEquals\": [\"aws:SourceArn\", \"aws:PrincipalArn\"],\n    }\n\n    for condition_operator, condition_operator_key in valid_condition_options.items():\n        if condition_operator in condition_statement:\n            for value in condition_operator_key:\n                if value in condition_statement[condition_operator]:\n                    # values are a list\n                    if isinstance(\n                        condition_statement[condition_operator][value],\n                        list,\n                    ):\n                        # if there is an arn/account without the source account -> we do not consider it safe\n                        # here by default we assume is true and look for false entries\n                        is_condition_valid = True\n                        for item in condition_statement[condition_operator][value]:\n                            if source_account not in item:\n                                is_condition_valid = False\n                                break\n\n                    # value is a string\n                    elif isinstance(\n                        condition_statement[condition_operator][value],\n                        str,\n                    ):\n                        if (\n                            source_account\n                            in condition_statement[condition_operator][value]\n                        ):\n                            is_condition_valid = True\n\n    return is_condition_valid\n", "path": "prowler/providers/aws/lib/policy_condition_parser/policy_condition_parser.py"}]}