aboutsummaryrefslogtreecommitdiff
path: root/agent
diff options
context:
space:
mode:
authorFabian Meumertzheim <meumertzheim@code-intelligence.com>2021-10-21 10:17:38 +0200
committerFabian Meumertzheim <fabian@meumertzhe.im>2021-10-21 15:49:56 +0200
commita56cf70a429708a2bcce14fc978481b04dd330fd (patch)
tree51675f51076a4d7e6e8f25ff7736215f0e123825 /agent
parentd4a1ce3f2e227bc30bcd2d97b623c193197e293e (diff)
downloadjazzer-api-a56cf70a429708a2bcce14fc978481b04dd330fd.tar.gz
Add ConsumerN, FunctionN and autofuzz methods up to N=5
Diffstat (limited to 'agent')
-rw-r--r--agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer2.java22
-rw-r--r--agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer3.java20
-rw-r--r--agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer4.java20
-rw-r--r--agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer5.java20
-rw-r--r--agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Function3.java20
-rw-r--r--agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Function4.java20
-rw-r--r--agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Function5.java20
-rw-r--r--agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Meta.java54
8 files changed, 196 insertions, 0 deletions
diff --git a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer2.java b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer2.java
new file mode 100644
index 00000000..31931605
--- /dev/null
+++ b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer2.java
@@ -0,0 +1,22 @@
+// Copyright 2021 Code Intelligence GmbH
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.code_intelligence.jazzer.autofuzz;
+
+import java.util.function.BiConsumer;
+
+@FunctionalInterface
+public interface Consumer2<T1, T2> extends BiConsumer<T1, T2> {
+ @Override void accept(T1 t1, T2 t2);
+}
diff --git a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer3.java b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer3.java
new file mode 100644
index 00000000..9e632601
--- /dev/null
+++ b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer3.java
@@ -0,0 +1,20 @@
+// Copyright 2021 Code Intelligence GmbH
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.code_intelligence.jazzer.autofuzz;
+
+@FunctionalInterface
+public interface Consumer3<T1, T2, T3> {
+ void accept(T1 t1, T2 t2, T3 t3);
+}
diff --git a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer4.java b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer4.java
new file mode 100644
index 00000000..5e619efb
--- /dev/null
+++ b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer4.java
@@ -0,0 +1,20 @@
+// Copyright 2021 Code Intelligence GmbH
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.code_intelligence.jazzer.autofuzz;
+
+@FunctionalInterface
+public interface Consumer4<T1, T2, T3, T4> {
+ void accept(T1 t1, T2 t2, T3 t3, T4 t4);
+}
diff --git a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer5.java b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer5.java
new file mode 100644
index 00000000..1e9e55c9
--- /dev/null
+++ b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Consumer5.java
@@ -0,0 +1,20 @@
+// Copyright 2021 Code Intelligence GmbH
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.code_intelligence.jazzer.autofuzz;
+
+@FunctionalInterface
+public interface Consumer5<T1, T2, T3, T4, T5> {
+ void accept(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5);
+}
diff --git a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Function3.java b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Function3.java
new file mode 100644
index 00000000..a4572d5b
--- /dev/null
+++ b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Function3.java
@@ -0,0 +1,20 @@
+// Copyright 2021 Code Intelligence GmbH
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.code_intelligence.jazzer.autofuzz;
+
+@FunctionalInterface
+public interface Function3<T1, T2, T3, R> {
+ R apply(T1 arg1, T2 arg2, T3 arg3);
+}
diff --git a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Function4.java b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Function4.java
new file mode 100644
index 00000000..3a26f516
--- /dev/null
+++ b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Function4.java
@@ -0,0 +1,20 @@
+// Copyright 2021 Code Intelligence GmbH
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.code_intelligence.jazzer.autofuzz;
+
+@FunctionalInterface
+public interface Function4<T1, T2, T3, T4, R> {
+ R apply(T1 arg1, T2 arg2, T3 arg3, T4 arg4);
+}
diff --git a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Function5.java b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Function5.java
new file mode 100644
index 00000000..1dc00347
--- /dev/null
+++ b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Function5.java
@@ -0,0 +1,20 @@
+// Copyright 2021 Code Intelligence GmbH
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.code_intelligence.jazzer.autofuzz;
+
+@FunctionalInterface
+public interface Function5<T1, T2, T3, T4, T5, R> {
+ R apply(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
+}
diff --git a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Meta.java b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Meta.java
index 4a679b8f..f0ec42eb 100644
--- a/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Meta.java
+++ b/agent/src/main/java/com/code_intelligence/jazzer/autofuzz/Meta.java
@@ -84,6 +84,36 @@ public class Meta {
}
@SuppressWarnings("unchecked")
+ public static <T1, T2> void autofuzz(FuzzedDataProvider data, Consumer2<T1, T2> func) {
+ Class<?>[] types = TypeResolver.resolveRawArguments(Consumer2.class, func.getClass());
+ func.accept((T1) consumeChecked(data, types, 0), (T2) consumeChecked(data, types, 1));
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T1, T2, T3> void autofuzz(FuzzedDataProvider data, Consumer3<T1, T2, T3> func) {
+ Class<?>[] types = TypeResolver.resolveRawArguments(Consumer3.class, func.getClass());
+ func.accept((T1) consumeChecked(data, types, 0), (T2) consumeChecked(data, types, 1),
+ (T3) consumeChecked(data, types, 2));
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T1, T2, T3, T4> void autofuzz(
+ FuzzedDataProvider data, Consumer4<T1, T2, T3, T4> func) {
+ Class<?>[] types = TypeResolver.resolveRawArguments(Consumer4.class, func.getClass());
+ func.accept((T1) consumeChecked(data, types, 0), (T2) consumeChecked(data, types, 1),
+ (T3) consumeChecked(data, types, 2), (T4) consumeChecked(data, types, 3));
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T1, T2, T3, T4, T5> void autofuzz(
+ FuzzedDataProvider data, Consumer5<T1, T2, T3, T4, T5> func) {
+ Class<?>[] types = TypeResolver.resolveRawArguments(Consumer5.class, func.getClass());
+ func.accept((T1) consumeChecked(data, types, 0), (T2) consumeChecked(data, types, 1),
+ (T3) consumeChecked(data, types, 2), (T4) consumeChecked(data, types, 3),
+ (T5) consumeChecked(data, types, 4));
+ }
+
+ @SuppressWarnings("unchecked")
public static <T1, R> R autofuzz(FuzzedDataProvider data, Function1<T1, R> func) {
Class<?>[] types = TypeResolver.resolveRawArguments(Function1.class, func.getClass());
return func.apply((T1) consumeChecked(data, types, 0));
@@ -95,6 +125,30 @@ public class Meta {
return func.apply((T1) consumeChecked(data, types, 0), (T2) consumeChecked(data, types, 1));
}
+ @SuppressWarnings("unchecked")
+ public static <T1, T2, T3, R> R autofuzz(FuzzedDataProvider data, Function3<T1, T2, T3, R> func) {
+ Class<?>[] types = TypeResolver.resolveRawArguments(Function3.class, func.getClass());
+ return func.apply((T1) consumeChecked(data, types, 0), (T2) consumeChecked(data, types, 1),
+ (T3) consumeChecked(data, types, 2));
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T1, T2, T3, T4, R> R autofuzz(
+ FuzzedDataProvider data, Function4<T1, T2, T3, T4, R> func) {
+ Class<?>[] types = TypeResolver.resolveRawArguments(Function4.class, func.getClass());
+ return func.apply((T1) consumeChecked(data, types, 0), (T2) consumeChecked(data, types, 1),
+ (T3) consumeChecked(data, types, 2), (T4) consumeChecked(data, types, 3));
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T1, T2, T3, T4, T5, R> R autofuzz(
+ FuzzedDataProvider data, Function5<T1, T2, T3, T4, T5, R> func) {
+ Class<?>[] types = TypeResolver.resolveRawArguments(Function5.class, func.getClass());
+ return func.apply((T1) consumeChecked(data, types, 0), (T2) consumeChecked(data, types, 1),
+ (T3) consumeChecked(data, types, 2), (T4) consumeChecked(data, types, 3),
+ (T5) consumeChecked(data, types, 4));
+ }
+
public static Object consume(FuzzedDataProvider data, Class<?> type) {
if (type == byte.class || type == Byte.class) {
return data.consumeByte();