-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
chore(cloudfront): add validations on corsBehavior of ResponseHeadersPolicy #32206
base: main
Are you sure you want to change the base?
Conversation
throw new Error('accessControlAllowHeaders needs to have at least one item'); | ||
} else if (headers.some((header) => !Token.isUnresolved(header) && containsMultipleStars(header))) { | ||
// Invalid request provided: AWS::CloudFront::ResponseHeadersPolicy | ||
throw new Error("accessControlAllowHeaders contains multiple '*' chars; only 1 is allowed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #32206 +/- ##
=======================================
Coverage 77.17% 77.17%
=======================================
Files 105 105
Lines 7169 7169
Branches 1315 1315
=======================================
Hits 5533 5533
Misses 1455 1455
Partials 181 181
Flags with carried forward coverage won't be shown. Click here to find out more.
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Issue # (if applicable)
N/A
Reason for this change
Currently, the values in
corsBehavior
ofResponseHeadersPolicy
have no validations.This PR adds validations for user's convenience.
Description of changes
Added following validations for
corsBehavior
:accessControlAllowHeaders
: should be >= 1 items, should not contain multiple*
chars, should not contain illegal charsaccessControlAllowMethods
: should be['ALL']
or set of allowed method namesaccessControlAllowOrigins
: should be >= 1 itemsaccessControlExposeHeaders
: should not contain illegal charsDescription of how you validated changes
Added unit tests on each edge case.
For details of the illegal characters above, see RFC 9110 section 5.6.2.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license