prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  CKV_AWS_300 S3 MPU lifecycle alert
  **Issue**
  Alert ID - CKV_AWS_300 
  Checkov sends false alert for MPU "aws_s3_bucket_lifecycle_configuration" despite having the correct rule configuration. In my scenario I'm having an empty filter in my terraform code. But as per logic in checkov code base, (checkov/checkov/terraform/checks/resource/aws/S3AbortIncompleteUploads.py) under scan_resource_conf method, the 'if' condition doesn't take the 'filter' condition into account. This in-turn throws a false alert.
  
  **Examples**
  ```hcl
  resource "aws_s3_bucket_lifecycle_configuration" "lifecycle_rule" {
    bucket = aws_s3_bucket.s3.id
    rule {
      abort_incomplete_multipart_upload {
        days_after_initiation = 3
      }
      id = "MPU 3days"
      filter {
      }
      status = "Enabled"
    }
  }
  ```
  
  **Version (please complete the following information):**
   - Checkov 2.3.155 (Latest)
  
  
  
  </issue>
  <code>
  [start of checkov/terraform/checks/resource/aws/S3AbortIncompleteUploads.py]
  1 from __future__ import annotations
  2 
  3 from typing import Any
  4 
  5 from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck
  6 from checkov.common.models.enums import CheckCategories, CheckResult
  7 
  8 
  9 class S3AbortIncompleteUploads(BaseResourceCheck):
  10     def __init__(self) -> None:
  11         """
  12         If you don't set this value in a lifecycle configuration you'll end up paying for s3
  13         resources you never could use
  14         """
  15         name = "Ensure S3 lifecycle configuration sets period for aborting failed uploads"
  16         id = "CKV_AWS_300"
  17         supported_resources = ("aws_s3_bucket_lifecycle_configuration",)
  18         categories = (CheckCategories.GENERAL_SECURITY,)
  19         super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)
  20 
  21     def scan_resource_conf(self, conf: dict[str, list[Any]]) -> CheckResult:
  22         self.evaluated_keys = ["rule"]
  23         rules = conf.get("rule")
  24         if rules and isinstance(rules, list):
  25             for idx_rule, rule in enumerate(rules):
  26                 if (
  27                     rule.get("abort_incomplete_multipart_upload")
  28                     and rule.get("status") == ["Enabled"]
  29                     and not rule.get("filter")
  30                 ):
  31                     self.evaluated_keys = [f"rule/[{idx_rule}]/abort_incomplete_multipart_upload"]
  32                     return CheckResult.PASSED
  33 
  34         return CheckResult.FAILED
  35 
  36 
  37 check = S3AbortIncompleteUploads()
  38
  [end of checkov/terraform/checks/resource/aws/S3AbortIncompleteUploads.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/resource/aws/S3AbortIncompleteUploads.py b/checkov/terraform/checks/resource/aws/S3AbortIncompleteUploads.py
  --- a/checkov/terraform/checks/resource/aws/S3AbortIncompleteUploads.py
  +++ b/checkov/terraform/checks/resource/aws/S3AbortIncompleteUploads.py
  @@ -23,12 +23,13 @@
           rules = conf.get("rule")
           if rules and isinstance(rules, list):
               for idx_rule, rule in enumerate(rules):
  -                if (
  -                    rule.get("abort_incomplete_multipart_upload")
  -                    and rule.get("status") == ["Enabled"]
  -                    and not rule.get("filter")
  -                ):
  +                if rule.get("abort_incomplete_multipart_upload") and rule.get("status") == ["Enabled"]:
                       self.evaluated_keys = [f"rule/[{idx_rule}]/abort_incomplete_multipart_upload"]
  +                    filter = rule.get("filter")
  +                    if filter and isinstance(filter, list) and filter[0]:
  +                        # it is possible to set an empty filter, which applies then to all objects
  +                        continue
  +
                       return CheckResult.PASSED
   
           return CheckResult.FAILED
  
verification_info: {"golden_diff": "diff --git a/checkov/terraform/checks/resource/aws/S3AbortIncompleteUploads.py b/checkov/terraform/checks/resource/aws/S3AbortIncompleteUploads.py\n--- a/checkov/terraform/checks/resource/aws/S3AbortIncompleteUploads.py\n+++ b/checkov/terraform/checks/resource/aws/S3AbortIncompleteUploads.py\n@@ -23,12 +23,13 @@\n         rules = conf.get(\"rule\")\n         if rules and isinstance(rules, list):\n             for idx_rule, rule in enumerate(rules):\n-                if (\n-                    rule.get(\"abort_incomplete_multipart_upload\")\n-                    and rule.get(\"status\") == [\"Enabled\"]\n-                    and not rule.get(\"filter\")\n-                ):\n+                if rule.get(\"abort_incomplete_multipart_upload\") and rule.get(\"status\") == [\"Enabled\"]:\n                     self.evaluated_keys = [f\"rule/[{idx_rule}]/abort_incomplete_multipart_upload\"]\n+                    filter = rule.get(\"filter\")\n+                    if filter and isinstance(filter, list) and filter[0]:\n+                        # it is possible to set an empty filter, which applies then to all objects\n+                        continue\n+\n                     return CheckResult.PASSED\n \n         return CheckResult.FAILED\n", "issue": "CKV_AWS_300 S3 MPU lifecycle alert\n**Issue**\r\nAlert ID - CKV_AWS_300 \r\nCheckov sends false alert for MPU \"aws_s3_bucket_lifecycle_configuration\" despite having the correct rule configuration. In my scenario I'm having an empty filter in my terraform code. But as per logic in checkov code base, (checkov/checkov/terraform/checks/resource/aws/S3AbortIncompleteUploads.py) under scan_resource_conf method, the 'if' condition doesn't take the 'filter' condition into account. This in-turn throws a false alert.\r\n\r\n**Examples**\r\n```hcl\r\nresource \"aws_s3_bucket_lifecycle_configuration\" \"lifecycle_rule\" {\r\n  bucket = aws_s3_bucket.s3.id\r\n  rule {\r\n    abort_incomplete_multipart_upload {\r\n      days_after_initiation = 3\r\n    }\r\n    id = \"MPU 3days\"\r\n    filter {\r\n    }\r\n    status = \"Enabled\"\r\n  }\r\n}\r\n```\r\n\r\n**Version (please complete the following information):**\r\n - Checkov 2.3.155 (Latest)\r\n\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom typing import Any\n\nfrom checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck\nfrom checkov.common.models.enums import CheckCategories, CheckResult\n\n\nclass S3AbortIncompleteUploads(BaseResourceCheck):\n    def __init__(self) -> None:\n        \"\"\"\n        If you don't set this value in a lifecycle configuration you'll end up paying for s3\n        resources you never could use\n        \"\"\"\n        name = \"Ensure S3 lifecycle configuration sets period for aborting failed uploads\"\n        id = \"CKV_AWS_300\"\n        supported_resources = (\"aws_s3_bucket_lifecycle_configuration\",)\n        categories = (CheckCategories.GENERAL_SECURITY,)\n        super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)\n\n    def scan_resource_conf(self, conf: dict[str, list[Any]]) -> CheckResult:\n        self.evaluated_keys = [\"rule\"]\n        rules = conf.get(\"rule\")\n        if rules and isinstance(rules, list):\n            for idx_rule, rule in enumerate(rules):\n                if (\n                    rule.get(\"abort_incomplete_multipart_upload\")\n                    and rule.get(\"status\") == [\"Enabled\"]\n                    and not rule.get(\"filter\")\n                ):\n                    self.evaluated_keys = [f\"rule/[{idx_rule}]/abort_incomplete_multipart_upload\"]\n                    return CheckResult.PASSED\n\n        return CheckResult.FAILED\n\n\ncheck = S3AbortIncompleteUploads()\n", "path": "checkov/terraform/checks/resource/aws/S3AbortIncompleteUploads.py"}]}