From 3d3a3289941d992159b4d4934a64456f5e243356 Mon Sep 17 00:00:00 2001 From: kddejong Date: Thu, 14 Mar 2019 13:26:58 -0500 Subject: [PATCH] Remove sub from Allowed Values regex rule --- .../resources/properties/AllowedPattern.py | 17 ----------------- .../properties/test_allowed_pattern.py | 2 +- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/cfnlint/rules/resources/properties/AllowedPattern.py b/src/cfnlint/rules/resources/properties/AllowedPattern.py index 20fd8e60ec..0684b6a3ff 100644 --- 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 @@ def initialize(self, cfn): 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 @@ def check(self, cfn, properties, value_specs, property_specs, path): 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 ) diff --git a/test/rules/resources/properties/test_allowed_pattern.py b/test/rules/resources/properties/test_allowed_pattern.py index f655f8578c..dc3b6729af 100644 --- a/test/rules/resources/properties/test_allowed_pattern.py +++ b/test/rules/resources/properties/test_allowed_pattern.py @@ -44,7 +44,7 @@ def test_file_positive(self): def test_file_negative_sg_description(self): """Test failure""" - self.helper_file_negative('test/fixtures/templates/bad/properties_sg_description.yaml', 3) + self.helper_file_negative('test/fixtures/templates/bad/properties_sg_description.yaml', 1) def test_file_negative_sg_ingress(self): """Test failure"""