Skip to content

Commit b93e60b

Browse files
authored
Merge pull request #292 from Nizernizer/main
log print and agent stats tag
2 parents 7a0200e + 4f6fc9a commit b93e60b

File tree

52 files changed

+230
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+230
-167
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ release
3030
# for jenv
3131
.java-version
3232

33+
dongtai-api.jar
34+
dongtai-core.jar
35+
dongtai-grpc.jar
36+
dongtai-spy.jar
37+
3338
logs

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Please refer to the [Quick Start](https://doc.dongtai.io).
7777

7878
### Supported Java versions and middleware
7979

80-
- Java 1.6+
80+
- Java 1.8+
8181
- Tomcat, Jetty, WebLogic, WebSphere, SpringBoot and Mainstream software and middleware.
8282

8383
<img src="https://static.scarf.sh/a.png?x-pxid=0c73ae79-fd43-46b9-a449-b8fcc259db85" />

README_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ DongTai-agent-java 由`agent.jar`、`dongtai-core.jar `、`dongtai-inject.jar`
8181

8282
#### 支持的Java版本及中间件
8383

84-
- Java 1.6+
84+
- Java 1.8+
8585
- Tomcat、Jetty、WebLogic、WebSphere、SpringBoot等主流软件和中间件
8686

8787
**notice:** `jdk 1.6`开发的Agent需要使用`Maven 3.2.5`进行构建

dongtai-agent/src/main/java/io/dongtai/iast/agent/AgentLauncher.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,21 @@ public class AgentLauncher {
3131
* fix bug: java.lang.ClassCastException: weblogic.net.http.SOAPHttpsURLConnection cannot be cast to javax.net.ssl.HttpsURLConnection
3232
*/
3333
System.setProperty("UseSunHttpHandler", "true");
34-
System.setProperty("java.io.tmpdir.dongtai", System.getProperty("java.io.tmpdir")+ File.separator +UUID.randomUUID().toString().replaceAll("-","")+"/");
34+
if (System.getProperty("java.io.tmpdir.dongtai") == null) {
35+
String tmpdir = System.getProperty("java.io.tmpdir");
36+
String appName = System.getProperty("dongtai.app.name");
37+
String appVersion = System.getProperty("dongtai.app.version");
38+
if (tmpdir == null) {
39+
tmpdir = File.separator + "tmp";
40+
}
41+
if (appName == null) {
42+
appName = "DemoProject";
43+
}
44+
if (appVersion == null) {
45+
appVersion = "v1.0.0";
46+
}
47+
System.setProperty("java.io.tmpdir.dongtai", tmpdir + File.separator + appName + "-" + appVersion + "-" + UUID.randomUUID().toString().replaceAll("-", "") + "/");
48+
}
3549
}
3650

3751
/**

dongtai-agent/src/main/java/io/dongtai/iast/agent/IastProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private IastProperties() {
4545
try {
4646
init();
4747
} catch (ClassNotFoundException e) {
48-
DongTaiLog.debug(e);
48+
DongTaiLog.error(e);
4949
}
5050
}
5151

dongtai-agent/src/main/java/io/dongtai/iast/agent/manager/EngineManager.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class EngineManager {
3737

3838
private final Instrumentation inst;
3939
private int runningStatus;
40+
private static boolean isCoreStop;
4041
private final IastProperties properties;
4142
private final String launchMode;
4243
private Class<?> classOfEngine;
@@ -298,6 +299,8 @@ public boolean install() {
298299
String.class)
299300
.invoke(null, launchMode, this.properties.getPropertiesFilePath(),
300301
AgentRegisterReport.getAgentFlag(), inst, agentPath);
302+
setRunningStatus(0);
303+
setCoreStop(false);
301304
return true;
302305
} catch (IOException e) {
303306
DongTaiLog.error("DongTai engine start failed, Reason: dongtai-spy.jar or dongtai-core.jar open failed. path: \n\tdongtai-core.jar: " + corePackage + "\n\tdongtai-spy.jar: " + spyPackage);
@@ -321,6 +324,8 @@ public boolean start() {
321324
if (classOfEngine != null) {
322325
classOfEngine.getMethod("start").invoke(null);
323326
DongTaiLog.info("DongTai engine start successfully.");
327+
setRunningStatus(0);
328+
setCoreStop(false);
324329
return true;
325330
}
326331
return false;
@@ -351,6 +356,8 @@ public boolean stop() {
351356
if (classOfEngine != null) {
352357
classOfEngine.getMethod("stop").invoke(null);
353358
DongTaiLog.info("DongTai engine stop successfully.");
359+
setRunningStatus(1);
360+
setCoreStop(true);
354361
return true;
355362
}
356363
return false;
@@ -379,6 +386,8 @@ public boolean stop() {
379386
*/
380387
public synchronized boolean uninstall() {
381388
if (null == IAST_CLASS_LOADER) {
389+
setRunningStatus(1);
390+
setCoreStop(true);
382391
return true;
383392
}
384393

@@ -399,6 +408,8 @@ public synchronized boolean uninstall() {
399408
classOfEngine = null;
400409
IAST_CLASS_LOADER.closeIfPossible();
401410
IAST_CLASS_LOADER = null;
411+
setRunningStatus(1);
412+
setCoreStop(true);
402413
return true;
403414
}
404415

@@ -409,4 +420,12 @@ public static String getPID() {
409420
}
410421
return PID;
411422
}
423+
424+
public static boolean isCoreStop() {
425+
return isCoreStop;
426+
}
427+
428+
public static void setCoreStop(boolean coreStop) {
429+
isCoreStop = coreStop;
430+
}
412431
}

dongtai-agent/src/main/java/io/dongtai/iast/agent/middlewarerecognition/dubbo/DubboService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ public boolean isMatch(RuntimeMXBean paramRuntimeMXBean, ClassLoader loader) {
1212
loader.loadClass("org.apache.dubbo.monitor.support.MonitorFilter");
1313
return true;
1414
} catch (Exception e) {
15-
DongTaiLog.debug(e);
15+
DongTaiLog.error(e);
1616
}
1717
try {
1818
loader.loadClass("com.alibaba.dubbo.monitor.support.MonitorFilter");
1919
return true;
2020
} catch (Exception e) {
21-
DongTaiLog.debug(e);
21+
DongTaiLog.error(e);
2222
}
2323
return false;
2424
}

dongtai-agent/src/main/java/io/dongtai/iast/agent/middlewarerecognition/servlet/ServletService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ public boolean isMatch(RuntimeMXBean paramRuntimeMXBean, ClassLoader loader) {
1212
loader.loadClass("javax.servlet.ServletRequest");
1313
return true;
1414
} catch (Exception e) {
15-
DongTaiLog.debug(e);
15+
DongTaiLog.error(e);
1616
}
1717
try {
1818
loader.loadClass("jakarta.servlet.ServletRequest");
1919
return true;
2020
} catch (Exception e) {
21-
DongTaiLog.debug(e);
21+
DongTaiLog.error(e);
2222
}
2323
return false;
2424
}

dongtai-agent/src/main/java/io/dongtai/iast/agent/middlewarerecognition/weblogic/WebLogic.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class WebLogic implements IServer {
1414
public boolean isMatch(RuntimeMXBean paramRuntimeMXBean, ClassLoader loader) {
1515
File runFile = new File(".", "bin/startWebLogic.sh");
1616
File configFile = new File(".", "init-info/domain-info.xml");
17+
System.setProperty("UseSunHttpHandler", "true");
1718
return runFile.exists() && configFile.exists();
1819
}
1920

dongtai-agent/src/main/java/io/dongtai/iast/agent/monitor/MonitorDaemonThread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public MonitorDaemonThread(EngineManager engineManager) {
3232
this.engineManager = engineManager;
3333
try {
3434
delayTime = Integer.parseInt(System.getProperty("iast.engine.delay.time", "0"));
35-
DongTaiLog.info("engine delay time is " + delayTime + " s");
35+
DongTaiLog.info("dongtai engine delay time is " + delayTime + " s");
3636
delayTime = delayTime * 1000;
3737
} catch (Exception e) {
3838
DongTaiLog.error("engine delay time must be int,eg: 10、20");

0 commit comments

Comments
 (0)