Repository: bridgecrewio/checkov

Issue:
[ERROR]  Failed to run check: Ensure Application Gateway WAF prevents message lookup in Log4j2.
**Describe the issue**
While performing checkov scan on our terraform dir, we are running into this error:

`2022-07-18 10:09:32,794 [MainThread  ] [ERROR]  Failed to run check: Ensure Application Gateway WAF prevents message lookup in Log4j2. See CVE-2021-44228 aka log4jshell for configuration: {'custom_rules': [[]], 'location': ['westeurope'], 'managed_rules': [{'exclusion': [[]], 'managed_rule_set': [{'rule_group_override': [[]], 'type': ['OWASP'], 'version': ['3.1'], '__startline__': [1], '__endline__': [1], 'start_line': [0], 'end_line': [0]}], '__startline__': [1], '__endline__': [1], 'start_line': [0], 'end_line': [0]}], 'name': ['waf-acc-weu-001'], 'policy_settings': [{'enabled': [True], 'file_upload_limit_in_mb': [100], 'max_request_body_size_in_kb': [128], 'mode': ['Prevention'], 'request_body_check': [True], '__startline__': [1], '__endline__': [1], 'start_line': [0], 'end_line': [0]}], 'resource_group_name': ['rg-acceptance-weu-001'], 'tags': [None], 'timeouts': [None], '__startline__': [1], '__endline__': [1], 'start_line': [0], 'end_line': [0], 'references_': ['data.azurerm_resource_group.resourcegroup.name', 'data.azurerm_resource_group.resourcegroup'], '__address__': 'azurerm_web_application_firewall_policy.agw_waf_policy_aks_acc'} at file: /tf/plan.json`

**Examples**
When looking into this page: https://docs.bridgecrew.io/docs/ensure-application-gateway-waf-prevents-message-lookup-in-log4j2, we saw a code example, but the thing is, we have exactly the same code,:

```
resource "azurerm_web_application_firewall_policy" "agw_waf_policy_aks_acc" {
  name                = "waf-acc-weu-001"
  resource_group_name = data.azurerm_resource_group.kbc_acc_resourcegroup.name
  location            = var.location

  policy_settings {
    enabled                     = true
    mode                        = "Prevention"
    request_body_check          = true
    # Set to 200 because ...
    file_upload_limit_in_mb     = 200
    # Set to 2000 because ...
    max_request_body_size_in_kb = 2000
  }

  managed_rules 

    managed_rule_set {
      type    = "OWASP"
      version = "3.2"
      }
    }
  }
}

```

**Version (please complete the following information):**
 - bridgecrew/checkov docker image without version specified

**Additional context**
Traceback:

```
Process ForkProcess-6:
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)
  File "/usr/local/lib/python3.8/site-packages/checkov/common/runners/runner_registry.py", line 76, in _parallel_run
    return runner.run(
  File "/usr/local/lib/python3.8/site-packages/checkov/terraform/plan_runner.py", line 72, 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 90, 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 110, in run_block
    results = registry.scan(scanned_file, entity, [], runner_filter)
  File "/usr/local/lib/python3.8/site-packages/checkov/common/checks/base_check_registry.py", line 124, 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 138, in run_check
    result = check.run(
  File "/usr/local/lib/python3.8/site-packages/checkov/common/checks/base_check.py", line 75, 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/azure/AppGatewayWAFACLCVE202144228.py", line 35, in scan_resource_conf
    if rule_override.get("rule_group_name") == ["REQUEST-944-APPLICATION-ATTACK-JAVA"]:
  File "/usr/local/lib/python3.8/site-packages/checkov/common/parsers/node.py", line 189, in __getattr__
    raise TemplateAttributeError(f'{name} is invalid')
checkov.common.parsers.node.TemplateAttributeError: get is invalid

```


Discussion:

Resolving patch:
diff --git a/checkov/terraform/checks/resource/azure/AppGatewayWAFACLCVE202144228.py b/checkov/terraform/checks/resource/azure/AppGatewayWAFACLCVE202144228.py
--- a/checkov/terraform/checks/resource/azure/AppGatewayWAFACLCVE202144228.py
+++ b/checkov/terraform/checks/resource/azure/AppGatewayWAFACLCVE202144228.py
@@ -32,7 +32,7 @@ def scan_resource_conf(self, conf: Dict[str, Any]) -> CheckResult:
                                 f"managed_rules/[0]/managed_rule_set[{idx_rule_set}]/rule_group_override/[{idx_override}]/disabled_rules",
                             ]
                         )
-                        if rule_override.get("rule_group_name") == ["REQUEST-944-APPLICATION-ATTACK-JAVA"]:
+                        if isinstance(rule_override, dict) and rule_override.get("rule_group_name") == ["REQUEST-944-APPLICATION-ATTACK-JAVA"]:
                             disabled_rules = rule_override.get("disabled_rules") or []
                             if isinstance(disabled_rules, list) and "944240" in force_list(disabled_rules[0]):
                                 return CheckResult.FAILED


Test patch:
diff --git a/tests/terraform/checks/resource/azure/example_AppGatewayWAFACLCVE202144228/main.tf b/tests/terraform/checks/resource/azure/example_AppGatewayWAFACLCVE202144228/main.tf
--- a/tests/terraform/checks/resource/azure/example_AppGatewayWAFACLCVE202144228/main.tf
+++ b/tests/terraform/checks/resource/azure/example_AppGatewayWAFACLCVE202144228/main.tf
@@ -9,6 +9,8 @@ resource "azurerm_web_application_firewall_policy" "owasp_3_1_default" {
     managed_rule_set {
       type    = "OWASP"
       version = "3.1"
+
+      rule_group_override = [{}]
     }
   }