-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[ZEPPELIN-6095] validate decoded url in jdbc interpreter #4838
[ZEPPELIN-6095] validate decoded url in jdbc interpreter #4838
Conversation
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.
The code looks good and works as intended!
I’ve checked that URLs with unallowable configurations, whether they are URL-encoded or contain white spaces, are properly blocked.
Btw, I'm curious-do we really need to remove white spaces here?
Can't we just leave the white spaces in the middle of the URL as is and let JDBC appropriately throw an error?
I have the same question too. Is there any potential risk if we have encoded while spaces in the JDBC URL? In Apache Kyuubi cases, it allows the user to pass the
For example,
|
@tbonelee @pan3793 I put the eliminating white spaces logic to block the unallowable configurations with white space included such as : The URL with eliminating white spaces is used only when validating, not when creating connection with the URL. So I think it does not cause risky situation like a URL containing white space is not connected. However I confirmed that if user put url with white space contained, the configuration does not apply and JDBC throws an error. So I will remove the eliminating white spaces logic. |
9328c68
to
29d4921
Compare
containsIgnoreCase(url, ALLOW_URL_IN_LOCAL_IN_FILE_NAME)) { | ||
String decodedUrl; | ||
try { | ||
decodedUrl = URLDecoder.decode(url, "UTF-8"); |
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.
If we wait for #4882 we can use decode(String s, Charset charset)
URLDecoder
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.
oh, I didn't noticed that decode(String s, Charser charset)
doesn't exist in JAVA8. Thank you for letting me know.
Then, if #4882 merged into master, I will request approval again
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.
#4882 was merged into master. Please use StandardCharsets as second input Parameter.
some thoughts:
|
containsIgnoreCase(url, ALLOW_URL_IN_LOCAL_IN_FILE_NAME)) { | ||
String decodedUrl; | ||
try { | ||
decodedUrl = URLDecoder.decode(url, "UTF-8"); |
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.
#4882 was merged into master. Please use StandardCharsets as second input Parameter.
|
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.
Minor adjustment necessary.
containsIgnoreCase(url, ALLOW_URL_IN_LOCAL_IN_FILE_NAME)) { | ||
String decodedUrl; | ||
try { | ||
decodedUrl = URLDecoder.decode(url, StandardCharsets.UTF_8.toString()); |
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.
decodedUrl = URLDecoder.decode(url, StandardCharsets.UTF_8.toString()); | |
decodedUrl = URLDecoder.decode(url, StandardCharsets.UTF_8); |
should be sufficient. Check https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/URLDecoder.html
LGTM, I have no further concerns. |
Thanks for @Reamer, I fix 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 have checked out your pull request, please perform a git rebase on the current master so that your pull request benefits from the JDK 11 transition.
@@ -42,6 +42,9 @@ | |||
import org.slf4j.LoggerFactory; | |||
|
|||
import java.io.IOException; | |||
import java.io.UnsupportedEncodingException; |
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.
Unnecessary import.
String decodedUrl; | ||
decodedUrl = URLDecoder.decode(url, StandardCharsets.UTF_8); | ||
|
||
if (containsIgnoreCase(decodedUrl, ALLOW_LOAD_LOCAL_IN_FILE_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.
Wrong indentation
if (containsIgnoreCase(decodedUrl, ALLOW_LOAD_LOCAL_IN_FILE_NAME) || | |
if (containsIgnoreCase(decodedUrl, ALLOW_LOAD_LOCAL_IN_FILE_NAME) || |
eecf6c5
to
b22eafe
Compare
@Reamer |
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.
LGTM
### What is this PR for? Add some validation check conditions to existing url validator in jdbc interpreter. So now it can check URLs with the conditions below if it has an unallowable configuration. - UTF-8 encoded ### What type of PR is it? Improvement ### Todos * [ ] - Task ### What is the Jira issue? [ZEPPELIN-6095](https://issues.apache.org/jira/browse/ZEPPELIN-6095) ### How should this be tested? Input the url with unallowable configurations in UTF-8 encoded in JDBC type interpreter. Then run the command in notebook and see if the command is blocked from running. ### Screenshots (if appropriate) ### Questions: * Does the license files need to update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Closes #4838 from s2moon98/add-jdbc-interpreter-url-validate. Signed-off-by: Philipp Dallig <philipp.dallig@gmail.com> (cherry picked from commit e463373) Signed-off-by: Philipp Dallig <philipp.dallig@gmail.com>
Merged into master/branch-0.12 |
What is this PR for?
Add some validation check conditions to existing url validator in jdbc interpreter. So now it can check URLs with the conditions below if it has an unallowable configuration.
What type of PR is it?
Improvement
Todos
What is the Jira issue?
ZEPPELIN-6095
How should this be tested?
Input the url with unallowable configurations in UTF-8 encoded in JDBC type interpreter. Then run the command in notebook and see if the command is blocked from running.
Screenshots (if appropriate)
Questions: