From 114234fc742fd14d74e4c00afb6897f512088cc7 Mon Sep 17 00:00:00 2001 From: tangyouyi1513 <17319335230@163.com> Date: Wed, 25 Oct 2017 18:45:55 +0800 Subject: [PATCH] fix the api of getting localhost for jboss6 (#49) * modify security policy log format * add support for macos add ognl.expression.minlength config to filter ognl expression * update ognl test-case * fix the api of getting localhost for jboss6 --- .../java/com/fuxi/javaagent/HookHandler.java | 5 +---- .../java/com/fuxi/javaagent/tool/OSUtil.java | 20 ++++++++----------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/agent/java/src/main/java/com/fuxi/javaagent/HookHandler.java b/agent/java/src/main/java/com/fuxi/javaagent/HookHandler.java index 668fde118..d491ef93e 100755 --- a/agent/java/src/main/java/com/fuxi/javaagent/HookHandler.java +++ b/agent/java/src/main/java/com/fuxi/javaagent/HookHandler.java @@ -41,10 +41,7 @@ import com.fuxi.javaagent.request.AbstractRequest; import com.fuxi.javaagent.request.HttpServletRequest; import com.fuxi.javaagent.response.HttpServletResponse; -import com.fuxi.javaagent.tool.FileUtil; -import com.fuxi.javaagent.tool.Reflection; -import com.fuxi.javaagent.tool.StackTrace; -import com.fuxi.javaagent.tool.TimeUtils; +import com.fuxi.javaagent.tool.*; import com.fuxi.javaagent.tool.hook.CustomLockObject; import com.fuxi.javaagent.tool.security.SqlConnectionChecker; import com.fuxi.javaagent.tool.security.TomcatSecurityChecker; diff --git a/agent/java/src/main/java/com/fuxi/javaagent/tool/OSUtil.java b/agent/java/src/main/java/com/fuxi/javaagent/tool/OSUtil.java index 596b60b0c..ea5cb44bf 100644 --- a/agent/java/src/main/java/com/fuxi/javaagent/tool/OSUtil.java +++ b/agent/java/src/main/java/com/fuxi/javaagent/tool/OSUtil.java @@ -32,31 +32,27 @@ import com.fuxi.javaagent.tool.model.NicModel; -import java.net.*; +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.NetworkInterface; import java.util.Enumeration; -import java.util.HashMap; import java.util.LinkedList; public class OSUtil { private static InetAddress inetAddress; - static { - try { - inetAddress = InetAddress.getLocalHost(); - } catch (UnknownHostException e) { - e.printStackTrace(); - } - } - public static String getHostName() { return inetAddress == null ? null : inetAddress.getHostName(); } public static LinkedList getIpAddress() { LinkedList ipList = new LinkedList(); - Enumeration allNetInterfaces = null; try { + if (inetAddress == null) { + inetAddress = InetAddress.getLocalHost(); + } + Enumeration allNetInterfaces = null; allNetInterfaces = NetworkInterface.getNetworkInterfaces(); if (allNetInterfaces != null) { @@ -75,7 +71,7 @@ public static LinkedList getIpAddress() { } } } - } catch (SocketException e) { + } catch (Exception e) { e.printStackTrace(); } return ipList;