You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/10/22 09:17:11 UTC

[GitHub] [inlong] github-code-scanning[bot] commented on a diff in pull request #6265: [INLONG-6264][Sort] Support TiDB

github-code-scanning[bot] commented on code in PR #6265:
URL: https://github.com/apache/inlong/pull/6265#discussion_r1002425906


##########
inlong-sort/sort-connectors/tidb/src/main/java/io/tidb/bigdata/jdbc/LoadBalancingDriver.java:
##########
@@ -0,0 +1,271 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.tidb.bigdata.jdbc;
+
+import static io.tidb.bigdata.jdbc.ExceptionHelper.call;
+import static io.tidb.bigdata.jdbc.ExceptionHelper.stringify;
+import static io.tidb.bigdata.jdbc.ExceptionHelper.uncheckedCall;
+import static java.util.Objects.requireNonNull;
+
+import io.tidb.bigdata.jdbc.impl.DiscovererImpl;
+import io.tidb.bigdata.jdbc.impl.RandomShuffleUrlMapper;
+import io.tidb.bigdata.jdbc.impl.RoundRobinUrlMapper;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
+import java.util.logging.Logger;
+
+public class LoadBalancingDriver implements Driver {
+  private static final Logger logger = Logger.getLogger(LoadBalancingDriver.class.getName());
+
+  private static final String MYSQL_URL_PREFIX = "jdbc:mysql://";
+  /**
+   * The value is set by {@link System#setProperty(String, String)}
+   */
+  private static final String TIDB_URL_MAPPER = "tidb.jdbc.url-mapper";
+  /**
+   * The value is set by {@link System#setProperty(String, String)}
+   */
+  private static final String URL_PROVIDER = "url.provider";
+  /**
+   * The value is set by {@link System#setProperty(String, String)}
+   */
+  private static final String TIDB_MIN_DISCOVER_INTERVAL_KEY = "tidb.jdbc.min-discovery-interval";
+  private static final long TIDB_MIN_DISCOVER_INTERVAL = 10000;
+  /**
+   * The value is set by {@link System#setProperty(String, String)}
+   */
+  private static final String TIDB_MAX_DISCOVER_INTERVAL_KEY = "tidb.jdbc.max-discovery-interval";
+  private static final long TIDB_MAX_DISCOVER_INTERVAL = 3600000;
+  private static final String MYSQL_DRIVER_NAME;
+  private static final String NEW_MYSQL_DRIVER_NAME = "com.mysql.cj.jdbc.Driver";
+  private static final String OLD_MYSQL_DRIVER_NAME = "com.mysql.jdbc.Driver";
+
+  private static final Base64.Encoder base64Encoder = Base64.getEncoder();
+  private static final AtomicInteger threadId = new AtomicInteger();
+  private static final ThreadLocal<MessageDigest> digestThreadLocal =
+      ThreadLocal.withInitial(() -> uncheckedCall(() -> MessageDigest.getInstance("md5")));

Review Comment:
   ## Use of a broken or risky cryptographic algorithm
   
   Cryptographic algorithm [md5](1) is weak and should not be used.
   
   [Show more details](https://github.com/apache/inlong/security/code-scanning/39)



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org