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

Ignore Mapping key issues when using Fn::Transform #2017

Merged
merged 1 commit into from
May 26, 2021

Conversation

kddejong
Copy link
Contributor

@kddejong kddejong commented May 21, 2021

Issue #, if available:
fix #2016
Description of changes:

  • Ignore Fn::Transform when evaluating the mapping key in a mapping rule E7003

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@@ -35,7 +35,7 @@ def check_key(self, key, path):
if not isinstance(key, six.string_types):
message = 'Mapping key ({0}) has to be a string.'
matches.append(RuleMatch(path[:], message.format(key)))
elif not re.match('^[a-zA-Z0-9.-]{1,255}$', key):
elif not re.match('^[a-zA-Z0-9.-]{1,255}$', key) and key != 'Fn::Transform':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool with this, but had a wilder general thought on #476

What if every violation on Transform lines were ignored, regardless of individual rule logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more filtering this out because we didn't flag this as a failure, then we started flagging it as a failure so wanted to bring it back to where it was.

Interesting. It could be possible. We would want to evaluate the start and end mark of the finding is within the transform so if someone is doing a one line json document we don't filter out everything.

As we continue to evaluate the need of credentials we may be able to test resolving the Transform as well. Your option would be a great way to not have an issue if we can't resolve credentials. We may be able to implement your idea fairly easily. I may test it out today actually :)

@PatMyron PatMyron changed the title Ignore key issues when using Fn::Transform Ignore Mapping key issues when using Fn::Transform May 21, 2021
@kddejong kddejong merged commit 14d5d41 into aws-cloudformation:master May 26, 2021
@kddejong kddejong deleted the fix/issue/2008 branch May 26, 2021 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

E7003 Errors when using Fn::Transform inside a Mapping
2 participants