Purge Go module cache from cosmovisor-installing images - #3355
Purge Go module cache from cosmovisor-installing images#3355UnbornAztecKing wants to merge 1 commit into
Conversation
The go install cosmovisor step in these testing Dockerfiles resolves cosmovisor's dependency graph and downloads full Go module source into /go/pkg/mod, which is committed into the shipped image. That source tree includes npm lockfiles (e.g. cosmos-sdk's docs/package-lock.json), which surface as SCA findings for build-time deps that are never installed or run at runtime (e.g. axios via wait-on via Docusaurus). Append 'go clean -modcache' in the same RUN layer so the cosmovisor binary survives in /go/bin while the module cache is never committed. Must be same-layer: image scanners inspect per-layer, so a later cleanup would not remove it from the earlier layer.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughEight Dockerfiles across protocol/testing directories are modified to combine the existing ChangesDockerfile modcache cleanup
Estimated code review effort: 1 (Trivial) | ~4 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
|
Tick the box to add this pull request to the merge queue (same as
|
What it is
Strips the Go module cache out of the container images that install
cosmovisor, so downloaded module source (including npm lockfiles like cosmos-sdk'sdocs/package-lock.json) is never committed into the shipped image.The
RUN go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.5.0step resolves cosmovisor's dependency graph and writes full module source into/go/pkg/mod, which persists in the image layer. That tree carries build-time npm manifests that SCA scanners flag even though the code is never installed (node_modules), loaded, or run at runtime.Concretely this closes the Wiz finding for axios
0.25.0(CVE-2026-42043) at/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.46.0-beta2.../docs/package-lock.jsoninmainnet-full-node. Dependency chain:cosmovisor v1.5.0 (indirect)→ cosmos-sdk module source →docs/Docusaurus 2.4.1 →@docusaurus/core→wait-on@6.0.1→axios@0.25.0. None of that is on the node's runtime path.The base image (
dydxprotocol-base, from the multi-stageprotocol/Dockerfile) already ships only the compiled binary with a cache-mounted modcache — so thego install cosmovisorlayer is the sole source of these artifacts.The change
Append
&& go clean -modcacheto the cosmovisor install, in the same RUN layer:RUN go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.5.0 && go clean -modcacheThe cosmovisor binary lands in
/go/bin(on PATH) and survives; the module cache is wiped before the layer is committed. Same-layer is required — scanners inspect per-layer, so a cleanup in a later layer would leave the artifact in the earlier one./go/pkg/modno longer committed; source manifests goneReviewer brief
Eight
protocol/testing/*/Dockerfiles, identical one-line change each. The load-bearing one ismainnet/Dockerfile(buildsmainnet-full-node). No source or dependency changes.Out of scope
protocol/scripts/create_full_node.sh— installs cosmovisor on a host VM, not a container layer; intentionally left unchanged.docs/off Docusaurus 2.4.1 (which is what actually pulls axios) — separate hygiene follow-up; not required to close this finding.Test plan
mainnet-full-nodeand confirmcosmovisorruns (entrypoint unaffected)/go/pkg/modis absent in the built imageSummary by CodeRabbit