Repository: bridgecrewio/checkov

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


Discussion:

Patch:
diff --git a/checkov/dockerfile/runner.py b/checkov/dockerfile/runner.py
index f0267d36e..c12a3655d 100644
--- a/checkov/dockerfile/runner.py
+++ b/checkov/dockerfile/runner.py
@@ -15,7 +15,7 @@ DOCKER_FILE_MASK = [DOCKERFILE_FILENAME]
 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 @@ class Runner(BaseRunner):
 
         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:


Test patch:
diff --git a/tests/dockerfile/test_runner.py b/tests/dockerfile/test_runner.py
index d57fa2e5e..fa7d36a6c 100644
--- a/tests/dockerfile/test_runner.py
+++ b/tests/dockerfile/test_runner.py
@@ -32,6 +32,21 @@ class TestRunnerValid(unittest.TestCase):
         self.assertEqual(report.skipped_checks, [])
         report.print_console()
 
+    def test_runner_failing_check_with_file_path(self):
+        current_dir = os.path.dirname(os.path.realpath(__file__))
+        valid_file_path = current_dir + "/resources/expose_port/fail/Dockerfile"
+        runner = Runner()
+        report = runner.run(
+            files=[valid_file_path],
+            external_checks_dir=None,
+            runner_filter=RunnerFilter(framework="all", checks=["CKV_DOCKER_1"]),
+        )
+        self.assertEqual(len(report.failed_checks), 1)
+        self.assertEqual(report.parsing_errors, [])
+        self.assertEqual(report.passed_checks, [])
+        self.assertEqual(report.skipped_checks, [])
+        report.print_console()
+
     def test_runner_passing_check(self):
         current_dir = os.path.dirname(os.path.realpath(__file__))
         valid_dir_path = current_dir + "/resources/expose_port/pass"