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

False positive flagged if quotes used when replacing variables in an ARG, ENV, or LABEL #36

Closed
rcjsuen opened this issue Apr 19, 2018 · 3 comments
Assignees
Labels

Comments

@rcjsuen
Copy link
Owner

rcjsuen commented Apr 19, 2018

The following Dockerfile will built without any problems. We need to fix the validator so that it doesn't consider the ENV instruction to be an error.

FROM scratch
ARG BUNDLE_WITHOUT
ENV BUNDLE_WITHOUT=${bundle_without:-'development test'}
$ dockerfile-utils lint Dockerfile
Line: 3
ENV BUNDLE_WITHOUT=${bundle_without:-'development test'}
                                                       ^
Error: Syntax error - can't find = in "}". Must be of the form: name=value
$ docker build .
Sending build context to Docker daemon  1.693MB
Step 1/3 : FROM scratch
 --->
Step 2/3 : ARG BUNDLE_WITHOUT
 ---> Running in 7cc436e68ec3
Removing intermediate container 7cc436e68ec3
 ---> 64a3e0a2f136
Step 3/3 : ENV BUNDLE_WITHOUT=${bundle_without:-'development test'}
 ---> Running in c148dc76c691
Removing intermediate container c148dc76c691
 ---> a608dc772a5d
Successfully built a608dc772a5d
@rcjsuen rcjsuen added the bug label Apr 19, 2018
@rcjsuen rcjsuen self-assigned this Apr 19, 2018
@rcjsuen rcjsuen changed the title False positive flagged if quotes used when replacing variables in an ENV False positive flagged if quotes used when replacing variables in an ENV or a LABEL Apr 19, 2018
@rcjsuen
Copy link
Owner Author

rcjsuen commented Apr 19, 2018

Since ENV and LABEL is written in the same way, LABEL instructions also suffer from this same problem.

FROM scratch
LABEL BUNDLE_WITHOUT=${bundle_without:-'development test'}
$ dockerfile-utils lint Dockerfile
Line: 2
LABEL BUNDLE_WITHOUT=${bundle_without:-'development test'}
                                                         ^
Error: Syntax error - can't find = in "}". Must be of the form: name=value
$ docker build .
Sending build context to Docker daemon  1.695MB
Step 1/2 : FROM scratch
 --->
Step 2/2 : LABEL BUNDLE_WITHOUT=${bundle_without:-'development test'}
 ---> Running in 2714ad3002f9
Removing intermediate container 2714ad3002f9
 ---> 02682ef791a9
Successfully built 02682ef791a9

@rcjsuen
Copy link
Owner Author

rcjsuen commented Apr 19, 2018

I don't think any code changes will be necessary on this end. Should just need to adopt the new version of dockerfile-ast after rcjsuen/dockerfile-ast#24 has been fixed.

@rcjsuen
Copy link
Owner Author

rcjsuen commented Apr 19, 2018

Same problem applies to ARG instructions although the error isn't quite the same.

FROM scratch
ARG BUNDLE_WITHOUT=${bundle_without:-'development test'}
$ dockerfile-utils lint Dockerfile
Line: 2
ARG BUNDLE_WITHOUT=${bundle_without:-'development test'}
                                                       ^
Error: ARG requires exactly one argument
$ docker build .
Sending build context to Docker daemon  1.695MB
Step 1/2 : FROM scratch
 --->
Step 2/2 : ARG BUNDLE_WITHOUT=${bundle_without:-'development test'}
 ---> Running in 0ec9a4a58d65

Removing intermediate container 0ec9a4a58d65
 ---> 6e9479050949
Successfully built 6e9479050949

@rcjsuen rcjsuen changed the title False positive flagged if quotes used when replacing variables in an ENV or a LABEL False positive flagged if quotes used when replacing variables in an ARG, ENV, or LABEL Apr 19, 2018
rcjsuen added a commit that referenced this issue May 25, 2018
Signed-off-by: Remy Suen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant