Skip to content

Commit 01ae872

Browse files
authored
Merge pull request HXSecurity#330 from Nizernizer/main
fix bug
2 parents 833f978 + 3010435 commit 01ae872

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ private static void doAttach(String pid, String agentArgs) {
114114
}
115115
}
116116

117-
private static boolean isLinux() {
118-
return OS_NAME.indexOf("linux") >= 0;
117+
private static boolean isArm() {
118+
return System.getProperty("os.arch").contains("arm") || System.getProperty("os.arch").contains("aarch");
119119
}
120120

121121
public static boolean isWindows() {
@@ -133,7 +133,10 @@ private static void extractJattach() throws IOException {
133133
} else if (isMacOs()) {
134134
JATTACH_FILE = System.getProperty("java.io.tmpdir")+ File.separator + "iast"+System.currentTimeMillis() + File.separator + "jattach-mac";
135135
FileUtils.getResourceToFile("bin/jattach-mac", JATTACH_FILE);
136-
} else {
136+
} else if (isArm()){
137+
JATTACH_FILE = System.getProperty("java.io.tmpdir")+ File.separator + "iast"+System.currentTimeMillis() + File.separator + "jattach-linux";
138+
FileUtils.getResourceToFile("bin/jattach-arm", JATTACH_FILE);
139+
}else {
137140
JATTACH_FILE = System.getProperty("java.io.tmpdir")+ File.separator + "iast"+System.currentTimeMillis() + File.separator + "jattach-linux";
138141
FileUtils.getResourceToFile("bin/jattach-linux", JATTACH_FILE);
139142
}

dongtai-agent/src/main/java/io/dongtai/iast/agent/util/FileUtils.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ public static void confReplace(String path) {
5050
StringBuffer buf = new StringBuffer();
5151
// 保存该行前面的内容
5252
while ((temp = br.readLine()) != null) {
53-
if (temp.contains("${HOSTNAME_AGENT_ID}")){
54-
temp = temp.replace("${HOSTNAME_AGENT_ID}", AgentRegisterReport.getInternalHostName()+"-"+AgentRegisterReport.getAgentFlag().toString());
55-
}else if (temp.contains("${HOSTNAME}")){
56-
temp = temp.replace("${HOSTNAME}",AgentRegisterReport.getInternalHostName());
57-
}else if (temp.contains("${AGENT_ID}")){
58-
temp = temp.replace("${AGENT_ID}",AgentRegisterReport.getAgentFlag().toString());
59-
}else if (temp.contains("${OPENAPI}")){
53+
if (temp.contains("${HOSTNAME_AGENT_ID}")) {
54+
temp = temp.replace("${HOSTNAME_AGENT_ID}", AgentRegisterReport.getInternalHostName() + "-" + AgentRegisterReport.getAgentFlag().toString());
55+
} else if (temp.contains("${HOSTNAME}")) {
56+
temp = temp.replace("${HOSTNAME}", AgentRegisterReport.getInternalHostName());
57+
} else if (temp.contains("${AGENT_ID}")) {
58+
temp = temp.replace("${AGENT_ID}", AgentRegisterReport.getAgentFlag().toString());
59+
} else if (temp.contains("${OPENAPI}")) {
6060
String logAddress = IastProperties.getInstance().getLogAddress();
61-
if (null == logAddress){
61+
if (null == logAddress) {
6262
String s = IastProperties.getInstance().getBaseUrl();
6363
try {
6464
String openApiDomain = new URI(s).getHost();
@@ -70,17 +70,16 @@ public static void confReplace(String path) {
7070
}
7171
temp = temp.replace("${OPENAPI}", s);
7272
}
73-
}else {
73+
} else {
7474
temp = temp.replace("${OPENAPI}", logAddress);
7575
}
76-
}else if (temp.contains("${LOG_PORT}")){
76+
} else if (temp.contains("${LOG_PORT}")) {
7777
String logPort = IastProperties.getInstance().getLogPort();
78-
if (null == logPort){
78+
if (null == logPort) {
7979
String s = IastProperties.getInstance().getBaseUrl();
8080
try {
8181
int openApiPort = new URI(s).getPort();
82-
temp = temp.replace("${LOG_PORT}", openApiPort > 0 ? Integer.toString(openApiPort) :
83-
("https".equalsIgnoreCase(new URI(s).getScheme()) ? "443" : "80"));
82+
temp = temp.replace("${LOG_PORT}", openApiPort > 0 ? Integer.toString(openApiPort) : "80");
8483
} catch (Exception e) {
8584
s = s.substring(s.indexOf("://") + 3, s.indexOf("/openapi"));
8685
if (s.contains(":")) {
@@ -90,11 +89,11 @@ public static void confReplace(String path) {
9089
temp = temp.replace("${LOG_PORT}", "80");
9190
}
9291
}
93-
}else {
92+
} else {
9493
temp = temp.replace("${LOG_PORT}", logPort);
9594
}
96-
}else if (temp.contains("${LOG_PATH}")){
97-
temp = temp.replace("${LOG_PATH}", System.getProperty("java.io.tmpdir.dongtai")+File.separator+"dongtaiJavaAgentLogs"+File.separator+"dongtai_javaagent.log");
95+
} else if (temp.contains("${LOG_PATH}")) {
96+
temp = temp.replace("${LOG_PATH}", System.getProperty("java.io.tmpdir.dongtai") + File.separator + "dongtaiJavaAgentLogs" + File.separator + "dongtai_javaagent.log");
9897
}
9998
buf = buf.append(temp);
10099
buf = buf.append(System.getProperty("line.separator"));
72.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)