diff --git a/Dockerfile b/Dockerfile index 4eedb03..88b23e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,27 +42,47 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* # ---- Static binaries -------------------------------------------------------- -# kubectl (checksum verified) +# All binaries below are checksum verified against the upstream release. +# kubectl RUN set -eux; \ curl -fsSLo /usr/local/bin/kubectl "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${TARGETARCH}/kubectl"; \ echo "$(curl -fsSL "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${TARGETARCH}/kubectl.sha256") /usr/local/bin/kubectl" | sha256sum -c -; \ chmod +x /usr/local/bin/kubectl -# yq (YAML processor) +# yq (YAML processor). The checksums file lists many hash algorithms per binary; +# the column for SHA-256 is found via checksums_hashes_order. RUN set -eux; \ - curl -fsSLo /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${TARGETARCH}"; \ - chmod +x /usr/local/bin/yq + base="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}"; \ + curl -fsSLo /tmp/yq "${base}/yq_linux_${TARGETARCH}"; \ + col="$(curl -fsSL "${base}/checksums_hashes_order" | grep -nx 'SHA-256' | cut -d: -f1)"; \ + want="$(curl -fsSL "${base}/checksums" | awk -v f="yq_linux_${TARGETARCH}" -v c="$((col + 1))" '$1 == f {print $c}')"; \ + test -n "$want"; \ + echo "${want} /tmp/yq" | sha256sum -c -; \ + install -m 0755 /tmp/yq /usr/local/bin/yq; \ + rm -f /tmp/yq -# grpcurl (gRPC debugging; release uses x86_64 / arm64 naming) +# grpcurl (gRPC debugging; release uses x86_64 / arm64 naming), checksum verified RUN set -eux; \ case "${TARGETARCH}" in amd64) A=x86_64;; arm64) A=arm64;; *) echo "unsupported arch ${TARGETARCH}"; exit 1;; esac; \ - curl -fsSL "https://github.com/fullstorydev/grpcurl/releases/download/v${GRPCURL_VERSION}/grpcurl_${GRPCURL_VERSION}_linux_${A}.tar.gz" \ - | tar -xz -C /usr/local/bin grpcurl + base="https://github.com/fullstorydev/grpcurl/releases/download/v${GRPCURL_VERSION}"; \ + f="grpcurl_${GRPCURL_VERSION}_linux_${A}.tar.gz"; \ + curl -fsSLo "/tmp/${f}" "${base}/${f}"; \ + want="$(curl -fsSL "${base}/grpcurl_${GRPCURL_VERSION}_checksums.txt" | awk -v f="${f}" '$2 == f {print $1}')"; \ + test -n "$want"; \ + echo "${want} /tmp/${f}" | sha256sum -c -; \ + tar -xz -C /usr/local/bin -f "/tmp/${f}" grpcurl; \ + rm -f "/tmp/${f}" -# stern (multi-pod log tailing) +# stern (multi-pod log tailing), checksum verified RUN set -eux; \ - curl -fsSL "https://github.com/stern/stern/releases/download/v${STERN_VERSION}/stern_${STERN_VERSION}_linux_${TARGETARCH}.tar.gz" \ - | tar -xz -C /usr/local/bin stern + base="https://github.com/stern/stern/releases/download/v${STERN_VERSION}"; \ + f="stern_${STERN_VERSION}_linux_${TARGETARCH}.tar.gz"; \ + curl -fsSLo "/tmp/${f}" "${base}/${f}"; \ + want="$(curl -fsSL "${base}/checksums.txt" | awk -v f="${f}" '$2 == f {print $1}')"; \ + test -n "$want"; \ + echo "${want} /tmp/${f}" | sha256sum -c -; \ + tar -xz -C /usr/local/bin -f "/tmp/${f}" stern; \ + rm -f "/tmp/${f}" # ---- Shell experience ------------------------------------------------------- COPY motd.txt /etc/motd