diff options
author | DavidKorczynski <david@adalogics.com> | 2022-06-28 17:22:02 -0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-28 20:22:02 +0100 |
commit | f40452d714b48b4130dbc5d199ce97f49df6b3ef (patch) | |
tree | 45ed56a9eb46436950de34632f5672d035d0d9eb /projects | |
parent | 1ae8bf7ee437e1d0289d4def1d6f9ec6bc0bc829 (diff) |
py-bigquery: initial integration (#7744)
* py-bigquery: initial integration
* rename project for the reasons described here https://github.com/google/oss-fuzz/pull/7900
* update pip and install grpcio in dockerfile
Diffstat (limited to 'projects')
-rw-r--r-- | projects/g-py-bigquery/Dockerfile | 22 | ||||
-rw-r--r-- | projects/g-py-bigquery/build.sh | 23 | ||||
-rw-r--r-- | projects/g-py-bigquery/fuzz_parser.py | 60 | ||||
-rw-r--r-- | projects/g-py-bigquery/project.yaml | 11 |
4 files changed, 116 insertions, 0 deletions
diff --git a/projects/g-py-bigquery/Dockerfile b/projects/g-py-bigquery/Dockerfile new file mode 100644 index 00000000..01d505c0 --- /dev/null +++ b/projects/g-py-bigquery/Dockerfile @@ -0,0 +1,22 @@ +# 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 pip3 install --upgrade pip && \ + pip3 install numpy ipython grpcio +RUN git clone https://github.com/googleapis/python-bigquery +COPY build.sh *.py $SRC/ +WORKDIR python-bigquery diff --git a/projects/g-py-bigquery/build.sh b/projects/g-py-bigquery/build.sh new file mode 100644 index 00000000..ab841a59 --- /dev/null +++ b/projects/g-py-bigquery/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. +# +################################################################################ + +pip3 install . + +# Build flask fuzzers +for fuzzer in $(find $SRC -name 'fuzz_*.py'); do + compile_python_fuzzer $fuzzer +done diff --git a/projects/g-py-bigquery/fuzz_parser.py b/projects/g-py-bigquery/fuzz_parser.py new file mode 100644 index 00000000..0f343a17 --- /dev/null +++ b/projects/g-py-bigquery/fuzz_parser.py @@ -0,0 +1,60 @@ +#!/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 +import IPython + +with atheris.instrument_imports(): + from google.cloud.bigquery.magics.line_arg_parser.lexer import Lexer + from google.cloud.bigquery.magics.line_arg_parser.parser import Parser + from google.cloud.bigquery.magics.line_arg_parser.parser import ParseError + from google.cloud.bigquery.magics.line_arg_parser.parser import QueryParamsParseError + +def TestOneInput(data): + fdp = atheris.FuzzedDataProvider(data) + s1 = fdp.ConsumeString(sys.maxsize) + + tokens = list(Lexer(s1)) + if len(tokens) == 0: + return + + lexer = Lexer(s1) + parser = Parser(lexer) + try: + parser.input_line() + except ParseError: + pass + + lexer = Lexer(s1) + parser = Parser(lexer) + try: + parser.collection_items() + except QueryParamsParseError: + pass + + lexer = Lexer(s1) + parser = Parser(lexer) + try: + parser.dict_items() + except QueryParamsParseError: + pass + +def main(): + atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True) + atheris.Fuzz() + +if __name__ == "__main__": + main() diff --git a/projects/g-py-bigquery/project.yaml b/projects/g-py-bigquery/project.yaml new file mode 100644 index 00000000..a2f5760d --- /dev/null +++ b/projects/g-py-bigquery/project.yaml @@ -0,0 +1,11 @@ +fuzzing_engines: +- libfuzzer +homepage: https://github.com/googleapis/python-bigquery +language: python +main_repo: https://github.com/googleapis/python-bigquery +sanitizers: +- address +- undefined +vendor_ccs: +- david@adalogics.com +- adam@adalogics.com |