aboutsummaryrefslogtreecommitdiff
path: root/bazel/fuzz_target.bzl
diff options
context:
space:
mode:
authorFabian Meumertzheim <meumertzheim@code-intelligence.com>2021-02-10 15:56:38 +0100
committerFabian Meumertzheim <fabian@meumertzhe.im>2021-02-12 09:57:26 +0100
commit5b94b7b5f1fa9f68832d58d037cdb0267de31906 (patch)
tree89f52f93058d9d72ec79ad730efa38f106d75f43 /bazel/fuzz_target.bzl
parent0bcfd380fae4e121e3275fe05c9b8101ffca3fff (diff)
downloadjazzer-api-5b94b7b5f1fa9f68832d58d037cdb0267de31906.tar.gz
Optionally read fuzz target info from JAR manifest
By reading the fuzz target class and custom hooks from a JAR manifest entry rather than a command-line argument, fuzz targets can be fully self-contained. This commit adds a Java function that looks for a unique `Jazzer-Fuzz-Target-Class` attribute in all manifests on the classpath and returns it to the driver if found. If no such entry is found, it falls back to the `--target_class` commandline parameter. In a similar way, the agent prepopulates the list of custom hooks to load with the merged values of `Jazzer-Hook-Classes` attributes in all manifests.
Diffstat (limited to 'bazel/fuzz_target.bzl')
-rw-r--r--bazel/fuzz_target.bzl13
1 files changed, 8 insertions, 5 deletions
diff --git a/bazel/fuzz_target.bzl b/bazel/fuzz_target.bzl
index f7b60c19..ca06a37e 100644
--- a/bazel/fuzz_target.bzl
+++ b/bazel/fuzz_target.bzl
@@ -23,19 +23,23 @@ def java_fuzz_target_test(
fuzzer_args = [],
**kwargs):
target_name = name + "_target"
+ deploy_manifest_lines = [
+ "Jazzer-Fuzz-Target-Class: %s" % target_class,
+ ]
+ if hook_classes:
+ deploy_manifest_lines += [
+ "Jazzer-Hook-Classes: %s" % ":".join(hook_classes),
+ ]
native.java_binary(
name = target_name,
visibility = ["//visibility:private"],
create_executable = False,
+ deploy_manifest_lines = deploy_manifest_lines,
**kwargs
)
additional_args = []
- hooks = ":".join(hook_classes)
- if hooks != "":
- additional_args.append("--custom_hooks=" + hooks)
-
native_libs_paths = ":".join(["$$(dirname $(rootpaths %s) | paste -sd ':' -)" % native_lib for native_lib in native_libs])
if native_libs_paths != "":
additional_args.append("--jvm_args=-Djava.library.path=" + native_libs_paths)
@@ -50,7 +54,6 @@ def java_fuzz_target_test(
args = [
"$(rootpath %s)" % driver,
"--cp=$(rootpath :%s_deploy.jar)" % target_name,
- "--target_class=" + target_class,
"--agent_path=$(rootpath //agent:jazzer_agent_deploy.jar)",
# Should be bigger than the JVM max heap size (4096m)
"-rss_limit_mb=5000",