diff --git a/dongtai-agent/src/main/java/io/dongtai/iast/agent/Agent.java b/dongtai-agent/src/main/java/io/dongtai/iast/agent/Agent.java index f882e8cfa..4903644c6 100644 --- a/dongtai-agent/src/main/java/io/dongtai/iast/agent/Agent.java +++ b/dongtai-agent/src/main/java/io/dongtai/iast/agent/Agent.java @@ -114,8 +114,8 @@ private static void doAttach(String pid, String agentArgs) { } } - private static boolean isLinux() { - return OS_NAME.indexOf("linux") >= 0; + private static boolean isArm() { + return System.getProperty("os.arch").contains("arm") || System.getProperty("os.arch").contains("aarch"); } public static boolean isWindows() { @@ -133,7 +133,10 @@ private static void extractJattach() throws IOException { } else if (isMacOs()) { JATTACH_FILE = System.getProperty("java.io.tmpdir")+ File.separator + "iast"+System.currentTimeMillis() + File.separator + "jattach-mac"; FileUtils.getResourceToFile("bin/jattach-mac", JATTACH_FILE); - } else { + } else if (isArm()){ + JATTACH_FILE = System.getProperty("java.io.tmpdir")+ File.separator + "iast"+System.currentTimeMillis() + File.separator + "jattach-linux"; + FileUtils.getResourceToFile("bin/jattach-arm", JATTACH_FILE); + }else { JATTACH_FILE = System.getProperty("java.io.tmpdir")+ File.separator + "iast"+System.currentTimeMillis() + File.separator + "jattach-linux"; FileUtils.getResourceToFile("bin/jattach-linux", JATTACH_FILE); } diff --git a/dongtai-agent/src/main/java/io/dongtai/iast/agent/util/FileUtils.java b/dongtai-agent/src/main/java/io/dongtai/iast/agent/util/FileUtils.java index 24975c634..5fd608fcf 100644 --- a/dongtai-agent/src/main/java/io/dongtai/iast/agent/util/FileUtils.java +++ b/dongtai-agent/src/main/java/io/dongtai/iast/agent/util/FileUtils.java @@ -50,15 +50,15 @@ public static void confReplace(String path) { StringBuffer buf = new StringBuffer(); // 保存该行前面的内容 while ((temp = br.readLine()) != null) { - if (temp.contains("${HOSTNAME_AGENT_ID}")){ - temp = temp.replace("${HOSTNAME_AGENT_ID}", AgentRegisterReport.getInternalHostName()+"-"+AgentRegisterReport.getAgentFlag().toString()); - }else if (temp.contains("${HOSTNAME}")){ - temp = temp.replace("${HOSTNAME}",AgentRegisterReport.getInternalHostName()); - }else if (temp.contains("${AGENT_ID}")){ - temp = temp.replace("${AGENT_ID}",AgentRegisterReport.getAgentFlag().toString()); - }else if (temp.contains("${OPENAPI}")){ + if (temp.contains("${HOSTNAME_AGENT_ID}")) { + temp = temp.replace("${HOSTNAME_AGENT_ID}", AgentRegisterReport.getInternalHostName() + "-" + AgentRegisterReport.getAgentFlag().toString()); + } else if (temp.contains("${HOSTNAME}")) { + temp = temp.replace("${HOSTNAME}", AgentRegisterReport.getInternalHostName()); + } else if (temp.contains("${AGENT_ID}")) { + temp = temp.replace("${AGENT_ID}", AgentRegisterReport.getAgentFlag().toString()); + } else if (temp.contains("${OPENAPI}")) { String logAddress = IastProperties.getInstance().getLogAddress(); - if (null == logAddress){ + if (null == logAddress) { String s = IastProperties.getInstance().getBaseUrl(); try { String openApiDomain = new URI(s).getHost(); @@ -70,17 +70,16 @@ public static void confReplace(String path) { } temp = temp.replace("${OPENAPI}", s); } - }else { + } else { temp = temp.replace("${OPENAPI}", logAddress); } - }else if (temp.contains("${LOG_PORT}")){ + } else if (temp.contains("${LOG_PORT}")) { String logPort = IastProperties.getInstance().getLogPort(); - if (null == logPort){ + if (null == logPort) { String s = IastProperties.getInstance().getBaseUrl(); try { int openApiPort = new URI(s).getPort(); - temp = temp.replace("${LOG_PORT}", openApiPort > 0 ? Integer.toString(openApiPort) : - ("https".equalsIgnoreCase(new URI(s).getScheme()) ? "443" : "80")); + temp = temp.replace("${LOG_PORT}", openApiPort > 0 ? Integer.toString(openApiPort) : "80"); } catch (Exception e) { s = s.substring(s.indexOf("://") + 3, s.indexOf("/openapi")); if (s.contains(":")) { @@ -90,11 +89,11 @@ public static void confReplace(String path) { temp = temp.replace("${LOG_PORT}", "80"); } } - }else { + } else { temp = temp.replace("${LOG_PORT}", logPort); } - }else if (temp.contains("${LOG_PATH}")){ - temp = temp.replace("${LOG_PATH}", System.getProperty("java.io.tmpdir.dongtai")+File.separator+"dongtaiJavaAgentLogs"+File.separator+"dongtai_javaagent.log"); + } else if (temp.contains("${LOG_PATH}")) { + temp = temp.replace("${LOG_PATH}", System.getProperty("java.io.tmpdir.dongtai") + File.separator + "dongtaiJavaAgentLogs" + File.separator + "dongtai_javaagent.log"); } buf = buf.append(temp); buf = buf.append(System.getProperty("line.separator")); diff --git a/dongtai-agent/src/main/resources/bin/jattach-arm b/dongtai-agent/src/main/resources/bin/jattach-arm new file mode 100755 index 000000000..3d957495b Binary files /dev/null and b/dongtai-agent/src/main/resources/bin/jattach-arm differ