prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Suppression comment in Dockerfile skips more checks than it should
  **Describe the issue**
  I tried to skip CKV_DOCKER_9 by adding a suppression comment into my Dockerfile, but it turned out that CKV_DOCKER_5 was also skipped.
  
  **Examples**
  Here's my Dockerfile with comment to skip CKV_DOCKER_9:
  ```dockerfile
  #checkov:skip=CKV_DOCKER_9
  FROM alpine:3.16
  RUN ls
  ```
  As you can see, CKV_DOCKER_5 is also marked as SKIPPED in the results:
  ```
  $ docker run -it --rm -v "$(pwd):$(pwd)" -w "$(pwd)" bridgecrew/checkov:2.2.104 --framework dockerfile --skip-download --file Dockerfile
  
         _               _              
     ___| |__   ___  ___| | _______   __
    / __| '_ \ / _ \/ __| |/ / _ \ \ / /
   | (__| | | |  __/ (__|   < (_) \ V / 
    \___|_| |_|\___|\___|_|\_\___/ \_/  
                                        
  By bridgecrew.io | version: 2.2.104 
  
  dockerfile scan results:
  
  Passed checks: 2, Failed checks: 2, Skipped checks: 2
  
  Check: CKV_DOCKER_11: "Ensure From Alias are unique for multistage builds."
  	PASSED for resource: Dockerfile.
  	File: Dockerfile:1-4
  Check: CKV_DOCKER_7: "Ensure the base image uses a non latest version tag"
  	PASSED for resource: Dockerfile.
  	File: Dockerfile:1-4
  Check: CKV_DOCKER_2: "Ensure that HEALTHCHECK instructions have been added to container images"
  	FAILED for resource: Dockerfile.
  	File: Dockerfile:1-4
  
  		1 | #checkov:skip=CKV_DOCKER_9
  		2 | FROM alpine:3.16
  		3 | RUN ls
  		4 | 
  
  Check: CKV_DOCKER_3: "Ensure that a user for the container has been created"
  	FAILED for resource: Dockerfile.
  	File: Dockerfile:1-4
  
  		1 | #checkov:skip=CKV_DOCKER_9
  		2 | FROM alpine:3.16
  		3 | RUN ls
  		4 | 
  
  Check: CKV_DOCKER_9: "Ensure that APT isn't used"
  	SKIPPED for resource: Dockerfile.
  	Suppress comment: No comment provided
  	File: Dockerfile:1-4
  Check: CKV_DOCKER_5: "Ensure update instructions are not use alone in the Dockerfile"
  	SKIPPED for resource: Dockerfile.
  	Suppress comment: No comment provided
  	File: Dockerfile:1-4
  ```
  
  **Version (please complete the following information):**
   - Checkov Version: 2.2.104
  
  
  --- 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/dockerfile/base_registry.py`
  Content:
  ```
  1 from __future__ import annotations
  2 
  3 from typing import TYPE_CHECKING, Any, cast
  4 
  5 from checkov.common.bridgecrew.check_type import CheckType
  6 from checkov.common.checks.base_check_registry import BaseCheckRegistry
  7 from checkov.common.models.enums import CheckResult
  8 
  9 if TYPE_CHECKING:
  10     from dockerfile_parse.parser import _Instruction  # only in extra_stubs
  11     from checkov.common.checks.base_check import BaseCheck
  12     from checkov.common.typing import _SkippedCheck, _CheckResult
  13     from checkov.runner_filter import RunnerFilter
  14 
  15 
  16 class Registry(BaseCheckRegistry):
  17     def __init__(self) -> None:
  18         super().__init__(CheckType.DOCKERFILE)
  19 
  20     def extract_entity_details(self, entity: dict[str, Any]) -> tuple[str, str, dict[str, Any]]:
  21         # not needed
  22         return "", "", {}
  23 
  24     def scan(
  25         self,
  26         scanned_file: str,
  27         entity: dict[str, list[_Instruction]],
  28         skipped_checks: list[_SkippedCheck],
  29         runner_filter: RunnerFilter,
  30         report_type: str | None = None,
  31     ) -> dict[BaseCheck, _CheckResult]:
  32 
  33         results: "dict[BaseCheck, _CheckResult]" = {}
  34         if not entity:
  35             return results
  36         for instruction, checks in self.checks.items():
  37             skip_info: _SkippedCheck = {}
  38             if instruction in entity:
  39 
  40                 for check in checks:
  41                     if check.id in [x['id'] for x in skipped_checks]:
  42                         skip_info = [x for x in skipped_checks if x['id'] == check.id][0]
  43 
  44                     if runner_filter.should_run_check(check, report_type=CheckType.DOCKERFILE):
  45                         self.update_result(
  46                             check=check,
  47                             entity_configuration=entity[instruction],
  48                             entity_name=instruction,
  49                             entity_type=instruction,
  50                             results=results,
  51                             scanned_file=scanned_file,
  52                             skip_info=skip_info,
  53                         )
  54 
  55         for check in self.wildcard_checks["*"]:
  56             skip_info = {}
  57             if skipped_checks:
  58                 if check.id in [x['id'] for x in skipped_checks]:
  59                     skip_info = [x for x in skipped_checks if x['id'] == check.id][0]
  60 
  61             if runner_filter.should_run_check(check, report_type=CheckType.DOCKERFILE):
  62                 self.update_result(
  63                     check=check,
  64                     entity_configuration=entity,
  65                     entity_name=scanned_file,
  66                     entity_type="*",
  67                     results=results,
  68                     scanned_file=scanned_file,
  69                     skip_info=skip_info,
  70                 )
  71         return results
  72 
  73     def update_result(
  74         self,
  75         check: BaseCheck,
  76         entity_configuration: list[_Instruction] | dict[str, list[_Instruction]],
  77         entity_name: str,
  78         entity_type: str,
  79         results: dict[BaseCheck, _CheckResult],
  80         scanned_file: str,
  81         skip_info: _SkippedCheck
  82     ) -> None:
  83         result = self.run_check(
  84             check=check,
  85             entity_configuration=entity_configuration,  # type:ignore[arg-type]  # special Dockerfile runner behaviour
  86             entity_name=entity_name,
  87             entity_type=entity_type,
  88             scanned_file=scanned_file,
  89             skip_info=skip_info,
  90         )
  91         results[check] = {}
  92         if result['result'] == CheckResult.SKIPPED:
  93             results[check]['result'] = result['result']
  94             results[check]['suppress_comment'] = result['suppress_comment']
  95             results[check]['results_configuration'] = None
  96         else:
  97             results[check]['result'] = cast("CheckResult", result['result'][0])
  98             results[check]['results_configuration'] = cast("dict[str, Any]", result['result'][1])
  99
  ```
  --- 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/dockerfile/base_registry.py b/checkov/dockerfile/base_registry.py
  --- a/checkov/dockerfile/base_registry.py
  +++ b/checkov/dockerfile/base_registry.py
  @@ -33,13 +33,16 @@
           results: "dict[BaseCheck, _CheckResult]" = {}
           if not entity:
               return results
  +
  +        skipped_check_ids = {skipped_check["id"]: skipped_check for skipped_check in skipped_checks}
  +
           for instruction, checks in self.checks.items():
  -            skip_info: _SkippedCheck = {}
               if instruction in entity:
  -
                   for check in checks:
  -                    if check.id in [x['id'] for x in skipped_checks]:
  -                        skip_info = [x for x in skipped_checks if x['id'] == check.id][0]
  +                    skip_info: "_SkippedCheck" = {}
  +                    if skipped_check_ids:
  +                        if check.id in skipped_check_ids:
  +                            skip_info = skipped_check_ids[check.id]
   
                       if runner_filter.should_run_check(check, report_type=CheckType.DOCKERFILE):
                           self.update_result(
  @@ -54,9 +57,9 @@
   
           for check in self.wildcard_checks["*"]:
               skip_info = {}
  -            if skipped_checks:
  -                if check.id in [x['id'] for x in skipped_checks]:
  -                    skip_info = [x for x in skipped_checks if x['id'] == check.id][0]
  +            if skipped_check_ids:
  +                if check.id in skipped_check_ids:
  +                    skip_info = skipped_check_ids[check.id]
   
               if runner_filter.should_run_check(check, report_type=CheckType.DOCKERFILE):
                   self.update_result(
  
verification_info: {"golden_diff": "diff --git a/checkov/dockerfile/base_registry.py b/checkov/dockerfile/base_registry.py\n--- a/checkov/dockerfile/base_registry.py\n+++ b/checkov/dockerfile/base_registry.py\n@@ -33,13 +33,16 @@\n         results: \"dict[BaseCheck, _CheckResult]\" = {}\n         if not entity:\n             return results\n+\n+        skipped_check_ids = {skipped_check[\"id\"]: skipped_check for skipped_check in skipped_checks}\n+\n         for instruction, checks in self.checks.items():\n-            skip_info: _SkippedCheck = {}\n             if instruction in entity:\n-\n                 for check in checks:\n-                    if check.id in [x['id'] for x in skipped_checks]:\n-                        skip_info = [x for x in skipped_checks if x['id'] == check.id][0]\n+                    skip_info: \"_SkippedCheck\" = {}\n+                    if skipped_check_ids:\n+                        if check.id in skipped_check_ids:\n+                            skip_info = skipped_check_ids[check.id]\n \n                     if runner_filter.should_run_check(check, report_type=CheckType.DOCKERFILE):\n                         self.update_result(\n@@ -54,9 +57,9 @@\n \n         for check in self.wildcard_checks[\"*\"]:\n             skip_info = {}\n-            if skipped_checks:\n-                if check.id in [x['id'] for x in skipped_checks]:\n-                    skip_info = [x for x in skipped_checks if x['id'] == check.id][0]\n+            if skipped_check_ids:\n+                if check.id in skipped_check_ids:\n+                    skip_info = skipped_check_ids[check.id]\n \n             if runner_filter.should_run_check(check, report_type=CheckType.DOCKERFILE):\n                 self.update_result(\n", "issue": "Suppression comment in Dockerfile skips more checks than it should\n**Describe the issue**\r\nI tried to skip CKV_DOCKER_9 by adding a suppression comment into my Dockerfile, but it turned out that CKV_DOCKER_5 was also skipped.\r\n\r\n**Examples**\r\nHere's my Dockerfile with comment to skip CKV_DOCKER_9:\r\n```dockerfile\r\n#checkov:skip=CKV_DOCKER_9\r\nFROM alpine:3.16\r\nRUN ls\r\n```\r\nAs you can see, CKV_DOCKER_5 is also marked as SKIPPED in the results:\r\n```\r\n$ docker run -it --rm -v \"$(pwd):$(pwd)\" -w \"$(pwd)\" bridgecrew/checkov:2.2.104 --framework dockerfile --skip-download --file Dockerfile\r\n\r\n       _               _              \r\n   ___| |__   ___  ___| | _______   __\r\n  / __| '_ \\ / _ \\/ __| |/ / _ \\ \\ / /\r\n | (__| | | |  __/ (__|   < (_) \\ V / \r\n  \\___|_| |_|\\___|\\___|_|\\_\\___/ \\_/  \r\n                                      \r\nBy bridgecrew.io | version: 2.2.104 \r\n\r\ndockerfile scan results:\r\n\r\nPassed checks: 2, Failed checks: 2, Skipped checks: 2\r\n\r\nCheck: CKV_DOCKER_11: \"Ensure From Alias are unique for multistage builds.\"\r\n\tPASSED for resource: Dockerfile.\r\n\tFile: Dockerfile:1-4\r\nCheck: CKV_DOCKER_7: \"Ensure the base image uses a non latest version tag\"\r\n\tPASSED for resource: Dockerfile.\r\n\tFile: Dockerfile:1-4\r\nCheck: CKV_DOCKER_2: \"Ensure that HEALTHCHECK instructions have been added to container images\"\r\n\tFAILED for resource: Dockerfile.\r\n\tFile: Dockerfile:1-4\r\n\r\n\t\t1 | #checkov:skip=CKV_DOCKER_9\r\n\t\t2 | FROM alpine:3.16\r\n\t\t3 | RUN ls\r\n\t\t4 | \r\n\r\nCheck: CKV_DOCKER_3: \"Ensure that a user for the container has been created\"\r\n\tFAILED for resource: Dockerfile.\r\n\tFile: Dockerfile:1-4\r\n\r\n\t\t1 | #checkov:skip=CKV_DOCKER_9\r\n\t\t2 | FROM alpine:3.16\r\n\t\t3 | RUN ls\r\n\t\t4 | \r\n\r\nCheck: CKV_DOCKER_9: \"Ensure that APT isn't used\"\r\n\tSKIPPED for resource: Dockerfile.\r\n\tSuppress comment: No comment provided\r\n\tFile: Dockerfile:1-4\r\nCheck: CKV_DOCKER_5: \"Ensure update instructions are not use alone in the Dockerfile\"\r\n\tSKIPPED for resource: Dockerfile.\r\n\tSuppress comment: No comment provided\r\n\tFile: Dockerfile:1-4\r\n```\r\n\r\n**Version (please complete the following information):**\r\n - Checkov Version: 2.2.104\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING, Any, cast\n\nfrom checkov.common.bridgecrew.check_type import CheckType\nfrom checkov.common.checks.base_check_registry import BaseCheckRegistry\nfrom checkov.common.models.enums import CheckResult\n\nif TYPE_CHECKING:\n    from dockerfile_parse.parser import _Instruction  # only in extra_stubs\n    from checkov.common.checks.base_check import BaseCheck\n    from checkov.common.typing import _SkippedCheck, _CheckResult\n    from checkov.runner_filter import RunnerFilter\n\n\nclass Registry(BaseCheckRegistry):\n    def __init__(self) -> None:\n        super().__init__(CheckType.DOCKERFILE)\n\n    def extract_entity_details(self, entity: dict[str, Any]) -> tuple[str, str, dict[str, Any]]:\n        # not needed\n        return \"\", \"\", {}\n\n    def scan(\n        self,\n        scanned_file: str,\n        entity: dict[str, list[_Instruction]],\n        skipped_checks: list[_SkippedCheck],\n        runner_filter: RunnerFilter,\n        report_type: str | None = None,\n    ) -> dict[BaseCheck, _CheckResult]:\n\n        results: \"dict[BaseCheck, _CheckResult]\" = {}\n        if not entity:\n            return results\n        for instruction, checks in self.checks.items():\n            skip_info: _SkippedCheck = {}\n            if instruction in entity:\n\n                for check in checks:\n                    if check.id in [x['id'] for x in skipped_checks]:\n                        skip_info = [x for x in skipped_checks if x['id'] == check.id][0]\n\n                    if runner_filter.should_run_check(check, report_type=CheckType.DOCKERFILE):\n                        self.update_result(\n                            check=check,\n                            entity_configuration=entity[instruction],\n                            entity_name=instruction,\n                            entity_type=instruction,\n                            results=results,\n                            scanned_file=scanned_file,\n                            skip_info=skip_info,\n                        )\n\n        for check in self.wildcard_checks[\"*\"]:\n            skip_info = {}\n            if skipped_checks:\n                if check.id in [x['id'] for x in skipped_checks]:\n                    skip_info = [x for x in skipped_checks if x['id'] == check.id][0]\n\n            if runner_filter.should_run_check(check, report_type=CheckType.DOCKERFILE):\n                self.update_result(\n                    check=check,\n                    entity_configuration=entity,\n                    entity_name=scanned_file,\n                    entity_type=\"*\",\n                    results=results,\n                    scanned_file=scanned_file,\n                    skip_info=skip_info,\n                )\n        return results\n\n    def update_result(\n        self,\n        check: BaseCheck,\n        entity_configuration: list[_Instruction] | dict[str, list[_Instruction]],\n        entity_name: str,\n        entity_type: str,\n        results: dict[BaseCheck, _CheckResult],\n        scanned_file: str,\n        skip_info: _SkippedCheck\n    ) -> None:\n        result = self.run_check(\n            check=check,\n            entity_configuration=entity_configuration,  # type:ignore[arg-type]  # special Dockerfile runner behaviour\n            entity_name=entity_name,\n            entity_type=entity_type,\n            scanned_file=scanned_file,\n            skip_info=skip_info,\n        )\n        results[check] = {}\n        if result['result'] == CheckResult.SKIPPED:\n            results[check]['result'] = result['result']\n            results[check]['suppress_comment'] = result['suppress_comment']\n            results[check]['results_configuration'] = None\n        else:\n            results[check]['result'] = cast(\"CheckResult\", result['result'][0])\n            results[check]['results_configuration'] = cast(\"dict[str, Any]\", result['result'][1])\n", "path": "checkov/dockerfile/base_registry.py"}], "after_files": [{"content": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING, Any, cast\n\nfrom checkov.common.bridgecrew.check_type import CheckType\nfrom checkov.common.checks.base_check_registry import BaseCheckRegistry\nfrom checkov.common.models.enums import CheckResult\n\nif TYPE_CHECKING:\n    from dockerfile_parse.parser import _Instruction  # only in extra_stubs\n    from checkov.common.checks.base_check import BaseCheck\n    from checkov.common.typing import _SkippedCheck, _CheckResult\n    from checkov.runner_filter import RunnerFilter\n\n\nclass Registry(BaseCheckRegistry):\n    def __init__(self) -> None:\n        super().__init__(CheckType.DOCKERFILE)\n\n    def extract_entity_details(self, entity: dict[str, Any]) -> tuple[str, str, dict[str, Any]]:\n        # not needed\n        return \"\", \"\", {}\n\n    def scan(\n        self,\n        scanned_file: str,\n        entity: dict[str, list[_Instruction]],\n        skipped_checks: list[_SkippedCheck],\n        runner_filter: RunnerFilter,\n        report_type: str | None = None,\n    ) -> dict[BaseCheck, _CheckResult]:\n\n        results: \"dict[BaseCheck, _CheckResult]\" = {}\n        if not entity:\n            return results\n\n        skipped_check_ids = {skipped_check[\"id\"]: skipped_check for skipped_check in skipped_checks}\n\n        for instruction, checks in self.checks.items():\n            if instruction in entity:\n                for check in checks:\n                    skip_info: \"_SkippedCheck\" = {}\n                    if skipped_check_ids:\n                        if check.id in skipped_check_ids:\n                            skip_info = skipped_check_ids[check.id]\n\n                    if runner_filter.should_run_check(check, report_type=CheckType.DOCKERFILE):\n                        self.update_result(\n                            check=check,\n                            entity_configuration=entity[instruction],\n                            entity_name=instruction,\n                            entity_type=instruction,\n                            results=results,\n                            scanned_file=scanned_file,\n                            skip_info=skip_info,\n                        )\n\n        for check in self.wildcard_checks[\"*\"]:\n            skip_info = {}\n            if skipped_check_ids:\n                if check.id in skipped_check_ids:\n                    skip_info = skipped_check_ids[check.id]\n\n            if runner_filter.should_run_check(check, report_type=CheckType.DOCKERFILE):\n                self.update_result(\n                    check=check,\n                    entity_configuration=entity,\n                    entity_name=scanned_file,\n                    entity_type=\"*\",\n                    results=results,\n                    scanned_file=scanned_file,\n                    skip_info=skip_info,\n                )\n        return results\n\n    def update_result(\n        self,\n        check: BaseCheck,\n        entity_configuration: list[_Instruction] | dict[str, list[_Instruction]],\n        entity_name: str,\n        entity_type: str,\n        results: dict[BaseCheck, _CheckResult],\n        scanned_file: str,\n        skip_info: _SkippedCheck\n    ) -> None:\n        result = self.run_check(\n            check=check,\n            entity_configuration=entity_configuration,  # type:ignore[arg-type]  # special Dockerfile runner behaviour\n            entity_name=entity_name,\n            entity_type=entity_type,\n            scanned_file=scanned_file,\n            skip_info=skip_info,\n        )\n        results[check] = {}\n        if result['result'] == CheckResult.SKIPPED:\n            results[check]['result'] = result['result']\n            results[check]['suppress_comment'] = result['suppress_comment']\n            results[check]['results_configuration'] = None\n        else:\n            results[check]['result'] = cast(\"CheckResult\", result['result'][0])\n            results[check]['results_configuration'] = cast(\"dict[str, Any]\", result['result'][1])\n", "path": "checkov/dockerfile/base_registry.py"}]}