diff options
author | Fabian Meumertzheim <meumertzheim@code-intelligence.com> | 2021-03-08 16:01:14 +0100 |
---|---|---|
committer | Fabian Meumertzheim <fabian@meumertzhe.im> | 2021-03-08 16:17:04 +0100 |
commit | e51010f4a73d3665f8bb7aab1ac990580ccb5d36 (patch) | |
tree | 4daa6247617ea242dc6495350ef00b446ec815e8 /examples | |
parent | e884cf54fe9b70dcbef1aff3c94f1bb5d08949c8 (diff) | |
download | jazzer-api-e51010f4a73d3665f8bb7aab1ac990580ccb5d36.tar.gz |
Add Kotlin fuzz target
Diffstat (limited to 'examples')
-rw-r--r-- | examples/BUILD.bazel | 23 | ||||
-rw-r--r-- | examples/src/main/java/com/example/KlaxonFuzzer.kt | 31 |
2 files changed, 54 insertions, 0 deletions
diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index 39392796..66a85855 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -1,3 +1,4 @@ +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library") load("//bazel:fuzz_target.bzl", "java_fuzz_target_test") java_fuzz_target_test( @@ -138,6 +139,28 @@ java_fuzz_target_test( ], ) +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", + # Prevent the JVM from optimizing away stack traces (interfers with deduplication). + "--jvm_args=-XX:-OmitStackTraceInFastThrow", + ], + target_class = "com.example.KlaxonFuzzer", + runtime_deps = [":KlaxonFuzzTarget"], +) + java_fuzz_target_test( name = "TurboJpegFuzzer", srcs = [ diff --git a/examples/src/main/java/com/example/KlaxonFuzzer.kt b/examples/src/main/java/com/example/KlaxonFuzzer.kt new file mode 100644 index 00000000..39216eea --- /dev/null +++ b/examples/src/main/java/com/example/KlaxonFuzzer.kt @@ -0,0 +1,31 @@ +// 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.example + +import com.beust.klaxon.KlaxonException +import com.beust.klaxon.Parser +import com.code_intelligence.jazzer.api.FuzzedDataProvider + +// Reproduces https://github.com/cbeust/klaxon/pull/330 +object KlaxonFuzzer { + + @JvmStatic + fun fuzzerTestOneInput(data: FuzzedDataProvider) { + try { + Parser.default().parse(StringBuilder(data.consumeRemainingAsString())) + } catch (_: KlaxonException) { + } + } +} |