Skip to content

Sanitize buildah image tag derived from build-context basename#25

Merged
Alex-XJK merged 1 commit into
mainfrom
release/v0.6.1-andy
Jul 19, 2026
Merged

Sanitize buildah image tag derived from build-context basename#25
Alex-XJK merged 1 commit into
mainfrom
release/v0.6.1-andy

Conversation

@Alex-XJK

Copy link
Copy Markdown
Owner

waypoint build derived the buildah tag as 'waypoint_:' without sanitizing the context directory's basename. A basename ending in a separator (e.g. tempfile.mkdtemp dirs like 'img3_4l96kk1_') or containing uppercase/other invalid characters produced a reference buildah rejects with "invalid reference format", aborting the build.

Sanitize the basename via imageRefComponent(): lowercase, collapse runs of disallowed characters to '-', trim trailing separators, and fall back to a short sha1 hash when nothing usable remains, so the result always matches the Docker/buildah name-component grammar.

Add build_test.go covering a basename that ends in '_' and contains an uppercase letter, plus the hash-fallback case.

waypoint build derived the buildah tag as 'waypoint_<basename>:<ts>' without sanitizing the context directory's basename. A basename ending in a separator (e.g. tempfile.mkdtemp dirs like 'img3_4l96kk1_') or containing uppercase/other invalid characters produced a reference buildah rejects with "invalid reference format", aborting the build.

Sanitize the basename via imageRefComponent(): lowercase, collapse runs of disallowed characters to '-', trim trailing separators, and fall back to a short sha1 hash when nothing usable remains, so the result always matches the Docker/buildah name-component grammar.

Add build_test.go covering a basename that ends in '_' and contains an uppercase letter, plus the hash-fallback case.
@Alex-XJK
Alex-XJK merged commit 1110972 into main Jul 19, 2026
3 checks passed
@Alex-XJK
Alex-XJK deleted the release/v0.6.1-andy branch July 19, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants