From 715d2daf0c2b09e2cc89c7f7aff15818d86d55d5 Mon Sep 17 00:00:00 2001 From: Arthur Chan Date: Mon, 15 Aug 2022 18:39:55 +0100 Subject: [PATCH] gc-iam:initial integration (#8086) Create fuzzer --- projects/gc-iam/Dockerfile | 22 ++++++++ projects/gc-iam/build.sh | 25 +++++++++ projects/gc-iam/fuzz_credentials.py | 80 +++++++++++++++++++++++++++++ projects/gc-iam/project.yaml | 12 +++++ 4 files changed, 139 insertions(+) create mode 100644 projects/gc-iam/Dockerfile create mode 100644 projects/gc-iam/build.sh create mode 100644 projects/gc-iam/fuzz_credentials.py create mode 100644 projects/gc-iam/project.yaml diff --git a/projects/gc-iam/Dockerfile b/projects/gc-iam/Dockerfile new file mode 100644 index 000000000..1cce92817 --- /dev/null +++ b/projects/gc-iam/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 git clone --depth=1 https://github.com/googleapis/python-iam +WORKDIR python-iam + +COPY build.sh fuzz_*.py $SRC/ diff --git a/projects/gc-iam/build.sh b/projects/gc-iam/build.sh new file mode 100644 index 000000000..de01259e0 --- /dev/null +++ b/projects/gc-iam/build.sh @@ -0,0 +1,25 @@ +#!/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. +# +################################################################################ + +# Build and install project (using current CFLAGS, CXXFLAGS). +pip3 install --upgrade pip +pip3 install google-cloud-core +pip3 install . + +for fuzzer in $(find $SRC -name 'fuzz_*.py'); do + compile_python_fuzzer $fuzzer +done diff --git a/projects/gc-iam/fuzz_credentials.py b/projects/gc-iam/fuzz_credentials.py new file mode 100644 index 000000000..56af2b827 --- /dev/null +++ b/projects/gc-iam/fuzz_credentials.py @@ -0,0 +1,80 @@ +#!/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 sys +import atheris +with atheris.instrument_imports(): + import google.cloud.iam_credentials_v1.services.iam_credentials as iam + +def TestOneInput(data): + fdp = atheris.FuzzedDataProvider(data) + + iam.IAMCredentialsClient._get_default_mtls_endpoint(None) + iam.IAMCredentialsClient._get_default_mtls_endpoint(fdp.ConsumeString(100)) + + iam.IAMCredentialsClient.service_account_path( + fdp.ConsumeString(100), + fdp.ConsumeString(100) + ) + iam.IAMCredentialsClient.parse_service_account_path(fdp.ConsumeString(100)) + iam.IAMCredentialsClient.parse_service_account_path( + "projects/%s/serviceAccounts/%s"%( + fdp.ConsumeString(100), + fdp.ConsumeString(100) + ) + ) + + iam.IAMCredentialsClient.common_billing_account_path(fdp.ConsumeString(100)) + iam.IAMCredentialsClient.parse_common_billing_account_path(fdp.ConsumeString(100)) + iam.IAMCredentialsClient.parse_common_billing_account_path( + "billingAccounts/%s/"%fdp.ConsumeString(100) + ) + + iam.IAMCredentialsClient.common_folder_path(fdp.ConsumeString(100)) + iam.IAMCredentialsClient.parse_common_folder_path(fdp.ConsumeString(100)) + iam.IAMCredentialsClient.parse_common_folder_path( + "folders/%s/"%fdp.ConsumeString(100) + ) + + iam.IAMCredentialsClient.common_organization_path(fdp.ConsumeString(100)) + iam.IAMCredentialsClient.parse_common_organization_path(fdp.ConsumeString(100)) + iam.IAMCredentialsClient.parse_common_organization_path( + "organizations/%s/"%fdp.ConsumeString(100) + ) + + iam.IAMCredentialsClient.common_project_path(fdp.ConsumeString(100)) + iam.IAMCredentialsClient.parse_common_project_path(fdp.ConsumeString(100)) + iam.IAMCredentialsClient.parse_common_project_path( + "projects/%s/"%fdp.ConsumeString(100) + ) + + iam.IAMCredentialsClient.common_location_path( + fdp.ConsumeString(100), + fdp.ConsumeString(100) + ) + iam.IAMCredentialsClient.parse_common_location_path(fdp.ConsumeString(100)) + iam.IAMCredentialsClient.parse_common_location_path( + "projects/%s/locations/%s"%( + fdp.ConsumeString(100), + fdp.ConsumeString(100) + ) + ) + +def main(): + atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True) + atheris.Fuzz() + +if __name__ == "__main__": + main() diff --git a/projects/gc-iam/project.yaml b/projects/gc-iam/project.yaml new file mode 100644 index 000000000..9a3d65206 --- /dev/null +++ b/projects/gc-iam/project.yaml @@ -0,0 +1,12 @@ +fuzzing_engines: +- libfuzzer +homepage: https://github.com/googleapis/python-iam +language: python +main_repo: https://github.com/googleapis/python-iam +sanitizers: +- address +- undefined +vendor_ccs: +- david@adalogics.com +- adam@adalogics.com +- arthur.chan@adalogics.com