Fix how the version override is provided to the install script - #79
Conversation
📝 WalkthroughWalkthroughThe Docker build now uses the default Kubescape installer for ChangesKubescape installation
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Max Goisser <[email protected]>
6cae5e1 to
fbe5de0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with 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.
Inline comments:
In `@Dockerfile`:
- Around line 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.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| 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 |
There was a problem hiding this comment.
🩺 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.
| 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.
matthyx
left a comment
There was a problem hiding this comment.
Verified by building the Dockerfile with --build-arg KUBESCAPE_VERSION=v4.0.11 (the exact scenario from #78): the installed binary now correctly reports v4.0.11 instead of silently pulling latest. KUBESCAPE_VERSION=latest path (used implicitly since action.yml always resolves latest to a concrete tag before build) still works too.
The install.sh script only accepts a version via the -v getopt flag (never read KUBESCAPE_VERSION from env), so this fix is correct. LGTM, no blockers.
Resolves #78
Summary by CodeRabbit
latestversion setting.