aboutsummaryrefslogtreecommitdiff
path: root/agent
diff options
context:
space:
mode:
authorFabian Meumertzheim <meumertzheim@code-intelligence.com>2021-10-18 18:06:34 +0200
committerFabian Meumertzheim <fabian@meumertzhe.im>2021-10-19 11:07:51 +0200
commitaa60a2e68aa011c45a273e5349c07f1b9007e7b2 (patch)
tree3301596547008cd11f7de120d931c07a558098ea /agent
parent908ee7f9505c684b0f6ddd66165af079d9aea315 (diff)
downloadjazzer-api-aa60a2e68aa011c45a273e5349c07f1b9007e7b2.tar.gz
Add an --autofuzz_ignore flag to ignore exception classes
Diffstat (limited to 'agent')
-rw-r--r--agent/src/main/java/com/code_intelligence/jazzer/autofuzz/FuzzTarget.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/FuzzTarget.java b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/FuzzTarget.java
index 677d107e..b5b97fd6 100644
--- a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/FuzzTarget.java
+++ b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/FuzzTarget.java
@@ -20,8 +20,10 @@ import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.net.URLDecoder;
import java.util.Arrays;
+import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
public class FuzzTarget {
private static final long MAX_EXECUTIONS_WITHOUT_INVOCATION = 100;
@@ -32,7 +34,7 @@ public class FuzzTarget {
private static long executionsSinceLastInvocation = 0;
public static void fuzzerInitialize(String[] args) {
- if (args.length != 1 || !args[0].contains("::")) {
+ if (args.length == 0 || !args[0].contains("::")) {
System.err.println(
"Expected the argument to --autofuzz to be a method reference (e.g. System.out::println)");
System.exit(1);
@@ -106,9 +108,26 @@ public class FuzzTarget {
}
System.exit(1);
}
+ List<Class<?>> alwaysIgnore =
+ Arrays.stream(args)
+ .skip(1)
+ .map(name -> {
+ try {
+ return Thread.currentThread().getContextClassLoader().loadClass(name);
+ } catch (ClassNotFoundException e) {
+ System.err.printf("Failed to find class '%s' specified in --autofuzz_ignore", name);
+ System.exit(1);
+ }
+ throw new Error("Not reached");
+ })
+ .collect(Collectors.toList());
throwsDeclarations =
Arrays.stream(targetMethods)
- .collect(Collectors.toMap(method -> method, Method::getExceptionTypes));
+ .collect(Collectors.toMap(method
+ -> method,
+ method
+ -> Stream.concat(Arrays.stream(method.getExceptionTypes()), alwaysIgnore.stream())
+ .toArray(Class[] ::new)));
}
public static void fuzzerTestOneInput(FuzzedDataProvider data) throws Throwable {