From ee327cb8e8ede92a37ccb5818dd311f70a0885d4 Mon Sep 17 00:00:00 2001 From: lostsnow Date: Wed, 21 Sep 2022 19:09:25 +0800 Subject: [PATCH] fixes uninstall cause reinstall fail --- .../io/dongtai/iast/agent/manager/EngineManager.java | 1 - .../iast/agent/monitor/impl/PerformanceMonitor.java | 10 ++++++---- .../dongtai/iast/agent/util/http/HttpClientUtils.java | 6 +----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/dongtai-agent/src/main/java/io/dongtai/iast/agent/manager/EngineManager.java b/dongtai-agent/src/main/java/io/dongtai/iast/agent/manager/EngineManager.java index 884a604e7..022e2c782 100644 --- a/dongtai-agent/src/main/java/io/dongtai/iast/agent/manager/EngineManager.java +++ b/dongtai-agent/src/main/java/io/dongtai/iast/agent/manager/EngineManager.java @@ -511,7 +511,6 @@ private void uninstallObject(){ setINSTANCE(null); Base64Encoder.setInstance(null); AbstractTomcat.setTomcatVersion(null); - HttpClientUtils.setDoNotVerify(null); IastProperties.setInstance(null); } } diff --git a/dongtai-agent/src/main/java/io/dongtai/iast/agent/monitor/impl/PerformanceMonitor.java b/dongtai-agent/src/main/java/io/dongtai/iast/agent/monitor/impl/PerformanceMonitor.java index c427ba2fa..20ebbf5af 100644 --- a/dongtai-agent/src/main/java/io/dongtai/iast/agent/monitor/impl/PerformanceMonitor.java +++ b/dongtai-agent/src/main/java/io/dongtai/iast/agent/monitor/impl/PerformanceMonitor.java @@ -5,7 +5,8 @@ import io.dongtai.iast.agent.manager.EngineManager; import io.dongtai.iast.agent.monitor.IMonitor; import io.dongtai.iast.agent.monitor.MonitorDaemonThread; -import io.dongtai.iast.agent.monitor.collector.*; +import io.dongtai.iast.agent.monitor.collector.IPerformanceCollector; +import io.dongtai.iast.agent.monitor.collector.MetricsBindCollectorEnum; import io.dongtai.iast.agent.report.AgentRegisterReport; import io.dongtai.iast.agent.util.ThreadUtils; import io.dongtai.iast.common.entity.performance.PerformanceMetrics; @@ -17,9 +18,7 @@ import org.json.JSONObject; import java.io.*; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLEncoder; +import java.net.*; import java.util.ArrayList; import java.util.List; @@ -90,6 +89,9 @@ public static Integer getDiskUsage() { } public static List getPerformanceMetrics() { + if (PERFORMANCE_METRICS == null) { + PERFORMANCE_METRICS = new ArrayList(); + } return PERFORMANCE_METRICS; } diff --git a/dongtai-agent/src/main/java/io/dongtai/iast/agent/util/http/HttpClientUtils.java b/dongtai-agent/src/main/java/io/dongtai/iast/agent/util/http/HttpClientUtils.java index 89635b6fc..5ae556d8e 100644 --- a/dongtai-agent/src/main/java/io/dongtai/iast/agent/util/http/HttpClientUtils.java +++ b/dongtai-agent/src/main/java/io/dongtai/iast/agent/util/http/HttpClientUtils.java @@ -32,14 +32,10 @@ public class HttpClientUtils { private static final String REQUEST_HEADER_TOKEN_KEY = "Authorization"; private static final String REQUEST_ENCODING_TYPE = "gzip"; private static final String SSL_SIGNATURE = "TLSv1.2"; - public static HostnameVerifier DO_NOT_VERIFY = new HttpClientHostnameVerifier(); + private final static HostnameVerifier DO_NOT_VERIFY = new HttpClientHostnameVerifier(); private final static IastProperties PROPERTIES = IastProperties.getInstance(); private final static Proxy PROXY = loadProxy(); - public static void setDoNotVerify(HostnameVerifier doNotVerify) { - DO_NOT_VERIFY = doNotVerify; - } - public static StringBuilder sendGet(String uri, String arg, String value) { try { if (arg != null && value != null) {