dockerfile-base-image-digest-pin
Dockerfile
FROMbase images are pinned by@sha256:digest.
Runs under: @noctcore/harness lint-meta, not ESLint · Factory: createDockerfileBaseImageDigestPinRule from @noctcore/lint-meta-rules · Category: ci · Fails CI by default: yes
FROM node:22-slim names whatever the registry serves at build time, so two builds of one commit can
differ and a moved tag ships a change nobody reviewed. tag@sha256:<digest> keeps the tag for readers
and fixes the bytes.
What it flags
Section titled “What it flags”Every FROM whose image has no @sha256: digest. Exempt: FROM scratch and FROM <earlier stage>.
An image chosen through a build arg (FROM ${BASE}) is resolved from its ARG BASE=<default> before
the first FROM; one that cannot be resolved is reported, since the text does not show what is
pulled. Each violation carries the 1-indexed line.
# BadFROM node:22-slim AS deps
# GoodFROM node:22-slim@sha256:<digest> AS depsFROM deps AS buildFROM scratchWhat it does not flag
Section titled “What it does not flag”FROM scratchandFROM <earlier stage>(a name given by a previousAS).FROM ${BASE}whoseARG BASE=<default>before the firstFROMis digest-pinned.- Dockerfiles under any
skipDirssegment (node_modules,.git,dist,.turbo,coverage) and files thedockerfileGlobsdo not match. - A
FROMsplit with a line continuation (\): it is not read. Add aContainerfileglob if you use Podman naming.
Options
Section titled “Options”createDockerfileBaseImageDigestPinRule(options?: DockerfileBaseImageDigestPinOptions): IMetaRule| Option | Type | Default | Meaning |
|---|---|---|---|
dockerfileGlobs |
string[] |
Dockerfile, Dockerfile.*, *.Dockerfile at any depth, dot-directories included |
Dockerfiles to scan. |
skipDirs |
string[] |
['node_modules', '.git', 'dist', '.turbo', 'coverage'] |
A path with any of these segments is skipped. |
ciCritical |
boolean |
true |
Whether a violation fails CI. |
When not to use it
Section titled “When not to use it”If your images are built only for local development and you accept whatever a tag serves at build time, skip it.