From 8969395f90c1a726e92f08b2c09d13b5cad74d62 Mon Sep 17 00:00:00 2001 From: cc11001100 Date: Thu, 21 Sep 2023 14:11:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AD=96=E7=95=A5hook=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=AF=8F=E4=B8=AA=E7=B1=BB=E5=8C=B9=E9=85=8D=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E5=91=BD=E4=B8=AD=E7=9A=84=E6=83=85=E5=86=B5=E4=BB=A5?= =?UTF-8?q?=E4=BE=BF=E8=A7=82=E6=B5=8B=E6=8E=92=E6=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enhance/plugin/core/DispatchClassPlugin.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/enhance/plugin/core/DispatchClassPlugin.java b/dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/enhance/plugin/core/DispatchClassPlugin.java index dd8794487..94ff44ffb 100644 --- a/dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/enhance/plugin/core/DispatchClassPlugin.java +++ b/dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/enhance/plugin/core/DispatchClassPlugin.java @@ -9,11 +9,15 @@ import io.dongtai.iast.core.handler.hookpoint.models.policy.PolicyNode; import io.dongtai.iast.core.utils.AsmUtils; import io.dongtai.log.DongTaiLog; -import org.objectweb.asm.*; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; import org.objectweb.asm.commons.JSRInlinerAdapter; import java.lang.reflect.Modifier; -import java.util.*; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; /** * @author dongzhiyong@huoxian.cn @@ -29,11 +33,14 @@ public DispatchClassPlugin() { public ClassVisitor dispatch(ClassVisitor classVisitor, ClassContext classContext, Policy policy) { ancestors = classContext.getAncestors(); className = classContext.getClassName(); - Set matchedClassNameSet = policy.getMatchedClass(classContext,className, ancestors); + Set matchedClassNameSet = policy.getMatchedClass(classContext, className, ancestors); + // 匹配的时候增加日志方便根据类或者策略观测定位问题 if (0 == matchedClassNameSet.size()) { + DongTaiLog.trace("class = {}, no matching policy, so ignored.", classContext.getClassName()); return classVisitor; } + DongTaiLog.trace("class = {}, matching policy classes = {}", classContext.getClassName(), String.join(", ", matchedClassNameSet)); classContext.setMatchedClassSet(matchedClassNameSet); return new ClassVisit(classVisitor, classContext, policy);