Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(query): revert changes in the 'platform_flag_with_from' query #7117

Merged
merged 11 commits into from
Jun 12, 2024
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 cgr.dev/chainguard/go@sha256:38db527239c4b33c6ebd1751007041e33cdf81de45f2195b1a60816eb351def1 as build_env
FROM cgr.dev/chainguard/go@sha256:38db527239c4b33c6ebd1751007041e33cdf81de45f2195b1a60816eb351def1 as build_env

Check warning on line 1 in Dockerfile

View workflow job for this annotation

GitHub Actions / kics-scan

[LOW] Using Platform Flag with FROM Command

'FROM' instruction should use the flag '--platform'

# Copy the source from the current directory to the Working Directory inside the container
WORKDIR /app
Expand Down Expand Up @@ -31,7 +31,7 @@
# Runtime image
# Ignore no User Cmd since KICS container is stopped afer scan
# kics-scan ignore-line
FROM --platform=linux/amd64 cgr.dev/chainguard/git@sha256:9dc48ca2f9b643fffece0d7079f4e3b0b40e343de1c8f0f583db551d3df3c419
FROM cgr.dev/chainguard/git@sha256:9dc48ca2f9b643fffece0d7079f4e3b0b40e343de1c8f0f583db551d3df3c419

ENV TERM xterm-256color

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "b16e8501-ef3c-44e1-a543-a093238099c9",
"queryName": "Using Platform Flag with FROM Command",
"severity": "LOW",
"severity": "INFO",
"category": "Best Practices",
"descriptionText": "'FROM' instruction should use the flag '--platform'",
"descriptionText": "'FROM' instruction should not use the flag '--platform'",
"descriptionUrl": "https://docs.docker.com/engine/reference/builder/#from",
"platform": "Dockerfile",
"descriptionID": "5bd0baab",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import data.generic.common as common_lib
CxPolicy[result] {
resource := input.document[i].command[name][_]

common_lib.contains_element(resource.Value, "as")
contains(resource.Cmd, "from")
not common_lib.contains_with_size(resource.Flags, "--platform")
contains(resource.Flags[j], "--platform")
contains(resource.Cmd, "from")

result := {
"documentId": input.document[i].id,
"searchKey": sprintf("FROM={{%s}}.{{%s}}", [name, resource.Original]),
"issueType": "IncorrectValue",
"keyExpectedValue": sprintf("FROM={{%s}}.{{%s}} should use the flag '--platform'", [name, resource.Original]),
"keyActualValue": sprintf("FROM={{%s}}.{{%s}} not use the flag '--platform'", [name, resource.Original]),
"keyExpectedValue": sprintf("FROM={{%s}}.{{%s}} should not use the '--platform' flag", [name, resource.Original]),
"keyActualValue": sprintf("FROM={{%s}}.{{%s}} is using the '--platform' flag", [name, resource.Original]),
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[
{
"queryName": "Using Platform Flag with FROM Command",
"severity": "LOW",
"line": 6
"severity": "INFO",
"line": 6,
"fileName": "positive1.dockerfile"
}
]
Loading