From a6edcb7c91c6bbf56769240e9b285227fd97d1bf Mon Sep 17 00:00:00 2001 From: PunGrumpy <108584943+PunGrumpy@users.noreply.github.com> Date: Sun, 12 Jul 2026 00:45:39 +0700 Subject: [PATCH 1/4] fix(core): filter option flags from FROM instruction parsing in pinImageVersion --- packages/core/src/rules/security.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/rules/security.ts b/packages/core/src/rules/security.ts index 7ba1ef3..4e93163 100644 --- a/packages/core/src/rules/security.ts +++ b/packages/core/src/rules/security.ts @@ -113,9 +113,9 @@ export const pinImageVersion: DockerfileRule = { // FROM image or FROM image:tag or FROM image@sha256:hash // Also respect multi-stage builds (AS stageName) const parts = inst.args.split(/\s+/u); - const [imagePart] = parts; + const imagePart = parts.find((p) => !p.startsWith("--")); - if (imagePart === "scratch") { + if (!imagePart || imagePart === "scratch") { continue; } From 83b932e9f3fd969fec4c52f61796cf60a52890c2 Mon Sep 17 00:00:00 2001 From: PunGrumpy <108584943+PunGrumpy@users.noreply.github.com> Date: Sun, 12 Jul 2026 00:45:42 +0700 Subject: [PATCH 2/4] fix(core): filter option flags from FROM instruction parsing in preferSlimBase --- packages/core/src/rules/image-size.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/rules/image-size.ts b/packages/core/src/rules/image-size.ts index a502c8d..23e8d4a 100644 --- a/packages/core/src/rules/image-size.ts +++ b/packages/core/src/rules/image-size.ts @@ -16,8 +16,9 @@ export const preferSlimBase: DockerfileRule = { for (const inst of instructions) { if (inst.instruction === "FROM") { - const [imagePart] = inst.args.split(/\s+/u); - if (imagePart === "scratch") { + const parts = inst.args.split(/\s+/u); + const imagePart = parts.find((p) => !p.startsWith("--")); + if (!imagePart || imagePart === "scratch") { continue; } From 9c43363ee693a4ba28aea4ecd522c93d085893fe Mon Sep 17 00:00:00 2001 From: PunGrumpy <108584943+PunGrumpy@users.noreply.github.com> Date: Sun, 12 Jul 2026 00:45:45 +0700 Subject: [PATCH 3/4] fix(core): filter option flags from COPY and ADD instruction parsing in orderLayers --- packages/core/src/rules/performance.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/core/src/rules/performance.ts b/packages/core/src/rules/performance.ts index 3b96d30..750ce18 100644 --- a/packages/core/src/rules/performance.ts +++ b/packages/core/src/rules/performance.ts @@ -57,8 +57,11 @@ export const orderLayers: DockerfileRule = { for (const inst of instructions) { if (inst.instruction === "COPY" || inst.instruction === "ADD") { const parts = inst.args.split(/\s+/u); - // If copying the current directory (e.g., COPY . .) - const [src] = parts; + const src = parts.find((p) => !p.startsWith("--")); + + if (!src) { + continue; + } if ( (src === "." || src === "./" || src === "*" || src.includes("src")) && From 553d249cf8bfe44e2e7708aea1afb70a27b8fe64 Mon Sep 17 00:00:00 2001 From: PunGrumpy <108584943+PunGrumpy@users.noreply.github.com> Date: Sun, 12 Jul 2026 00:49:31 +0700 Subject: [PATCH 4/4] chore(changeset): add changeset for FROM and COPY option flag parsing --- .changeset/fix-from-copy-option-parsing.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-from-copy-option-parsing.md diff --git a/.changeset/fix-from-copy-option-parsing.md b/.changeset/fix-from-copy-option-parsing.md new file mode 100644 index 0000000..a9b21ff --- /dev/null +++ b/.changeset/fix-from-copy-option-parsing.md @@ -0,0 +1,5 @@ +--- +"@docker-doctor/cli": patch +--- + +Fix `FROM` and `COPY`/`ADD` instruction parsing in rules to correctly skip option flags (e.g. `--platform`, `--chown`), preventing false-positive diagnostics or layer ordering check failures.