prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Crash mentioned in issue #2370 still exist for AWS Batch Job with Fargate  
  **Describe the issue**
  Checkov is failing for Fargate AWS Batch Job with error - `[ERROR]  Failed to run check: Batch job does not define a privileged container for configuration`. I am using terraform `resource "aws_batch_job_definition"` and as per AWS document, Fargate Batch Jobs do not have Privileged parameters. [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-jobdefinition-containerproperties.html#cfn-batch-jobdefinition-containerproperties-privileged](url)
  
  **Examples**
  https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/batch_job_definition#fargate-platform-capability
  
  **Exception Trace**
  ```
  2022-08-19 15:22:00,858 [MainThread  ] [DEBUG]  Scanning file: /tf.json
  2022-08-19 15:22:00,858 [MainThread  ] [DEBUG]  Should run check CKV_AWS_210: True
  2022-08-19 15:22:00,858 [MainThread  ] [DEBUG]  Running check: Batch job does not define a privileged container on file /tf.json
  2022-08-19 15:22:00,860 [MainThread  ] [ERROR]  Failed to run check: Batch job does not define a privileged container for configuration: {'container_properties': ['{"command":["echo","test"],"fargatePlatformConfiguration":{"platformVersion":"LATEST"},"image":"busybox","resourceRequirements":[{"type":"VCPU","value":"0.25"},{"type":"MEMORY","value":"512"}]}'], 'name': ['tf_test_batch_job_definition'], 'parameters': [None], 'platform_capabilities': [['FARGATE']], 'propagate_tags': [False], 'retry_strategy': [[]], 'tags': [None], 'timeout': [[]], 'type': ['container'], '__startline__': [14], '__endline__': [26], 'start_line': [13], 'end_line': [25], '__address__': 'aws_batch_job_definition.test', '__change_actions__': ['create']} at file: /tf.json
  Process ForkProcess-4:
  Traceback (most recent call last):
    File "/usr/local/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
      self.run()
    File "/usr/local/lib/python3.8/multiprocessing/process.py", line 108, in run
      self._target(*self._args, **self._kwargs)
    File "/usr/local/lib/python3.8/site-packages/checkov/common/parallelizer/parallel_runner.py", line 37, in func_wrapper
      result = original_func(item)
  2022-08-19 15:22:00,862 [MainThread  ] [DEBUG]  Environment variable BITBUCKET_REPO_FULL_NAME was not set. Cannot fetch branch restrictions.
    File "/usr/local/lib/python3.8/site-packages/checkov/common/runners/runner_registry.py", line 83, in _parallel_run
      return runner.run(
    File "/usr/local/lib/python3.8/site-packages/checkov/terraform/plan_runner.py", line 74, in run
      self.check_tf_definition(report, root_folder, runner_filter)
    File "/usr/local/lib/python3.8/site-packages/checkov/terraform/plan_runner.py", line 92, in check_tf_definition
      self.run_block(definition[block_type], None, full_file_path, root_folder, report, scanned_file,
    File "/usr/local/lib/python3.8/site-packages/checkov/terraform/plan_runner.py", line 112, in run_block
      results = registry.scan(scanned_file, entity, [], runner_filter, report_type=CheckType.TERRAFORM_PLAN)
    File "/usr/local/lib/python3.8/site-packages/checkov/common/checks/base_check_registry.py", line 126, in scan
      result = self.run_check(check, entity_configuration, entity_name, entity_type, scanned_file, skip_info)
    File "/usr/local/lib/python3.8/site-packages/checkov/common/checks/base_check_registry.py", line 140, in run_check
      result = check.run(
    File "/usr/local/lib/python3.8/site-packages/checkov/common/checks/base_check.py", line 70, in run
      check_result["result"] = self.scan_entity_conf(entity_configuration, entity_type)
    File "/usr/local/lib/python3.8/site-packages/checkov/terraform/checks/resource/base_resource_check.py", line 43, in scan_entity_conf
      return self.scan_resource_conf(conf)
    File "/usr/local/lib/python3.8/site-packages/checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py", line 26, in scan_resource_conf
      if container.get("privileged"):
    File "/usr/local/lib/python3.8/site-packages/checkov/common/parsers/node.py", line 34, in __getattr__
      raise TemplateAttributeError(f'{name} is invalid')
  checkov.common.parsers.node.TemplateAttributeError: get is invalid
  ```
  
  
  **Desktop (please complete the following information):**
   - OS: [MacOS, Linux]
   - Checkov Version [2.1.137]
  
  **Additional context**
  The issue was also mentioned in #2370 and it was Fixed by https://github.com/bridgecrewio/checkov/pull/2372 but I don't see that the Fargate type was considered in the test.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py`
  Content:
  ```
  1 import json
  2 import logging
  3 
  4 from checkov.common.models.enums import CheckResult, CheckCategories
  5 from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck
  6 
  7 
  8 class BatchJobIsNotPrivileged(BaseResourceCheck):
  9     def __init__(self):
  10         name = "Batch job does not define a privileged container"
  11         id = "CKV_AWS_210"
  12         supported_resources = ['aws_batch_job_definition']
  13         categories = [CheckCategories.GENERAL_SECURITY]
  14         super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)
  15 
  16     def scan_resource_conf(self, conf):
  17         if conf.get("container_properties"):
  18             if type(conf.get("container_properties")[0]) is str:
  19                 try:
  20                     container = json.loads(conf.get("container_properties")[0])
  21                 except json.JSONDecodeError as e:
  22                     logging.error(e)
  23                     return CheckResult.UNKNOWN
  24             else:
  25                 container = conf.get("container_properties")[0]
  26             if container.get("privileged"):
  27                 return CheckResult.FAILED
  28             return CheckResult.PASSED
  29         return CheckResult.UNKNOWN
  30 
  31 
  32 check = BatchJobIsNotPrivileged()
  33
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py b/checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py
  --- a/checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py
  +++ b/checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py
  @@ -1,28 +1,34 @@
  +from __future__ import annotations
  +
   import json
   import logging
  +from typing import Any
   
   from checkov.common.models.enums import CheckResult, CheckCategories
   from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck
   
   
   class BatchJobIsNotPrivileged(BaseResourceCheck):
  -    def __init__(self):
  +    def __init__(self) -> None:
           name = "Batch job does not define a privileged container"
           id = "CKV_AWS_210"
  -        supported_resources = ['aws_batch_job_definition']
  -        categories = [CheckCategories.GENERAL_SECURITY]
  +        supported_resources = ("aws_batch_job_definition",)
  +        categories = (CheckCategories.GENERAL_SECURITY,)
           super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)
   
  -    def scan_resource_conf(self, conf):
  -        if conf.get("container_properties"):
  -            if type(conf.get("container_properties")[0]) is str:
  +    def scan_resource_conf(self, conf: dict[str, list[Any]]) -> CheckResult:
  +        container_properties = conf.get("container_properties")
  +        if container_properties:
  +            if isinstance(container_properties[0], str):
                   try:
  -                    container = json.loads(conf.get("container_properties")[0])
  +                    container = json.loads(container_properties[0])
                   except json.JSONDecodeError as e:
                       logging.error(e)
                       return CheckResult.UNKNOWN
               else:
  -                container = conf.get("container_properties")[0]
  +                container = container_properties[0]
  +            if not isinstance(container, dict):
  +                return CheckResult.UNKNOWN
               if container.get("privileged"):
                   return CheckResult.FAILED
               return CheckResult.PASSED
  
verification_info: {"golden_diff": "diff --git a/checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py b/checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py\n--- a/checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py\n+++ b/checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py\n@@ -1,28 +1,34 @@\n+from __future__ import annotations\n+\n import json\n import logging\n+from typing import Any\n \n from checkov.common.models.enums import CheckResult, CheckCategories\n from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck\n \n \n class BatchJobIsNotPrivileged(BaseResourceCheck):\n-    def __init__(self):\n+    def __init__(self) -> None:\n         name = \"Batch job does not define a privileged container\"\n         id = \"CKV_AWS_210\"\n-        supported_resources = ['aws_batch_job_definition']\n-        categories = [CheckCategories.GENERAL_SECURITY]\n+        supported_resources = (\"aws_batch_job_definition\",)\n+        categories = (CheckCategories.GENERAL_SECURITY,)\n         super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)\n \n-    def scan_resource_conf(self, conf):\n-        if conf.get(\"container_properties\"):\n-            if type(conf.get(\"container_properties\")[0]) is str:\n+    def scan_resource_conf(self, conf: dict[str, list[Any]]) -> CheckResult:\n+        container_properties = conf.get(\"container_properties\")\n+        if container_properties:\n+            if isinstance(container_properties[0], str):\n                 try:\n-                    container = json.loads(conf.get(\"container_properties\")[0])\n+                    container = json.loads(container_properties[0])\n                 except json.JSONDecodeError as e:\n                     logging.error(e)\n                     return CheckResult.UNKNOWN\n             else:\n-                container = conf.get(\"container_properties\")[0]\n+                container = container_properties[0]\n+            if not isinstance(container, dict):\n+                return CheckResult.UNKNOWN\n             if container.get(\"privileged\"):\n                 return CheckResult.FAILED\n             return CheckResult.PASSED\n", "issue": "Crash mentioned in issue #2370 still exist for AWS Batch Job with Fargate  \n**Describe the issue**\r\nCheckov is failing for Fargate AWS Batch Job with error - `[ERROR]  Failed to run check: Batch job does not define a privileged container for configuration`. I am using terraform `resource \"aws_batch_job_definition\"` and as per AWS document, Fargate Batch Jobs do not have Privileged parameters. [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-jobdefinition-containerproperties.html#cfn-batch-jobdefinition-containerproperties-privileged](url)\r\n\r\n**Examples**\r\nhttps://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/batch_job_definition#fargate-platform-capability\r\n\r\n**Exception Trace**\r\n```\r\n2022-08-19 15:22:00,858 [MainThread  ] [DEBUG]  Scanning file: /tf.json\r\n2022-08-19 15:22:00,858 [MainThread  ] [DEBUG]  Should run check CKV_AWS_210: True\r\n2022-08-19 15:22:00,858 [MainThread  ] [DEBUG]  Running check: Batch job does not define a privileged container on file /tf.json\r\n2022-08-19 15:22:00,860 [MainThread  ] [ERROR]  Failed to run check: Batch job does not define a privileged container for configuration: {'container_properties': ['{\"command\":[\"echo\",\"test\"],\"fargatePlatformConfiguration\":{\"platformVersion\":\"LATEST\"},\"image\":\"busybox\",\"resourceRequirements\":[{\"type\":\"VCPU\",\"value\":\"0.25\"},{\"type\":\"MEMORY\",\"value\":\"512\"}]}'], 'name': ['tf_test_batch_job_definition'], 'parameters': [None], 'platform_capabilities': [['FARGATE']], 'propagate_tags': [False], 'retry_strategy': [[]], 'tags': [None], 'timeout': [[]], 'type': ['container'], '__startline__': [14], '__endline__': [26], 'start_line': [13], 'end_line': [25], '__address__': 'aws_batch_job_definition.test', '__change_actions__': ['create']} at file: /tf.json\r\nProcess ForkProcess-4:\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.8/multiprocessing/process.py\", line 315, in _bootstrap\r\n    self.run()\r\n  File \"/usr/local/lib/python3.8/multiprocessing/process.py\", line 108, in run\r\n    self._target(*self._args, **self._kwargs)\r\n  File \"/usr/local/lib/python3.8/site-packages/checkov/common/parallelizer/parallel_runner.py\", line 37, in func_wrapper\r\n    result = original_func(item)\r\n2022-08-19 15:22:00,862 [MainThread  ] [DEBUG]  Environment variable BITBUCKET_REPO_FULL_NAME was not set. Cannot fetch branch restrictions.\r\n  File \"/usr/local/lib/python3.8/site-packages/checkov/common/runners/runner_registry.py\", line 83, in _parallel_run\r\n    return runner.run(\r\n  File \"/usr/local/lib/python3.8/site-packages/checkov/terraform/plan_runner.py\", line 74, in run\r\n    self.check_tf_definition(report, root_folder, runner_filter)\r\n  File \"/usr/local/lib/python3.8/site-packages/checkov/terraform/plan_runner.py\", line 92, in check_tf_definition\r\n    self.run_block(definition[block_type], None, full_file_path, root_folder, report, scanned_file,\r\n  File \"/usr/local/lib/python3.8/site-packages/checkov/terraform/plan_runner.py\", line 112, in run_block\r\n    results = registry.scan(scanned_file, entity, [], runner_filter, report_type=CheckType.TERRAFORM_PLAN)\r\n  File \"/usr/local/lib/python3.8/site-packages/checkov/common/checks/base_check_registry.py\", line 126, in scan\r\n    result = self.run_check(check, entity_configuration, entity_name, entity_type, scanned_file, skip_info)\r\n  File \"/usr/local/lib/python3.8/site-packages/checkov/common/checks/base_check_registry.py\", line 140, in run_check\r\n    result = check.run(\r\n  File \"/usr/local/lib/python3.8/site-packages/checkov/common/checks/base_check.py\", line 70, in run\r\n    check_result[\"result\"] = self.scan_entity_conf(entity_configuration, entity_type)\r\n  File \"/usr/local/lib/python3.8/site-packages/checkov/terraform/checks/resource/base_resource_check.py\", line 43, in scan_entity_conf\r\n    return self.scan_resource_conf(conf)\r\n  File \"/usr/local/lib/python3.8/site-packages/checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py\", line 26, in scan_resource_conf\r\n    if container.get(\"privileged\"):\r\n  File \"/usr/local/lib/python3.8/site-packages/checkov/common/parsers/node.py\", line 34, in __getattr__\r\n    raise TemplateAttributeError(f'{name} is invalid')\r\ncheckov.common.parsers.node.TemplateAttributeError: get is invalid\r\n```\r\n\r\n\r\n**Desktop (please complete the following information):**\r\n - OS: [MacOS, Linux]\r\n - Checkov Version [2.1.137]\r\n\r\n**Additional context**\r\nThe issue was also mentioned in #2370 and it was Fixed by https://github.com/bridgecrewio/checkov/pull/2372 but I don't see that the Fargate type was considered in the test.\r\n\n", "before_files": [{"content": "import json\nimport logging\n\nfrom checkov.common.models.enums import CheckResult, CheckCategories\nfrom checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck\n\n\nclass BatchJobIsNotPrivileged(BaseResourceCheck):\n    def __init__(self):\n        name = \"Batch job does not define a privileged container\"\n        id = \"CKV_AWS_210\"\n        supported_resources = ['aws_batch_job_definition']\n        categories = [CheckCategories.GENERAL_SECURITY]\n        super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)\n\n    def scan_resource_conf(self, conf):\n        if conf.get(\"container_properties\"):\n            if type(conf.get(\"container_properties\")[0]) is str:\n                try:\n                    container = json.loads(conf.get(\"container_properties\")[0])\n                except json.JSONDecodeError as e:\n                    logging.error(e)\n                    return CheckResult.UNKNOWN\n            else:\n                container = conf.get(\"container_properties\")[0]\n            if container.get(\"privileged\"):\n                return CheckResult.FAILED\n            return CheckResult.PASSED\n        return CheckResult.UNKNOWN\n\n\ncheck = BatchJobIsNotPrivileged()\n", "path": "checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport json\nimport logging\nfrom typing import Any\n\nfrom checkov.common.models.enums import CheckResult, CheckCategories\nfrom checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck\n\n\nclass BatchJobIsNotPrivileged(BaseResourceCheck):\n    def __init__(self) -> None:\n        name = \"Batch job does not define a privileged container\"\n        id = \"CKV_AWS_210\"\n        supported_resources = (\"aws_batch_job_definition\",)\n        categories = (CheckCategories.GENERAL_SECURITY,)\n        super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)\n\n    def scan_resource_conf(self, conf: dict[str, list[Any]]) -> CheckResult:\n        container_properties = conf.get(\"container_properties\")\n        if container_properties:\n            if isinstance(container_properties[0], str):\n                try:\n                    container = json.loads(container_properties[0])\n                except json.JSONDecodeError as e:\n                    logging.error(e)\n                    return CheckResult.UNKNOWN\n            else:\n                container = container_properties[0]\n            if not isinstance(container, dict):\n                return CheckResult.UNKNOWN\n            if container.get(\"privileged\"):\n                return CheckResult.FAILED\n            return CheckResult.PASSED\n        return CheckResult.UNKNOWN\n\n\ncheck = BatchJobIsNotPrivileged()\n", "path": "checkov/terraform/checks/resource/aws/BatchJobIsNotPrivileged.py"}]}