Harden CI downloads by adding checksum verification - #489
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e90e16a7e2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| $(cat kubernetes-server-${os}-${arch}.tar.gz.sha256) kubernetes-server-${os}-${arch}.tar.gz | ||
| EOF |
There was a problem hiding this comment.
Re-indent heredoc body to keep workflow YAML valid
The heredoc payload is flush-left inside the run: | block, so YAML parsing treats $(cat kubernetes-server-...) as a new top-level key instead of script content. In my local check (ruby/Psych), this file fails to parse with could not find expected ':' at this line, which means GitHub Actions cannot load this workflow as written and the Unit test job will not run. The same indentation issue appears again in the second heredoc block.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR hardens the CI “Unit test” job by verifying checksums for externally downloaded build/test tooling (kubebuilder, Kubernetes tarballs, etcd) before extracting or executing them, reducing supply-chain risk in the GitHub Actions workflow.
Changes:
- Adds
set -euo pipefailand normalizesos/archfromgo envfor consistent artifact naming. - Replaces
curl -L -Owith strictercurlflags that fail on HTTP/network errors. - Verifies downloaded artifacts using
sha256sum --checkagainst published checksum files before extraction.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/workflow.yaml |
Updates the kubebuilder/tools install step to enforce stricter shell behavior, hardened downloads, and checksum verification. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
.github/workflows/workflow.yaml:103
kubectlis chmod'd atkubernetes/client/bin/kubectl, but later the workflow installskubectlfromkubernetes/server/bin/kubectl. This makes the chmod a no-op and could leave the installedkubectlwithout the expected executable bit. Use the same source path consistently for chmod + mv (client or server).
chmod +x "kubebuilder_${os}_${arch}"
chmod +x kubernetes/server/bin/kube-apiserver
chmod +x kubernetes/client/bin/kubectl
chmod +x "etcd-v${ETCD_VERSION}-${os}-${arch}/etcd"
- Files reviewed: 1/1 changed files
- Comments generated: 1
| "https://dl.k8s.io/v${KUBERNETES_VERSION}/kubernetes-client-${os}-${arch}.tar.gz" | ||
| curl --fail --show-error --silent --location --remote-name \ | ||
| "https://dl.k8s.io/v${KUBERNETES_VERSION}/kubernetes-client-${os}-${arch}.tar.gz.sha256" | ||
| sha256sum --check --status <<EOF | ||
| $(cat kubernetes-client-${os}-${arch}.tar.gz.sha256) kubernetes-client-${os}-${arch}.tar.gz | ||
| EOF | ||
|
|
||
| curl --fail --show-error --silent --location --remote-name \ | ||
| "https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz" | ||
| curl --fail --show-error --silent --location --remote-name \ | ||
| "https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/SHA256SUMS" | ||
| grep " etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz$" SHA256SUMS | sha256sum --check --status | ||
|
|
||
| tar -zxvf "kubernetes-server-${os}-${arch}.tar.gz" | ||
| tar -zxvf "kubernetes-client-${os}-${arch}.tar.gz" | ||
| tar -zxvf "etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz" | ||
|
|
||
| chmod +x "kubebuilder_${os}_${arch}" | ||
| chmod +x kubernetes/server/bin/kube-apiserver | ||
| chmod +x kubernetes/client/bin/kubectl |
There was a problem hiding this comment.
The workflow downloads and verifies the Kubernetes client tarball, but the only subsequent reference is a chmod on kubernetes/client/bin/kubectl (the installed kubectl comes from the server tree). If the client tarball isn't needed, dropping its download/verify/extract will reduce CI time and surface area; otherwise, install kubectl from the client tarball consistently.
This issue also appears on line 99 of the same file.
| "https://dl.k8s.io/v${KUBERNETES_VERSION}/kubernetes-client-${os}-${arch}.tar.gz" | |
| curl --fail --show-error --silent --location --remote-name \ | |
| "https://dl.k8s.io/v${KUBERNETES_VERSION}/kubernetes-client-${os}-${arch}.tar.gz.sha256" | |
| sha256sum --check --status <<EOF | |
| $(cat kubernetes-client-${os}-${arch}.tar.gz.sha256) kubernetes-client-${os}-${arch}.tar.gz | |
| EOF | |
| curl --fail --show-error --silent --location --remote-name \ | |
| "https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz" | |
| curl --fail --show-error --silent --location --remote-name \ | |
| "https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/SHA256SUMS" | |
| grep " etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz$" SHA256SUMS | sha256sum --check --status | |
| tar -zxvf "kubernetes-server-${os}-${arch}.tar.gz" | |
| tar -zxvf "kubernetes-client-${os}-${arch}.tar.gz" | |
| tar -zxvf "etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz" | |
| chmod +x "kubebuilder_${os}_${arch}" | |
| chmod +x kubernetes/server/bin/kube-apiserver | |
| chmod +x kubernetes/client/bin/kubectl | |
| "https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz" | |
| curl --fail --show-error --silent --location --remote-name \ | |
| "https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/SHA256SUMS" | |
| grep " etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz$" SHA256SUMS | sha256sum --check --status | |
| tar -zxvf "kubernetes-server-${os}-${arch}.tar.gz" | |
| tar -zxvf "etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz" | |
| chmod +x "kubebuilder_${os}_${arch}" | |
| chmod +x kubernetes/server/bin/kube-apiserver |
There was a problem hiding this comment.
lgtm, with this we can just close without merging - #488
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
e90e16a to
2d6d000
Compare
Motivation
Unit testjob are verified before extraction or execution while preserving the existing installation behavior and versions.Description
Install kubebuilderstep in.github/workflows/workflow.yamlto start withset -euo pipefailand to computeosandarchfromgo envfor consistent filenames.curl -L -Oinvocations withcurl --fail --show-error --silent --location --remote-nameto fail loudly on network errors.kubebuilder_${os}_${arch}againstchecksums.txt, for Kubernetes server/client tarballs against their.sha256files usingsha256sum --check, and for the etcd tarball againstSHA256SUMS./usr/local/kubebuilder/bin) and preserved the pinnedKUBEBUILDER_VERSION,KUBERNETES_VERSION, andETCD_VERSIONvalues.Testing
nl/sedto confirm the newInstall kubebuilderblock is present and well-formed, and this check succeeded.rgforsha256sum --check,checksums.txt, andSHA256SUMSto validate checksum checks were added, and this search succeeded.pythonscript that callsyaml.safe_load, but the environment lacksPyYAMLso YAML parsing could not be executed.Codex Task