mirror of https://github.com/google/oss-fuzz.git
python-tasks: initial integration (#8192)
This commit is contained in:
parent
4ec2c13401
commit
66e90bbf6c
|
@ -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 apt-get update && apt-get install -y make autoconf automake libtool
|
||||||
|
RUN pip3 install --upgrade pip && pip install google-api-core google-cloud-core mock
|
||||||
|
RUN git clone --depth 1 https://github.com/googleapis/python-tasks
|
||||||
|
WORKDIR python-tasks
|
||||||
|
COPY build.sh *.py $SRC/
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/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.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
GRPC_PYTHON_CFLAGS="${CFLAGS}" GRPC_PYTHON_BUILD_SYSTEM_RE2=true GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip3 install .
|
||||||
|
for fuzzer in $(find $SRC -name 'fuzz_*.py'); do
|
||||||
|
compile_python_fuzzer $fuzzer
|
||||||
|
done
|
|
@ -0,0 +1,77 @@
|
||||||
|
#!/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 os
|
||||||
|
import sys
|
||||||
|
import mock
|
||||||
|
import atheris
|
||||||
|
|
||||||
|
from google.auth import credentials as ga_credentials
|
||||||
|
from google.cloud.tasks_v2.services.cloud_tasks import CloudTasksClient
|
||||||
|
from google.cloud.tasks_v2.types import queue
|
||||||
|
from google.cloud.tasks_v2.types import cloudtasks
|
||||||
|
|
||||||
|
|
||||||
|
def get_request_queue(fdp, client):
|
||||||
|
request = cloudtasks.GetQueueRequest()
|
||||||
|
request.name = fdp.ConsumeUnicodeNoSurrogates(20)
|
||||||
|
with mock.patch.object(type(client.transport.get_queue), "__call__") as call:
|
||||||
|
call.return_value = queue.Queue()
|
||||||
|
client.get_queue(request)
|
||||||
|
|
||||||
|
|
||||||
|
def update_queue(fdp, client):
|
||||||
|
request = cloudtasks.UpdateQueueRequest()
|
||||||
|
with mock.patch.object(type(client.transport.update_queue), "__call__") as call:
|
||||||
|
call.return_value = queue.Queue(
|
||||||
|
name=fdp.ConsumeUnicodeNoSurrogates(20),
|
||||||
|
state=queue.Queue.State.RUNNING,
|
||||||
|
)
|
||||||
|
response = client.update_queue(request)
|
||||||
|
|
||||||
|
|
||||||
|
def delete_queue(fdp, client):
|
||||||
|
request = cloudtasks.DeleteQueueRequest()
|
||||||
|
request.name = fdp.ConsumeUnicodeNoSurrogates(20)
|
||||||
|
with mock.patch.object(type(client.transport.delete_queue), "__call__") as call:
|
||||||
|
call.return_value = None
|
||||||
|
response = client.delete_queue(request)
|
||||||
|
|
||||||
|
|
||||||
|
def TestOneInput(data):
|
||||||
|
fdp = atheris.FuzzedDataProvider(data)
|
||||||
|
client = CloudTasksClient(
|
||||||
|
credentials=ga_credentials.AnonymousCredentials(),
|
||||||
|
)
|
||||||
|
|
||||||
|
api_targets = [
|
||||||
|
get_request_queue,
|
||||||
|
update_queue,
|
||||||
|
delete_queue
|
||||||
|
]
|
||||||
|
num_of_calls = fdp.ConsumeIntInRange(1, 10)
|
||||||
|
for i in range(num_of_calls):
|
||||||
|
target = api_targets[fdp.ConsumeIntInRange(0, len(api_targets)-1)]
|
||||||
|
target(fdp, client)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
atheris.instrument_all()
|
||||||
|
atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
|
||||||
|
atheris.Fuzz()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
|
@ -0,0 +1,11 @@
|
||||||
|
homepage: "https://github.com/googleapis/python-tasks"
|
||||||
|
language: python
|
||||||
|
main_repo: "https://github.com/googleapis/python-tasks"
|
||||||
|
fuzzing_engines:
|
||||||
|
- libfuzzer
|
||||||
|
sanitizers:
|
||||||
|
- address
|
||||||
|
- undefined
|
||||||
|
vendor_ccs:
|
||||||
|
- david@adalogics.com
|
||||||
|
- adam@adalogics.com
|
Loading…
Reference in New Issue