prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  update-locale triggers CKV_DOCKER_5
  **Describe the issue**
  CKV_DOCKER_5 (Ensure update instructions are not use alone in the Dockerfile) fails in anything that has `update` in it. From reading the source, it. seems that CKV_DOCKER_5 is geared towards `apt-get update` and `apt-get install` which, from the code, are cancelling each other out so the `update_cnt` variable remains 0. I have other `update` command like `update-locale`. I'm not sure if it's part of the issue in my Dockerfile that I need to deal or I could just ignore the failure message.
  
  **Examples**
  ```
  RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
    dpkg-reconfigure --frontend noninteractive locales && \
    update-locale LANG=en_US.UTF-8
  ```
  
  **Version (please complete the following information):**
   - Checkov Version 2.2.229
  
  
  </issue>
  <code>
  [start of checkov/dockerfile/checks/UpdateNotAlone.py]
  1 from __future__ import annotations
  2 
  3 from typing import TYPE_CHECKING
  4 
  5 from checkov.common.models.enums import CheckCategories, CheckResult
  6 from checkov.dockerfile.base_dockerfile_check import BaseDockerfileCheck
  7 
  8 if TYPE_CHECKING:
  9     from dockerfile_parse.parser import _Instruction
  10 
  11 install_commands = (
  12     "install",
  13     "source-install",
  14     "reinstall",
  15     "groupinstall",
  16     "localinstall",
  17     "add",
  18 )
  19 update_commands = (
  20     "update",
  21     "--update",
  22 )
  23 
  24 
  25 class UpdateNotAlone(BaseDockerfileCheck):
  26     def __init__(self) -> None:
  27         name = "Ensure update instructions are not use alone in the Dockerfile"
  28         id = "CKV_DOCKER_5"
  29         supported_instructions = ("RUN",)
  30         categories = (CheckCategories.APPLICATION_SECURITY,)
  31         super().__init__(name=name, id=id, categories=categories, supported_instructions=supported_instructions)
  32 
  33     def scan_resource_conf(self, conf: list[_Instruction]) -> tuple[CheckResult, list[_Instruction] | None]:
  34         update_instructions = []
  35         update_cnt = 0
  36         i = 0
  37         for instruction in conf:
  38             content = instruction["content"]
  39             if instruction["instruction"] in self.supported_instructions:
  40 
  41                 if any(x in content for x in update_commands):
  42                     update_cnt = update_cnt + 1
  43                     update_instructions.append(i)
  44                 if any(x in content for x in install_commands):
  45                     update_cnt = update_cnt - 1
  46             i = i + 1
  47 
  48         if update_cnt <= 0:
  49             return CheckResult.PASSED, None
  50         output = []
  51         for i in update_instructions:
  52             output.append(conf[i])
  53 
  54         return CheckResult.FAILED, output
  55 
  56 
  57 check = UpdateNotAlone()
  58
  [end of checkov/dockerfile/checks/UpdateNotAlone.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/checkov/dockerfile/checks/UpdateNotAlone.py b/checkov/dockerfile/checks/UpdateNotAlone.py
  --- a/checkov/dockerfile/checks/UpdateNotAlone.py
  +++ b/checkov/dockerfile/checks/UpdateNotAlone.py
  @@ -1,5 +1,6 @@
   from __future__ import annotations
   
  +import re
   from typing import TYPE_CHECKING
   
   from checkov.common.models.enums import CheckCategories, CheckResult
  @@ -8,6 +9,8 @@
   if TYPE_CHECKING:
       from dockerfile_parse.parser import _Instruction
   
  +UPDATE_COMMANDS_PATTERN = re.compile(r"\s+(?:--)?update(?!\S)")
  +
   install_commands = (
       "install",
       "source-install",
  @@ -15,10 +18,7 @@
       "groupinstall",
       "localinstall",
       "add",
  -)
  -update_commands = (
  -    "update",
  -    "--update",
  +    "upgrade"
   )
   
   
  @@ -38,7 +38,7 @@
               content = instruction["content"]
               if instruction["instruction"] in self.supported_instructions:
   
  -                if any(x in content for x in update_commands):
  +                if re.search(UPDATE_COMMANDS_PATTERN, content):
                       update_cnt = update_cnt + 1
                       update_instructions.append(i)
                   if any(x in content for x in install_commands):
  
verification_info: {"golden_diff": "diff --git a/checkov/dockerfile/checks/UpdateNotAlone.py b/checkov/dockerfile/checks/UpdateNotAlone.py\n--- a/checkov/dockerfile/checks/UpdateNotAlone.py\n+++ b/checkov/dockerfile/checks/UpdateNotAlone.py\n@@ -1,5 +1,6 @@\n from __future__ import annotations\n \n+import re\n from typing import TYPE_CHECKING\n \n from checkov.common.models.enums import CheckCategories, CheckResult\n@@ -8,6 +9,8 @@\n if TYPE_CHECKING:\n     from dockerfile_parse.parser import _Instruction\n \n+UPDATE_COMMANDS_PATTERN = re.compile(r\"\\s+(?:--)?update(?!\\S)\")\n+\n install_commands = (\n     \"install\",\n     \"source-install\",\n@@ -15,10 +18,7 @@\n     \"groupinstall\",\n     \"localinstall\",\n     \"add\",\n-)\n-update_commands = (\n-    \"update\",\n-    \"--update\",\n+    \"upgrade\"\n )\n \n \n@@ -38,7 +38,7 @@\n             content = instruction[\"content\"]\n             if instruction[\"instruction\"] in self.supported_instructions:\n \n-                if any(x in content for x in update_commands):\n+                if re.search(UPDATE_COMMANDS_PATTERN, content):\n                     update_cnt = update_cnt + 1\n                     update_instructions.append(i)\n                 if any(x in content for x in install_commands):\n", "issue": "update-locale triggers CKV_DOCKER_5\n**Describe the issue**\r\nCKV_DOCKER_5 (Ensure update instructions are not use alone in the Dockerfile) fails in anything that has `update` in it. From reading the source, it. seems that CKV_DOCKER_5 is geared towards `apt-get update` and `apt-get install` which, from the code, are cancelling each other out so the `update_cnt` variable remains 0. I have other `update` command like `update-locale`. I'm not sure if it's part of the issue in my Dockerfile that I need to deal or I could just ignore the failure message.\r\n\r\n**Examples**\r\n```\r\nRUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \\\r\n  dpkg-reconfigure --frontend noninteractive locales && \\\r\n  update-locale LANG=en_US.UTF-8\r\n```\r\n\r\n**Version (please complete the following information):**\r\n - Checkov Version 2.2.229\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nfrom checkov.common.models.enums import CheckCategories, CheckResult\nfrom checkov.dockerfile.base_dockerfile_check import BaseDockerfileCheck\n\nif TYPE_CHECKING:\n    from dockerfile_parse.parser import _Instruction\n\ninstall_commands = (\n    \"install\",\n    \"source-install\",\n    \"reinstall\",\n    \"groupinstall\",\n    \"localinstall\",\n    \"add\",\n)\nupdate_commands = (\n    \"update\",\n    \"--update\",\n)\n\n\nclass UpdateNotAlone(BaseDockerfileCheck):\n    def __init__(self) -> None:\n        name = \"Ensure update instructions are not use alone in the Dockerfile\"\n        id = \"CKV_DOCKER_5\"\n        supported_instructions = (\"RUN\",)\n        categories = (CheckCategories.APPLICATION_SECURITY,)\n        super().__init__(name=name, id=id, categories=categories, supported_instructions=supported_instructions)\n\n    def scan_resource_conf(self, conf: list[_Instruction]) -> tuple[CheckResult, list[_Instruction] | None]:\n        update_instructions = []\n        update_cnt = 0\n        i = 0\n        for instruction in conf:\n            content = instruction[\"content\"]\n            if instruction[\"instruction\"] in self.supported_instructions:\n\n                if any(x in content for x in update_commands):\n                    update_cnt = update_cnt + 1\n                    update_instructions.append(i)\n                if any(x in content for x in install_commands):\n                    update_cnt = update_cnt - 1\n            i = i + 1\n\n        if update_cnt <= 0:\n            return CheckResult.PASSED, None\n        output = []\n        for i in update_instructions:\n            output.append(conf[i])\n\n        return CheckResult.FAILED, output\n\n\ncheck = UpdateNotAlone()\n", "path": "checkov/dockerfile/checks/UpdateNotAlone.py"}]}