mirror of https://github.com/google/oss-fuzz.git
google-py-crc32c: initial integration (#7742)
This commit is contained in:
parent
2af5e25a48
commit
9f6368db95
|
@ -0,0 +1,20 @@
|
|||
# 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 git clone https://github.com/googleapis/python-crc32c
|
||||
COPY build.sh *.py $SRC/
|
||||
WORKDIR python-crc32c
|
|
@ -0,0 +1,45 @@
|
|||
#!/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.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
git submodule update --init --recursive
|
||||
|
||||
mkdir usr
|
||||
export CRC32C_INSTALL_PREFIX=$(pwd)/usr
|
||||
|
||||
mkdir google_crc32c/build
|
||||
cd google_crc32c/build
|
||||
cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCRC32C_BUILD_TESTS=no \
|
||||
-DCRC32C_BUILD_BENCHMARKS=no \
|
||||
-DBUILD_SHARED_LIBS=yes \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=${CRC32C_INSTALL_PREFIX} \
|
||||
../
|
||||
make all install
|
||||
cd ../../
|
||||
|
||||
|
||||
python3 setup.py build_ext \
|
||||
--include-dirs=$(pwd)/usr/include \
|
||||
--library-dirs=$(pwd)/usr/lib \
|
||||
--rpath=$(pwd)/usr/lib
|
||||
pip3 install -e .[testing]
|
||||
|
||||
# Build fuzzers in $OUT.
|
||||
for fuzzer in $(find $SRC -name 'fuzz_*.py'); do
|
||||
compile_python_fuzzer $fuzzer
|
||||
done
|
|
@ -0,0 +1,33 @@
|
|||
#!/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 atheris
|
||||
import sys
|
||||
|
||||
with atheris.instrument_imports():
|
||||
import google_crc32c
|
||||
|
||||
def TestOneInput(data):
|
||||
val1 = google_crc32c.value(data)
|
||||
val2 = google_crc32c.Checksum(data)._crc
|
||||
assert val1 == val2
|
||||
|
||||
|
||||
def main():
|
||||
atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
|
||||
atheris.Fuzz()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,11 @@
|
|||
fuzzing_engines:
|
||||
- libfuzzer
|
||||
homepage: https://github.com/googleapis/python-crc32c
|
||||
language: python
|
||||
main_repo: https://github.com/googleapis/python-crc32c
|
||||
sanitizers:
|
||||
- address
|
||||
- undefined
|
||||
vendor_ccs:
|
||||
- david@adalogics.com
|
||||
- adam@adalogics.com
|
Loading…
Reference in New Issue