We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
E3031 CidrIp contains invalid characters fails when Fn::Sub is present
*cfn-lint version: (`cfn-lint --version`)*

`cfn-lint 0.16.0`

*Description of issue.*

When `CidrIp` value is `!Sub`ed from `Parameters` - E3031 lint error is raised. Sample template:

```lang=yaml
AWSTemplateFormatVersion: 2010-09-09

Description: AMI Builder Stack

Parameters:

  BuilderCidr:
    Type: String

Resources:

  SecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Description
      VpcId: vpc-id
      SecurityGroupIngress:
      - IpProtocol: tcp
        FromPort: 1
        ToPort: 65535
        CidrIp: !Sub ${BuilderCidr}
```

Expected output: successful lint
Actual output:

```
E3031 CidrIp contains invalid characters (Pattern: x.x.x.x/y) at Resources/SecurityGroup/Properties/SecurityGroupIngress/0/CidrIp/Fn::Sub
```

> Cfn-lint uses the [CloudFormation Resource Specifications](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html) as the base to do validation. These files are included as part of the application version. Please update to the latest version of `cfn-lint` or update the spec files manually (`cfn-lint -u`)

The problem still persists after running `cfn-lint -u`

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/cfnlint/rules/resources/properties/AllowedPattern.py`
Content:
```
1 """
2   Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 
4   Permission is hereby granted, free of charge, to any person obtaining a copy of this
5   software and associated documentation files (the "Software"), to deal in the Software
6   without restriction, including without limitation the rights to use, copy, modify,
7   merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
8   permit persons to whom the Software is furnished to do so.
9 
10   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
11   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
12   PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
13   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
14   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
15   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 """
17 import re
18 import six
19 from cfnlint import CloudFormationLintRule
20 from cfnlint import RuleMatch
21 
22 from cfnlint.helpers import RESOURCE_SPECS
23 
24 
25 class AllowedPattern(CloudFormationLintRule):
26     """Check if properties have a valid value"""
27     id = 'E3031'
28     shortdesc = 'Check if property values adhere to a specific pattern'
29     description = 'Check if properties have a valid value in case of a pattern (Regular Expression)'
30     source_url = 'https://github.com/awslabs/cfn-python-lint/blob/master/docs/cfn-resource-specification.md#allowedpattern'
31     tags = ['resources', 'property', 'allowed pattern', 'regex']
32 
33     def initialize(self, cfn):
34         """Initialize the rule"""
35         for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes'):
36             self.resource_property_types.append(resource_type_spec)
37         for property_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes'):
38             self.resource_sub_property_types.append(property_type_spec)
39 
40     def check_sub(self, value, path, property_name, **kwargs):
41         """Check Value of a Sub"""
42         matches = []
43 
44         if isinstance(value, list):
45             if isinstance(value[0], six.string_types):
46                 # Remove the sub (${}) from the value
47                 stripped_value = re.sub(r'\${.*}', '', value[0])
48                 matches.extend(self.check_value(stripped_value, path[:] + [0], property_name, **kwargs))
49         else:
50             # Remove the sub (${}) from the value
51             stripped_value = re.sub(r'\${.*}', '', value)
52             matches.extend(self.check_value(stripped_value, path[:], property_name, **kwargs))
53         return matches
54 
55     def check_value(self, value, path, property_name, **kwargs):
56         """Check Value"""
57         matches = []
58 
59         # Get the Allowed Pattern Regex
60         value_pattern_regex = kwargs.get('value_specs', {}).get('AllowedPatternRegex', {})
61         # Get the "Human Readable" version for the error message. Optional, if not specified,
62         # the RegEx itself is used.
63         value_pattern = kwargs.get('value_specs', {}).get('AllowedPattern', value_pattern_regex)
64 
65         if value_pattern_regex:
66             regex = re.compile(value_pattern_regex)
67             if not regex.match(value):
68                 full_path = ('/'.join(str(x) for x in path))
69 
70                 message = '{} contains invalid characters (Pattern: {}) at {}'
71                 matches.append(RuleMatch(path, message.format(property_name, value_pattern, full_path)))
72 
73         return matches
74 
75     def check(self, cfn, properties, value_specs, property_specs, path):
76         """Check itself"""
77         matches = list()
78         for p_value, p_path in properties.items_safe(path[:]):
79             for prop in p_value:
80                 if prop in value_specs:
81                     value = value_specs.get(prop).get('Value', {})
82                     if value:
83                         value_type = value.get('ValueType', '')
84                         property_type = property_specs.get('Properties').get(prop).get('Type')
85                         matches.extend(
86                             cfn.check_value(
87                                 p_value, prop, p_path,
88                                 check_value=self.check_value,
89                                 check_sub=self.check_sub,
90                                 value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get('ValueTypes').get(value_type, {}),
91                                 cfn=cfn, property_type=property_type, property_name=prop
92                             )
93                         )
94         return matches
95 
96     def match_resource_sub_properties(self, properties, property_type, path, cfn):
97         """Match for sub properties"""
98         matches = list()
99 
100         specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type, {}).get('Properties', {})
101         property_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type)
102         matches.extend(self.check(cfn, properties, specs, property_specs, path))
103 
104         return matches
105 
106     def match_resource_properties(self, properties, resource_type, path, cfn):
107         """Check CloudFormation Properties"""
108         matches = list()
109 
110         specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type, {}).get('Properties', {})
111         resource_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type)
112         matches.extend(self.check(cfn, properties, specs, resource_specs, path))
113 
114         return matches
115
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/cfnlint/rules/resources/properties/AllowedPattern.py b/src/cfnlint/rules/resources/properties/AllowedPattern.py
--- a/src/cfnlint/rules/resources/properties/AllowedPattern.py
+++ b/src/cfnlint/rules/resources/properties/AllowedPattern.py
@@ -15,7 +15,6 @@
   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 """
 import re
-import six
 from cfnlint import CloudFormationLintRule
 from cfnlint import RuleMatch
 
@@ -37,21 +36,6 @@
         for property_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes'):
             self.resource_sub_property_types.append(property_type_spec)
 
-    def check_sub(self, value, path, property_name, **kwargs):
-        """Check Value of a Sub"""
-        matches = []
-
-        if isinstance(value, list):
-            if isinstance(value[0], six.string_types):
-                # Remove the sub (${}) from the value
-                stripped_value = re.sub(r'\${.*}', '', value[0])
-                matches.extend(self.check_value(stripped_value, path[:] + [0], property_name, **kwargs))
-        else:
-            # Remove the sub (${}) from the value
-            stripped_value = re.sub(r'\${.*}', '', value)
-            matches.extend(self.check_value(stripped_value, path[:], property_name, **kwargs))
-        return matches
-
     def check_value(self, value, path, property_name, **kwargs):
         """Check Value"""
         matches = []
@@ -86,7 +70,6 @@
                             cfn.check_value(
                                 p_value, prop, p_path,
                                 check_value=self.check_value,
-                                check_sub=self.check_sub,
                                 value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get('ValueTypes').get(value_type, {}),
                                 cfn=cfn, property_type=property_type, property_name=prop
                             )

{"golden_diff": "diff --git a/src/cfnlint/rules/resources/properties/AllowedPattern.py b/src/cfnlint/rules/resources/properties/AllowedPattern.py\n--- a/src/cfnlint/rules/resources/properties/AllowedPattern.py\n+++ b/src/cfnlint/rules/resources/properties/AllowedPattern.py\n@@ -15,7 +15,6 @@\n   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n \"\"\"\n import re\n-import six\n from cfnlint import CloudFormationLintRule\n from cfnlint import RuleMatch\n \n@@ -37,21 +36,6 @@\n         for property_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes'):\n             self.resource_sub_property_types.append(property_type_spec)\n \n-    def check_sub(self, value, path, property_name, **kwargs):\n-        \"\"\"Check Value of a Sub\"\"\"\n-        matches = []\n-\n-        if isinstance(value, list):\n-            if isinstance(value[0], six.string_types):\n-                # Remove the sub (${}) from the value\n-                stripped_value = re.sub(r'\\${.*}', '', value[0])\n-                matches.extend(self.check_value(stripped_value, path[:] + [0], property_name, **kwargs))\n-        else:\n-            # Remove the sub (${}) from the value\n-            stripped_value = re.sub(r'\\${.*}', '', value)\n-            matches.extend(self.check_value(stripped_value, path[:], property_name, **kwargs))\n-        return matches\n-\n     def check_value(self, value, path, property_name, **kwargs):\n         \"\"\"Check Value\"\"\"\n         matches = []\n@@ -86,7 +70,6 @@\n                             cfn.check_value(\n                                 p_value, prop, p_path,\n                                 check_value=self.check_value,\n-                                check_sub=self.check_sub,\n                                 value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get('ValueTypes').get(value_type, {}),\n                                 cfn=cfn, property_type=property_type, property_name=prop\n                             )\n", "issue": "E3031 CidrIp contains invalid characters fails when Fn::Sub is present\n*cfn-lint version: (`cfn-lint --version`)*\r\n\r\n`cfn-lint 0.16.0`\r\n\r\n*Description of issue.*\r\n\r\nWhen `CidrIp` value is `!Sub`ed from `Parameters` - E3031 lint error is raised. Sample template:\r\n\r\n```lang=yaml\r\nAWSTemplateFormatVersion: 2010-09-09\r\n\r\nDescription: AMI Builder Stack\r\n\r\nParameters:\r\n\r\n  BuilderCidr:\r\n    Type: String\r\n\r\nResources:\r\n\r\n  SecurityGroup:\r\n    Type: AWS::EC2::SecurityGroup\r\n    Properties:\r\n      GroupDescription: Description\r\n      VpcId: vpc-id\r\n      SecurityGroupIngress:\r\n      - IpProtocol: tcp\r\n        FromPort: 1\r\n        ToPort: 65535\r\n        CidrIp: !Sub ${BuilderCidr}\r\n```\r\n\r\nExpected output: successful lint\r\nActual output:\r\n\r\n```\r\nE3031 CidrIp contains invalid characters (Pattern: x.x.x.x/y) at Resources/SecurityGroup/Properties/SecurityGroupIngress/0/CidrIp/Fn::Sub\r\n```\r\n\r\n> Cfn-lint uses the [CloudFormation Resource Specifications](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html) as the base to do validation. These files are included as part of the application version. Please update to the latest version of `cfn-lint` or update the spec files manually (`cfn-lint -u`)\r\n\r\nThe problem still persists after running `cfn-lint -u`\n", "before_files": [{"content": "\"\"\"\n  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nimport re\nimport six\nfrom cfnlint import CloudFormationLintRule\nfrom cfnlint import RuleMatch\n\nfrom cfnlint.helpers import RESOURCE_SPECS\n\n\nclass AllowedPattern(CloudFormationLintRule):\n    \"\"\"Check if properties have a valid value\"\"\"\n    id = 'E3031'\n    shortdesc = 'Check if property values adhere to a specific pattern'\n    description = 'Check if properties have a valid value in case of a pattern (Regular Expression)'\n    source_url = 'https://github.com/awslabs/cfn-python-lint/blob/master/docs/cfn-resource-specification.md#allowedpattern'\n    tags = ['resources', 'property', 'allowed pattern', 'regex']\n\n    def initialize(self, cfn):\n        \"\"\"Initialize the rule\"\"\"\n        for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes'):\n            self.resource_property_types.append(resource_type_spec)\n        for property_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes'):\n            self.resource_sub_property_types.append(property_type_spec)\n\n    def check_sub(self, value, path, property_name, **kwargs):\n        \"\"\"Check Value of a Sub\"\"\"\n        matches = []\n\n        if isinstance(value, list):\n            if isinstance(value[0], six.string_types):\n                # Remove the sub (${}) from the value\n                stripped_value = re.sub(r'\\${.*}', '', value[0])\n                matches.extend(self.check_value(stripped_value, path[:] + [0], property_name, **kwargs))\n        else:\n            # Remove the sub (${}) from the value\n            stripped_value = re.sub(r'\\${.*}', '', value)\n            matches.extend(self.check_value(stripped_value, path[:], property_name, **kwargs))\n        return matches\n\n    def check_value(self, value, path, property_name, **kwargs):\n        \"\"\"Check Value\"\"\"\n        matches = []\n\n        # Get the Allowed Pattern Regex\n        value_pattern_regex = kwargs.get('value_specs', {}).get('AllowedPatternRegex', {})\n        # Get the \"Human Readable\" version for the error message. Optional, if not specified,\n        # the RegEx itself is used.\n        value_pattern = kwargs.get('value_specs', {}).get('AllowedPattern', value_pattern_regex)\n\n        if value_pattern_regex:\n            regex = re.compile(value_pattern_regex)\n            if not regex.match(value):\n                full_path = ('/'.join(str(x) for x in path))\n\n                message = '{} contains invalid characters (Pattern: {}) at {}'\n                matches.append(RuleMatch(path, message.format(property_name, value_pattern, full_path)))\n\n        return matches\n\n    def check(self, cfn, properties, value_specs, property_specs, path):\n        \"\"\"Check itself\"\"\"\n        matches = list()\n        for p_value, p_path in properties.items_safe(path[:]):\n            for prop in p_value:\n                if prop in value_specs:\n                    value = value_specs.get(prop).get('Value', {})\n                    if value:\n                        value_type = value.get('ValueType', '')\n                        property_type = property_specs.get('Properties').get(prop).get('Type')\n                        matches.extend(\n                            cfn.check_value(\n                                p_value, prop, p_path,\n                                check_value=self.check_value,\n                                check_sub=self.check_sub,\n                                value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get('ValueTypes').get(value_type, {}),\n                                cfn=cfn, property_type=property_type, property_name=prop\n                            )\n                        )\n        return matches\n\n    def match_resource_sub_properties(self, properties, property_type, path, cfn):\n        \"\"\"Match for sub properties\"\"\"\n        matches = list()\n\n        specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type, {}).get('Properties', {})\n        property_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type)\n        matches.extend(self.check(cfn, properties, specs, property_specs, path))\n\n        return matches\n\n    def match_resource_properties(self, properties, resource_type, path, cfn):\n        \"\"\"Check CloudFormation Properties\"\"\"\n        matches = list()\n\n        specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type, {}).get('Properties', {})\n        resource_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type)\n        matches.extend(self.check(cfn, properties, specs, resource_specs, path))\n\n        return matches\n", "path": "src/cfnlint/rules/resources/properties/AllowedPattern.py"}], "after_files": [{"content": "\"\"\"\n  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nimport re\nfrom cfnlint import CloudFormationLintRule\nfrom cfnlint import RuleMatch\n\nfrom cfnlint.helpers import RESOURCE_SPECS\n\n\nclass AllowedPattern(CloudFormationLintRule):\n    \"\"\"Check if properties have a valid value\"\"\"\n    id = 'E3031'\n    shortdesc = 'Check if property values adhere to a specific pattern'\n    description = 'Check if properties have a valid value in case of a pattern (Regular Expression)'\n    source_url = 'https://github.com/awslabs/cfn-python-lint/blob/master/docs/cfn-resource-specification.md#allowedpattern'\n    tags = ['resources', 'property', 'allowed pattern', 'regex']\n\n    def initialize(self, cfn):\n        \"\"\"Initialize the rule\"\"\"\n        for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes'):\n            self.resource_property_types.append(resource_type_spec)\n        for property_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes'):\n            self.resource_sub_property_types.append(property_type_spec)\n\n    def check_value(self, value, path, property_name, **kwargs):\n        \"\"\"Check Value\"\"\"\n        matches = []\n\n        # Get the Allowed Pattern Regex\n        value_pattern_regex = kwargs.get('value_specs', {}).get('AllowedPatternRegex', {})\n        # Get the \"Human Readable\" version for the error message. Optional, if not specified,\n        # the RegEx itself is used.\n        value_pattern = kwargs.get('value_specs', {}).get('AllowedPattern', value_pattern_regex)\n\n        if value_pattern_regex:\n            regex = re.compile(value_pattern_regex)\n            if not regex.match(value):\n                full_path = ('/'.join(str(x) for x in path))\n\n                message = '{} contains invalid characters (Pattern: {}) at {}'\n                matches.append(RuleMatch(path, message.format(property_name, value_pattern, full_path)))\n\n        return matches\n\n    def check(self, cfn, properties, value_specs, property_specs, path):\n        \"\"\"Check itself\"\"\"\n        matches = list()\n        for p_value, p_path in properties.items_safe(path[:]):\n            for prop in p_value:\n                if prop in value_specs:\n                    value = value_specs.get(prop).get('Value', {})\n                    if value:\n                        value_type = value.get('ValueType', '')\n                        property_type = property_specs.get('Properties').get(prop).get('Type')\n                        matches.extend(\n                            cfn.check_value(\n                                p_value, prop, p_path,\n                                check_value=self.check_value,\n                                value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get('ValueTypes').get(value_type, {}),\n                                cfn=cfn, property_type=property_type, property_name=prop\n                            )\n                        )\n        return matches\n\n    def match_resource_sub_properties(self, properties, property_type, path, cfn):\n        \"\"\"Match for sub properties\"\"\"\n        matches = list()\n\n        specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type, {}).get('Properties', {})\n        property_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type)\n        matches.extend(self.check(cfn, properties, specs, property_specs, path))\n\n        return matches\n\n    def match_resource_properties(self, properties, resource_type, path, cfn):\n        \"\"\"Check CloudFormation Properties\"\"\"\n        matches = list()\n\n        specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type, {}).get('Properties', {})\n        resource_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type)\n        matches.extend(self.check(cfn, properties, specs, resource_specs, path))\n\n        return matches\n", "path": "src/cfnlint/rules/resources/properties/AllowedPattern.py"}]}