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

hadolint halts if the character after a heredoc close is not whitespace, reports an invalid error #99

Open
bzip2 opened this issue Aug 21, 2024 · 0 comments

Comments

@bzip2
Copy link

bzip2 commented Aug 21, 2024

When hadolint (2.12.1) parses a heredoc RUN or COPY command, it checks the character that follows the command (i.e., right after the second instance of the identifier/delimiter/keyword), unless it's at the end of the file. If that character is not whitespace, hadolint reports an error, um, erroneously.

Basically the same bug was reported last year but in the hadolint/hadolint repo. I'm fairly sure the bug stems from Language/Docker/Parser/Prelude.hs. It doesn't matter if the unrelated character is part of a comment or a command, but obviously it's unrelated.

Minimal example of failure:

FROM scratch
RUN  <<EOR
echo "asdf"
EOR
# 

dd:5:1 unexpected '#' expecting a new line followed by the next instruction

This works:

FROM scratch
RUN  <<EOR
echo "asdf"
EOR
 #

The same goes for heredoc COPY commands/instructions. This fails:

FROM nginx
COPY <<EOF /usr/share/nginx/html/index.html
(your index page goes here)
EOF
#
COPY <<EOF /usr/share/nginx/html/index.html
(your index page goes here)
EOF
copy.dockerfile:6:1 unexpected '#' expecting a new line followed by the next instruction

But this works:

FROM nginx
COPY <<EOF /usr/share/nginx/html/index.html
(your index page goes here)
EOF
 #
COPY <<EOF /usr/share/nginx/html/index.html
(your index page goes here)
EOF

copy.dockerfile:1 DL3006 warning: Always tag the version of an image explicitly

Thanks.

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

No branches or pull requests

1 participant