Add W1053: Warn on dynamic references with spaces#4412
Merged
Conversation
Dynamic references like '{{ resolve:ssm:Param }}' with spaces between
'{{' and 'resolve' are silently treated as literal strings by
CloudFormation instead of being resolved. This adds a warning rule
to detect this common mistake.
Fixes aws-cloudformation#4171
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4412 +/- ##
==========================================
- Coverage 93.54% 93.45% -0.09%
==========================================
Files 418 424 +6
Lines 14145 14365 +220
Branches 2817 2866 +49
==========================================
+ Hits 13232 13425 +193
- Misses 567 582 +15
- Partials 346 358 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Dynamic references like
{{ resolve:ssm:Param }}with spaces between{{andresolveare silently treated as literal strings by CloudFormation instead of being resolved. This adds W1053, a warning rule to detect this common mistake.Testing
Confirmed against CloudFormation directly:
{{resolve:ssm:CfnLintTest4171}}→ resolves to the parameter value ✅{{ resolve:ssm:CfnLintTest4171 }}→ left as a literal string, not resolved ❌Changes
src/cfnlint/helpers.py— AddedREGEX_DYN_REF_SPACESregexsrc/cfnlint/jsonschema/_filter.py— Detect spaced dynamic references in the filtersrc/cfnlint/rules/jsonschema/JsonSchema.py— RegisterdynamicReferenceSpaceskeywordsrc/cfnlint/rules/functions/DynamicReferenceSpaces.py— New W1053 ruleFixes #4171