Repository: bridgecrewio/checkov

Issue:
AWS API Gateway data_trace_enabled
**Describe the issue**
The `data_trace_enabled` property of [aws_api_gateway_method_settings](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method_settings) corresponds to the "Log full requests/responses data" field in the AWS console.  This field is documented in [the AWS documentation ](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html) as 
> This can be useful to troubleshoot APIs, but can result in logging sensitive data. We recommend that you don't enable Log full requests/responses data for production APIs.

As such, I think it would make sense to have a check that enforces this field to be set to false

**Examples**
```
resource "aws_api_gateway_method_settings" "path_specific" {
  rest_api_id = aws_api_gateway_rest_api.example.id
  stage_name  = aws_api_gateway_stage.example.stage_name
  method_path = "path1/GET"

  settings {
    data_trace_enabled = true
  }
}
```
Should be flagged by a new check

**Version (please complete the following information):**
 - Checkov Version 2.1.270



Discussion:
hey @NickG123 thanks for reaching out. As far as I understand this flag is set to `false` by default, right? Then the check should look for resources, which enables it, right?

Are you interested in contributing this new check?
Hi @gruebel, yes that matches my understanding as well.  If you think it's an appropriate check I'd love to give it a stab 😄  I'll try to find some time to have a look.

To help bootstrap my understanding of the code base, do you have an example of a similar check I could use as a starting point?
Thanks.
yeah sure, here is a PR, which has all the important things you also need to do #2999

Resolving patch:
diff --git a/checkov/terraform/checks/resource/aws/APIGatewayMethodSettingsDataTrace.py b/checkov/terraform/checks/resource/aws/APIGatewayMethodSettingsDataTrace.py
new file mode 100644
--- /dev/null
+++ b/checkov/terraform/checks/resource/aws/APIGatewayMethodSettingsDataTrace.py
@@ -0,0 +1,20 @@
+from checkov.terraform.checks.resource.base_resource_negative_value_check import BaseResourceNegativeValueCheck
+from checkov.common.models.enums import CheckCategories
+
+
+class APIGatewayMethodSettingsDataTrace(BaseResourceNegativeValueCheck):
+    def __init__(self):
+        name = "Ensure Data Trace is not enabled in API Gateway Method Settings"
+        id = "CKV_AWS_276"
+        supported_resources = ('aws_api_gateway_method_settings',)
+        categories = (CheckCategories.LOGGING,)
+        super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)
+
+    def get_inspected_key(self):
+        return "settings/[0]/data_trace_enabled"
+
+    def get_forbidden_values(self):
+        return [True]
+
+
+check = APIGatewayMethodSettingsDataTrace()


Test patch:
diff --git a/tests/terraform/checks/resource/aws/example_APIGatewayMethodSettingsDataTrace/main.tf b/tests/terraform/checks/resource/aws/example_APIGatewayMethodSettingsDataTrace/main.tf
new file mode 100644
--- /dev/null
+++ b/tests/terraform/checks/resource/aws/example_APIGatewayMethodSettingsDataTrace/main.tf
@@ -0,0 +1,25 @@
+resource "aws_api_gateway_method_settings" "fail" {
+  rest_api_id = aws_api_gateway_rest_api.test.id
+  stage_name  = aws_api_gateway_stage.test.stage_name
+  method_path = "path1/GET"
+
+  settings {
+    data_trace_enabled = true
+  }
+}
+
+resource "aws_api_gateway_method_settings" "pass_explicit" {
+  rest_api_id = aws_api_gateway_rest_api.test.id
+  stage_name  = aws_api_gateway_stage.test.stage_name
+  method_path = "path1/GET"
+
+  settings {
+    data_trace_enabled = false
+  }
+}
+
+resource "aws_api_gateway_method_settings" "pass_implicit" {
+  rest_api_id = aws_api_gateway_rest_api.test.id
+  stage_name  = aws_api_gateway_stage.test.stage_name
+  method_path = "path1/GET"
+}
\ No newline at end of file
diff --git a/tests/terraform/checks/resource/aws/test_APIGatewayMethodSettingsDataTrace.py b/tests/terraform/checks/resource/aws/test_APIGatewayMethodSettingsDataTrace.py
new file mode 100644
--- /dev/null
+++ b/tests/terraform/checks/resource/aws/test_APIGatewayMethodSettingsDataTrace.py
@@ -0,0 +1,40 @@
+import os
+import unittest
+
+from checkov.runner_filter import RunnerFilter
+from checkov.terraform.runner import Runner
+from checkov.terraform.checks.resource.aws.APIGatewayMethodSettingsDataTrace import check
+
+
+class TestAPIGatewayMethodSettingsDataTrace(unittest.TestCase):
+
+    def test(self):
+        runner = Runner()
+        current_dir = os.path.dirname(os.path.realpath(__file__))
+
+        test_files_dir = os.path.join(current_dir, "example_APIGatewayMethodSettingsDataTrace")
+        report = runner.run(root_folder=test_files_dir, runner_filter=RunnerFilter(checks=[check.id]))
+        summary = report.get_summary()
+
+        passing_resources = {
+            "aws_api_gateway_method_settings.pass_explicit",
+            "aws_api_gateway_method_settings.pass_implicit",
+        }
+        failing_resources = {
+            "aws_api_gateway_method_settings.fail",
+        }
+
+        passed_check_resources = set([c.resource for c in report.passed_checks])
+        failed_check_resources = set([c.resource for c in report.failed_checks])
+
+        self.assertEqual(summary["passed"], 2)
+        self.assertEqual(summary["failed"], 1)
+        self.assertEqual(summary["skipped"], 0)
+        self.assertEqual(summary["parsing_errors"], 0)
+
+        self.assertEqual(passing_resources, passed_check_resources)
+        self.assertEqual(failing_resources, failed_check_resources)
+
+
+if __name__ == '__main__':
+    unittest.main()