-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
KAFKA-3692: Add quotes to variables in kafka-run-class.sh #1364
Conversation
It would be good to explain the purpose of doing this. |
@ijuma @ewencp @granders @hachikuji Please review this. We did a check whether |
Thanks @Ishiihara. Are they needed everywhere or just in conditions? |
@ijuma I think it is a good practice to use the double quotes if we are unsure about whether there are spaces or not. |
Someone who is more of an expert in shell scripting should probably review this. Have you tested that this works correctly when the path is already quoted? |
We are currently running muckrake with this change. https://jenkins.confluent.io/job/system-test-confluent-platform-branch-builder/28/console |
@ijuma By "double-quoted", do you mean something like
If this is what you mean, this is not a problem. Double quotes as I understand it cause bash to interpret certain symbols as ordinary characters rather than program symbols to be parsed. |
@ijuma @granthenke It would definitely be more robust to spaces in path names to have In general, given how surprising and quirky bash can be, and the fact that most people (including myself) have a very superficial knowledge of it, we should probably at the very least incorporate a bash linter like the one @gwenshap mentioned (I think this one: https://github.com/koalaman/shellcheck) |
Thanks for the explanation @granders |
This seems fine to me, unless we also want to also add the fix KAFKA-1508. |
IMHO, since this is a major release, now is the time to quote all variable references. This script is effectively a Kafka API much like the other APIs. I think users are willing to accept some breaking changes if they happen for a good reason, not that this should break anything. Hopefully, people aren't already relying on the variables not being quoted but if they are, asking them to change that assumption is ok for a major release with the justification that not relying on subtle bash expansion rules is a much more robust API. With a combination of quoting all variable references and checking for file existence before adding files to the classpath, I don't think there's any need to depend on whether nullglob is enabled or disabled. It shouldn't matter. Specifically, a file exists check should be added to the |
We are on a fourth (going on fifth) release candidate of a major release. We need to stabilize the release as much as possible. |
Stabilizing is the priority as you said. I view this more as a security fix than a scope expansion. Not quoting variable references is like allow XSSing, SQL injection, etc. in a product. I think it's worth plugging such holes. |
2c5833f
to
dda32cc
Compare
@Ishiihara reverted the patch to dda32cc, and both of us have been doing a mix of manual and automated verification on this:
|
@granders @gwenshap @ijuma @theduderog Thanks for all the reviews and suggestions. I made the suggested modifications and add quotes to all variables in all scripts. However, with this change, we do see some unexpected behaviors:
If we double quote To avoid unexpected behavior, we decided to roll back to dda32cc To ensure that the changes are working @granders and I did a couple of manual tests. The things I did includes the following:
|
do | ||
CLASSPATH=$CLASSPATH:$dir/* | ||
CLASSPATH="$CLASSPATH:$dir/*" |
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.
In line 98, we quote $CLASSPATH
and $file
separately while here we quote both variables together. Is it because of the *
?
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 believe the two forms are equivalent
Thanks for the thorough testing. There were a couple of cosmetic questions, but changing that would invalidate part of the testing and given the brittleness of this code, I think we should just merge as is. LGTM. |
Author: Liquan Pei <[email protected]> Reviewers: Geoff Anderson <[email protected]>, Jun Rao <[email protected]>, Ismael Juma <[email protected]> Closes #1364 from Ishiihara/add-quote-classpath (cherry picked from commit fb421db) Signed-off-by: Ismael Juma <[email protected]>
Merged to trunk and 0.10.0 branches. |
Author: Liquan Pei <[email protected]> Reviewers: Geoff Anderson <[email protected]>, Jun Rao <[email protected]>, Ismael Juma <[email protected]> Closes apache#1364 from Ishiihara/add-quote-classpath
…h an AdminClient (apache#1364)
No description provided.