prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Dockerfile scan fails when in directory and used -f
  **Describe the bug**
  When running directory scan checkov shows Dockerfile failed checks. When scanning file no errors are shown.
  
  **To Reproduce**
  Create Dockerfile in directory `test` with content:
  ```
  FROM debian:buster
  
  ENV CHECKOV_VERSION 1.0.775
  
  RUN export DEBIAN_FRONTEND=noninteractive && \
    apt-get -y update && \
    apt-get -y --no-install-recommends install wget unzip ca-certificates git python3 python3-pip python3-setuptools python3-wheel && \
    pip3 install -U checkov=="${CHECKOV_VERSION}"
  ```
  
  `checkov -f test/Dockerfile` won't show errors
  `checkov -d test` will show error
  
  **Expected behavior**
  Show error in both cases.
  
  **Screenshots**
  <img width="892" alt="Screenshot 2021-04-10 at 09 39 21" src="https://user-images.githubusercontent.com/672767/114262507-a54dde80-99e0-11eb-9e9e-3e3f5d2d2a7f.png">
  
  **Desktop (please complete the following information):**
   - OS: MacOS 11.2.3
   - Python: 3.9.4
   - Checkov Version 2.0.27
  
  
  </issue>
  <code>
  [start of checkov/dockerfile/runner.py]
  1 import logging
  2 import os
  3 from dockerfile_parse.constants import DOCKERFILE_FILENAME
  4 
  5 from checkov.common.output.record import Record
  6 from checkov.common.output.report import Report
  7 from checkov.common.runners.base_runner import BaseRunner, filter_ignored_directories
  8 from checkov.dockerfile.parser import parse, collect_skipped_checks
  9 from checkov.dockerfile.registry import registry
  10 from checkov.runner_filter import RunnerFilter
  11 
  12 DOCKER_FILE_MASK = [DOCKERFILE_FILENAME]
  13 
  14 
  15 class Runner(BaseRunner):
  16     check_type = "dockerfile"
  17 
  18     def run(self, root_folder, external_checks_dir=None, files=None, runner_filter=RunnerFilter(),
  19             collect_skip_comments=True):
  20         report = Report(self.check_type)
  21         definitions = {}
  22         definitions_raw = {}
  23         parsing_errors = {}
  24         files_list = []
  25         if external_checks_dir:
  26             for directory in external_checks_dir:
  27                 registry.load_external_checks(directory)
  28 
  29         if files:
  30             for file in files:
  31                 if file in DOCKER_FILE_MASK:
  32                     (definitions[file], definitions_raw[file]) = parse(file)
  33 
  34         if root_folder:
  35             for root, d_names, f_names in os.walk(root_folder):
  36                 filter_ignored_directories(d_names)
  37                 for file in f_names:
  38                     if file in DOCKER_FILE_MASK:
  39                         files_list.append(os.path.join(root, file))
  40 
  41             for file in files_list:
  42                 relative_file_path = f'/{os.path.relpath(file, os.path.commonprefix((root_folder, file)))}'
  43                 try:
  44                     (definitions[relative_file_path], definitions_raw[relative_file_path]) = parse(file)
  45                 except TypeError:
  46                     logging.info(f'Dockerfile skipping {file} as it is not a valid dockerfile template')
  47 
  48         for docker_file_path in definitions.keys():
  49 
  50             # There are a few cases here. If -f was used, there could be a leading / because it's an absolute path,
  51             # or there will be no leading slash; root_folder will always be none.
  52             # If -d is used, root_folder will be the value given, and -f will start with a / (hardcoded above).
  53             # The goal here is simply to get a valid path to the file (which docker_file_path does not always give).
  54             if docker_file_path[0] == '/':
  55                 path_to_convert = (root_folder + docker_file_path) if root_folder else docker_file_path
  56             else:
  57                 path_to_convert = (os.path.join(root_folder, docker_file_path)) if root_folder else docker_file_path
  58 
  59             file_abs_path = os.path.abspath(path_to_convert)
  60             skipped_checks = collect_skipped_checks(definitions[docker_file_path])
  61             instructions = definitions[docker_file_path]
  62 
  63             results = registry.scan(docker_file_path, instructions, skipped_checks,
  64                                     runner_filter)
  65             for check, check_result in results.items():
  66                 result_configuration = check_result['results_configuration']
  67                 startline = 0
  68                 endline = 0
  69                 result_instruction = ""
  70                 if result_configuration:
  71                     startline = result_configuration['startline']
  72                     endline = result_configuration['endline']
  73                     result_instruction = result_configuration["instruction"]
  74 
  75                 codeblock = []
  76                 self.calc_record_codeblock(codeblock, definitions_raw, docker_file_path, endline, startline)
  77                 record = Record(check_id=check.id, check_name=check.name, check_result=check_result,
  78                                 code_block=codeblock,
  79                                 file_path=docker_file_path,
  80                                 file_line_range=[startline,
  81                                                  endline],
  82                                 resource="{}.{}".format(docker_file_path,
  83                                                         result_instruction,
  84                                                         startline),
  85                                 evaluations=None, check_class=check.__class__.__module__,
  86                                 file_abs_path=file_abs_path, entity_tags=None)
  87                 report.add_record(record=record)
  88 
  89         return report
  90 
  91 
  92     def calc_record_codeblock(self, codeblock, definitions_raw, docker_file_path, endline, startline):
  93         for line in range(startline, endline + 1):
  94             codeblock.append((line, definitions_raw[docker_file_path][line]))
  95
  [end of checkov/dockerfile/runner.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/runner.py b/checkov/dockerfile/runner.py
  --- a/checkov/dockerfile/runner.py
  +++ b/checkov/dockerfile/runner.py
  @@ -15,7 +15,7 @@
   class Runner(BaseRunner):
       check_type = "dockerfile"
   
  -    def run(self, root_folder, external_checks_dir=None, files=None, runner_filter=RunnerFilter(),
  +    def run(self, root_folder=None, external_checks_dir=None, files=None, runner_filter=RunnerFilter(),
               collect_skip_comments=True):
           report = Report(self.check_type)
           definitions = {}
  @@ -28,7 +28,7 @@
   
           if files:
               for file in files:
  -                if file in DOCKER_FILE_MASK:
  +                if os.path.basename(file) in DOCKER_FILE_MASK:
                       (definitions[file], definitions_raw[file]) = parse(file)
   
           if root_folder:
  
verification_info: {"golden_diff": "diff --git a/checkov/dockerfile/runner.py b/checkov/dockerfile/runner.py\n--- a/checkov/dockerfile/runner.py\n+++ b/checkov/dockerfile/runner.py\n@@ -15,7 +15,7 @@\n class Runner(BaseRunner):\n     check_type = \"dockerfile\"\n \n-    def run(self, root_folder, external_checks_dir=None, files=None, runner_filter=RunnerFilter(),\n+    def run(self, root_folder=None, external_checks_dir=None, files=None, runner_filter=RunnerFilter(),\n             collect_skip_comments=True):\n         report = Report(self.check_type)\n         definitions = {}\n@@ -28,7 +28,7 @@\n \n         if files:\n             for file in files:\n-                if file in DOCKER_FILE_MASK:\n+                if os.path.basename(file) in DOCKER_FILE_MASK:\n                     (definitions[file], definitions_raw[file]) = parse(file)\n \n         if root_folder:\n", "issue": "Dockerfile scan fails when in directory and used -f\n**Describe the bug**\r\nWhen running directory scan checkov shows Dockerfile failed checks. When scanning file no errors are shown.\r\n\r\n**To Reproduce**\r\nCreate Dockerfile in directory `test` with content:\r\n```\r\nFROM debian:buster\r\n\r\nENV CHECKOV_VERSION 1.0.775\r\n\r\nRUN export DEBIAN_FRONTEND=noninteractive && \\\r\n  apt-get -y update && \\\r\n  apt-get -y --no-install-recommends install wget unzip ca-certificates git python3 python3-pip python3-setuptools python3-wheel && \\\r\n  pip3 install -U checkov==\"${CHECKOV_VERSION}\"\r\n```\r\n\r\n`checkov -f test/Dockerfile` won't show errors\r\n`checkov -d test` will show error\r\n\r\n**Expected behavior**\r\nShow error in both cases.\r\n\r\n**Screenshots**\r\n<img width=\"892\" alt=\"Screenshot 2021-04-10 at 09 39 21\" src=\"https://user-images.githubusercontent.com/672767/114262507-a54dde80-99e0-11eb-9e9e-3e3f5d2d2a7f.png\">\r\n\r\n**Desktop (please complete the following information):**\r\n - OS: MacOS 11.2.3\r\n - Python: 3.9.4\r\n - Checkov Version 2.0.27\r\n\n", "before_files": [{"content": "import logging\nimport os\nfrom dockerfile_parse.constants import DOCKERFILE_FILENAME\n\nfrom checkov.common.output.record import Record\nfrom checkov.common.output.report import Report\nfrom checkov.common.runners.base_runner import BaseRunner, filter_ignored_directories\nfrom checkov.dockerfile.parser import parse, collect_skipped_checks\nfrom checkov.dockerfile.registry import registry\nfrom checkov.runner_filter import RunnerFilter\n\nDOCKER_FILE_MASK = [DOCKERFILE_FILENAME]\n\n\nclass Runner(BaseRunner):\n    check_type = \"dockerfile\"\n\n    def run(self, root_folder, external_checks_dir=None, files=None, runner_filter=RunnerFilter(),\n            collect_skip_comments=True):\n        report = Report(self.check_type)\n        definitions = {}\n        definitions_raw = {}\n        parsing_errors = {}\n        files_list = []\n        if external_checks_dir:\n            for directory in external_checks_dir:\n                registry.load_external_checks(directory)\n\n        if files:\n            for file in files:\n                if file in DOCKER_FILE_MASK:\n                    (definitions[file], definitions_raw[file]) = parse(file)\n\n        if root_folder:\n            for root, d_names, f_names in os.walk(root_folder):\n                filter_ignored_directories(d_names)\n                for file in f_names:\n                    if file in DOCKER_FILE_MASK:\n                        files_list.append(os.path.join(root, file))\n\n            for file in files_list:\n                relative_file_path = f'/{os.path.relpath(file, os.path.commonprefix((root_folder, file)))}'\n                try:\n                    (definitions[relative_file_path], definitions_raw[relative_file_path]) = parse(file)\n                except TypeError:\n                    logging.info(f'Dockerfile skipping {file} as it is not a valid dockerfile template')\n\n        for docker_file_path in definitions.keys():\n\n            # There are a few cases here. If -f was used, there could be a leading / because it's an absolute path,\n            # or there will be no leading slash; root_folder will always be none.\n            # If -d is used, root_folder will be the value given, and -f will start with a / (hardcoded above).\n            # The goal here is simply to get a valid path to the file (which docker_file_path does not always give).\n            if docker_file_path[0] == '/':\n                path_to_convert = (root_folder + docker_file_path) if root_folder else docker_file_path\n            else:\n                path_to_convert = (os.path.join(root_folder, docker_file_path)) if root_folder else docker_file_path\n\n            file_abs_path = os.path.abspath(path_to_convert)\n            skipped_checks = collect_skipped_checks(definitions[docker_file_path])\n            instructions = definitions[docker_file_path]\n\n            results = registry.scan(docker_file_path, instructions, skipped_checks,\n                                    runner_filter)\n            for check, check_result in results.items():\n                result_configuration = check_result['results_configuration']\n                startline = 0\n                endline = 0\n                result_instruction = \"\"\n                if result_configuration:\n                    startline = result_configuration['startline']\n                    endline = result_configuration['endline']\n                    result_instruction = result_configuration[\"instruction\"]\n\n                codeblock = []\n                self.calc_record_codeblock(codeblock, definitions_raw, docker_file_path, endline, startline)\n                record = Record(check_id=check.id, check_name=check.name, check_result=check_result,\n                                code_block=codeblock,\n                                file_path=docker_file_path,\n                                file_line_range=[startline,\n                                                 endline],\n                                resource=\"{}.{}\".format(docker_file_path,\n                                                        result_instruction,\n                                                        startline),\n                                evaluations=None, check_class=check.__class__.__module__,\n                                file_abs_path=file_abs_path, entity_tags=None)\n                report.add_record(record=record)\n\n        return report\n\n\n    def calc_record_codeblock(self, codeblock, definitions_raw, docker_file_path, endline, startline):\n        for line in range(startline, endline + 1):\n            codeblock.append((line, definitions_raw[docker_file_path][line]))\n", "path": "checkov/dockerfile/runner.py"}]}