go-pin-versions
What it does
Section titled “What it does”Reports a go install or go get of a package without a version, or at latest or none (example.com/tool@latest). example.com/tool@v1.4.0 is pinned. A path that starts with . or / (a package of the current module) is not reported.
Why it matters
Section titled “Why it matters”@latest builds whatever release is newest on the day of the build, so the tool in the image changes between builds and a new release can fail or behave differently. Without any version, go install uses the version in the go.mod of the working directory (and fails when there is none), and go get moves it to the latest release. In both cases the Dockerfile does not say which version ends up in the image.
Write the version: go install example.com/tool@v1.4.0.
Example
Section titled “Example”...RUN gem install --source https://rubygems.org rails:7.0RUN gem install rails:7.0RUN gem install rails -v 7.0RUN go install example.com/xRUN go install example.com/x@v1RUN go install example.com/x@latestConfiguration
Section titled “Configuration”dockerfile: lint: rules: go-pin-versions: warn # off (default), warn, errorEnabled by the presets: dockerfile/hadolint.
Suppress one line with sudsy-disable-next-line go-pin-versions in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| hadolint | DL3062 |
partial | go install and go get; go run is not checked. |