Skip to content

fix(query): fix fp for api_gateway_method_does_not_contains_an_api_key#7557

Merged
cx-artur-ribeiro merged 6 commits into
Checkmarx:masterfrom
cx-andre-pereira:AST-98286--FP_API_Gateway_Method_Does_Not_Contains_An_API_Key--terraform/aws
Jul 16, 2025
Merged

fix(query): fix fp for api_gateway_method_does_not_contains_an_api_key#7557
cx-artur-ribeiro merged 6 commits into
Checkmarx:masterfrom
cx-andre-pereira:AST-98286--FP_API_Gateway_Method_Does_Not_Contains_An_API_Key--terraform/aws

Conversation

@cx-andre-pereira

@cx-andre-pereira cx-andre-pereira commented Jul 16, 2025

Copy link
Copy Markdown
Contributor

Reason for Proposed Changes

  • The current implementation of the query flags every declaration of an AWS API Gateway method (in Terraform) if it either omits the api_key_required field or sets it to a value other than true.
  • However, the HTTP method "OPTIONS",commonly used for Cross-Origin Resource Sharing (CORS) preflight requests, cannot , let alone require having this field set to true.
  • As a result, the current logic incorrectly flags valid "OPTIONS" methods as False Positives.

Proposed Changes

  • To prevent these FPs, the query has been updated to include a conditional check: if the http_method is "OPTIONS", the rule will no longer raise a flag, regardless of the api_key_required value.
  • This change ensures that CORS preflight configurations are not mistakenly flagged.

Note: it was considered an extra check to ensure the field is actually set to false if the HTTP method is "OPTIONS", but due to not representing a security flaw / representing an idea that directly opposes the objective of this query (i.e. guaranteeing a field is set to false when the whole purpose of the query is assuring it is set to true).

originalPR

I submit this contribution under the Apache-2.0 license.

@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner July 16, 2025 10:57
@github-actions github-actions Bot added community Community contribution query New query feature terraform Terraform query aws PR related with AWS Cloud labels Jul 16, 2025

@cx-eduardo-semanas cx-eduardo-semanas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@cx-artur-ribeiro cx-artur-ribeiro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@cx-artur-ribeiro cx-artur-ribeiro merged commit 5966575 into Checkmarx:master Jul 16, 2025
35 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws PR related with AWS Cloud community Community contribution query New query feature terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants