Skip to content

Commit

Permalink
arrow-py: initial integration (#10100)
Browse files Browse the repository at this point in the history
Signed-off-by: David Korczynski <david@adalogics.com>
  • Loading branch information
DavidKorczynski authored Apr 17, 2023
1 parent c58d80e commit 7e14b08
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 0 deletions.
20 changes: 20 additions & 0 deletions projects/arrow-py/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 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 pip3 install --upgrade pip
RUN git clone https://github.com/arrow-py/arrow arrow
COPY *.sh *py $SRC/
WORKDIR $SRC/arrow
21 changes: 21 additions & 0 deletions projects/arrow-py/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -eu
# Copyright 2023 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 .
# Build fuzzers in $OUT.
for fuzzer in $(find $SRC -name 'fuzz_*.py'); do
compile_python_fuzzer $fuzzer
done
47 changes: 47 additions & 0 deletions projects/arrow-py/fuzz_datetime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/python3
# Copyright 2023 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
# Auto-fuzz heuristics used: py-autofuzz-heuristics-4.1
# Imports by the generated code
import arrow


def TestOneInput(data):
fdp = atheris.FuzzedDataProvider(data)
datetime_string = fdp.ConsumeUnicodeNoSurrogates(
fdp.ConsumeIntInRange(1, 4096))

# Class target.
try:
c1 = arrow.parser.DateTimeParser()
c1.parse_iso(datetime_string)
except (
arrow.parser.ParserMatchError,
arrow.parser.ParserError,
):
pass


def main():
atheris.instrument_all()
atheris.Setup(sys.argv, TestOneInput)
atheris.Fuzz()


if __name__ == "__main__":
main()
43 changes: 43 additions & 0 deletions projects/arrow-py/fuzz_tzinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/python3
# Copyright 2023 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
# Auto-fuzz heuristics used: py-autofuzz-heuristics-4.1
# Imports by the generated code
import arrow


def TestOneInput(data):
fdp = atheris.FuzzedDataProvider(data)
tzinfo_string = fdp.ConsumeUnicodeNoSurrogates(fdp.ConsumeIntInRange(1, 4096))

# Class target.
try:
c1 = arrow.parser.TzinfoParser()
c1.parse(tzinfo_string)
except (arrow.parser.ParserError,):
pass


def main():
atheris.instrument_all()
atheris.Setup(sys.argv, TestOneInput)
atheris.Fuzz()


if __name__ == "__main__":
main()
9 changes: 9 additions & 0 deletions projects/arrow-py/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
homepage: https://github.com/arrow-py/arrow
main_repo: https://github.com/arrow-py/arrow
language: python
fuzzing_engines:
- libfuzzer
sanitizers:
- address
vendor_ccs:
- david@adalogics.com

0 comments on commit 7e14b08

Please sign in to comment.