Skip to content

Commit f1eb0f0

Browse files
author
‘niuerzhuang’
committed
fix: kafka exception.
1 parent a2fb0b5 commit f1eb0f0

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/enhance/plugin/PluginRegister.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,23 @@ public class PluginRegister {
2929

3030
public PluginRegister() {
3131
this.plugins = new ArrayList<DispatchPlugin>();
32-
this.plugins.add(new DispatchSpringApplication());
32+
if(!"false".equals(System.getProperty("dongtai.plugin.api"))){
33+
this.plugins.add(new DispatchSpringApplication());
34+
}
3335
this.plugins.add(new DispatchJ2ee());
34-
this.plugins.add(new DispatchKafka());
36+
if(!"false".equals(System.getProperty("dongtai.plugin.kafka"))) {
37+
this.plugins.add(new DispatchKafka());
38+
}
3539
this.plugins.add(new DispatchJdbc());
36-
this.plugins.add(new DispatchShiro());
37-
this.plugins.add(new DispatchFeign());
38-
this.plugins.add(new DispatchDubbo());
39-
40+
if(!"false".equals(System.getProperty("dongtai.plugin.shiro"))) {
41+
this.plugins.add(new DispatchShiro());
42+
}
43+
if(!"false".equals(System.getProperty("dongtai.plugin.feign"))) {
44+
this.plugins.add(new DispatchFeign());
45+
}
46+
if(!"false".equals(System.getProperty("dongtai.plugin.dubbo"))) {
47+
this.plugins.add(new DispatchDubbo());
48+
}
4049
this.plugins.add(new DispatchClassPlugin());
4150
}
4251

dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/enhance/plugin/service/kafka/KafkaAbstractConfigInitAdviceAdapter.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.dongtai.iast.core.bytecode.enhance.asm.AsmTypes;
55
import io.dongtai.iast.core.handler.hookpoint.service.ServiceType;
66
import io.dongtai.iast.core.utils.AsmUtils;
7+
import org.objectweb.asm.Label;
78
import org.objectweb.asm.MethodVisitor;
89
import org.objectweb.asm.Type;
910
import org.objectweb.asm.commons.AdviceAdapter;
@@ -20,6 +21,12 @@ protected KafkaAbstractConfigInitAdviceAdapter(MethodVisitor mv, int access, Str
2021
@Override
2122
protected void onMethodExit(int opcode) {
2223
if (opcode != ATHROW) {
24+
Label tryL = new Label();
25+
Label catchL = new Label();
26+
Label exHandlerL = new Label();
27+
visitTryCatchBlock(tryL, catchL, exHandlerL, ASM_TYPE_THROWABLE.getInternalName());
28+
visitLabel(tryL);
29+
2330
localServers = newLocal(Type.getType(List.class));
2431
loadThis();
2532
push("bootstrap.servers");
@@ -39,6 +46,13 @@ protected void onMethodExit(int opcode) {
3946
push("");
4047
push("KafkaUrlHandler");
4148
invokeInterface(ASM_TYPE_SPY_DISPATCHER, SPY$reportService);
49+
50+
visitLabel(catchL);
51+
Label endL = new Label();
52+
visitJumpInsn(GOTO, endL);
53+
visitLabel(exHandlerL);
54+
visitVarInsn(ASTORE, this.nextLocal);
55+
visitLabel(endL);
4256
}
4357
}
4458
}

0 commit comments

Comments
 (0)