Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dockerfile: don't allow non-Dockerfile syntax for directives #5646

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

tonistiigi
Copy link
Member

regression from #4962

ParseDirectives code was changed when "check" directive was added and copied over logic from DetectSyntax function. This does not look correct as the only allowed formatting for Dockerfile directives is with a Dockerfile comment. "#syntax" is a special case because we want to allow frontend forwarding capability also in non-Dockerfile sources that use different style of comments or using config files with JSON as frontend entrypoints.

Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lint issue: https://github.com/moby/buildkit/actions/runs/12719620183/job/35460112008?pr=5646#step:4:484

  > [linux/amd64->freebsd/amd64 golangci-lint 1/1] RUN --mount=target=/go/src/github.com/moby/buildkit     --mount=target=/root/.cache,type=cache,id=lint-cache-default-freebsd/amd64   xx-go --wrap &&   golangci-lint run --build-tags "" &&   touch /golangci-lint.done:
746.9 frontend/dockerfile/parser/directives_test.go:147:2: ineffectual assignment to ref (ineffassign)
746.9 	ref, _, _, ok = ParseDirective("check", []byte(dt))
746.9 	^

ParseDirectives code was changed when "check" directive was added and
copied over logic from DetectSyntax function. This does not look correct
as the only allowed formatting for Dockerfile directives is with a
Dockerfile comment. "#syntax" is a special case because we want to
allow frontend forwarding capability also in non-Dockerfile sources that
use different style of comments or using config files with JSON as
frontend entrypoints.

Signed-off-by: Tonis Tiigi <[email protected]>
@tonistiigi tonistiigi force-pushed the directive-parse-format-fix branch from 525856e to a3adbd6 Compare January 13, 2025 19:12
@tonistiigi tonistiigi added this to the v0.19.0 milestone Jan 14, 2025
@crazy-max crazy-max merged commit fa5aead into moby:master Jan 14, 2025
98 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants