yuqi1129 commented on code in PR #12036:
URL: https://github.com/apache/gravitino/pull/12036#discussion_r3599906168
##########
catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/utils/DataSourceUtils.java:
##########
@@ -92,6 +115,30 @@ private static Properties getProperties(JdbcConfig
jdbcConfig) {
return properties;
}
+ /**
+ * Rejects DBCP2 connection-pool properties that would let catalog
configuration run arbitrary
+ * classes on the server: {@code connectionFactoryClassName}, {@code
evictionPolicyClassName} and
+ * {@code driverClassName} (class names loaded via reflection), plus {@code
initialSize} (blocked
+ * as defense in depth to keep pool creation lazy).
+ *
+ * @param config the JDBC configuration properties forwarded to the DBCP2
factory
+ * @throws GravitinoRuntimeException if an unsafe connection-pool property
is present
+ */
+ private static void rejectUnsafePoolProperties(Map<String, String> config) {
+ if (config == null) {
+ return;
+ }
+ for (String key : config.keySet()) {
+ for (String unsafe : UNSAFE_POOL_PROPERTIES) {
+ if (unsafe.equalsIgnoreCase(key)) {
+ throw new GravitinoRuntimeException(
Review Comment:
A minor suggestion: Since you use `equalsIgnoreCase` here, and
`DRIVERCLASSNAME` and `driverClassName` will be treated as equal, I suggest you
use the user value in the error message.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]