Skip to content

Commit

Permalink
Remove sub from Allowed Values regex rule
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Mar 14, 2019
1 parent c4cba40 commit 3d3a328
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
17 changes: 0 additions & 17 deletions src/cfnlint/rules/resources/properties/AllowedPattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 = []
Expand Down Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion test/rules/resources/properties/test_allowed_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 3d3a328

Please sign in to comment.