gc-iam:initial integration (#8086)

Create fuzzer
This commit is contained in:
Arthur Chan 2022-08-15 18:39:55 +01:00 committed by GitHub
parent 66e90bbf6c
commit 715d2daf0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 139 additions and 0 deletions

View File

@ -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/

25
projects/gc-iam/build.sh Normal file
View File

@ -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

View File

@ -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()

View File

@ -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