From f59601ac2becf03e3f97727a5e20086150fb3c97 Mon Sep 17 00:00:00 2001 From: Rik Date: Mon, 9 Jan 2023 04:48:54 +0100 Subject: [PATCH] python-phonenumbers: initial integration (#9369) Fuzzer for Python port of Google's libphonenumber [Tests mentioned](https://google.github.io/oss-fuzz/getting-started/new-project-guide/#testing-locally) in docs have been run: ``` python infra/helper.py build_image python-phonenumbers python infra/helper.py build_fuzzers --sanitizer address python-phonenumbers python infra/helper.py check_build python-phonenumbers python infra/helper.py run_fuzzer python-phonenumbers python_phonenumbers_fuzzer ``` --- projects/python-phonenumbers/Dockerfile | 27 +++++++++++++++++++++++ projects/python-phonenumbers/build.sh | 24 ++++++++++++++++++++ projects/python-phonenumbers/project.yaml | 11 +++++++++ 3 files changed, 62 insertions(+) create mode 100644 projects/python-phonenumbers/Dockerfile create mode 100755 projects/python-phonenumbers/build.sh create mode 100644 projects/python-phonenumbers/project.yaml diff --git a/projects/python-phonenumbers/Dockerfile b/projects/python-phonenumbers/Dockerfile new file mode 100644 index 000000000..fda4cc4ad --- /dev/null +++ b/projects/python-phonenumbers/Dockerfile @@ -0,0 +1,27 @@ +# 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 git clone --depth 1 https://github.com/daviddrysdale/python-phonenumbers.git python-phonenumbers +RUN git clone --depth 1 https://github.com/rikfie/python-phonenumbers-fuzzer.git ppf && \ + mv ppf/*_fuzzer.py $SRC/ && \ + rm -rf ppf + +WORKDIR python-phonenumbers/python + +COPY build.sh $SRC/ \ No newline at end of file diff --git a/projects/python-phonenumbers/build.sh b/projects/python-phonenumbers/build.sh new file mode 100755 index 000000000..593e9d1e1 --- /dev/null +++ b/projects/python-phonenumbers/build.sh @@ -0,0 +1,24 @@ +#!/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. +# +################################################################################ + +pip3 install --upgrade pip +pip3 install . + +# Build fuzzers in $OUT. +for fuzzer in $(find $SRC -name '*_fuzzer.py'); do + compile_python_fuzzer $fuzzer +done diff --git a/projects/python-phonenumbers/project.yaml b/projects/python-phonenumbers/project.yaml new file mode 100644 index 000000000..7c590f4a9 --- /dev/null +++ b/projects/python-phonenumbers/project.yaml @@ -0,0 +1,11 @@ +homepage: "https://github.com/daviddrysdale/python-phonenumbers" +language: python +primary_contact: "rik@purpleguy.nl" +auto_ccs: + - "drysdale@google.com" +main_repo: "https://github.com/daviddrysdale/python-phonenumbers.git" +fuzzing_engines: + - libfuzzer +sanitizers: + - address + - undefined