aboutsummaryrefslogtreecommitdiff
path: root/bazel/fuzz_target.bzl
diff options
context:
space:
mode:
Diffstat (limited to 'bazel/fuzz_target.bzl')
-rw-r--r--bazel/fuzz_target.bzl40
1 files changed, 32 insertions, 8 deletions
diff --git a/bazel/fuzz_target.bzl b/bazel/fuzz_target.bzl
index bd90e500..c70543bd 100644
--- a/bazel/fuzz_target.bzl
+++ b/bazel/fuzz_target.bzl
@@ -17,7 +17,7 @@ def java_fuzz_target_test(
target_class = None,
deps = [],
hook_classes = [],
- native_libs = [],
+ data = [],
sanitizer = None,
visibility = None,
tags = [],
@@ -25,6 +25,12 @@ def java_fuzz_target_test(
srcs = [],
size = None,
timeout = None,
+ env = None,
+ verify_crash_input = True,
+ verify_crash_reproducer = True,
+ expect_crash = True,
+ # Default is that the reproducer does not throw any exception.
+ expected_findings = [],
**kwargs):
target_name = name + "_target"
deploy_manifest_lines = []
@@ -47,8 +53,6 @@ def java_fuzz_target_test(
**kwargs
)
- additional_args = []
-
if sanitizer == None:
driver = "//driver:jazzer_driver"
elif sanitizer == "address":
@@ -60,19 +64,39 @@ def java_fuzz_target_test(
native.java_test(
name = name,
- runtime_deps = ["//bazel:fuzz_target_test_wrapper"],
+ runtime_deps = [
+ "//bazel/tools/java:fuzz_target_test_wrapper",
+ "//agent:jazzer_api_deploy.jar",
+ ":%s_deploy.jar" % target_name,
+ ],
+ jvm_flags = [
+ # Use the same memory settings for reproducers as those suggested by Jazzer when
+ # encountering an OutOfMemoryError.
+ "-Xmx1620m",
+ # Ensure that reproducers can be compiled even if they contain UTF-8 characters.
+ "-Dfile.encoding=UTF-8",
+ ],
size = size or "enormous",
timeout = timeout or "moderate",
args = [
"$(rootpath %s)" % driver,
+ "$(rootpath //agent:jazzer_api_deploy.jar)",
"$(rootpath :%s_deploy.jar)" % target_name,
- ] + additional_args + fuzzer_args,
+ str(verify_crash_input),
+ str(verify_crash_reproducer),
+ str(expect_crash),
+ # args are shell tokenized and thus quotes are required in the case where
+ # expected_findings is empty.
+ "'" + ",".join(expected_findings) + "'",
+ ] + fuzzer_args,
data = [
":%s_deploy.jar" % target_name,
- "//agent:jazzer_agent_deploy.jar",
+ "//agent:jazzer_agent_deploy",
+ "//agent:jazzer_api_deploy.jar",
driver,
- ] + native_libs,
- main_class = "FuzzTargetTestWrapper",
+ ] + data,
+ env = env,
+ main_class = "com.code_intelligence.jazzer.tools.FuzzTargetTestWrapper",
use_testrunner = False,
tags = tags,
visibility = visibility,