prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Don't validate SAM transformed resources for rule I3042
  ### CloudFormation Lint Version
  
  v0.71.1
  
  ### What operating system are you using?
  
  Mac
  
  ### Describe the bug
  
  When SAM transforms templates it can create hardcoded ARNs based on its scenario. It would make sense to not validate those ARNs against rule I3042
  
  ### Expected behavior
  
  To not raise I3042 on resources that are created by SAM transform.
  
  ### Reproduction template
  
  ```yaml
  
  ```
  
  </issue>
  <code>
  [start of src/cfnlint/rules/resources/HardCodedArnProperties.py]
  1 """
  2 Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3 SPDX-License-Identifier: MIT-0
  4 """
  5 import re
  6 
  7 from cfnlint.rules import CloudFormationLintRule, RuleMatch
  8 
  9 
  10 class HardCodedArnProperties(CloudFormationLintRule):
  11     """Checks Resources if ARNs use correctly placed Pseudo Parameters instead of hardcoded Partition, Region, and Account Number"""
  12 
  13     id = "I3042"
  14     shortdesc = "ARNs should use correctly placed Pseudo Parameters"
  15     description = "Checks Resources if ARNs use correctly placed Pseudo Parameters instead of hardcoded Partition, Region, and Account Number"
  16     source_url = ""
  17     tags = ["resources"]
  18     regex = re.compile(
  19         r"arn:(\$\{[^:]*::[^:]*}|[^:]*):[^:]+:(\$\{[^:]*::[^:]*}|[^:]*):(\$\{[^:]*::[^:]*}|[^:]*)"
  20     )
  21 
  22     def __init__(self):
  23         """Init"""
  24         super().__init__()
  25         self.config_definition = {
  26             "partition": {
  27                 "default": True,
  28                 "type": "boolean",
  29             },
  30             "region": {
  31                 "default": False,
  32                 "type": "boolean",
  33             },
  34             "accountId": {
  35                 "default": False,
  36                 "type": "boolean",
  37             },
  38         }
  39         self.configure()
  40 
  41     def _match_values(self, cfnelem, path):
  42         """Recursively search for values matching the searchRegex"""
  43         values = []
  44         if isinstance(cfnelem, dict):
  45             for key in cfnelem:
  46                 pathprop = path[:]
  47                 pathprop.append(key)
  48                 values.extend(self._match_values(cfnelem[key], pathprop))
  49         elif isinstance(cfnelem, list):
  50             for index, item in enumerate(cfnelem):
  51                 pathprop = path[:]
  52                 pathprop.append(index)
  53                 values.extend(self._match_values(item, pathprop))
  54         else:
  55             # Leaf node
  56             if isinstance(cfnelem, str):  # and re.match(searchRegex, cfnelem):
  57                 for variable in re.findall(self.regex, cfnelem):
  58                     if "Fn::Sub" in path:
  59                         values.append(path + [variable])
  60 
  61         return values
  62 
  63     def match_values(self, cfn):
  64         """
  65         Search for values in all parts of the templates that match the searchRegex
  66         """
  67         results = []
  68         results.extend(self._match_values(cfn.template.get("Resources", {}), []))
  69         # Globals are removed during a transform.  They need to be checked manually
  70         results.extend(self._match_values(cfn.template.get("Globals", {}), []))
  71         return results
  72 
  73     def match(self, cfn):
  74         """Check CloudFormation Resources"""
  75         matches = []
  76 
  77         # Get a list of paths to every leaf node string containing at least one ${parameter}
  78         parameter_string_paths = self.match_values(cfn)
  79         # We want to search all of the paths to check if each one contains an 'Fn::Sub'
  80         for parameter_string_path in parameter_string_paths:
  81             path = ["Resources"] + parameter_string_path[:-1]
  82             candidate = parameter_string_path[-1]
  83 
  84             # !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
  85             # is valid even with aws as the account #.  This handles empty string
  86             if self.config["partition"] and not re.match(
  87                 r"^\$\{\w+}|\$\{AWS::Partition}|$", candidate[0]
  88             ):
  89                 # or not re.match(r'^(\$\{\w+}|\$\{AWS::Region}|)$', candidate[1]) or not re.match(r'^\$\{\w+}|\$\{AWS::AccountId}|aws|$', candidate[2]):
  90                 message = "ARN in Resource {0} contains hardcoded Partition in ARN or incorrectly placed Pseudo Parameters"
  91                 matches.append(RuleMatch(path, message.format(path[1])))
  92             if self.config["region"] and not re.match(
  93                 r"^(\$\{\w+}|\$\{AWS::Region}|)$", candidate[1]
  94             ):
  95                 # or  or not re.match(r'^\$\{\w+}|\$\{AWS::AccountId}|aws|$', candidate[2]):
  96                 message = "ARN in Resource {0} contains hardcoded Region in ARN or incorrectly placed Pseudo Parameters"
  97                 matches.append(RuleMatch(path, message.format(path[1])))
  98             if self.config["accountId"] and not re.match(
  99                 r"^\$\{\w+}|\$\{AWS::AccountId}|aws|$", candidate[2]
  100             ):
  101                 message = "ARN in Resource {0} contains hardcoded AccountId in ARN or incorrectly placed Pseudo Parameters"
  102                 matches.append(RuleMatch(path, message.format(path[1])))
  103 
  104         return matches
  105
  [end of src/cfnlint/rules/resources/HardCodedArnProperties.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/HardCodedArnProperties.py b/src/cfnlint/rules/resources/HardCodedArnProperties.py
  --- a/src/cfnlint/rules/resources/HardCodedArnProperties.py
  +++ b/src/cfnlint/rules/resources/HardCodedArnProperties.py
  @@ -71,9 +71,13 @@
           return results
   
       def match(self, cfn):
  -        """Check CloudFormation Resources"""
           matches = []
   
  +        transforms = cfn.transform_pre["Transform"]
  +        transforms = transforms if isinstance(transforms, list) else [transforms]
  +        if "AWS::Serverless-2016-10-31" in cfn.transform_pre["Transform"]:
  +            return matches
  +
           # Get a list of paths to every leaf node string containing at least one ${parameter}
           parameter_string_paths = self.match_values(cfn)
           # We want to search all of the paths to check if each one contains an 'Fn::Sub'
  
verification_info: {"golden_diff": "diff --git a/src/cfnlint/rules/resources/HardCodedArnProperties.py b/src/cfnlint/rules/resources/HardCodedArnProperties.py\n--- a/src/cfnlint/rules/resources/HardCodedArnProperties.py\n+++ b/src/cfnlint/rules/resources/HardCodedArnProperties.py\n@@ -71,9 +71,13 @@\n         return results\r\n \r\n     def match(self, cfn):\r\n-        \"\"\"Check CloudFormation Resources\"\"\"\r\n         matches = []\r\n \r\n+        transforms = cfn.transform_pre[\"Transform\"]\r\n+        transforms = transforms if isinstance(transforms, list) else [transforms]\r\n+        if \"AWS::Serverless-2016-10-31\" in cfn.transform_pre[\"Transform\"]:\r\n+            return matches\r\n+\r\n         # Get a list of paths to every leaf node string containing at least one ${parameter}\r\n         parameter_string_paths = self.match_values(cfn)\r\n         # We want to search all of the paths to check if each one contains an 'Fn::Sub'\n", "issue": "Don't validate SAM transformed resources for rule I3042\n### CloudFormation Lint Version\n\nv0.71.1\n\n### What operating system are you using?\n\nMac\n\n### Describe the bug\n\nWhen SAM transforms templates it can create hardcoded ARNs based on its scenario. It would make sense to not validate those ARNs against rule I3042\n\n### Expected behavior\n\nTo not raise I3042 on resources that are created by SAM transform.\n\n### Reproduction template\n\n```yaml\r\n\r\n```\n", "before_files": [{"content": "\"\"\"\r\nCopyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\r\nSPDX-License-Identifier: MIT-0\r\n\"\"\"\r\nimport re\r\n\r\nfrom cfnlint.rules import CloudFormationLintRule, RuleMatch\r\n\r\n\r\nclass HardCodedArnProperties(CloudFormationLintRule):\r\n    \"\"\"Checks Resources if ARNs use correctly placed Pseudo Parameters instead of hardcoded Partition, Region, and Account Number\"\"\"\r\n\r\n    id = \"I3042\"\r\n    shortdesc = \"ARNs should use correctly placed Pseudo Parameters\"\r\n    description = \"Checks Resources if ARNs use correctly placed Pseudo Parameters instead of hardcoded Partition, Region, and Account Number\"\r\n    source_url = \"\"\r\n    tags = [\"resources\"]\r\n    regex = re.compile(\r\n        r\"arn:(\\$\\{[^:]*::[^:]*}|[^:]*):[^:]+:(\\$\\{[^:]*::[^:]*}|[^:]*):(\\$\\{[^:]*::[^:]*}|[^:]*)\"\r\n    )\r\n\r\n    def __init__(self):\r\n        \"\"\"Init\"\"\"\r\n        super().__init__()\r\n        self.config_definition = {\r\n            \"partition\": {\r\n                \"default\": True,\r\n                \"type\": \"boolean\",\r\n            },\r\n            \"region\": {\r\n                \"default\": False,\r\n                \"type\": \"boolean\",\r\n            },\r\n            \"accountId\": {\r\n                \"default\": False,\r\n                \"type\": \"boolean\",\r\n            },\r\n        }\r\n        self.configure()\r\n\r\n    def _match_values(self, cfnelem, path):\r\n        \"\"\"Recursively search for values matching the searchRegex\"\"\"\r\n        values = []\r\n        if isinstance(cfnelem, dict):\r\n            for key in cfnelem:\r\n                pathprop = path[:]\r\n                pathprop.append(key)\r\n                values.extend(self._match_values(cfnelem[key], pathprop))\r\n        elif isinstance(cfnelem, list):\r\n            for index, item in enumerate(cfnelem):\r\n                pathprop = path[:]\r\n                pathprop.append(index)\r\n                values.extend(self._match_values(item, pathprop))\r\n        else:\r\n            # Leaf node\r\n            if isinstance(cfnelem, str):  # and re.match(searchRegex, cfnelem):\r\n                for variable in re.findall(self.regex, cfnelem):\r\n                    if \"Fn::Sub\" in path:\r\n                        values.append(path + [variable])\r\n\r\n        return values\r\n\r\n    def match_values(self, cfn):\r\n        \"\"\"\r\n        Search for values in all parts of the templates that match the searchRegex\r\n        \"\"\"\r\n        results = []\r\n        results.extend(self._match_values(cfn.template.get(\"Resources\", {}), []))\r\n        # Globals are removed during a transform.  They need to be checked manually\r\n        results.extend(self._match_values(cfn.template.get(\"Globals\", {}), []))\r\n        return results\r\n\r\n    def match(self, cfn):\r\n        \"\"\"Check CloudFormation Resources\"\"\"\r\n        matches = []\r\n\r\n        # Get a list of paths to every leaf node string containing at least one ${parameter}\r\n        parameter_string_paths = self.match_values(cfn)\r\n        # We want to search all of the paths to check if each one contains an 'Fn::Sub'\r\n        for parameter_string_path in parameter_string_paths:\r\n            path = [\"Resources\"] + parameter_string_path[:-1]\r\n            candidate = parameter_string_path[-1]\r\n\r\n            # !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole\r\n            # is valid even with aws as the account #.  This handles empty string\r\n            if self.config[\"partition\"] and not re.match(\r\n                r\"^\\$\\{\\w+}|\\$\\{AWS::Partition}|$\", candidate[0]\r\n            ):\r\n                # or not re.match(r'^(\\$\\{\\w+}|\\$\\{AWS::Region}|)$', candidate[1]) or not re.match(r'^\\$\\{\\w+}|\\$\\{AWS::AccountId}|aws|$', candidate[2]):\r\n                message = \"ARN in Resource {0} contains hardcoded Partition in ARN or incorrectly placed Pseudo Parameters\"\r\n                matches.append(RuleMatch(path, message.format(path[1])))\r\n            if self.config[\"region\"] and not re.match(\r\n                r\"^(\\$\\{\\w+}|\\$\\{AWS::Region}|)$\", candidate[1]\r\n            ):\r\n                # or  or not re.match(r'^\\$\\{\\w+}|\\$\\{AWS::AccountId}|aws|$', candidate[2]):\r\n                message = \"ARN in Resource {0} contains hardcoded Region in ARN or incorrectly placed Pseudo Parameters\"\r\n                matches.append(RuleMatch(path, message.format(path[1])))\r\n            if self.config[\"accountId\"] and not re.match(\r\n                r\"^\\$\\{\\w+}|\\$\\{AWS::AccountId}|aws|$\", candidate[2]\r\n            ):\r\n                message = \"ARN in Resource {0} contains hardcoded AccountId in ARN or incorrectly placed Pseudo Parameters\"\r\n                matches.append(RuleMatch(path, message.format(path[1])))\r\n\r\n        return matches\r\n", "path": "src/cfnlint/rules/resources/HardCodedArnProperties.py"}]}