Repository: bridgecrewio/checkov

Issue:
Inline Terraform Skips Broken – v1.0.612
**Describe the bug**
Checkov errors immediately if there are any skips defined in my Terraform resources. Behavior is correct on 1.0.611 but is broken on 1.0.612 and 1.0.613.

**To Reproduce**
Steps to reproduce the behavior:
1. Create a test resource in Terraform
```
resource "aws_s3_bucket" "mybucket" {
  #checkov:skip=CKV_AWS_19:Data in this bucket does not need encryption.
  bucket = "my-bucket"
  acl    = "private"
}
```
2. Run `checkov -d .` on v1.0.612 or v1.0.613.
3. See error

**Expected behavior**
Checkov scans my resources using all checks except CKV_AWS_19.

**Output**
```
checkov -d .
Traceback (most recent call last):
  File "/usr/local/bin/checkov", line 5, in <module>
    run()
  File "/usr/local/lib/python3.9/site-packages/checkov/main.py", line 63, in run
    scan_reports = runner_registry.run(root_folder=root_folder, external_checks_dir=external_checks_dir,
  File "/usr/local/lib/python3.9/site-packages/checkov/common/runners/runner_registry.py", line 30, in run
    scan_report = runner.run(root_folder, external_checks_dir=external_checks_dir, files=files,
  File "/usr/local/lib/python3.9/site-packages/checkov/terraform/runner.py", line 55, in run
    self.check_tf_definition(report, root_folder, runner_filter, collect_skip_comments)
  File "/usr/local/lib/python3.9/site-packages/checkov/terraform/runner.py", line 89, in check_tf_definition
    definitions_context = parser_registry.enrich_definitions_context(definition, collect_skip_comments)
  File "/usr/local/lib/python3.9/site-packages/checkov/terraform/context_parsers/registry.py", line 28, in enrich_definitions_context
    self.definitions_context[tf_file][definition_type] = context_parser.run(tf_file, definition_blocks, collect_skip_comments)
  File "/usr/local/lib/python3.9/site-packages/checkov/terraform/context_parsers/base_parser.py", line 118, in run
    self.context = self._collect_skip_comments(definition_blocks)
  File "/usr/local/lib/python3.9/site-packages/checkov/terraform/context_parsers/base_parser.py", line 87, in _collect_skip_comments
    if skip_check['id'] in bc_id_mapping:
TypeError: argument of type 'NoneType' is not iterable
```

**Desktop (please complete the following information):**
 - Mac 10.15.7
 - 1.0.612, 1.0.613

**Additional context**
I imagine this may have to do with the change at https://github.com/bridgecrewio/checkov/commit/751b0aace12dfd0f0f24cd042a659f9eab3bf24d#diff-79435bbd626a6a0ce4070183c5f5070eb31621991464e9948ec5de7d021ad15aR65



Discussion:

Resolving patch:
diff --git a/checkov/terraform/context_parsers/base_parser.py b/checkov/terraform/context_parsers/base_parser.py
--- a/checkov/terraform/context_parsers/base_parser.py
+++ b/checkov/terraform/context_parsers/base_parser.py
@@ -84,7 +84,7 @@ def _collect_skip_comments(self, definition_blocks):
             for _, entity_context in context_search:
                 for (skip_check_line_num, skip_check) in comments:
                     if entity_context['start_line'] < skip_check_line_num < entity_context['end_line']:
-                        if skip_check['id'] in bc_id_mapping:
+                        if bc_id_mapping and skip_check['id'] in bc_id_mapping:
                             skip_check['id'] = bc_id_mapping[skip_check['id']]
                         skipped_checks.append(skip_check)
             dpath.new(self.context, entity_context_path + ['skipped_checks'], skipped_checks)


Test patch: