[ZEPPELIN-6204] do not allow init params in JDBC URLs for H2#4949
Conversation
|
I don't know whether we are preventing features that others want to use with these changes. Doesn't it make more sense to secure the H2 server according to the requirements? After all, Zeppelin is just one JDBC client of many. |
|
Just a small thought. I was wondering if decoding the full URL before parsing could lead to unexpected behavior in some edge cases. For example, if a parameter value contains encoded characters like I’m not sure if values like passwords are actually allowed or commonly used in this context, so this might not be relevant. But I thought it was worth mentioning just in case. 🙏 |
| private static final String ALLOW_LOAD_LOCAL = "allowLoadLocal"; | ||
|
|
||
| private static final String ALLOW_LOAD_LOCAL_IN_FILE_NAME = "allowLoadLocalInfile"; | ||
|
|
||
| private static final String AUTO_DESERIALIZE = "autoDeserialize"; | ||
| private static final String ALLOW_LOAD_LOCAL_IN_FILE_IN_PATH = "allowLoadLocalInfileInPath"; | ||
|
|
||
| private static final String ALLOW_LOCAL_IN_FILE_NAME = "allowLocalInfile"; | ||
|
|
||
| private static final String ALLOW_URL_IN_LOCAL_IN_FILE_NAME = "allowUrlInLocalInfile"; | ||
|
|
||
| private static final String AUTO_DESERIALIZE = "autoDeserialize"; | ||
|
|
||
| private static final String SOCKET_FACTORY = "socketFactory"; | ||
|
|
||
| private static final String INIT = "INIT"; | ||
|
|
There was a problem hiding this comment.
could be nice to group these into a Set.
There was a problem hiding this comment.
I'm happy to stick with the existing code style.
| } | ||
|
|
||
| // Split the URL into the base part and the parameters part | ||
| String[] parts = url.split("[?&;]"); |
There was a problem hiding this comment.
could be a bit faster if the regex was cached to avoid rebuilding every time
There was a problem hiding this comment.
the cost of this regex will be tiny compared to the I/O cost of using JDBC commands so I'm not very interested in optimising every line of code here
The code in this PR ignores the param values. It only worries about the param names. |
|
@pjfanning Thanks for the clarification. I took a closer look and you're right. Decoding encoded special characters in values before validation would at most introduce an extra key, but it does not interfere with the parsing of subsequent parameters. I had initially worried about false negatives (i.e. cases where disallowed parameters might go undetected), but that doesn't seem to be the case. Thanks again, and sorry for the confusion. |
fd38a07 to
fbcec66
Compare
|
@jongyoul do you think this could be merged? |
|
I’ve merged this into master. |
|
Thanks @tbonelee - I would regard it more as a bug fix or fixes. It shouldn't change the behaviour for any use cases that we want to support. |
What is this PR for?
ZEPPELIN-6204
Slight tidy of the existing disallow list for strings in JDBC urls so that they are checked against just the query params and not the hostname in the URL.
What type of PR is it?
Bug Fix
Todos
What is the Jira issue?
How should this be tested?
Screenshots (if appropriate)
Questions: