Repository: bridgecrewio/checkov

Issue:
CKV_DOCKER_11 false positive when `--platform` is used
**Describe the issue**

CKV_DOCKER_11 false positive when `--platform` is used (possibly other arguments as well)

For reference: _"CKV_DOCKER_11: "Ensure From Alias are unique for multistage builds."_  In other words, make sure you add `as myAlias` at the end of your `FROM` line

**Examples**

This will PASS as expected:
`FROM node:16 as build`

Now, add `--platform` and it will FAIL:
`FROM --platform=linux/amd64 node:16 as build`

**Version (please complete the following information):**
```
> checkov -v      
2.3.240
```

**Additional context**
Add any other context about the problem here.



Discussion:
hey @LinguineCode thanks for reaching out.

I tried to reproduce it, but the mentioned check is passing for me. Can you please provide your `checkov` version and if possible a more complete example?
> hey @LinguineCode thanks for reaching out.
> 
> I tried to reproduce it, but the mentioned check is passing for me. Can you please provide your `checkov` version and if possible a more complete example?

My pleasure, here you go:

> ```
> > checkov -v
> 2.3.240
> ```

> ```
> > checkov --quiet -f Dockerfile
> dockerfile scan results:
> 
> Passed checks: 6, Failed checks: 1, Skipped checks: 0
> 
> Check: CKV_DOCKER_11: "Ensure From Alias are unique for multistage builds."
> 	FAILED for resource: Dockerfile.FROM
> 	File: Dockerfile:1-1
> 	Guide: https://docs.bridgecrew.io/docs/ensure-docker-from-alias-is-unique-for-multistage-builds
> 
> 		1 | FROM --platform=linux/amd64 node:16 as FOO
>
> >
> ```

Here's the `Dockerfile`:
```Dockerfile
FROM --platform=linux/amd64 node:16 as FOO
RUN npm install

FROM --platform=linux/amd64 node:16 as BAR
RUN npm run

USER nobody
HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1

CMD mycommand.sh
```
thanks, that did the trick 😄 

Resolving patch:
diff --git a/checkov/dockerfile/checks/AliasIsUnique.py b/checkov/dockerfile/checks/AliasIsUnique.py
--- a/checkov/dockerfile/checks/AliasIsUnique.py
+++ b/checkov/dockerfile/checks/AliasIsUnique.py
@@ -24,13 +24,12 @@ def scan_resource_conf(self, conf: list[_Instruction]) -> tuple[CheckResult, lis
         alias = []
         for instruction in conf:
             if " as " in instruction["value"]:
-                temp = instruction["value"].split()
-                alias += [temp[2]]
+                alias.append(instruction["value"].rsplit(maxsplit=1)[-1])
 
         if len(alias) == len(set(alias)):
             return CheckResult.PASSED, None
-        else:
-            return CheckResult.FAILED, [conf[0]]
+
+        return CheckResult.FAILED, [conf[0]]
 
 
 check = AliasIsUnique()


Test patch:
diff --git a/tests/dockerfile/checks/example_AliasIsUnique/success_platform/Dockerfile b/tests/dockerfile/checks/example_AliasIsUnique/success_platform/Dockerfile
new file mode 100644
--- /dev/null
+++ b/tests/dockerfile/checks/example_AliasIsUnique/success_platform/Dockerfile
@@ -0,0 +1,10 @@
+FROM --platform=linux/amd64 node:16 as FOO
+RUN npm install
+
+FROM --platform=linux/amd64 node:16 as BAR
+RUN npm run
+
+USER nobody
+HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1
+
+CMD mycommand.sh
diff --git a/tests/dockerfile/checks/test_AliasIsUnique.py b/tests/dockerfile/checks/test_AliasIsUnique.py
--- a/tests/dockerfile/checks/test_AliasIsUnique.py
+++ b/tests/dockerfile/checks/test_AliasIsUnique.py
@@ -15,14 +15,17 @@ def test(self):
         report = runner.run(root_folder=test_files_dir, runner_filter=RunnerFilter(checks=[check.id]))
         summary = report.get_summary()
 
-        passing_resources = {"/success/Dockerfile."}
+        passing_resources = {
+            "/success/Dockerfile.",
+            "/success_platform/Dockerfile.",
+        }
         failing_resources = {"/failure/Dockerfile.FROM"}
 
-        passed_check_resources = set([c.resource for c in report.passed_checks])
-        failed_check_resources = set([c.resource for c in report.failed_checks])
+        passed_check_resources = {c.resource for c in report.passed_checks}
+        failed_check_resources = {c.resource for c in report.failed_checks}
 
-        self.assertEqual(summary["passed"], 1)
-        self.assertEqual(summary["failed"], 1)
+        self.assertEqual(summary["passed"], len(passing_resources))
+        self.assertEqual(summary["failed"], len(failing_resources))
         self.assertEqual(summary["skipped"], 0)
         self.assertEqual(summary["parsing_errors"], 0)