From 3d3fb7d583a9c09cd4c26d278d999fe842016cf2 Mon Sep 17 00:00:00 2001 From: David Lakin Date: Wed, 29 May 2024 17:19:43 -0400 Subject: [PATCH] [g-api-resource-manager] Update Project Repo to Fix Build (#12015) Fixes [Monorail Issue 59721][Monorail-issue]. The https://github.com/googleapis/python-resource-manager repository was archived on 2023-09-05 and the project was moved to the `google-cloud-resource-manager` package in the https://github.com/googleapis/google-cloud-python repository. The upstream migration removed the source code from the original repo, resulting in the broken build. [Monorail-issue]: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=59721 ## Other Changes Introduced Here ### Fixes for Missing Instrumentation of Native Extension Code See 9a8989bf73899b232ac16f970dfa9bf72a8904bb ### Fuzzer Update See d33e0a4156132bbc4293f8169aba415cd21bd075 ## Related PRs Fixing Similar Issues - #12014 - #12016 --- projects/g-api-resource-manager/Dockerfile | 10 ++++--- projects/g-api-resource-manager/build.sh | 7 ++++- .../fuzz_tag_values_client.py | 30 +++++++++---------- projects/g-api-resource-manager/project.yaml | 4 +-- 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/projects/g-api-resource-manager/Dockerfile b/projects/g-api-resource-manager/Dockerfile index ff8669d5f..8059029be 100644 --- a/projects/g-api-resource-manager/Dockerfile +++ b/projects/g-api-resource-manager/Dockerfile @@ -15,8 +15,10 @@ ################################################################################ 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-resource-manager -WORKDIR python-resource-manager +RUN apt-get update && \ + apt-get install -y libre2-dev zlib1g-dev libssl-dev +RUN python3 -m pip install --upgrade pip && \ + python3 -m pip install --upgrade mock +RUN git clone --depth 1 https://github.com/googleapis/google-cloud-python $SRC/google-cloud-python +WORKDIR $SRC/google-cloud-python/packages/google-cloud-resource-manager COPY build.sh *.py $SRC/ diff --git a/projects/g-api-resource-manager/build.sh b/projects/g-api-resource-manager/build.sh index 52a888371..1e640cb36 100755 --- a/projects/g-api-resource-manager/build.sh +++ b/projects/g-api-resource-manager/build.sh @@ -15,7 +15,12 @@ # ################################################################################ -GRPC_PYTHON_CFLAGS="${CFLAGS}" GRPC_PYTHON_BUILD_SYSTEM_RE2=true GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip3 install -v . +GRPC_PYTHON_CFLAGS="${CFLAGS}" \ +GRPC_PYTHON_BUILD_SYSTEM_RE2=true \ +GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true \ +GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true \ +MAX_JOBS=$(nproc) \ +python3 -m pip install -v . --no-binary :all: for fuzzer in $(find $SRC -name 'fuzz_*.py'); do compile_python_fuzzer $fuzzer diff --git a/projects/g-api-resource-manager/fuzz_tag_values_client.py b/projects/g-api-resource-manager/fuzz_tag_values_client.py index 66b06ab4d..2000b7b6b 100644 --- a/projects/g-api-resource-manager/fuzz_tag_values_client.py +++ b/projects/g-api-resource-manager/fuzz_tag_values_client.py @@ -14,23 +14,22 @@ # limitations under the License. """Fuzzer for google/cloud/resourcemanager_v3/services/tag_values/client.py""" -import os import sys +import mock import atheris -import mock - -from google.auth import credentials as ga_credentials -from google.longrunning import operations_pb2 -from google.iam.v1 import iam_policy_pb2 -from google.iam.v1 import policy_pb2 -from google.cloud.resourcemanager_v3.services.tag_values import ( - TagValuesAsyncClient, - TagValuesClient, - pagers, - transports, -) -from google.cloud.resourcemanager_v3.types import tag_values +with atheris.instrument_imports(): + from google.auth import credentials as ga_credentials + from google.longrunning import operations_pb2 + from google.iam.v1 import iam_policy_pb2 + from google.iam.v1 import policy_pb2 + from google.cloud.resourcemanager_v3.services.tag_values import ( + TagValuesAsyncClient, + TagValuesClient, + pagers, + transports, + ) + from google.cloud.resourcemanager_v3.types import tag_values def test_get_tag_value(fdp, client): @@ -133,8 +132,7 @@ def TestOneInput(data): target(fdp, client) def main(): - atheris.instrument_all() - atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True) + atheris.Setup(sys.argv, TestOneInput) atheris.Fuzz() if __name__ == "__main__": diff --git a/projects/g-api-resource-manager/project.yaml b/projects/g-api-resource-manager/project.yaml index 581e11bad..827d49d26 100644 --- a/projects/g-api-resource-manager/project.yaml +++ b/projects/g-api-resource-manager/project.yaml @@ -1,8 +1,8 @@ fuzzing_engines: - libfuzzer -homepage: https://github.com/googleapis/python-resource-manager +homepage: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-resource-manager language: python -main_repo: https://github.com/googleapis/python-resource-manager +main_repo: https://github.com/googleapis/google-cloud-python sanitizers: - address - undefined