Skip to content

Commit

Permalink
release: 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
‘niuerzhuang’ committed Jun 6, 2022
1 parent fe94971 commit 521ba64
Show file tree
Hide file tree
Showing 18 changed files with 411 additions and 33 deletions.
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.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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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));
}
}
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.2</version>
<version>1.7.0</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.2</version>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>io.dongtai.iast</groupId>
<artifactId>dongtai-log</artifactId>
<version>1.7.2</version>
<version>1.7.0</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.2");
response.addHeader("DongTai", "v1.7.0");
}

@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.2");
response.addHeader("DongTai", "v1.7.0");
}

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.2</version>
<version>1.7.0</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.2</version>
<version>1.7.0</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.2</version>
<version>1.7.0</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.2</version>
<version>1.7.0</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.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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
}
}


}
24 changes: 24 additions & 0 deletions dongtai-core/src/test/java/com/secnium/iast/core/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.secnium.iast.core;

import java.util.concurrent.atomic.AtomicLong;

public class Test {

private static final ThreadLocal<Long> 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);
}

}
Loading

0 comments on commit 521ba64

Please sign in to comment.