Skip to content

Commit a2b74d9

Browse files
committed
fix benchmark compile
1 parent 8d30453 commit a2b74d9

File tree

3 files changed

+139
-146
lines changed

3 files changed

+139
-146
lines changed

rasp/jvm/JVMAgent/src/main/java/com/security/smithloader/SmithAgent.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ public static Object ExceptionProxy(Object MethodNameObj,int classID, int method
9999
return obj;
100100
}
101101

102+
public static void RecordProxy(int classID, int methodID, long t1, long t2) {
103+
if (checkRecursive!= null && checkRecursive.get() == true) {
104+
return;
105+
}
106+
if (checkRecursive!= null && checkRecursive.get() == false) {
107+
checkRecursive.set(true);
108+
}
109+
if(SmithProberProxyObj!= null) {
110+
Class<?>[] argType = new Class[]{int.class,int.class, long.class, long.class};
111+
Reflection.invokeMethod(SmithProberProxyObj,"record",argType,classID,methodID,t1,t2);
112+
}
113+
if (checkRecursive != null && checkRecursive.get() == true) {
114+
checkRecursive.set(false);
115+
}
116+
}
117+
102118
private static boolean loadSmithProber(String proberPath, Instrumentation inst) {
103119
boolean bret = false;
104120
boolean bexception = false;

rasp/jvm/JVMProbe/src/main/java/com/security/smith/SmithProbe.java

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ public class SmithProbe implements ClassFileTransformer, MessageHandler, EventHa
172172
public SmithProbe() {
173173
disable = false;
174174
scanswitch = true;
175+
records = new ConcurrentHashMap<>();
176+
recordsTotal = new ConcurrentHashMap<>();
177+
hooktimeRecords = new ConcurrentHashMap<>();
178+
runtimeRecords = new ConcurrentHashMap<>();
175179
}
176180

177181
public void setInst(Instrumentation inst) {
@@ -215,10 +219,7 @@ public void init() {
215219
limits = new ConcurrentHashMap<>();
216220
hookTypes = new ConcurrentHashMap<>();
217221
switchConfig = new ConcurrentHashMap<>();
218-
records = new ConcurrentHashMap<>();
219-
recordsTotal = new ConcurrentHashMap<>();
220-
hooktimeRecords = new ConcurrentHashMap<>();
221-
runtimeRecords = new ConcurrentHashMap<>();
222+
222223

223224
MessageSerializer.initInstance(proberVersion);
224225
MessageEncoder.initInstance();
@@ -397,6 +398,7 @@ public void start() {
397398
detectTimerTask,
398399
TimeUnit.MINUTES.toMillis(1)
399400
);
401+
400402
smithproxyTimerTask = new SmithproxyTimerTask();
401403
smithproxyTimerTask.setSmithProxy(smithProxy);
402404

@@ -421,6 +423,16 @@ public void start() {
421423
reloadClasses();
422424

423425
SmithLogger.logger.info("probe start leave");
426+
new Timer(true).schedule(
427+
new TimerTask() {
428+
@Override
429+
public void run() {
430+
show();
431+
}
432+
},
433+
TimeUnit.SECONDS.toMillis(5),
434+
TimeUnit.SECONDS.toMillis(10)
435+
);
424436
}
425437

426438
public void stop() {
@@ -515,28 +527,6 @@ public void uninit() {
515527
SmithLogger.loggerProberUnInit();
516528

517529
}
518-
new Timer(true).schedule(
519-
new TimerTask() {
520-
@Override
521-
public void run() {
522-
onTimer();
523-
}
524-
},
525-
0,
526-
TimeUnit.MINUTES.toMillis(1)
527-
);
528-
529-
new Timer(true).schedule(
530-
new TimerTask() {
531-
@Override
532-
public void run() {
533-
show();
534-
}
535-
},
536-
TimeUnit.SECONDS.toMillis(5),
537-
TimeUnit.SECONDS.toMillis(10)
538-
);
539-
}
540530

541531
private void reloadClasses() {
542532
reloadClasses(smithClasses.keySet());

0 commit comments

Comments
 (0)