Mutable reference scan¶
Which references does Aval report, and what can it miss? The full rules behind Pin your dependencies.
How the scan works¶
- It reads files only; it never fetches, resolves or runs anything.
- At most 1 MiB per file. A bigger or unreadable file it should check is a
scanfinding that cannot be accepted: shrink or split it. - Lockfiles (
pnpm-lock.yaml,go.sum,Cargo.lock, ...) are hashed, not scanned.
Python¶
- Generate the file:
uv pip compile --generate-hashes requirements.in -o requirements.txt, thenpip install --require-hashes -r requirements.txt. - Once one entry of a requirements file has a hash, every entry needs one.
- Any
requirements*.txtpath is checked, alsorequirements/dev.txt. - Poetry needs
poetry.lockand PipenvPipfile.locknext to the manifest. Apyproject.tomlwith[project]dependencies needsuv.lock,pdm.lockorpoetry.lock, next to it or at the workspace root. - A file named by
pip install -r/-c, or by an include line inside a requirements file (resolved next to that file), must be in the scope, or it is reported.
Container images¶
- Images in test code: in
*.go,*.py,*.java,*.kt,*.ts,*.jsand*.csfiles that mention testcontainers, a quotedname:tagwithout a digest (PostgresContainer("postgres:16")). Alocalhost, dotted or 4+ digithost:portliteral ("localhost:5432","127.0.0.1:8080","db:5432"), a clock time ("12:30"), asha256:digest, a literal with a space or a scheme, and a name without a tag are not reported. Any other quotedname:tag, such as"classpath:schema.sql", is reported and can be accepted inscope.allowMutable; an image whose tag is 4 or more digits without a registry ("app:2024") is taken for ahost:portand not reported. - Images in
docker run,podman run,docker composeandkubectl run/create --imagecommands. A compose file the command uses must be inscope.source; it can be YAML or JSON (compose.json). - An image from a variable Aval cannot resolve (
${DB_IMAGE}), a Helm template ({{ .Values.image }}), a YAML alias, block scalar or tag (image: *img,image: >-,image: !!str ...) is reported: write the reference inline, or render the chart into the scope. - Dockerfiles are read twice. The line pass reads each line as an
instruction (continuations joined with a space,
RUNheredocs as scripts). The BuildKit pass splits the file as BuildKit does, for files namedDockerfile,Dockerfile.*,*.dockerfile,Dockerfileplus a name without a dot (Dockerfile-dev), and the same withContainerfile: comment lines stand alone, continuations join with nothing between (FROM db:1\then6isdb:16),# escape=sets the escape character (continuations and heredoc words), heredoc bodies are kept apart. - Both passes treat
COPY --from=andRUN --mount=...,from=like aFROM: a stage name or index is fine, an image needs a digest. An instruction behindONBUILDis checked like the same one without it. - The BuildKit pass also reports a file BuildKit refuses (an invalid
# escape=, a repeated directive, an unterminated heredoc), a heredoc name with a quote,\or$, or an empty one, and aFROMimage with a variable that is not a globalARGwith a value (FROM alpine:$V): give the globalARGa default, or write the image. - Kustomize: an
images:(orimageTags:) entry withnewNameornewTagneeds adigest:. Reported by name and index (resources[2]): a remote or out-of-scoperesources,componentsorbasesentry (vendor it); a patch orreplacementsentry that sets an image, or is given by an out-of-scope path; atransformersorgeneratorsentry with an image transformer or an out-of-scope path; ahelmChartsentry, unless the chart is local (norepo,Chart.yamlin the scope underhelmGlobals.chartHome, defaultcharts, inside the kustomization directory) and novaluesInlinesets an image; anytagSuffix(kustomize drops the digest). An undecodable kustomization is reported by its path. The overlay is not built. - YAML is read twice: the line pass matches
image:on every line, also inside a block scalar a template renders; the parser matches every key that decodes toimage("ima\x67e":,? image,!!binary aW1hZ2U=:). A key with another tag, or one the parser cannot decode in a file it rejects, is reported; in*.tplfiles, files undertemplates/and rejected files, a key a template writes (ima{{ "ge" }}:) is reported by its text, except arangekey variable alone ({{ $key | quote }}:) directly underlabels:orannotations:. A Composebuild.dockerfile_inlineis checked as a Dockerfile, andbuild.additional_contextsvalues withdocker-image://as images. - JSON is read the same way, but only in Compose files, files under
templates/and files a kustomization in scope lists inresources.
Scripts¶
Reported, also in Dockerfile RUN lines and heredocs:
curl … | sh, also throughtee;bash -c "$(curl …)",python -c "$(curl …)",eval "$(curl …)";source <(wget …);releases/latestURLs.
Files scanned as scripts: *.sh, *.bash, *.zsh, *.mk, Makefile,
and in-scope files without an extension whose first line is a sh,
bash, zsh, ksh or dash shebang (./setup). A script with another extension is hashed but not
scanned.
scope.allowMutable¶
refis the text Aval prints: for a missing lockfile, the manifest path (go.mod); quotes in shell commands are dropped. A finding Aval reports because it cannot tell (a templated key,resources[2], a heredoc name, aFROMline) is in thecontainerecosystem, accepted by its printedref.fileis the path Aval prints before the line number, relative to the contract (runner.commandfor the command), and limits the entry to that file. Without it, arefthat two files report (resources[0]repeats) is not accepted, and the finding asks forfile.filesis a list of globs, matched likescope.source, instead offile(not both). The entry accepts its exactrefin every file in scope that a glob matches, never inrunner.command. Each glob must match a file in scope, or the contract is invalid (exit 2). There is norefwildcard: every accepted reference is one somebody wrote down.- With
scope.contracts, each contract's entries apply to its own findings. - It is part of the contract, so it changes the fingerprint and shows in review.
aval runstill prints the finding, marked(allowed: <reason>).
Limits¶
The scanner reads text and is a safety net, not a guarantee; the guarantee is the declared scope and the pins you write.
- Not detected: unversioned downloads other than
releases/latest(curl -o tool URL,curl URL | tar x); Helm values split intorepositoryandtag, or YAML a template prints; a JSON6902 patch file in the scope named bypath:; JSON outside the files above;--build-argvalues (theARGdefault is checked; outsideFROMthe last value of a name wins); the BuildKit pass on a source file named likedockerfile_test.go. - In test code: an image in a variable built from parts, in a constant
or helper in a file that does not mention testcontainers, a
module's default image (
PostgresContainer()without an image), the Ryuk reaper image, source files larger than 1 MiB or unreadable, and source in other languages or extensions (.rs,.mjs,.tsx,.groovy,.scala). Write the image with its digest ("postgres:16@sha256:<digest>"), or declare it inscope.resolve. - Shell commands are split without a full parser: a quoted
;or>also splits, which can cause needless misses. - An option Aval does not know to take a value
(
tool --opt value install x) hides the subcommand. - For the gaps, declare the reference in
scope.resolve(url,image) and runaval run --shadow.