LuciferYang commented on code in PR #12036:
URL: https://github.com/apache/gravitino/pull/12036#discussion_r3600542081


##########
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:
   Done in b92808dd0 — the message now reports the user-supplied key (e.g. 
`DRIVERCLASSNAME`) rather than the canonical driverClassName, and the 
case-insensitive tests assert the as-typed key. Thanks!



##########
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:
   Done in b92808dd0, the message now reports the user-supplied key (e.g. 
`DRIVERCLASSNAME`) rather than the canonical driverClassName, and the 
case-insensitive tests assert the as-typed key. Thanks!



-- 
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]

Reply via email to