Skip to content

Commit

Permalink
Merge pull request #331 from Nizernizer/main
Browse files Browse the repository at this point in the history
Release 1.7.1
  • Loading branch information
Nizernizer authored Jun 23, 2022
2 parents 01ae872 + 84deda8 commit f919105
Show file tree
Hide file tree
Showing 20 changed files with 77 additions and 87 deletions.
4 changes: 2 additions & 2 deletions dongtai-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.dongtai.iast</groupId>
<artifactId>iast</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
</parent>
<artifactId>dongtai-agent</artifactId>
<name>dongtai-agent</name>
Expand Down Expand Up @@ -48,7 +48,7 @@
<dependency>
<groupId>io.dongtai.iast</groupId>
<artifactId>dongtai-log</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>io.dongtai.iast</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author [email protected]
*/
public class Constant {
public static final String AGENT_VERSION_VALUE = "v1.7.0";
public static final String AGENT_VERSION_VALUE = "v1.7.1";
public static final String LANGUAGE = "JAVA";

public final static String API_AGENT_REGISTER = "/api/v1/agent/register";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
import org.json.JSONArray;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
Expand Down Expand Up @@ -76,6 +73,19 @@ public static Integer getCpuUsage() {
return CPU_USAGE;
}

public static Integer getDiskUsage() {
try {
File[] files = File.listRoots();
for (File file : files) {
double rate = ((file.getTotalSpace()-file.getUsableSpace())*1.0/file.getTotalSpace())*100;
return (int) rate;
}
}catch (Exception e){
DongTaiLog.error(e);
}
return 0;
}

public static List<PerformanceMetrics> getPerformanceMetrics() {
return PERFORMANCE_METRICS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ private static String getMemInfo() {
JSONObject memoryReport = new JSONObject();
memoryReport.put("total", ByteUtils.formatByteSize(memoryUsage.getMax()));
memoryReport.put("use", ByteUtils.formatByteSize(memoryUsage.getUsed()));
memoryReport.put("rate", memoryUsage.getUsed() / memoryUsage.getMax());
double rate = (memoryUsage.getUsed()*1.0 / memoryUsage.getMax())*100;
memoryReport.put("rate", (int) rate);
return memoryReport.toString();
}

Expand All @@ -86,7 +87,9 @@ private static String getMemInfo() {
* @return
*/
public static String getDiskInfo() {
return "{}";
JSONObject diskInfo = new JSONObject();
diskInfo.put("rate", PerformanceMonitor.getDiskUsage());
return diskInfo.toString();
}


Expand Down
4 changes: 2 additions & 2 deletions dongtai-agent/src/main/resources/iast.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
iast.name=dongtai-Enterprise 1.7.0
iast.name=dongtai-Enterprise 1.7.1
iast.response.name=dongtai
iast.response.value=1.7.0
iast.response.value=1.7.1
iast.server.url=https://iast.io/openapi
iast.server.token=39133a96f5735c253edd908078846c1051824edc
iast.allhook.enable=false
Expand Down
4 changes: 2 additions & 2 deletions dongtai-agent/src/main/resources/iast.properties.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# iast.properties file example
iast.name=dongtai-Enterprise 1.7.0
iast.name=dongtai-Enterprise 1.7.1
iast.response.name=dongtai
iast.response.value=1.7.0
iast.response.value=1.7.1
iast.server.url=https://iast.io/openapi
iast.server.token=39133a96f5735c253edd908078846c1051824edc
iast.allhook.enable=false
Expand Down
76 changes: 26 additions & 50 deletions dongtai-agent/src/test/java/com/secnium/iast/agent/AgentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ public static void replace(String path) {
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}")){
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");
} 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"));
Expand Down Expand Up @@ -98,48 +98,24 @@ public void doAaaa() {
}

public static void main(String[] args) {
// com.sun.management.OperatingSystemMXBean osmxb = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
// double systemCpuLoad = osmxb.getSystemCpuLoad()/osmxb.getAvailableProcessors();
// double processCpuLoad = osmxb.getProcessCpuLoad();
// System.out.println(systemCpuLoad);
// System.out.println(processCpuLoad);


// OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
// for (Method method : operatingSystemMXBean.getClass().getDeclaredMethods()) {
// method.setAccessible(true);
// if (method.getName().startsWith("get")
// && Modifier.isPublic(method.getModifiers())) {
// Object value;
// try {
// value = method.invoke(operatingSystemMXBean);
// } catch (Exception e) {
// value = e;
// } // try
// System.out.println(method.getName() + " = " + value);
// } // if
// } // for


OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean)
ManagementFactory.getOperatingSystemMXBean();
double load;
for(int i=0; i<10; i++) {
load = ((com.sun.management.OperatingSystemMXBean) mbean).getSystemCpuLoad();
System.out.println(load);
if((load<0.0 || load>1.0) && load != -1.0) {
throw new RuntimeException("getSystemCpuLoad() returns " + load
+ " which is not in the [0.0,1.0] interval");
}
try {
Thread.sleep(200);
} catch(InterruptedException e) {
e.printStackTrace();
}
File[] files = File.listRoots();
for (File file : files) {
System.out.println(file + "磁盘的空间大小为:" + file.getTotalSpace() / 1024 / 1024 / 1024 + "G");
System.out.println(file + "磁盘的可使用空间大小为:" + file.getUsableSpace() / 1024 / 1024 / 1024 + "G");
System.out.println(file + "磁盘的空闲空间大小为:" + file.getFreeSpace() / 1024 / 1024 / 1024 + "G");
double rate = ((file.getTotalSpace()-file.getUsableSpace())*1.0/file.getTotalSpace())*100;
System.out.println((int) rate);
}
}

@Test
private static void printUsage() {

File[] files = File.listRoots();
for (File file : files) {
System.out.println(file + "磁盘的空间大小为:" + file.getTotalSpace() / 1024 / 1024 / 1024 + "G");
System.out.println(file + "磁盘的可使用空间大小为:" + file.getUsableSpace() / 1024 / 1024 / 1024 + "G");
System.out.println(file + "磁盘的空闲空间大小为:" + file.getFreeSpace() / 1024 / 1024 / 1024 + "G");
System.out.println("------------------------------------------------------------------");
}
}
}
6 changes: 3 additions & 3 deletions dongtai-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>iast</artifactId>
<groupId>io.dongtai.iast</groupId>
<version>1.7.0</version>
<version>1.7.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -39,12 +39,12 @@
<dependency>
<groupId>cn.huoxian.iast</groupId>
<artifactId>dongtai-spring-api</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>io.dongtai.iast</groupId>
<artifactId>dongtai-log</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class JakartaResponseWrapper extends HttpServletResponseWrapper implement

public JakartaResponseWrapper(HttpServletResponse response) {
super(response);
response.addHeader("DongTai", "v1.7.0");
response.addHeader("DongTai", "v1.7.1");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ServletResponseWrapper extends HttpServletResponseWrapper implement

public ServletResponseWrapper(HttpServletResponse response) {
super(response);
response.addHeader("DongTai", "v1.7.0");
response.addHeader("DongTai", "v1.7.1");
}

private String getLine() {
Expand Down
2 changes: 1 addition & 1 deletion dongtai-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>iast</artifactId>
<groupId>io.dongtai.iast</groupId>
<version>1.7.0</version>
<version>1.7.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
6 changes: 3 additions & 3 deletions dongtai-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.dongtai.iast</groupId>
<artifactId>iast</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
</parent>
<artifactId>dongtai-core</artifactId>
<name>dongtai-core</name>
Expand Down Expand Up @@ -159,7 +159,7 @@
<dependency>
<groupId>io.dongtai.iast</groupId>
<artifactId>dongtai-spy</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -224,7 +224,7 @@
<dependency>
<groupId>io.dongtai.iast</groupId>
<artifactId>dongtai-log</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>io.dongtai.iast</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author [email protected]
*/
public class Constants {
public static final String AGENT_VERSION_VALUE = "v1.7.0";
public static final String AGENT_VERSION_VALUE = "v1.7.1";
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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24747,6 +24747,7 @@ java/util/IllegalFormatException
java/util/InvalidPropertiesFormatException
java/util/JumboEnumSet
java/util/JumboEnumSet$EnumSetIterator
java/util/LinkedHashMap
java/util/LinkedHashMap$*
java/util/LinkedHashMap$1
java/util/LinkedHashMap$2
Expand Down Expand Up @@ -24874,9 +24875,9 @@ java/util/spi/LocaleNameProvider
java/util/spi/LocaleServiceProvider
java/util/spi/TimeZoneNameProvider
java/util/StringTokenizer
java/util/stream/BaseStream
java/util/stream/IntStream
java/util/stream/Stream
# java/util/stream/BaseStream
# java/util/stream/IntStream
# java/util/stream/Stream
java/util/zip/*
javassist/ByteArrayClassPath
javassist/CannotCompileException
Expand Down
2 changes: 1 addition & 1 deletion dongtai-log/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>iast</artifactId>
<groupId>io.dongtai.iast</groupId>
<version>1.7.0</version>
<version>1.7.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion dongtai-plugins/dongtai-grpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>dongtai-plugins</artifactId>
<groupId>io.dongtai.iast</groupId>
<version>1.7.0</version>
<version>1.7.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions dongtai-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>iast</artifactId>
<groupId>io.dongtai.iast</groupId>
<version>1.7.0</version>
<version>1.7.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -24,7 +24,7 @@
<dependency>
<groupId>io.dongtai.iast</groupId>
<artifactId>dongtai-core</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
6 changes: 3 additions & 3 deletions dongtai-spring-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<parent>
<artifactId>iast</artifactId>
<groupId>io.dongtai.iast</groupId>
<version>1.7.0</version>
<version>1.7.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<groupId>cn.huoxian.iast</groupId>
<artifactId>dongtai-spring-api</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand All @@ -28,7 +28,7 @@
<dependency>
<groupId>io.dongtai.iast</groupId>
<artifactId>dongtai-log</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion dongtai-spy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>iast</artifactId>
<groupId>io.dongtai.iast</groupId>
<version>1.7.0</version>
<version>1.7.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<groupId>io.dongtai.iast</groupId>
<artifactId>iast</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
<packaging>pom</packaging>

<name>dongtai-agent-java</name>
Expand Down Expand Up @@ -118,12 +118,12 @@
<dependency>
<groupId>io.dongtai.iast</groupId>
<artifactId>dongtai-spy</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>io.dongtai.iast</groupId>
<artifactId>dongtai-core</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down

0 comments on commit f919105

Please sign in to comment.