load("@rules_java//java:defs.bzl", "java_binary") load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library") load("//bazel:fuzz_target.bzl", "java_fuzz_target_test") java_fuzz_target_test( name = "ExampleFuzzer", srcs = [ "src/main/java/com/example/ExampleFuzzer.java", "src/main/java/com/example/ExampleFuzzerHooks.java", ], # Comment out the next line to keep the fuzzer running indefinitely. hook_classes = ["com.example.ExampleFuzzerHooks"], target_class = "com.example.ExampleFuzzer", ) java_fuzz_target_test( name = "ExampleFuzzerWithNative", srcs = [ "src/main/java/com/example/ExampleFuzzerWithNative.java", ], native_libs = ["//examples/src/main/native"], # Bazel creates shared libraries with an incorrect extension on macOS. tags = ["broken-on-darwin"], target_class = "com.example.ExampleFuzzerWithNative", use_asan = True, ) java_fuzz_target_test( name = "ExamplePathTraversalFuzzer", srcs = [ "src/main/java/com/example/ExamplePathTraversalFuzzer.java", "src/main/java/com/example/ExamplePathTraversalFuzzerHooks.java", ], hook_classes = ["com.example.ExamplePathTraversalFuzzerHooks"], target_class = "com.example.ExamplePathTraversalFuzzer", ) java_fuzz_target_test( name = "ExampleValueProfileFuzzer", srcs = [ "src/main/java/com/example/ExampleValueProfileFuzzer.java", ], # Comment out the next line to keep the fuzzer running indefinitely. fuzzer_args = ["-use_value_profile=1"], target_class = "com.example.ExampleValueProfileFuzzer", ) java_fuzz_target_test( name = "ExampleOutOfMemoryFuzzer", srcs = [ "src/main/java/com/example/ExampleOutOfMemoryFuzzer.java", ], fuzzer_args = ["--jvm_args=-Xmx512m"], target_class = "com.example.ExampleOutOfMemoryFuzzer", ) java_fuzz_target_test( name = "ExampleStackOverflowFuzzer", srcs = [ "src/main/java/com/example/ExampleStackOverflowFuzzer.java", ], # Crashes with a segfault before any stack trace printing is reached. tags = ["broken-on-darwin"], target_class = "com.example.ExampleStackOverflowFuzzer", ) java_fuzz_target_test( name = "JpegImageParserFuzzer", srcs = [ "src/main/java/com/example/JpegImageParserFuzzer.java", ], fuzzer_args = ["-fork=5"], # The exit codes of the forked libFuzzer processes are not picked up correctly. tags = ["broken-on-darwin"], target_class = "com.example.JpegImageParserFuzzer", deps = [ "@maven//:org_apache_commons_commons_imaging", ], ) java_fuzz_target_test( name = "GifImageParserFuzzer", srcs = [ "src/main/java/com/example/GifImageParserFuzzer.java", ], target_class = "com.example.GifImageParserFuzzer", deps = [ "@maven//:org_apache_commons_commons_imaging", ], ) java_fuzz_target_test( name = "TiffImageParserFuzzer", srcs = [ "src/main/java/com/example/TiffImageParserFuzzer.java", ], tags = ["manual"], target_class = "com.example.TiffImageParserFuzzer", deps = [ "@maven//:org_apache_commons_commons_imaging", ], ) java_fuzz_target_test( name = "JsonSanitizerCrashFuzzer", srcs = [ "src/main/java/com/example/JsonSanitizerCrashFuzzer.java", ], target_class = "com.example.JsonSanitizerCrashFuzzer", deps = [ "@maven//:com_mikesamuel_json_sanitizer", ], ) java_fuzz_target_test( name = "JsonSanitizerDenylistFuzzer", srcs = [ "src/main/java/com/example/JsonSanitizerDenylistFuzzer.java", ], target_class = "com.example.JsonSanitizerDenylistFuzzer", deps = [ "@maven//:com_mikesamuel_json_sanitizer", ], ) java_fuzz_target_test( name = "JsonSanitizerIdempotenceFuzzer", srcs = [ "src/main/java/com/example/JsonSanitizerIdempotenceFuzzer.java", ], target_class = "com.example.JsonSanitizerIdempotenceFuzzer", deps = [ "@maven//:com_mikesamuel_json_sanitizer", ], ) java_fuzz_target_test( name = "JsonSanitizerValidJsonFuzzer", srcs = [ "src/main/java/com/example/JsonSanitizerValidJsonFuzzer.java", ], target_class = "com.example.JsonSanitizerValidJsonFuzzer", deps = [ "@maven//:com_google_code_gson_gson", "@maven//:com_mikesamuel_json_sanitizer", ], ) java_fuzz_target_test( name = "JacksonCborFuzzer", srcs = [ "src/main/java/com/example/JacksonCborFuzzer.java", ], target_class = "com.example.JacksonCborFuzzer", deps = [ "@maven//:com_fasterxml_jackson_core_jackson_core", "@maven//:com_fasterxml_jackson_core_jackson_databind", "@maven//:com_fasterxml_jackson_dataformat_jackson_dataformat_cbor", ], ) java_fuzz_target_test( name = "FastJsonFuzzer", srcs = [ "src/main/java/com/example/FastJsonFuzzer.java", ], target_class = "com.example.FastJsonFuzzer", deps = [ "@maven//:com_alibaba_fastjson", ], ) kt_jvm_library( name = "KlaxonFuzzTarget", srcs = [ "src/main/java/com/example/KlaxonFuzzer.kt", ], deps = [ "//agent/src/main/java/com/code_intelligence/jazzer/api", "@maven//:com_beust_klaxon", ], ) java_fuzz_target_test( name = "KlaxonFuzzer", fuzzer_args = [ "--keep_going=7", ], target_class = "com.example.KlaxonFuzzer", runtime_deps = [":KlaxonFuzzTarget"], ) java_fuzz_target_test( name = "TurboJpegFuzzer", srcs = [ "src/main/java/com/example/TurboJpegFuzzer.java", ], fuzzer_args = [ "-rss_limit_mb=8196", ], native_libs = [ "@libjpeg_turbo//:turbojpeg_native", ], tags = ["manual"], target_class = "com.example.TurboJpegFuzzer", use_asan = True, deps = [ "@libjpeg_turbo//:turbojpeg_java", ], ) java_binary( name = "examples", create_executable = False, resource_jars = [ ":ExampleFuzzer_target_deploy.jar", ":ExampleValueProfileFuzzer_target_deploy.jar", ":FastJsonFuzzer_target_deploy.jar", ":JacksonCborFuzzer_target_deploy.jar", ":JpegImageParserFuzzer_target_deploy.jar", ":JsonSanitizerDenylistFuzzer_target_deploy.jar", ], visibility = ["//visibility:public"], )