fix(core): extract a shared image-reference parser#16
Open
PunGrumpy wants to merge 2 commits into
Open
Conversation
…and stage aliases Extract a shared parseImageRef/collectStageAliases helper and use it in pinImageVersion and preferSlimBase, replacing manual first-colon splitting that misread registry ports as tags, digest pins as untagged/non-slim images, and multi-stage aliases as bare image names.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extracts a single, correct image-reference parser (
parseImageRef+collectStageAliasesin@docker-doctor/core) and rewritespin-image-versionandprefer-slim-baseto use it, replacing two hand-rolled "split on the first:" implementations that each produced wrong diagnostics.Implements plan 004. Depends on 002 (CLI integration tests) and 003 (rule-specificity fixes to
security.ts).Why
Both rules split image references on the first
:, producing four distinct wrong answers:FROM myregistry.example.com:5000/team/app— registry port read as the tag, so a fully-untagged image was treated as pinned.pin-image-version(the flagship security rule) returned nothing on private-registry images.FROM node@sha256:…— the:insidesha256:matched the split, soprefer-slim-basewarned that a gold-standard digest pin "may be a full-OS distribution". TheisShaguard was unreachable.FROM builder(stage alias) andFROM ${NODE_IMAGE}(ARG-driven) — both produced bogus "does not specify a tag" warnings, so every multi-stage Dockerfile that names its stages got spurious output.Behavior change (why the changeset)
.changeset/shy-lemons-parse.md→@docker-doctor/clipatch. Diagnostics change on Dockerfiles using registry ports, digest pins, and multi-stage aliases. Verified live against the built CLI:FROM myregistry.example.com:5000/team/apppin-image-versionfires ✓FROM node@sha256:…prefer-slim-basefiredFROM node:22-alpine AS build/FROM buildbuildFROM node:22prefer-slim-basefires ✓FROM node:latestpin-image-version+prefer-slim-base✓Division of labor (preserved deliberately)
pin-image-versionowns "is it pinned";prefer-slim-baseowns "is the pinned thing slim".prefer-slim-basenow stays silent on untagged images so one problem isn't double-penalized.Tests
packages/core/test/image-ref.test.ts— table-driven unit tests forparseImageRef(9 rows) andcollectStageAliases(3 cases).pin-image-version(+4) andprefer-slim-base(+3) inrules.test.ts— purely additive, no existing assertion changed.ultracite check0.Stacking
Base is
advisor/003-fix-rule-specificity-bugs(PR #15), which itself stacks onadvisor/002-...(PR #14) — both prerequisites are still open. GitHub auto-retargets this PR tomainonce #14 and #15 merge. Merge order: #14 → #15 → this.🤖 Generated with Claude Code