-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Issue #439 Strip out double quotes in ARG value #834
Issue #439 Strip out double quotes in ARG value #834
Conversation
* Strip out double quotes enclosing ARG value after parsing dockerfile
pkg/dockerfile/dockerfile.go
Outdated
return stages, metaArgs, nil | ||
} | ||
|
||
// stripEnclosingDoubleQuotes removes double quotes enclosing the value of each instructions.ArgCommand in a slice | ||
func stripEnclosingDoubleQuotes(metaArgs []instructions.ArgCommand) []instructions.ArgCommand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add table driven unit tests here for this function only
- value like
"foo"
- For empty value
""
? What happens then?
maybe we shd keep quotes as is then? - value
foo
- invalid value
"foo
shd probably error out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some other test cases to add would be
5. When metaArgs
is empty
6. Multiple mataArgs
instructions have ""
. (All get resolved)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just something to consider, something like \"foo\"
would probably need to maintain the quotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add table driven unit tests here for this function only
- value like
"foo"
- For empty value
""
? What happens then?
maybe we shd keep quotes as is then?- value
foo
- invalid value
"foo
shd probably error out?
- Docker seems to strip out the quotes and treat it as a valid, but blank string
- Yup, Docker also seems to error when either quote isn't matched
We also might want to handle single quotes as docker seems to handle those as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just something to consider, something like
\"foo\"
would probably need to maintain the quotes
Ya, it seems that Docker does not remove the quotes in that case which will result in an error for things like image name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't look thoroughly at this, but this may be what docker uses to resolve quotes, which we could potentially use as well to ensure we respond to this as docker does
@priyawadhwa kaniko is currently using that same package to do the variable expansion. I was surprised that it doesn't seem to be handling the quotes, but I didn't see anything in the documentation referring to that. I did notice that in a recent version (later than what kaniko seems to be using) that |
Yah that sounds like it could be! We could definitely bump up the version if you think that would work |
Unfortunately doesn't seem to be related
|
026bffd
to
ac2821f
Compare
Add additional tests to ensure that ARG values with quotes are handled properly
ac2821f
to
ec2e770
Compare
Fixes #439
Description
Strip out double quotes enclosing ARG value after parsing Dockerfile. This brings Kaniko into parity with Docker for handling ARG values. This prevents failures where things like image names would not parse correctly due to the double quotes remaining.
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Reviewer Notes
Release Notes
Describe any changes here so maintainer can include it in the release notes, or delete this block.