Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
FROM alpine:latest
ARG KUBESCAPE_VERSION=latest
RUN apk add --no-cache git bash curl jq
RUN curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | KUBESCAPE_VERSION=${KUBESCAPE_VERSION} /bin/bash
RUN if [ "${KUBESCAPE_VERSION}" = "latest" ]; then \
curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash; \
else \
curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash -s -- -v "${KUBESCAPE_VERSION}"; \
fi
Comment on lines +4 to +8

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Fail the build when the installer download fails.

Both branches pipe curl -s into Bash. If the download fails because of a network or DNS error, Bash can receive empty input and return success. The Docker build can then produce an image without Kubescape.

Download the script with curl -fsSL before executing it, or enable pipeline failure handling.

Proposed fix
-RUN if [ "${KUBESCAPE_VERSION}" = "latest" ]; then \
-      curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash; \
-    else \
-      curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash -s -- -v "${KUBESCAPE_VERSION}"; \
-    fi
+RUN curl -fsSL https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh -o /tmp/kubescape-install.sh && \
+    if [ "${KUBESCAPE_VERSION}" = "latest" ]; then \
+      /bin/bash /tmp/kubescape-install.sh; \
+    else \
+      /bin/bash /tmp/kubescape-install.sh -v "${KUBESCAPE_VERSION}"; \
+    fi && \
+    rm -f /tmp/kubescape-install.sh
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN if [ "${KUBESCAPE_VERSION}" = "latest" ]; then \
curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash; \
else \
curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash -s -- -v "${KUBESCAPE_VERSION}"; \
fi
RUN curl -fsSL https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh -o /tmp/kubescape-install.sh && \
if [ "${KUBESCAPE_VERSION}" = "latest" ]; then \
/bin/bash /tmp/kubescape-install.sh; \
else \
/bin/bash /tmp/kubescape-install.sh -v "${KUBESCAPE_VERSION}"; \
fi && \
rm -f /tmp/kubescape-install.sh
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile` around lines 4 - 8, Update the Kubescape installer commands in
both branches of the Dockerfile conditional to use curl failure handling, such
as -fsSL, before piping the downloaded script to Bash, ensuring network, DNS,
and HTTP download failures cause the Docker build to fail.

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Loading