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

E3031 'string' does not match '^.*$' #3771

Closed
dr3 opened this issue Oct 20, 2024 · 1 comment · Fixed by #3772
Closed

E3031 'string' does not match '^.*$' #3771

dr3 opened this issue Oct 20, 2024 · 1 comment · Fixed by #3772

Comments

@dr3
Copy link

dr3 commented Oct 20, 2024

CloudFormation Lint Version

1.17.2

What operating system are you using?

Mac

Describe the bug

(Introduced In 1.17.0, works in 1.16.1)

String does not match '^.*$' (which is regex for "anything")

E3031 '#if($context.identity.claims.account_type == "ADMIN") \n  #return\n#else\n  $util.error("MUST BE ADMIN")\n#end\n' does not match '^.*$'
testing2.yaml:29:7

Expected behavior

It passes

Reproduction template

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Example

Resources:
  GraphQLApi:
    Type: AWS::AppSync::GraphQLApi
    Properties:
      Name: !Ref APIName
      AuthenticationType: OPENID_CONNECT
      OpenIDConnectConfig:
        Issuer: https://securetoken.google.com/foobar

  NoneDataSource:
    Type: AWS::AppSync::DataSource
    Properties:
      ApiId: !GetAtt GraphQLApi.ApiId
      Name: "NoneSource"
      Type: NONE

  AdminOnlyAuthFunction:
    Type: AWS::AppSync::FunctionConfiguration
    Properties:
      ApiId: !GetAtt GraphQLApi.ApiId
      Name: auth_admin_logic
      Description: Must be admin user
      DataSourceName: !GetAtt NoneDataSource.Name
      FunctionVersion: "2018-05-29"
      RequestMappingTemplate: >
        #if($context.identity.claims.account_type == "ADMIN") 
          #return
        #else
          $util.error("MUST BE ADMIN")
        #end
      ResponseMappingTemplate: >
        #return

Parameters:
  APIName:
    Type: String
@kddejong
Copy link
Contributor

Looks like the re.search doesn't do multiline pattern matching so the newlines are throwing it off. Instead of spending resources validating that its a string it just makes sense to remove it. This field is related to some boto automation in which we are taking patterns from botocore. We had an exception for "." so added one for "^.$" as well.

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 a pull request may close this issue.

2 participants