-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added support for Jazzer's fuzzerInitialize and fuzzerTearDown call…
…backs * Fixed defect where AnalysisReplayerManager#next could return null * Changed CampaignAnalyzer#closeConnection to more gracefully terminate the forked analysis process * Changed from using old Jazzer replayer to using Jazzer's FuzzTarget and LifecycleMethodsInvoker to perform analysis reruns
- Loading branch information
1 parent
29f4345
commit 22bd28b
Showing
9 changed files
with
137 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
meringue-jazzer-extension/src/main/java/edu/neu/ccs/prl/meringue/FuzzTargetRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package edu.neu.ccs.prl.meringue; | ||
|
||
import com.code_intelligence.jazzer.driver.FuzzTargetHolder; | ||
import com.code_intelligence.jazzer.driver.FuzzedDataProviderImpl; | ||
import com.code_intelligence.jazzer.driver.LifecycleMethodsInvoker; | ||
import com.code_intelligence.jazzer.utils.Log; | ||
|
||
import java.lang.invoke.MethodHandle; | ||
import java.lang.invoke.MethodHandles; | ||
import java.lang.reflect.Method; | ||
|
||
public final class FuzzTargetRunner { | ||
private final MethodHandle fuzzTargetMethod; | ||
private final LifecycleMethodsInvoker lifecycleMethodsInvoker; | ||
private final boolean useFuzzedDataProvider; | ||
private final Object fuzzTargetInstance; | ||
|
||
public FuzzTargetRunner(String testClassName) throws Throwable { | ||
FuzzTargetHolder.FuzzTarget fuzzTarget = findFuzzTarget(testClassName); | ||
lifecycleMethodsInvoker = fuzzTarget.lifecycleMethodsInvoker; | ||
fuzzTarget.method.setAccessible(true); | ||
fuzzTargetMethod = MethodHandles.lookup().unreflect(fuzzTarget.method); | ||
useFuzzedDataProvider = fuzzTarget.usesFuzzedDataProvider(); | ||
fuzzTargetInstance = fuzzTarget.newInstance.call(); | ||
lifecycleMethodsInvoker.beforeFirstExecution(); | ||
Runtime.getRuntime().addShutdownHook(new Thread(this::shutdown)); | ||
} | ||
|
||
public Throwable run(byte[] data) { | ||
try { | ||
if (useFuzzedDataProvider) { | ||
try (FuzzedDataProviderImpl provider = FuzzedDataProviderImpl.withJavaData(data)) { | ||
runInternal(provider); | ||
} | ||
} else { | ||
runInternal(data); | ||
} | ||
} catch (Throwable t) { | ||
return t; | ||
} | ||
return null; | ||
} | ||
|
||
public void runInternal(Object argument) throws Throwable { | ||
lifecycleMethodsInvoker.beforeEachExecution(); | ||
if (fuzzTargetInstance == null) { | ||
fuzzTargetMethod.invoke(argument); | ||
} else { | ||
fuzzTargetMethod.invoke(fuzzTargetInstance, argument); | ||
} | ||
} | ||
|
||
private void shutdown() { | ||
try { | ||
lifecycleMethodsInvoker.afterLastExecution(); | ||
} catch (Throwable t) { | ||
Log.finding(t); | ||
} | ||
} | ||
|
||
private FuzzTargetHolder.FuzzTarget findFuzzTarget(String testClassName) throws ReflectiveOperationException { | ||
Class<?> clazz = Class.forName("com.code_intelligence.jazzer.driver.FuzzTargetFinder"); | ||
Method m = clazz.getDeclaredMethod("findFuzzTarget", String.class); | ||
m.setAccessible(true); | ||
return (FuzzTargetHolder.FuzzTarget) m.invoke(null, testClassName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 12 additions & 6 deletions
18
meringue-jazzer-extension/src/main/java/edu/neu/ccs/prl/meringue/JazzerReplayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
meringue-jazzer-extension/src/main/resources/META-INF/NOTICE.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters