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(Config Schema): validate resourcePolicy is array #8051

Merged

Conversation

glb
Copy link
Contributor

@glb glb commented Aug 5, 2020

In the AWS provider, the resourcePolicy must be an array. If you paste a resource policy from the console, your stack will fail to create.

Closes: #7795
Addresses: #8018

@glb
Copy link
Contributor Author

glb commented Aug 5, 2020

I don't love that the test takes so long to run but I don't know a faster way to do it; based on tests in #7335. If there is a better way to test this I'd be happy to make the change.

@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2020

Codecov Report

Merging #8051 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8051      +/-   ##
==========================================
+ Coverage   88.36%   88.37%   +0.01%     
==========================================
  Files         248      248              
  Lines        9446     9446              
==========================================
+ Hits         8347     8348       +1     
+ Misses       1099     1098       -1     
Impacted Files Coverage Δ
lib/plugins/aws/provider/awsProvider.js 92.77% <ø> (ø)
lib/classes/ConfigSchemaHandler/index.js 93.02% <0.00%> (+1.16%) ⬆️

Continue to review full report at Codecov.

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

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

@glb Great thanks for that!

Still please see my comment about testing, I think value of such tests is neglible, while maintanance cost becomes significant

lib/plugins/aws/provider/awsProvider.test.js Outdated Show resolved Hide resolved
lib/plugins/aws/provider/awsProvider.js Outdated Show resolved Hide resolved
In the AWS provider, the `resourcePolicy` must be an array. If you paste
a resource policy from the console, your stack will fail to create.
@glb glb force-pushed the 7795-check-apigateway-resource-policy-structure branch from 954a060 to f8c1f28 Compare August 11, 2020 19:45
@glb
Copy link
Contributor Author

glb commented Aug 11, 2020

Thanks @medikoo ! I have updated, rebased, and done manual testing with invalid and valid values for resourcePolicy:

serverless.yml
service: test

provider:
  name: aws
  resourcePolicy:
    - test

Output:

Serverless: Configuration error at 'provider.resourcePolicy[0]': should be object
serverless.yml
service: test

provider:
  name: aws
  resourcePolicy: {}

Output:

Serverless: Configuration error at 'provider.resourcePolicy': should be array
serverless.yml
service: test

provider:
  name: aws
  resourcePolicy: 
  - Effect: Allow
    Principal: "*"
    Action: "*"
    Resource: "*"

Output: no error (though arguably that's a terrible resource policy. 😆 )

@glb glb requested a review from medikoo August 17, 2020 13:59
Copy link
Contributor

@medikoo medikoo 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 @glb !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add checks for API Gateway resource policy structure
3 participants