Skip to content
DashboardWebsite

Dockerfile Pack

URL slug: dockerfile

The Dockerfile pack reviews changed build stages for security, performance, and reliability issues. It accepts a unified git diff or a complete Dockerfile. It checks for unpinned base images, unchecked downloads, secrets in the image, a final stage that runs as root, inefficient layer order, and shutdown signals that may not reach the process.

A diff file reaches this pack when its path matches one of these globs:

GlobMatches
*DockerfileDockerfile, services/api/Dockerfile
*Dockerfile.*Dockerfile.dev, docker/Dockerfile.prod
*.dockerfileworker.dockerfile
*ContainerfileContainerfile

BuildKit’s Dockerfile.dockerignore matches a glob, but the pack skips files ending in .dockerignore.

The pack also recognises a complete Dockerfile pasted on its own (sniff() returns 0.9). The content must start with FROM, optionally preceded by ARG instructions, and another Dockerfile instruction must follow the FROM. A Markdown page or SQL query that merely contains a FROM line does not match.

parse_dockerfile_input (opentremor_pack_dockerfile/parser.py) handles input in these steps:

  1. A complete Dockerfile becomes a diff that adds every line. Both input types then use the same stage splitter and rules.
  2. The parser reads a diff file by file with core’s split_unified_diff and iter_hunks (opentremor_core.libs.diff). It joins each file’s hunks in order and inserts a line containing only @@ where the diff skips lines.
  3. Each FROM line opens a stage. A stage runs up to the next FROM. When a diff replaces a FROM line (-FROM node:18 then +FROM node:20), both lines stay in one stage. Changed lines before the first FROM shown in the input form an unknown unit. These lines may be the end of a stage whose FROM is above the diff or global ARG lines.
  4. The parser keeps only stages with a real change. Core’s change_kind sets each unit’s action.
Unittypename
FROM golang:1.23 AS build, followed by another stagestagebuild
FROM gcr.io/distroless/static:nonroot, the last stagefinal-stagegcr.io/distroless/static:nonroot
Changed lines before any FROM shown in the inputstage or final-stageunknown

The parser marks the last stage that survives the change as final-stage; rules treat it as the image that ships. A diff may stop before the end of the file, so a later stage may exist that the diff does not show. Rules about the final stage therefore have MEDIUM confidence at most.

Markers in the stageaction
+ onlyadd
- onlydelete
bothmodify
{
"hash": "<sha256 of the normalised body>",
"type": "final-stage",
"name": "node:20-slim",
"action": "add",
"body": "+FROM node:20-slim\n+WORKDIR /app\n+CMD npm start",
"metadata": {
"generated_at_utc": "2026-10-26T10:30:00Z",
"source_path": "services/api/Dockerfile",
"group_path": null
}
}

source_path comes from the diff header’s b/... side. It is null for a complete Dockerfile. group_path is always null.

The body keeps its +, -, and space markers. A rule such as “the diff removes the USER line” needs to distinguish a removed line from an unchanged one.

Rules live as Markdown in the package’s opentremor_pack_dockerfile/rules/ directory:

FileServed at
dockerfile-rules.mdGET /v1/dockerfile/rules
Rule IDAreaWhat it catches
DOCK-001Supply chainA changed FROM line uses a mutable tag without a digest, or pulls from a registry outside the default list (which orgs can replace).
DOCK-003Supply chainADD fetches a remote URL without --checksum=sha256:....
DOCK-004Supply chainA RUN command downloads a script, archive, or binary and uses it without an integrity check.
DOCK-007Supply chainA package manager uses plain HTTP or has signature checks disabled.
DOCK-005SecretsARG or ENV carries a secret, or COPY or ADD brings in a secret file.
DOCK-006SecretsA stage copies a secret file or directory from an earlier stage.
DOCK-010SecretsThe diff removes a RUN --mount=type=secret and passes the same secret another way.
DOCK-011SecretsThe final stage copies the whole build context; asks the reader to check .dockerignore.
DOCK-002PrivilegeThe final stage runs as root or the diff removes the line that dropped privileges.
DOCK-008PrivilegeA command makes a path world-writable.
DOCK-009PrivilegeThe final stage installs an SSH server or sudo.
DOCK-012Build commandsA RUN command expands a build argument without quotes.
DOCK-PERF-001 to -004PerformanceDependency layer order, apt lists, build tools in the runtime image, or caches and build outputs shipped in the image.
DOCK-REL-001, -002ReliabilityThe diff removes HEALTHCHECK; shell-form CMD or ENTRYPOINT may not pass SIGTERM.

Performance and Reliability rules have LOW or MEDIUM severity and do not fail the merge check on their own. Core syncs built-in rules from the pack file for orgs that have not edited them (OpenTremor-core#0034).

diff --git a/services/api/Dockerfile b/services/api/Dockerfile
new file mode 100644
--- /dev/null
+++ b/services/api/Dockerfile
@@ -0,0 +1,10 @@
+FROM node:20 AS build
+ARG NPM_TOKEN
+WORKDIR /app
+COPY . .
+RUN echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc && npm ci
+
+FROM node:20-slim
+COPY --from=build /app /app
+RUN curl -fsSL https://get.example.com/agent/install.sh | sh
+CMD npm start

The parser creates two units, both with action add:

  • A stage named build. The LLM matches DOCK-005 because the build argument is written to .npmrc. It also matches DOCK-001 because node:20 has no digest, and DOCK-PERF-001 because COPY . . comes before npm ci.
  • A final-stage named node:20-slim. The LLM matches DOCK-006 because the copied /app contains the token, DOCK-004 because the command pipes a download to sh, DOCK-002 because the stage has no USER, and DOCK-REL-002 because CMD uses shell form.

The pack includes a similar demo sample so an org can review example findings before connecting a repository.