Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with directives failing when they aren't a dict #1877

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/cfnlint/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,21 @@ def get_valid_getatts(self):

def get_directives(self):
results = {}
for resource_name, resource_values in self.template.get('Resources', {}).items():
if isinstance(resource_values, dict):
ignore_rule_ids = resource_values.get('Metadata', {}).get(
'cfn-lint', {}).get('config', {}).get('ignore_checks', [])
for ignore_rule_id in ignore_rule_ids:
if ignore_rule_id not in results:
results[ignore_rule_id] = []
value_location = self._loc(resource_values)
name_location = self._loc(resource_name)
results[ignore_rule_id].append({
'start': (name_location[0] + 1, name_location[1] + 1),
'end': (value_location[2] + 1, value_location[3] + 1),
})
resources = self.get_resources()
if resources:
for resource_name, resource_values in resources.items():
if isinstance(resource_values, dict):
ignore_rule_ids = resource_values.get('Metadata', {}).get(
'cfn-lint', {}).get('config', {}).get('ignore_checks', [])
for ignore_rule_id in ignore_rule_ids:
if ignore_rule_id not in results:
results[ignore_rule_id] = []
value_location = self._loc(resource_values)
name_location = self._loc(resource_name)
results[ignore_rule_id].append({
'start': (name_location[0] + 1, name_location[1] + 1),
'end': (value_location[2] + 1, value_location[3] + 1),
})
return results

def _get_sub_resource_properties(self, keys, properties, path):
Expand Down