aboutsummaryrefslogtreecommitdiff
path: root/projects/python-lz4
diff options
context:
space:
mode:
authorDavidKorczynski <david@adalogics.com>2021-01-19 14:49:52 +0000
committerGitHub <noreply@github.com>2021-01-19 06:49:52 -0800
commitc849022b7504cb7fc54f4a3e01ad3493188e408a (patch)
treefa6c9cb55d1fa76af03fdb7bc19c6febcb3fbd4a /projects/python-lz4
parentb516c4b72d63d689a7e5335928345cc05e434d92 (diff)
downloadoss-fuzz-c849022b7504cb7fc54f4a3e01ad3493188e408a.tar.gz
[python-lz4] initial integration (#4989)
Diffstat (limited to 'projects/python-lz4')
-rw-r--r--projects/python-lz4/Dockerfile24
-rw-r--r--projects/python-lz4/build.sh34
-rw-r--r--projects/python-lz4/fuzz_lz4.py31
-rw-r--r--projects/python-lz4/project.yaml11
4 files changed, 100 insertions, 0 deletions
diff --git a/projects/python-lz4/Dockerfile b/projects/python-lz4/Dockerfile
new file mode 100644
index 000000000..8598ed33d
--- /dev/null
+++ b/projects/python-lz4/Dockerfile
@@ -0,0 +1,24 @@
+# Copyright 2021 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
+RUN git clone --depth 1 https://github.com/python-lz4/python-lz4
+
+COPY build.sh $SRC/
+COPY fuzz_* $SRC/
+
+WORKDIR $SRC/python-lz4
+
diff --git a/projects/python-lz4/build.sh b/projects/python-lz4/build.sh
new file mode 100644
index 000000000..66f6419ac
--- /dev/null
+++ b/projects/python-lz4/build.sh
@@ -0,0 +1,34 @@
+#!/bin/bash -eu
+# Copyright 2021 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.
+#
+################################################################################
+
+python3 setup.py install
+
+# Build fuzzers in $OUT.
+for fuzzer in $(find $SRC -name 'fuzz_*.py'); do
+ fuzzer_basename=$(basename -s .py $fuzzer)
+ fuzzer_package=${fuzzer_basename}.pkg
+ pyinstaller --distpath $OUT --onefile --name $fuzzer_package $fuzzer
+
+ # Create execution wrapper.
+ echo "#!/bin/sh
+# LLVMFuzzerTestOneInput for fuzzer detection.
+this_dir=\$(dirname \"\$0\")
+LD_PRELOAD=\$this_dir/sanitizer_with_fuzzer.so \
+ASAN_OPTIONS=\$ASAN_OPTIONS:symbolize=1:external_symbolizer_path=\$this_dir/llvm-symbolizer:detect_leaks=0 \
+\$this_dir/$fuzzer_package \$@" > $OUT/$fuzzer_basename
+ chmod u+x $OUT/$fuzzer_basename
+done
diff --git a/projects/python-lz4/fuzz_lz4.py b/projects/python-lz4/fuzz_lz4.py
new file mode 100644
index 000000000..ff6787d1b
--- /dev/null
+++ b/projects/python-lz4/fuzz_lz4.py
@@ -0,0 +1,31 @@
+#!/usr/bin/python3
+# Copyright 2021 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 lz4.frame
+
+def TestOneInput(data):
+ c =lz4.frame.compress(data)
+ d = lz4.frame.decompress(c)
+ assert(data == d)
+ return
+
+def main():
+ atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
+ atheris.Fuzz()
+
+if __name__ == "__main__":
+ main()
diff --git a/projects/python-lz4/project.yaml b/projects/python-lz4/project.yaml
new file mode 100644
index 000000000..0f1311053
--- /dev/null
+++ b/projects/python-lz4/project.yaml
@@ -0,0 +1,11 @@
+homepage: "https://github.com/lz4/lz4"
+language: python
+primary_contact: "jonathan.underwood@gmail.com"
+auto_ccs:
+ - "david@adalogics.com"
+fuzzing_engines:
+ - libfuzzer
+sanitizers:
+ - address
+ - undefined
+main_repo: 'https://github.com/lz4/lz4'