-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(terraform): Over permissive Lambda Cors check (Terraform & Cloudformation) #7113
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
feat(terraform): Over permissive Lambda Cors check (Terraform & Cloudformation) #7113
Conversation
| - "AWS::Lambda::Url.ValidLambdaUrlOnlyMethodsStar" | ||
| fail: | ||
| - "AWS::Lambda::Url.InvalidLambdaUrl" | ||
| evaluated_keys: |
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.
what is the purpose of the evaluated keys here?
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.
I didn't find any documentation about this field but I assume it asserts that the evaluated keys are the same keys that has an attribute field in the check yaml itself.
So if for example I ensured that the attribute AllowOrigins doesn't contain * it should appear in the tests evaluated_keys (otherwise the tests fail)
tsmithv11
left a comment
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.
Looks good! The resource type we want to filter on is the function
checkov/cloudformation/checks/graph_checks/LambdaOpenCorsPolicy.yaml
Outdated
Show resolved
Hide resolved
checkov/terraform/checks/graph_checks/aws/LambdaOpenCorsPolicy.yaml
Outdated
Show resolved
Hide resolved
6b8a796 to
17977cd
Compare
…ambda_function_url
checkov/cloudformation/checks/graph_checks/LambdaOpenCorsPolicy.yaml
Outdated
Show resolved
Hide resolved
becc4d4 to
bd43493
Compare
bd43493 to
235a21a
Compare
| check_list.sort(reverse=True, key=lambda s: int(s.split('_')[-1])) | ||
|
|
||
| for i in range(1, len(aws_checks) + 3): | ||
| for i in range(1, len(aws_checks) + 2): |
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.
why is this needed?
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.
He added the same check to 2 frameworks, so they need the same ID
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Description
This PR adds graph checks for over permissive AWS Lambda CORS (Cross-Origin Resource Sharing) both for Terraform and Cloudformation.
This check aligns to the run policy ID
7bf83882-02ad-4f79-803c-ed4588e166cdNew/Edited policies (Delete if not relevant)
Description
AWS Lambda URL resource (
aws_lambda_function_url/AWS::Lambda::Url) that is connected to a lambda resource (aws_lambda_function_url/AWS::Lambda::Function) can't have bothallow_origins: *andallow_methods: *Fix
Define at least one
allow_originsorallow_methodsas non*valueChecklist: