From ee39b4603c39c9ea764a7565442b09aa8504ca50 Mon Sep 17 00:00:00 2001 From: AdamKorcz <44787359+AdamKorcz@users.noreply.github.com> Date: Wed, 3 Aug 2022 12:02:49 +0100 Subject: [PATCH] jackson-databind: add writer fuzzer (#8137) Signed-off-by: AdamKorcz --- projects/jackson-databind/Dockerfile | 2 +- .../jackson-databind/ObjectWriterFuzzer.java | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 projects/jackson-databind/ObjectWriterFuzzer.java diff --git a/projects/jackson-databind/Dockerfile b/projects/jackson-databind/Dockerfile index 57971cd09..08f4359ae 100644 --- a/projects/jackson-databind/Dockerfile +++ b/projects/jackson-databind/Dockerfile @@ -38,4 +38,4 @@ RUN git clone --depth 1 https://github.com/FasterXML/jackson-annotations RUN git clone --depth 1 https://github.com/FasterXML/jackson-core COPY build.sh $SRC/ -COPY ObjectReaderFuzzer.java $SRC/ \ No newline at end of file +COPY ObjectReaderFuzzer.java ObjectWriterFuzzer.java $SRC/ \ No newline at end of file diff --git a/projects/jackson-databind/ObjectWriterFuzzer.java b/projects/jackson-databind/ObjectWriterFuzzer.java new file mode 100644 index 000000000..a021e660d --- /dev/null +++ b/projects/jackson-databind/ObjectWriterFuzzer.java @@ -0,0 +1,47 @@ +import com.code_intelligence.jazzer.api.FuzzedDataProvider; + +import java.util.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.core.JsonProcessingException; + +public class ObjectWriterFuzzer { + public static void fuzzerTestOneInput(FuzzedDataProvider data) { + ObjectMapper mapper = new ObjectMapper(); + + try { + DummyClass dc = mapper.readValue(data.consumeRemainingAsString(), DummyClass.class); + byte[] jb = mapper.writeValueAsBytes(dc); + } catch (JsonProcessingException e) { } + } + + public static class DummyClass { + public TreeMap _treeMap; + public List _arrayList; + public Set _hashSet; + public Map _hashMap; + public List _asList = Arrays.asList(1, 2, 3); + public int[] _intArray; + public long[] _longArray; + public short[] _shortArray; + public float[] _floatArray; + public double[] _doubleArray; + public byte[] _byteArray; + public char[] _charArray; + public String[] _stringArray; + public BitSet _bitSet; + public Date _date; + public TimeZone _timeZone; + public Calendar _calendar; + public Locale _locale; + public Integer[] _integerArray; + public boolean _boolean; + public char _char; + public byte _byte; + public short _short; + public int _int; + public float _float; + public Long _long; + public Double _double; + } +} \ No newline at end of file