diff --git a/projects/orjson/Dockerfile b/projects/orjson/Dockerfile new file mode 100644 index 000000000..a158f5837 --- /dev/null +++ b/projects/orjson/Dockerfile @@ -0,0 +1,29 @@ +# Copyright 2022 Google LLC +# +# 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. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder-python +RUN apt-get update && apt-get install -y make autoconf automake libtool + +RUN python3 -m pip install --upgrade pip + +RUN rm -rf /usr/local/bin/cargo +RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2022-07-26 --profile minimal -y +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN git clone --depth 1 https://github.com/ijl/orjson orjson + +WORKDIR orjson +COPY build.sh *.py $SRC/ diff --git a/projects/orjson/build.sh b/projects/orjson/build.sh new file mode 100755 index 000000000..33321d2e9 --- /dev/null +++ b/projects/orjson/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash -eu +# Copyright 2022 Google LLC +# +# 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. +# +################################################################################ + +export RUSTFLAGS="" +python3 -m pip install . + +for fuzzer in $(find $SRC -name 'fuzz_*.py');do + compile_python_fuzzer $fuzzer +done diff --git a/projects/orjson/fuzz_orjson.py b/projects/orjson/fuzz_orjson.py new file mode 100644 index 000000000..60fa90cc8 --- /dev/null +++ b/projects/orjson/fuzz_orjson.py @@ -0,0 +1,41 @@ +#!/usr/bin/python3 +# Copyright 2022 Google LLC +# +# 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. + +import sys +import atheris +import orjson + + +def TestOneInput(data): + fdp = atheris.FuzzedDataProvider(data) + original = fdp.ConsumeUnicode(sys.maxsize) + + try: + orjson_data = orjson.loads(original) + except ValueError: + return + + encoded = orjson.dumps(orjson_data) + del encoded + + +def main(): + atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True) + atheris.instrument_all() + atheris.Fuzz() + + +if __name__ == "__main__": + main() diff --git a/projects/orjson/project.yaml b/projects/orjson/project.yaml new file mode 100644 index 000000000..960fee481 --- /dev/null +++ b/projects/orjson/project.yaml @@ -0,0 +1,11 @@ +homepage: "https://github.com/ijl/orjson" +language: python +fuzzing_engines: + - libfuzzer +sanitizers: + - address + - undefined +main_repo: "https://github.com/ijl/orjson" +vendor_ccs: + - maxnair.dev@gmail.com +file_github_issue: true