From 521ba647e011140ef9fe574d9a38716e5a4ea962 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=98niuerzhuang=E2=80=99?=
<‘niuerzhuang@huoxian.cn’>
Date: Mon, 6 Jun 2022 16:42:00 +0800
Subject: [PATCH] release: 1.7.0
---
.../java/io/dongtai/iast/agent/Constant.java | 2 +-
.../com/secnium/iast/agent/AgentTest.java | 76 ++++++-
dongtai-api/pom.xml | 6 +-
.../api/jakarta/JakartaResponseWrapper.java | 2 +-
.../api/servlet2/ServletResponseWrapper.java | 2 +-
dongtai-common/pom.xml | 2 +-
dongtai-core/pom.xml | 6 +-
.../io/dongtai/iast/core/utils/Constants.java | 2 +-
.../secnium/iast/core/AgentEngineTest.java | 36 +++-
.../test/java/com/secnium/iast/core/Test.java | 24 +++
.../io/dongtai/iast/core/RemoteConfig.java | 200 ++++++++++++++++++
.../java/io/dongtai/iast/core/Scatest.java | 64 ++++++
dongtai-log/pom.xml | 2 +-
dongtai-plugins/dongtai-grpc/pom.xml | 2 +-
dongtai-plugins/pom.xml | 4 +-
dongtai-spring-api/pom.xml | 6 +-
dongtai-spy/pom.xml | 2 +-
pom.xml | 6 +-
18 files changed, 411 insertions(+), 33 deletions(-)
create mode 100644 dongtai-core/src/test/java/com/secnium/iast/core/Test.java
create mode 100644 dongtai-core/src/test/java/io/dongtai/iast/core/RemoteConfig.java
create mode 100644 dongtai-core/src/test/java/io/dongtai/iast/core/Scatest.java
diff --git a/dongtai-agent/src/main/java/io/dongtai/iast/agent/Constant.java b/dongtai-agent/src/main/java/io/dongtai/iast/agent/Constant.java
index bf08cbc58..0c3e52088 100644
--- a/dongtai-agent/src/main/java/io/dongtai/iast/agent/Constant.java
+++ b/dongtai-agent/src/main/java/io/dongtai/iast/agent/Constant.java
@@ -4,7 +4,7 @@
* @author dongzhiyong@huoxian.cn
*/
public class Constant {
- public static final String AGENT_VERSION_VALUE = "v1.7.2";
+ public static final String AGENT_VERSION_VALUE = "v1.7.0";
public static final String LANGUAGE = "JAVA";
public final static String API_AGENT_REGISTER = "/api/v1/agent/register";
diff --git a/dongtai-agent/src/test/java/com/secnium/iast/agent/AgentTest.java b/dongtai-agent/src/test/java/com/secnium/iast/agent/AgentTest.java
index 4d78cdc56..6c9d82b8c 100644
--- a/dongtai-agent/src/test/java/com/secnium/iast/agent/AgentTest.java
+++ b/dongtai-agent/src/test/java/com/secnium/iast/agent/AgentTest.java
@@ -1,9 +1,15 @@
package com.secnium.iast.agent;
+import java.io.*;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.Arrays;
+import java.util.Scanner;
+import io.dongtai.iast.agent.IastProperties;
+import io.dongtai.iast.agent.report.AgentRegisterReport;
import io.dongtai.log.DongTaiLog;
import org.junit.Test;
@@ -21,7 +27,75 @@ public void appendToolsPath() {
}
}
+ @Test
+ public void changeFile() {
+ replace("/Users/erzhuangniu/workspace/DongTai-agent-java/dongtai-agent/src/main/resources/bin/fluent.conf");
+ }
+
+ public static void replace(String path) {
+ String temp = "";
+
+ try {
+ File file = new File(path);
+ FileInputStream fis = new FileInputStream(file);
+ InputStreamReader isr = new InputStreamReader(fis);
+ BufferedReader br = new BufferedReader(isr);
+ StringBuffer buf = new StringBuffer();
+ // 保存该行前面的内容
+ while ((temp = br.readLine()) != null) {
+ if (temp.contains("${HOSTNAME_AGENT_ID}")){
+ temp.replace("${HOSTNAME_AGENT_ID}", AgentRegisterReport.getInternalHostName()+"-"+AgentRegisterReport.getAgentFlag().toString());
+ }else if (temp.contains("${HOSTNAME}")){
+ temp.replace("${HOSTNAME}",AgentRegisterReport.getInternalHostName());
+ }else if (temp.contains("${AGENT_ID}")){
+ temp.replace("${AGENT_ID}",AgentRegisterReport.getAgentFlag().toString());
+ }else if (temp.contains("${OPENAPI}")){
+ temp.replace("${OPENAPI}", IastProperties.getInstance().getBaseUrl());
+ }else if (temp.contains("${LOG_PORT}")){
+ temp.replace("${LOG_PORT}",IastProperties.getInstance().getLogPort());
+ }else if (temp.contains("${LOG_PATH}")){
+ temp.replace("${LOG_PATH}", System.getProperty("dongtai.log.path")+File.separator+"dongtai_javaagent.log");
+ }
+ buf = buf.append(temp);
+ buf = buf.append(System.getProperty("line.separator"));
+ }
+ br.close();
+ FileOutputStream fos = new FileOutputStream(file);
+ PrintWriter pw = new PrintWriter(fos);
+ pw.write(buf.toString().toCharArray());
+ pw.flush();
+ pw.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void doFluent() {
+ String[] execution = {
+ "nohup",
+ "tail",
+ "-f",
+ "/var/folders/xy/xyx56h3s29z6376gvk32621h0000gn/T//gunsTest001-042401-8579dc8d088d4a1680977352f6652aba/iast/fluent.conf"
+ };
+ try {
+ Runtime.getRuntime().exec(execution);
+ System.out.println("aasdasdsa");
+ } catch (IOException e) {
+ DongTaiLog.error(e);
+ }
+ }
+
+ @Test
+ public void doAaaa() {
+ String s = "https://iast.io/openapi";
+ int i = s.indexOf("://");
+ int i1 = s.indexOf("/openapi");
+ System.out.println();
+ }
+
public static void main(String[] args) {
- System.out.println(System.getProperty("java.io.tmpdir.dongtai"));
+ String a = "52.81.92.214:30158";
+ System.out.println(a.substring(a.indexOf(":")+1));
}
}
diff --git a/dongtai-api/pom.xml b/dongtai-api/pom.xml
index f55df18d3..28d4aac85 100644
--- a/dongtai-api/pom.xml
+++ b/dongtai-api/pom.xml
@@ -5,7 +5,7 @@
iast
io.dongtai.iast
- 1.7.2
+ 1.7.0
4.0.0
@@ -39,12 +39,12 @@
cn.huoxian.iast
dongtai-spring-api
- 1.7.2
+ 1.7.0
io.dongtai.iast
dongtai-log
- 1.7.2
+ 1.7.0
diff --git a/dongtai-api/src/main/java/io/dongtai/api/jakarta/JakartaResponseWrapper.java b/dongtai-api/src/main/java/io/dongtai/api/jakarta/JakartaResponseWrapper.java
index 4c5aad244..52760398d 100644
--- a/dongtai-api/src/main/java/io/dongtai/api/jakarta/JakartaResponseWrapper.java
+++ b/dongtai-api/src/main/java/io/dongtai/api/jakarta/JakartaResponseWrapper.java
@@ -23,7 +23,7 @@ public class JakartaResponseWrapper extends HttpServletResponseWrapper implement
public JakartaResponseWrapper(HttpServletResponse response) {
super(response);
- response.addHeader("DongTai", "v1.7.2");
+ response.addHeader("DongTai", "v1.7.0");
}
@Override
diff --git a/dongtai-api/src/main/java/io/dongtai/api/servlet2/ServletResponseWrapper.java b/dongtai-api/src/main/java/io/dongtai/api/servlet2/ServletResponseWrapper.java
index e2993e87a..8cd4623e3 100644
--- a/dongtai-api/src/main/java/io/dongtai/api/servlet2/ServletResponseWrapper.java
+++ b/dongtai-api/src/main/java/io/dongtai/api/servlet2/ServletResponseWrapper.java
@@ -21,7 +21,7 @@ public class ServletResponseWrapper extends HttpServletResponseWrapper implement
public ServletResponseWrapper(HttpServletResponse response) {
super(response);
- response.addHeader("DongTai", "v1.7.2");
+ response.addHeader("DongTai", "v1.7.0");
}
private String getLine() {
diff --git a/dongtai-common/pom.xml b/dongtai-common/pom.xml
index 36994e228..592237e87 100644
--- a/dongtai-common/pom.xml
+++ b/dongtai-common/pom.xml
@@ -5,7 +5,7 @@
iast
io.dongtai.iast
- 1.7.2
+ 1.7.0
4.0.0
diff --git a/dongtai-core/pom.xml b/dongtai-core/pom.xml
index e0eaa12bc..59a08506a 100755
--- a/dongtai-core/pom.xml
+++ b/dongtai-core/pom.xml
@@ -7,7 +7,7 @@
io.dongtai.iast
iast
- 1.7.2
+ 1.7.0
dongtai-core
dongtai-core
@@ -159,7 +159,7 @@
io.dongtai.iast
dongtai-spy
- 1.7.2
+ 1.7.0
provided
@@ -224,7 +224,7 @@
io.dongtai.iast
dongtai-log
- 1.7.2
+ 1.7.0
io.dongtai.iast
diff --git a/dongtai-core/src/main/java/io/dongtai/iast/core/utils/Constants.java b/dongtai-core/src/main/java/io/dongtai/iast/core/utils/Constants.java
index 9dcf0237f..76a5319e3 100644
--- a/dongtai-core/src/main/java/io/dongtai/iast/core/utils/Constants.java
+++ b/dongtai-core/src/main/java/io/dongtai/iast/core/utils/Constants.java
@@ -4,7 +4,7 @@
* @author dongzhiyong@huoxian.cn
*/
public class Constants {
- public static final String AGENT_VERSION_VALUE = "v1.7.2";
+ public static final String AGENT_VERSION_VALUE = "v1.7.0";
public final static String API_REPORT_UPLOAD = "/api/v1/report/upload";
public final static String SERVER_ADDRESS = "/api/v1/agent/update";
public final static String API_HOOK_PROFILE = "/api/v1/profiles";
diff --git a/dongtai-core/src/test/java/com/secnium/iast/core/AgentEngineTest.java b/dongtai-core/src/test/java/com/secnium/iast/core/AgentEngineTest.java
index 2d255d8e4..a21787b62 100644
--- a/dongtai-core/src/test/java/com/secnium/iast/core/AgentEngineTest.java
+++ b/dongtai-core/src/test/java/com/secnium/iast/core/AgentEngineTest.java
@@ -1,27 +1,43 @@
package com.secnium.iast.core;
+import io.dongtai.iast.core.utils.threadlocal.BooleanThreadLocal;
import io.dongtai.log.DongTaiLog;
-
-import java.util.concurrent.TimeUnit;
+import org.junit.Test;
public class AgentEngineTest {
public static void main(String[] args) {
- new AgentEngineTest().a();
+
}
- public AgentEngineTest(){
+ public AgentEngineTest() {
}
- public void a(){
+ @Test
+ public void a() {
+ BooleanThreadLocal booleanThreadLocal = new BooleanThreadLocal(false);
+ System.out.println(booleanThreadLocal.isEnterEntry());
+ booleanThreadLocal.set(true);
+ System.out.println(booleanThreadLocal.isEnterEntry());
+ booleanThreadLocal.remove();
+ System.out.println(booleanThreadLocal.isEnterEntry());
+ }
+
+ @Test
+ public void b(boolean a) {
try {
- System.out.println("b");
- TimeUnit.SECONDS.sleep(10);
- System.out.println("a");
- } catch (InterruptedException e) {
- DongTaiLog.error(e);
+ if (a){
+ try {
+ throw new IllegalStateException("DongTai agent request replay");
+ }catch (RuntimeException e){
+ System.out.println("DongTai agent request replay, please ignore");
+ }
+ }
+ } catch (NullPointerException e) {
+ DongTaiLog.info("DongTai agent request replay, please ignore");
}
}
+
}
diff --git a/dongtai-core/src/test/java/com/secnium/iast/core/Test.java b/dongtai-core/src/test/java/com/secnium/iast/core/Test.java
new file mode 100644
index 000000000..d8bb2654e
--- /dev/null
+++ b/dongtai-core/src/test/java/com/secnium/iast/core/Test.java
@@ -0,0 +1,24 @@
+package com.secnium.iast.core;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+public class Test {
+
+ private static final ThreadLocal responseTime = new ThreadLocal<>();
+
+ public void execute(int count){
+ for (int i = 0; i < count; i++) {
+ responseTime.set(System.currentTimeMillis());
+ String testLine = "response time:"+(System.currentTimeMillis()-responseTime.get())+"ms";
+ }
+ }
+
+ @org.junit.Test
+ public void test(){
+ Long start = System.currentTimeMillis();
+ execute(10000);
+ Long end = System.currentTimeMillis();
+ System.out.println(end-start);
+ }
+
+}
diff --git a/dongtai-core/src/test/java/io/dongtai/iast/core/RemoteConfig.java b/dongtai-core/src/test/java/io/dongtai/iast/core/RemoteConfig.java
new file mode 100644
index 000000000..f11c58745
--- /dev/null
+++ b/dongtai-core/src/test/java/io/dongtai/iast/core/RemoteConfig.java
@@ -0,0 +1,200 @@
+package io.dongtai.iast.core;
+
+import com.google.gson.reflect.TypeToken;
+import io.dongtai.iast.common.entity.performance.PerformanceMetrics;
+import io.dongtai.iast.common.entity.performance.metrics.CpuInfoMetrics;
+import io.dongtai.iast.common.entity.performance.metrics.MemoryUsageMetrics;
+import io.dongtai.iast.common.entity.performance.metrics.ThreadInfoMetrics;
+import io.dongtai.iast.common.entity.response.PlainResult;
+import io.dongtai.iast.core.bytecode.enhance.plugin.fallback.FallbackSwitch;
+import io.dongtai.iast.core.utils.config.entity.RemoteConfigEntityV2;
+import io.dongtai.iast.core.utils.config.entity.PerformanceEntity;
+import io.dongtai.iast.core.utils.config.entity.PerformanceLimitThreshold;
+import io.dongtai.iast.core.utils.json.GsonUtils;
+import io.dongtai.iast.core.utils.threadlocal.BooleanThreadLocal;
+import io.dongtai.log.DongTaiLog;
+import org.json.JSONObject;
+import org.junit.Test;
+
+import java.util.List;
+
+public class RemoteConfig {
+
+ /**
+ * 全局配置
+ */
+ private static String existsRemoteConfigMeta = "{}";
+ private static Boolean enableAutoFallback;
+ /**
+ * 高频hook限流相关配置
+ */
+ private static Double hookLimitTokenPerSecond;
+ private static Double hookLimitInitBurstSeconds;
+ /**
+ * 高频流量限流相关配置
+ */
+ private static Double heavyTrafficLimitTokenPerSecond;
+ private static Double heavyTrafficLimitInitBurstSeconds;
+ private static Integer heavyTrafficBreakerWaitDuration;
+ /**
+ * 性能熔断阈值相关配置
+ */
+ private static Integer performanceBreakerWindowSize;
+ private static Double performanceBreakerFailureRate;
+ private static Integer performanceBreakerWaitDuration;
+ private static Integer performanceLimitRiskMaxMetricsCount;
+ private static List performanceLimitRiskThreshold;
+ private static List performanceLimitMaxThreshold;
+ /**
+ * 二次降级阈值相关配置
+ */
+ private static Double secondFallbackFrequencyTokenPerSecond;
+ private static Double secondFallbackFrequencyInitBurstSeconds;
+ private static Long secondFallbackDuration;
+
+
+ private static final String REMOTE_CONFIG_DEFAULT_META = "{}";
+ private static final String REMOTE_CONFIG_NEW_META = "{\"status\":201,\"msg\":\"\\u64cd\\u4f5c\\u6210\\u529f\",\"data\":{\"enableAutoFallback\":true,\"performanceLimitRiskMaxMetricsCount\":30,\"systemIsUninstall\":true,\"jvmIsUninstall\": true,\"applicationIsUninstall\": true,\"system\":[{\"fallbackName\":\"cpuUsagePercentage\",\"conditions\":\"greater\",\"value\":100,\"description\":\"系统 CPU 使用率阈值\"},{\"fallbackName\":\"sysMemUsagePercentage\",\"conditions\":\"greater\",\"value\":100,\"description\":\"系统内存使用率阈值\"},{\"fallbackName\":\"sysMemUsageUsed\",\"conditions\":\"greater\",\"value\":100000000000,\"description\":\"系统内存使用值阈值\"}],\"jvm\":[{\"fallbackName\":\"jvmMemUsagePercentage\",\"conditions\":\"greater\",\"value\":100,\"description\":\"JVM 内存使用率阈值\"},{\"fallbackName\":\"jvmMemUsageUsed\",\"conditions\":\"greater\",\"value\":100000000000,\"description\":\"JVM 内存使用值阈值\"},{\"fallbackName\":\"threadCount\",\"conditions\":\"greater\",\"value\":100000,\"description\":\"总线程数阈值\"},{\"fallbackName\":\"daemonThreadCount\",\"conditions\":\"greater\",\"value\":1000000,\"description\":\"守护线程数阈值\"},{\"fallbackName\":\"dongTaiThreadCount\",\"conditions\":\"greater\",\"value\":1000000,\"description\":\"洞态IAST线程数阈值\"}],\"appliaction\":[{\"fallbackName\":\"hookLimitTokenPerSecond\",\"conditions\":\"greater\",\"value\":10000,\"description\":\"单请求 HOOK 限流\"},{\"fallbackName\":\"heavyTrafficLimitTokenPerSecond\",\"conditions\":\"greater\",\"value\":100000000,\"description\":\"高频 HOOK 限流\"}]}}";
+
+ /**
+ * 解析远程配置响应
+ */
+ private static RemoteConfigEntityV2 parseRemoteConfigResponse(String remoteResponse) {
+ try {
+ // 默认响应标识调用失败
+ if (REMOTE_CONFIG_DEFAULT_META.equals(remoteResponse)) {
+ FallbackSwitch.setPerformanceFallback(false);
+ return null;
+ }
+ if (REMOTE_CONFIG_DEFAULT_META.equals(new JSONObject(remoteResponse).get("data"))){
+ FallbackSwitch.setPerformanceFallback(false);
+ return null;
+ }
+ PlainResult result = GsonUtils.toObject(remoteResponse, new TypeToken>() {
+ }.getType());
+ // 服务端响应成功状态码
+ if (result.isSuccess()) {
+ return result.getData();
+ } else {
+ DongTaiLog.warn("remoteConfig request not success, status:{}, msg:{},response:{}", result.getStatus(), result.getMsg(),
+ GsonUtils.toJson(remoteResponse));
+ return null;
+ }
+ } catch (Throwable t) {
+ DongTaiLog.warn("remoteConfig parse failed: msg:{}, err:{}, response:{}", t.getMessage(), t.getCause(), GsonUtils.toJson(remoteResponse));
+ return null;
+ }
+ }
+
+ public void syncRemoteConfig() {
+ try {
+ // 远端有配置且和上次配置内容不一致时,重新更新配置文件
+ String remoteResponse = REMOTE_CONFIG_NEW_META;
+ RemoteConfigEntityV2 remoteConfigEntity = parseRemoteConfigResponse(remoteResponse);
+ List application = remoteConfigEntity.getApplication();
+ List jvm = remoteConfigEntity.getJvm();
+ List system = remoteConfigEntity.getSystem();
+ PerformanceLimitThreshold performanceLimitThreshold = new PerformanceLimitThreshold();
+ MemoryUsageMetrics memoryUsage = new MemoryUsageMetrics();
+ ThreadInfoMetrics threadInfoMetrics = new ThreadInfoMetrics();
+ CpuInfoMetrics cpuInfoMetrics = new CpuInfoMetrics();
+ MemoryUsageMetrics memoryNoHeapUsage = new MemoryUsageMetrics();
+
+
+ if (null != remoteConfigEntity && !remoteResponse.equals(existsRemoteConfigMeta)) {
+ if (remoteConfigEntity.getEnableAutoFallback() != null) {
+ enableAutoFallback = remoteConfigEntity.getEnableAutoFallback();
+ }
+ if (remoteConfigEntity.getPerformanceLimitRiskMaxMetricsCount() != null) {
+ performanceLimitRiskMaxMetricsCount = remoteConfigEntity.getPerformanceLimitRiskMaxMetricsCount()/30 + remoteConfigEntity.getPerformanceLimitRiskMaxMetricsCount()%30==0?0:1;
+ }
+
+ performanceLimitRiskMaxMetricsCount = remoteConfigEntity.getPerformanceLimitRiskMaxMetricsCount();
+ if (remoteConfigEntity.getApplication() != null) {
+ for (PerformanceEntity performanceEntity:application){
+ switch (performanceEntity.getFallbackName()){
+ case "hookLimitTokenPerSecond":
+ hookLimitTokenPerSecond = performanceEntity.getValue();
+ break;
+ case "heavyTrafficLimitTokenPerSecond":
+ heavyTrafficLimitTokenPerSecond = performanceEntity.getValue();
+ break;
+ }
+ }
+ }
+
+ if (remoteConfigEntity.getJvm() != null) {
+ for (PerformanceEntity performanceEntity:jvm){
+ switch (performanceEntity.getFallbackName()){
+ case "jvmMemUsagePercentage":{
+ memoryUsage.setMemUsagePercentage(performanceEntity.getValue());
+ break;
+ }
+ case "jvmMemUsageUsed":{
+ memoryUsage.setUsed(performanceEntity.getValue().longValue());
+ break;
+ }
+ case "threadCount":{
+ threadInfoMetrics.setThreadCount(performanceEntity.getValue().intValue());
+ break;
+ }
+ case "daemonThreadCount":{
+ threadInfoMetrics.setDaemonThreadCount(performanceEntity.getValue().intValue());
+ break;
+ }
+ case "dongTaiThreadCount":{
+ threadInfoMetrics.setDongTaiThreadCount(performanceEntity.getValue().intValue());
+ break;
+ }
+ }
+ }
+ }
+
+ if (remoteConfigEntity.getSystem() != null) {
+ for (PerformanceEntity performanceEntity:system){
+ switch (performanceEntity.getFallbackName()){
+ case "cpuUsagePercentage":{
+ cpuInfoMetrics.setCpuUsagePercentage(performanceEntity.getValue());
+ break;
+ }
+ case "sysMemUsagePercentage":{
+ memoryNoHeapUsage.setMemUsagePercentage(performanceEntity.getValue());
+ break;
+ }
+ case "sysMemUsageUsed":{
+ memoryNoHeapUsage.setUsed(performanceEntity.getValue().longValue());
+ break;
+ }
+ }
+ }
+ }
+
+ threadInfoMetrics.setPeakThreadCount(1000000000);
+ memoryUsage.setMax(1000000000000L);
+ memoryNoHeapUsage.setMax(1000000000000L);
+ performanceLimitThreshold.setThreadInfo(threadInfoMetrics);
+ performanceLimitThreshold.setMemoryUsage(memoryUsage);
+ performanceLimitThreshold.setMemoryNoHeapUsage(memoryNoHeapUsage);
+ performanceLimitThreshold.setCpuUsage(cpuInfoMetrics);
+ performanceLimitRiskThreshold = performanceLimitRiskThreshold;
+ existsRemoteConfigMeta = remoteResponse;
+ DongTaiLog.debug("Sync remote config successful.");
+ }
+ } catch (Throwable t) {
+ DongTaiLog.warn("Sync remote config failed, msg: {}, error: {}", t.getMessage(), t.getCause());
+ }
+ }
+
+ private static final BooleanThreadLocal HEAVY_HOOK_FALLBACK = new BooleanThreadLocal(false);
+
+ @Test
+ public void testJson(){
+ HEAVY_HOOK_FALLBACK.remove();
+ System.out.println(HEAVY_HOOK_FALLBACK.get());
+ HEAVY_HOOK_FALLBACK.remove();
+ System.out.println(HEAVY_HOOK_FALLBACK.get());
+ HEAVY_HOOK_FALLBACK.remove();
+ System.out.println(HEAVY_HOOK_FALLBACK.get());
+ }
+
+}
diff --git a/dongtai-core/src/test/java/io/dongtai/iast/core/Scatest.java b/dongtai-core/src/test/java/io/dongtai/iast/core/Scatest.java
new file mode 100644
index 000000000..e74217be5
--- /dev/null
+++ b/dongtai-core/src/test/java/io/dongtai/iast/core/Scatest.java
@@ -0,0 +1,64 @@
+package io.dongtai.iast.core;
+
+import io.dongtai.iast.core.bytecode.sca.ScaScanner;
+import io.dongtai.iast.core.bytecode.sca.SignatureAlgorithm;
+import io.dongtai.iast.core.handler.hookpoint.vulscan.ReportConstant;
+import io.dongtai.log.DongTaiLog;
+import org.json.JSONObject;
+
+import java.io.InputStream;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.concurrent.TimeUnit;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+public class Scatest {
+
+ public static void main(String[] args) throws InterruptedException {
+ TimeUnit.SECONDS.sleep(15);
+ scanJarLib("/Users/erzhuangniu/Desktop/Desktop0301/webgoat-server-8.2.2.jar");
+ TimeUnit.SECONDS.sleep(5);
+ TimeUnit.MILLISECONDS.sleep(500);
+ }
+
+
+ private static void scanJarLib(String packagePath) {
+ try {
+ JarFile file = new JarFile(packagePath);
+ Enumeration entries = file.entries();
+ String entryName;
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+ entryName = entry.getName();
+ if (entryName.endsWith(".jar")) {
+// DongTaiLog.info(entryName);
+// TimeUnit.SECONDS.sleep(1);
+ InputStream is = getJarInputStream(packagePath, entryName);
+ String signature = SignatureAlgorithm.getSignature(is, "SHA-1");
+ String packageName = entry.getName();
+ if (signature == null) {
+ continue;
+ }
+ JSONObject packageObj = new JSONObject();
+ packageObj.put(ReportConstant.SCA_PACKAGE_PATH, "jar:file:" + packagePath + "!/" + entryName);
+ packageObj.put(ReportConstant.SCA_PACKAGE_NAME, packageName);
+ packageObj.put(ReportConstant.SCA_PACKAGE_SIGNATURE, signature);
+ packageObj.put(ReportConstant.SCA_PACKAGE_ALGORITHM, "SHA-1");
+ }
+ }
+ } catch (Exception e) {
+ DongTaiLog.error(e.getMessage());
+ }
+ }
+
+ public static InputStream getJarInputStream(String filePath, String name) throws Exception {
+ URL url = new URL("jar:file:" + filePath + "!/" + name);
+ JarURLConnection jarConnection = (JarURLConnection) url
+ .openConnection();
+
+ return jarConnection.getInputStream();
+ }
+
+}
diff --git a/dongtai-log/pom.xml b/dongtai-log/pom.xml
index 398b0786e..5f96dc39b 100644
--- a/dongtai-log/pom.xml
+++ b/dongtai-log/pom.xml
@@ -5,7 +5,7 @@
iast
io.dongtai.iast
- 1.7.2
+ 1.7.0
4.0.0
diff --git a/dongtai-plugins/dongtai-grpc/pom.xml b/dongtai-plugins/dongtai-grpc/pom.xml
index 8f107f4ed..64c07f295 100644
--- a/dongtai-plugins/dongtai-grpc/pom.xml
+++ b/dongtai-plugins/dongtai-grpc/pom.xml
@@ -5,7 +5,7 @@
dongtai-plugins
io.dongtai.iast
- 1.7.2
+ 1.7.0
4.0.0
diff --git a/dongtai-plugins/pom.xml b/dongtai-plugins/pom.xml
index eb02c50d9..99e02c4e4 100644
--- a/dongtai-plugins/pom.xml
+++ b/dongtai-plugins/pom.xml
@@ -5,7 +5,7 @@
iast
io.dongtai.iast
- 1.7.2
+ 1.7.0
4.0.0
@@ -24,7 +24,7 @@
io.dongtai.iast
dongtai-core
- 1.7.2
+ 1.7.0
provided
diff --git a/dongtai-spring-api/pom.xml b/dongtai-spring-api/pom.xml
index 6a0442fc3..83dac11dc 100644
--- a/dongtai-spring-api/pom.xml
+++ b/dongtai-spring-api/pom.xml
@@ -5,13 +5,13 @@
iast
io.dongtai.iast
- 1.7.2
+ 1.7.0
4.0.0
cn.huoxian.iast
dongtai-spring-api
- 1.7.2
+ 1.7.0
8
@@ -28,7 +28,7 @@
io.dongtai.iast
dongtai-log
- 1.7.2
+ 1.7.0
diff --git a/dongtai-spy/pom.xml b/dongtai-spy/pom.xml
index f32d49c58..de5b96eaa 100644
--- a/dongtai-spy/pom.xml
+++ b/dongtai-spy/pom.xml
@@ -5,7 +5,7 @@
iast
io.dongtai.iast
- 1.7.2
+ 1.7.0
4.0.0
diff --git a/pom.xml b/pom.xml
index 7df39526f..1503f2138 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,7 +41,7 @@
io.dongtai.iast
iast
- 1.7.2
+ 1.7.0
pom
dongtai-agent-java
@@ -118,12 +118,12 @@
io.dongtai.iast
dongtai-spy
- 1.7.2
+ 1.7.0
io.dongtai.iast
dongtai-core
- 1.7.2
+ 1.7.0
test