prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  E2506 prevents using SourceSecurityGroupId for non-vpc security groups
  https://github.com/aws-cloudformation/cfn-lint/blob/4a7af2bd53a9ad1ccaba3a509437c53102ade522/src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.py#L33-L40
  
  I couldn't see any reason in the [cloudformation reference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group-rule-1.html#cfn-ec2-security-group-rule-sourcesecuritygroupid) that this wouldn't be valid, and I was able successfully create the following stack, where SecurityGroupB seems to be correctly restricted to traffic from SecurityGroupA. I _think_ that this rule is incorrect, unless I'm missing something
  
  ```yaml
  AWSTemplateFormatVersion: '2010-09-09'
  Resources:
    SecurityGroupA:
      Type: AWS::EC2::SecurityGroup
      Properties:
        GroupDescription: Group A
        SecurityGroupIngress:
          - FromPort: 80
            ToPort: 80
            IpProtocol: tcp
            CidrIp: 0.0.0.0/0
  
    SecurityGroupB:
      Type: AWS::EC2::SecurityGroup
      Properties:
        GroupDescription: Group B
        SecurityGroupIngress:
          - FromPort: 80
            ToPort: 80
            IpProtocol: tcp
            SourceSecurityGroupId:
              Fn::GetAtt:
                - SecurityGroupA
                - GroupId
  ```
  
  </issue>
  <code>
  [start of src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.py]
  1 """
  2 Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3 SPDX-License-Identifier: MIT-0
  4 """
  5 from cfnlint.rules import CloudFormationLintRule, RuleMatch
  6 
  7 
  8 class SecurityGroupIngress(CloudFormationLintRule):
  9     """Check if EC2 Security Group Ingress Properties"""
  10 
  11     id = "E2506"
  12     shortdesc = "Resource EC2 Security Group Ingress Properties"
  13     description = (
  14         "See if EC2 Security Group Ingress Properties are set correctly. "
  15         'Check that "SourceSecurityGroupId" or "SourceSecurityGroupName" are '
  16         " are exclusive and using the type of Ref or GetAtt "
  17     )
  18     source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group-ingress.html"
  19     tags = ["resources", "ec2", "securitygroup"]
  20 
  21     def check_ingress_rule(self, vpc_id, properties, path):
  22         """Check ingress rule"""
  23 
  24         matches = []
  25         if vpc_id:
  26             # Check that SourceSecurityGroupName isn't specified
  27             if properties.get("SourceSecurityGroupName", None):
  28                 path_error = path[:] + ["SourceSecurityGroupName"]
  29                 message = (
  30                     "SourceSecurityGroupName shouldn't be specified for "
  31                     "Vpc Security Group at {0}"
  32                 )
  33                 matches.append(
  34                     RuleMatch(
  35                         path_error, message.format("/".join(map(str, path_error)))
  36                     )
  37                 )
  38 
  39         else:
  40             if properties.get("SourceSecurityGroupId", None):
  41                 path_error = path[:] + ["SourceSecurityGroupId"]
  42                 message = (
  43                     "SourceSecurityGroupId shouldn't be specified for "
  44                     "Non-Vpc Security Group at {0}"
  45                 )
  46                 matches.append(
  47                     RuleMatch(
  48                         path_error, message.format("/".join(map(str, path_error)))
  49                     )
  50                 )
  51 
  52         return matches
  53 
  54     def match(self, cfn):
  55         """Check EC2 Security Group Ingress Resource Parameters"""
  56 
  57         matches = []
  58 
  59         resources = cfn.get_resources(resource_type="AWS::EC2::SecurityGroup")
  60         for resource_name, resource_object in resources.items():
  61             properties = resource_object.get("Properties", {})
  62             if properties:
  63                 vpc_id = properties.get("VpcId", None)
  64                 ingress_rules = properties.get("SecurityGroupIngress")
  65                 if isinstance(ingress_rules, list):
  66                     for index, ingress_rule in enumerate(ingress_rules):
  67                         path = [
  68                             "Resources",
  69                             resource_name,
  70                             "Properties",
  71                             "SecurityGroupIngress",
  72                             index,
  73                         ]
  74                         matches.extend(
  75                             self.check_ingress_rule(
  76                                 vpc_id=vpc_id, properties=ingress_rule, path=path
  77                             )
  78                         )
  79 
  80         resources = None
  81         resources = cfn.get_resources(resource_type="AWS::EC2::SecurityGroupIngress")
  82         for resource_name, resource_object in resources.items():
  83             properties = resource_object.get("Properties", {})
  84             group_id = properties.get("GroupId", None)
  85             path = ["Resources", resource_name, "Properties"]
  86             if group_id:
  87                 vpc_id = "vpc-1234567"
  88             else:
  89                 vpc_id = None
  90 
  91             if properties:
  92                 path = ["Resources", resource_name, "Properties"]
  93                 matches.extend(
  94                     self.check_ingress_rule(
  95                         vpc_id=vpc_id, properties=properties, path=path
  96                     )
  97                 )
  98         return matches
  99
  [end of src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.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/src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.py b/src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.py
  --- a/src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.py
  +++ b/src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.py
  @@ -36,19 +36,6 @@
                       )
                   )
   
  -        else:
  -            if properties.get("SourceSecurityGroupId", None):
  -                path_error = path[:] + ["SourceSecurityGroupId"]
  -                message = (
  -                    "SourceSecurityGroupId shouldn't be specified for "
  -                    "Non-Vpc Security Group at {0}"
  -                )
  -                matches.append(
  -                    RuleMatch(
  -                        path_error, message.format("/".join(map(str, path_error)))
  -                    )
  -                )
  -
           return matches
   
       def match(self, cfn):
  
verification_info: {"golden_diff": "diff --git a/src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.py b/src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.py\n--- a/src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.py\n+++ b/src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.py\n@@ -36,19 +36,6 @@\n                     )\n                 )\n \n-        else:\n-            if properties.get(\"SourceSecurityGroupId\", None):\n-                path_error = path[:] + [\"SourceSecurityGroupId\"]\n-                message = (\n-                    \"SourceSecurityGroupId shouldn't be specified for \"\n-                    \"Non-Vpc Security Group at {0}\"\n-                )\n-                matches.append(\n-                    RuleMatch(\n-                        path_error, message.format(\"/\".join(map(str, path_error)))\n-                    )\n-                )\n-\n         return matches\n \n     def match(self, cfn):\n", "issue": "E2506 prevents using SourceSecurityGroupId for non-vpc security groups\nhttps://github.com/aws-cloudformation/cfn-lint/blob/4a7af2bd53a9ad1ccaba3a509437c53102ade522/src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.py#L33-L40\r\n\r\nI couldn't see any reason in the [cloudformation reference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group-rule-1.html#cfn-ec2-security-group-rule-sourcesecuritygroupid) that this wouldn't be valid, and I was able successfully create the following stack, where SecurityGroupB seems to be correctly restricted to traffic from SecurityGroupA. I _think_ that this rule is incorrect, unless I'm missing something\r\n\r\n```yaml\r\nAWSTemplateFormatVersion: '2010-09-09'\r\nResources:\r\n  SecurityGroupA:\r\n    Type: AWS::EC2::SecurityGroup\r\n    Properties:\r\n      GroupDescription: Group A\r\n      SecurityGroupIngress:\r\n        - FromPort: 80\r\n          ToPort: 80\r\n          IpProtocol: tcp\r\n          CidrIp: 0.0.0.0/0\r\n\r\n  SecurityGroupB:\r\n    Type: AWS::EC2::SecurityGroup\r\n    Properties:\r\n      GroupDescription: Group B\r\n      SecurityGroupIngress:\r\n        - FromPort: 80\r\n          ToPort: 80\r\n          IpProtocol: tcp\r\n          SourceSecurityGroupId:\r\n            Fn::GetAtt:\r\n              - SecurityGroupA\r\n              - GroupId\r\n```\n", "before_files": [{"content": "\"\"\"\nCopyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: MIT-0\n\"\"\"\nfrom cfnlint.rules import CloudFormationLintRule, RuleMatch\n\n\nclass SecurityGroupIngress(CloudFormationLintRule):\n    \"\"\"Check if EC2 Security Group Ingress Properties\"\"\"\n\n    id = \"E2506\"\n    shortdesc = \"Resource EC2 Security Group Ingress Properties\"\n    description = (\n        \"See if EC2 Security Group Ingress Properties are set correctly. \"\n        'Check that \"SourceSecurityGroupId\" or \"SourceSecurityGroupName\" are '\n        \" are exclusive and using the type of Ref or GetAtt \"\n    )\n    source_url = \"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group-ingress.html\"\n    tags = [\"resources\", \"ec2\", \"securitygroup\"]\n\n    def check_ingress_rule(self, vpc_id, properties, path):\n        \"\"\"Check ingress rule\"\"\"\n\n        matches = []\n        if vpc_id:\n            # Check that SourceSecurityGroupName isn't specified\n            if properties.get(\"SourceSecurityGroupName\", None):\n                path_error = path[:] + [\"SourceSecurityGroupName\"]\n                message = (\n                    \"SourceSecurityGroupName shouldn't be specified for \"\n                    \"Vpc Security Group at {0}\"\n                )\n                matches.append(\n                    RuleMatch(\n                        path_error, message.format(\"/\".join(map(str, path_error)))\n                    )\n                )\n\n        else:\n            if properties.get(\"SourceSecurityGroupId\", None):\n                path_error = path[:] + [\"SourceSecurityGroupId\"]\n                message = (\n                    \"SourceSecurityGroupId shouldn't be specified for \"\n                    \"Non-Vpc Security Group at {0}\"\n                )\n                matches.append(\n                    RuleMatch(\n                        path_error, message.format(\"/\".join(map(str, path_error)))\n                    )\n                )\n\n        return matches\n\n    def match(self, cfn):\n        \"\"\"Check EC2 Security Group Ingress Resource Parameters\"\"\"\n\n        matches = []\n\n        resources = cfn.get_resources(resource_type=\"AWS::EC2::SecurityGroup\")\n        for resource_name, resource_object in resources.items():\n            properties = resource_object.get(\"Properties\", {})\n            if properties:\n                vpc_id = properties.get(\"VpcId\", None)\n                ingress_rules = properties.get(\"SecurityGroupIngress\")\n                if isinstance(ingress_rules, list):\n                    for index, ingress_rule in enumerate(ingress_rules):\n                        path = [\n                            \"Resources\",\n                            resource_name,\n                            \"Properties\",\n                            \"SecurityGroupIngress\",\n                            index,\n                        ]\n                        matches.extend(\n                            self.check_ingress_rule(\n                                vpc_id=vpc_id, properties=ingress_rule, path=path\n                            )\n                        )\n\n        resources = None\n        resources = cfn.get_resources(resource_type=\"AWS::EC2::SecurityGroupIngress\")\n        for resource_name, resource_object in resources.items():\n            properties = resource_object.get(\"Properties\", {})\n            group_id = properties.get(\"GroupId\", None)\n            path = [\"Resources\", resource_name, \"Properties\"]\n            if group_id:\n                vpc_id = \"vpc-1234567\"\n            else:\n                vpc_id = None\n\n            if properties:\n                path = [\"Resources\", resource_name, \"Properties\"]\n                matches.extend(\n                    self.check_ingress_rule(\n                        vpc_id=vpc_id, properties=properties, path=path\n                    )\n                )\n        return matches\n", "path": "src/cfnlint/rules/resources/ectwo/SecurityGroupIngress.py"}]}