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

Fix a bug parsing files with ! operator #389

Closed
wants to merge 1 commit into from

Conversation

Pr0methean
Copy link

@Pr0methean Pr0methean commented Oct 27, 2023

I have a Cfn template that uses ! as a type specifier before strings that contain newlines. For example:

            /etc/cfn/cfn-hup.conf:
              content:
                Fn::Join:
                - ''
                - - ! '[main]

'
                  - stack=
                  - Ref: AWS::StackId
                  - ! '

'
                  - region=
                  - Ref: AWS::Region
                  - ! '

'
              group: root
              mode: '000444'
              owner: root

That leads to errors like these:

Error: Resources.ArtifactEncryptionKey.Properties.KeyPolicy.Statement[0].Principal.AWS.Fn::Join[1][0]: unknown variant `!`, expected one of `Base64`, `Cidr`, `FindInMap`, `GetAtt`, `GetAZs`, `If`, `ImportValue`, `Join`, `Select`, `Split`, `Sub`, `Ref` at line 205 column 19

This PR fixes those errors by changing the return type of IntrinsicFunction::from_enum so that it can wrap the next token instead of an IntrinsicFunction, and adding a match case for "!" that does so.

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

@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Merging #389 (2af15de) into main (8f9e75b) will decrease coverage by 0.0%.
The diff coverage is 42.9%.

Components Coverage Δ
Parser 77.1% <42.9%> (-0.4%) ⬇️
Intermediate Representation 82.1% <ø> (ø)
Synthesizers 87.8% <ø> (ø)
Other 45.8% <ø> (ø)
@@           Coverage Diff           @@
##            main    #389     +/-   ##
=======================================
- Coverage   84.1%   84.0%   -0.0%     
=======================================
  Files         27      27             
  Lines       4752    4756      +4     
  Branches    4752    4756      +4     
=======================================
+ Hits        3995    3996      +1     
- Misses       559     562      +3     
  Partials     198     198             
Files Coverage Δ
src/parser/resource/mod.rs 78.7% <100.0%> (ø)
src/parser/intrinsics/mod.rs 70.7% <33.3%> (-1.5%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f9e75b...2af15de. Read the comment docs.

Copy link
Collaborator

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution. Please add a test case that covers this change and make sure the code is passing the linter.

auto-merge was automatically disabled March 11, 2024 18:40

Pull request was closed

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.

2 participants