Prewarm Go dependencies for TW tasks#14
Conversation
| && wget -q https://go.dev/dl/go1.23.1.linux-amd64.tar.gz -O /tmp/go.tar.gz \ | ||
| && tar -C /usr/local -xzf /tmp/go.tar.gz \ | ||
| && rm /tmp/go.tar.gz \ |
There was a problem hiding this comment.
No checksum verification on Go tarball download
The tarball is fetched from go.dev/dl/ over HTTPS and extracted immediately without verifying a SHA-256 digest against a known-good value. A compromised CDN response or a partial download would be extracted silently; tar accepts partial archives as long as the stream doesn't terminate mid-block. The official Go download page publishes SHA-256 digests for every release — adding a sha256sum --check step before tar would close this gap and is a standard practice in secure Dockerfiles that fetch remote binaries.
Prompt To Fix With AI
This is a comment left during a code review.
Path: data/tw/task-6902ef3ab97fe23e2ad27209/environment/Dockerfile
Line: 11-13
Comment:
**No checksum verification on Go tarball download**
The tarball is fetched from `go.dev/dl/` over HTTPS and extracted immediately without verifying a SHA-256 digest against a known-good value. A compromised CDN response or a partial download would be extracted silently; `tar` accepts partial archives as long as the stream doesn't terminate mid-block. The official Go download page publishes SHA-256 digests for every release — adding a `sha256sum --check` step before `tar` would close this gap and is a standard practice in secure Dockerfiles that fetch remote binaries.
How can I resolve this? If you propose a fix, please make it concise.| RUN if ! command -v go >/dev/null 2>&1; then \ | ||
| apt-get update \ | ||
| && apt-get install -y --no-install-recommends ca-certificates wget \ | ||
| && wget -q https://go.dev/dl/go1.23.1.linux-amd64.tar.gz -O /tmp/go.tar.gz \ | ||
| && tar -C /usr/local -xzf /tmp/go.tar.gz \ | ||
| && rm /tmp/go.tar.gz \ | ||
| && rm -rf /var/lib/apt/lists/*; \ | ||
| fi \ | ||
| && PATH="/usr/local/go/bin:${PATH}" go mod download |
There was a problem hiding this comment.
Conditional install may silently use wrong Go version
The guard if ! command -v go >/dev/null 2>&1 skips installation whenever any go binary is on the PATH — regardless of version. The comment states the intent is to install "the version used by the task's test runner" (1.23.1), but if the base image happens to ship Go at a different version the condition will pass, go mod download will run with that version, and the ENV PATH extension will simply prepend the non-existent /usr/local/go/bin without error. The baked module cache may then be incompatible with whatever go the agent or verifier actually resolves at runtime. Pinning the check to the exact version string (e.g. go version | grep -q go1.23.1) would make this intent explicit and enforceable.
Prompt To Fix With AI
This is a comment left during a code review.
Path: data/tw/task-6902ef3ab97fe23e2ad27209/environment/Dockerfile
Line: 8-16
Comment:
**Conditional install may silently use wrong Go version**
The guard `if ! command -v go >/dev/null 2>&1` skips installation whenever any `go` binary is on the PATH — regardless of version. The comment states the intent is to install "the version used by the task's test runner" (1.23.1), but if the base image happens to ship Go at a different version the condition will pass, `go mod download` will run with that version, and the `ENV PATH` extension will simply prepend the non-existent `/usr/local/go/bin` without error. The baked module cache may then be incompatible with whatever `go` the agent or verifier actually resolves at runtime. Pinning the check to the exact version string (e.g. `go version | grep -q go1.23.1`) would make this intent explicit and enforceable.
How can I resolve this? If you propose a fix, please make it concise.| RUN if ! command -v go >/dev/null 2>&1; then \ | ||
| apt-get update \ | ||
| && apt-get install -y --no-install-recommends ca-certificates wget \ | ||
| && wget -q https://go.dev/dl/go1.23.1.linux-amd64.tar.gz -O /tmp/go.tar.gz \ |
There was a problem hiding this comment.
Architecture hard-coded to
linux-amd64
The tarball name go1.23.1.linux-amd64.tar.gz will install the wrong binary — or fail at runtime under non-emulated execution — if the Docker build ever runs on an ARM64 host. The 37 other tasks rely on whatever Go the base image ships (which is presumably already arch-appropriate), but this task installs from a fixed URL. Consider using $(dpkg --print-architecture) or $(uname -m) to derive the correct suffix, or document the assumption that build infrastructure is always x86-64.
Prompt To Fix With AI
This is a comment left during a code review.
Path: data/tw/task-6902ef3ab97fe23e2ad27209/environment/Dockerfile
Line: 11
Comment:
**Architecture hard-coded to `linux-amd64`**
The tarball name `go1.23.1.linux-amd64.tar.gz` will install the wrong binary — or fail at runtime under non-emulated execution — if the Docker build ever runs on an ARM64 host. The 37 other tasks rely on whatever Go the base image ships (which is presumably already arch-appropriate), but this task installs from a fixed URL. Consider using `$(dpkg --print-architecture)` or `$(uname -m)` to derive the correct suffix, or document the assumption that build infrastructure is always x86-64.
How can I resolve this? If you propose a fix, please make it concise.
Summary
docker_imagefrom all 38 TW Go task configs so Harbor builds each task DockerfileGOPROXY=offandGOSUMDB=offValidation
docker_imagegit diff --checkGreptile Summary
This PR prewarns Go dependencies for all 38 TW Go tasks by moving from a pre-built Harbor image (referenced via
docker_imageintask.toml) to a built-on-demand Dockerfile that runsgo mod downloadat image-build time and then forces offline resolution at runtime withGOPROXY=offandGOSUMDB=off.WORKDIR /app,RUN go mod download, andENV GOPROXY=off GOSUMDB=off; eachtask.tomldrops thedocker_imageline to trigger a Harbor build.grafana_grafana): extends the pattern with a conditional Go 1.23.1 installation fromgo.dev/dl/, patching the PATH for both theRUNstep and the final environment — this is the only file with meaningful divergence from the template.task.tomlfiles: the sole change in each is removingdocker_image; no other configuration fields are touched.Confidence Score: 4/5
Safe to merge. The 37 standard Dockerfiles are straightforward and the approach is validated by the 38-task test run described in the PR.
The change is mechanically consistent across all 38 tasks and the author has run a full validation sweep. The only non-trivial file is the Grafana grafana Dockerfile, which has three minor hardening gaps: no SHA-256 check on the downloaded Go binary, the architecture is hardcoded to amd64, and the version guard doesn't enforce the specific 1.23.1 release if Go is already present in the image. None of these would break existing runs, but they are worth closing before the pattern is reused or the image is built on different hardware.
data/tw/task-6902ef3ab97fe23e2ad27209/environment/Dockerfile is the only file that warrants a second look; all other Dockerfiles and task.tomls are templated and consistent.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Harbor image build triggered\nby absence of docker_image in task.toml] --> B{Is this grafana_grafana?} B -- No --> C[FROM pre-built base image\nWORKDIR /app] B -- Yes --> D[FROM pre-built base image\nWORKDIR /app] D --> E{go already on PATH?} E -- No --> F[apt-get install wget ca-certs\nwget go1.23.1.linux-amd64.tar.gz\ntar -C /usr/local -xzf\nPATH prepended] E -- Yes --> G[Skip install, use existing go] F --> H[go mod download] G --> H C --> I[go mod download] H --> J[ENV GOPROXY=off\nGOSUMDB=off\nPATH patched] I --> K[ENV GOPROXY=off\nGOSUMDB=off] J --> L[Agent / verifier runs\nAll deps resolved from image cache only] K --> L%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD A[Harbor image build triggered\nby absence of docker_image in task.toml] --> B{Is this grafana_grafana?} B -- No --> C[FROM pre-built base image\nWORKDIR /app] B -- Yes --> D[FROM pre-built base image\nWORKDIR /app] D --> E{go already on PATH?} E -- No --> F[apt-get install wget ca-certs\nwget go1.23.1.linux-amd64.tar.gz\ntar -C /usr/local -xzf\nPATH prepended] E -- Yes --> G[Skip install, use existing go] F --> H[go mod download] G --> H C --> I[go mod download] H --> J[ENV GOPROXY=off\nGOSUMDB=off\nPATH patched] I --> K[ENV GOPROXY=off\nGOSUMDB=off] J --> L[Agent / verifier runs\nAll deps resolved from image cache only] K --> LPrompt To Fix All With AI
Reviews (1): Last reviewed commit: "Prewarm Go dependencies for TW tasks" | Re-trigger Greptile