- On January 1, 2020 this library will no longer support Python 2 on the latest released version. - Previously released library versions will continue to be available. For more information please + As of January 1, 2020 this library no longer supports Python 2 on the latest released version. + Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.
{% block body %} {% endblock %} diff --git a/docs/conf.py b/docs/conf.py index b3c313e..78c4e74 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,21 +38,18 @@ "sphinx.ext.napoleon", "sphinx.ext.todo", "sphinx.ext.viewcode", + "recommonmark", ] # autodoc/autosummary flags autoclass_content = "both" -autodoc_default_flags = ["members"] +autodoc_default_options = {"members": True} autosummary_generate = True # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # source_suffix = ['.rst', '.md'] @@ -340,7 +337,7 @@ intersphinx_mapping = { "python": ("http://python.readthedocs.org/en/latest/", None), "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), "grpc": ("https://grpc.io/grpc/python/", None), } diff --git a/docs/gapic/v1alpha/api.rst b/docs/gapic/v1alpha/api.rst deleted file mode 100644 index fd817f9..0000000 --- a/docs/gapic/v1alpha/api.rst +++ /dev/null @@ -1,6 +0,0 @@ -Client for Web Security Scanner API -=================================== - -.. automodule:: google.cloud.websecurityscanner_v1alpha - :members: - :inherited-members: \ No newline at end of file diff --git a/docs/gapic/v1alpha/types.rst b/docs/gapic/v1alpha/types.rst deleted file mode 100644 index 47a1393..0000000 --- a/docs/gapic/v1alpha/types.rst +++ /dev/null @@ -1,5 +0,0 @@ -Types for Web Security Scanner API Client -========================================= - -.. automodule:: google.cloud.websecurityscanner_v1alpha.types - :members: \ No newline at end of file diff --git a/docs/gapic/v1beta/api.rst b/docs/gapic/v1beta/api.rst deleted file mode 100644 index 68a9c24..0000000 --- a/docs/gapic/v1beta/api.rst +++ /dev/null @@ -1,6 +0,0 @@ -Client for Web Security Scanner API -=================================== - -.. automodule:: google.cloud.websecurityscanner_v1beta - :members: - :inherited-members: \ No newline at end of file diff --git a/docs/gapic/v1beta/types.rst b/docs/gapic/v1beta/types.rst deleted file mode 100644 index f0f68e0..0000000 --- a/docs/gapic/v1beta/types.rst +++ /dev/null @@ -1,5 +0,0 @@ -Types for Web Security Scanner API Client -========================================= - -.. automodule:: google.cloud.websecurityscanner_v1beta.types - :members: \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 980ca1f..6774b3d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,5 +1,7 @@ .. include:: README.rst +.. include:: multiprocessing.rst + Api Reference ------------- This package includes clients for multiple versions of the Web Security Scanner API. By default, you will get ``v1beta``, the latest version. @@ -7,8 +9,8 @@ This package includes clients for multiple versions of the Web Security Scanner .. toctree:: :maxdepth: 2 - gapic/v1beta/api - gapic/v1beta/types + websecurityscanner_v1beta/services + websecurityscanner_v1beta/types The previous alpha release, spelled ``v1alpha`` is provided to continue to support code previously written against it. In order to use it, you will want to import from it e.g., ``google.cloud.websecurityscanner_v1alpha`` in lieu of ``google.cloud.websecurityscanner`` (or the equivalent ``google.cloud.websecurityscanner_v1beta``). @@ -17,8 +19,19 @@ v1alpha .. toctree:: :maxdepth: 2 - gapic/v1alpha/api - gapic/v1alpha/types + websecurityscanner_v1alpha/services + websecurityscanner_v1alpha/types + + +Migration Guide +--------------- + +See the guide below for instructions on migrating to the 1.x release of this library. + +.. toctree:: + :maxdepth: 2 + + UPGRADING Changelog @@ -29,4 +42,4 @@ For a list of all ``google-cloud-websecurityscanner`` releases. .. toctree:: :maxdepth: 2 - changelog \ No newline at end of file + changelog diff --git a/docs/multiprocessing.rst b/docs/multiprocessing.rst new file mode 100644 index 0000000..1cb29d4 --- /dev/null +++ b/docs/multiprocessing.rst @@ -0,0 +1,7 @@ +.. note:: + + Because this client uses :mod:`grpcio` library, it is safe to + share instances across threads. In multiprocessing scenarios, the best + practice is to create client instances *after* the invocation of + :func:`os.fork` by :class:`multiprocessing.Pool` or + :class:`multiprocessing.Process`. diff --git a/docs/websecurityscanner_v1alpha/services.rst b/docs/websecurityscanner_v1alpha/services.rst new file mode 100644 index 0000000..338bf5a --- /dev/null +++ b/docs/websecurityscanner_v1alpha/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Websecurityscanner v1alpha API +======================================================== + +.. automodule:: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner + :members: + :inherited-members: diff --git a/docs/websecurityscanner_v1alpha/types.rst b/docs/websecurityscanner_v1alpha/types.rst new file mode 100644 index 0000000..a4cf71b --- /dev/null +++ b/docs/websecurityscanner_v1alpha/types.rst @@ -0,0 +1,5 @@ +Types for Google Cloud Websecurityscanner v1alpha API +===================================================== + +.. automodule:: google.cloud.websecurityscanner_v1alpha.types + :members: diff --git a/docs/websecurityscanner_v1beta/services.rst b/docs/websecurityscanner_v1beta/services.rst new file mode 100644 index 0000000..70be826 --- /dev/null +++ b/docs/websecurityscanner_v1beta/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Websecurityscanner v1beta API +======================================================= + +.. automodule:: google.cloud.websecurityscanner_v1beta.services.web_security_scanner + :members: + :inherited-members: diff --git a/docs/websecurityscanner_v1beta/types.rst b/docs/websecurityscanner_v1beta/types.rst new file mode 100644 index 0000000..912ef2b --- /dev/null +++ b/docs/websecurityscanner_v1beta/types.rst @@ -0,0 +1,5 @@ +Types for Google Cloud Websecurityscanner v1beta API +==================================================== + +.. automodule:: google.cloud.websecurityscanner_v1beta.types + :members: diff --git a/google/cloud/websecurityscanner_v1alpha/__init__.py b/google/cloud/websecurityscanner_v1alpha/__init__.py index dd58363..c38963d 100644 --- a/google/cloud/websecurityscanner_v1alpha/__init__.py +++ b/google/cloud/websecurityscanner_v1alpha/__init__.py @@ -1,41 +1,79 @@ # -*- coding: utf-8 -*- -# + # Copyright 2020 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 # -# https://www.apache.org/licenses/LICENSE-2.0 +# 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 __future__ import absolute_import -import sys -import warnings - -from google.cloud.websecurityscanner_v1alpha import types -from google.cloud.websecurityscanner_v1alpha.gapic import enums -from google.cloud.websecurityscanner_v1alpha.gapic import web_security_scanner_client - - -if sys.version_info[:2] == (2, 7): - message = ( - "A future version of this library will drop support for Python 2.7." - "More details about Python 2 support for Google Cloud Client Libraries" - "can be found at https://cloud.google.com/python/docs/python2-sunset/" - ) - warnings.warn(message, DeprecationWarning) - - -class WebSecurityScannerClient(web_security_scanner_client.WebSecurityScannerClient): - __doc__ = web_security_scanner_client.WebSecurityScannerClient.__doc__ - enums = enums +from .services.web_security_scanner import WebSecurityScannerClient +from .types.crawled_url import CrawledUrl +from .types.finding import Finding +from .types.finding_addon import OutdatedLibrary +from .types.finding_addon import ViolatingResource +from .types.finding_addon import VulnerableHeaders +from .types.finding_addon import VulnerableParameters +from .types.finding_addon import Xss +from .types.finding_type_stats import FindingTypeStats +from .types.scan_config import ScanConfig +from .types.scan_run import ScanRun +from .types.web_security_scanner import CreateScanConfigRequest +from .types.web_security_scanner import DeleteScanConfigRequest +from .types.web_security_scanner import GetFindingRequest +from .types.web_security_scanner import GetScanConfigRequest +from .types.web_security_scanner import GetScanRunRequest +from .types.web_security_scanner import ListCrawledUrlsRequest +from .types.web_security_scanner import ListCrawledUrlsResponse +from .types.web_security_scanner import ListFindingTypeStatsRequest +from .types.web_security_scanner import ListFindingTypeStatsResponse +from .types.web_security_scanner import ListFindingsRequest +from .types.web_security_scanner import ListFindingsResponse +from .types.web_security_scanner import ListScanConfigsRequest +from .types.web_security_scanner import ListScanConfigsResponse +from .types.web_security_scanner import ListScanRunsRequest +from .types.web_security_scanner import ListScanRunsResponse +from .types.web_security_scanner import StartScanRunRequest +from .types.web_security_scanner import StopScanRunRequest +from .types.web_security_scanner import UpdateScanConfigRequest -__all__ = ("enums", "types", "WebSecurityScannerClient") +__all__ = ( + "CrawledUrl", + "CreateScanConfigRequest", + "DeleteScanConfigRequest", + "Finding", + "FindingTypeStats", + "GetFindingRequest", + "GetScanConfigRequest", + "GetScanRunRequest", + "ListCrawledUrlsRequest", + "ListCrawledUrlsResponse", + "ListFindingTypeStatsRequest", + "ListFindingTypeStatsResponse", + "ListFindingsRequest", + "ListFindingsResponse", + "ListScanConfigsRequest", + "ListScanConfigsResponse", + "ListScanRunsRequest", + "ListScanRunsResponse", + "OutdatedLibrary", + "ScanConfig", + "ScanRun", + "StartScanRunRequest", + "StopScanRunRequest", + "UpdateScanConfigRequest", + "ViolatingResource", + "VulnerableHeaders", + "VulnerableParameters", + "Xss", + "WebSecurityScannerClient", +) diff --git a/google/cloud/websecurityscanner_v1alpha/gapic/enums.py b/google/cloud/websecurityscanner_v1alpha/gapic/enums.py deleted file mode 100644 index eb85ac6..0000000 --- a/google/cloud/websecurityscanner_v1alpha/gapic/enums.py +++ /dev/null @@ -1,146 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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. - -"""Wrappers for protocol buffer enum types.""" - -import enum - - -class Finding(object): - class FindingType(enum.IntEnum): - """ - Types of Findings. - - Attributes: - FINDING_TYPE_UNSPECIFIED (int): The invalid finding type. - MIXED_CONTENT (int): A page that was served over HTTPS also resources over HTTP. A - man-in-the-middle attacker could tamper with the HTTP resource and gain - full access to the website that loads the resource or to monitor the - actions taken by the user. - OUTDATED_LIBRARY (int): The version of an included library is known to contain a security issue. - The scanner checks the version of library in use against a known list of - vulnerable libraries. False positives are possible if the version - detection fails or if the library has been manually patched. - ROSETTA_FLASH (int): This type of vulnerability occurs when the value of a request parameter - is reflected at the beginning of the response, for example, in requests - using JSONP. Under certain circumstances, an attacker may be able to - supply an alphanumeric-only Flash file in the vulnerable parameter - causing the browser to execute the Flash file as if it originated on the - vulnerable server. - XSS_CALLBACK (int): A cross-site scripting (XSS) bug is found via JavaScript callback. For - detailed explanations on XSS, see - https://www.google.com/about/appsecurity/learning/xss/. - XSS_ERROR (int): A potential cross-site scripting (XSS) bug due to JavaScript breakage. - In some circumstances, the application under test might modify the test - string before it is parsed by the browser. When the browser attempts to - runs this modified test string, it will likely break and throw a - JavaScript execution error, thus an injection issue is occurring. - However, it may not be exploitable. Manual verification is needed to see - if the test string modifications can be evaded and confirm that the issue - is in fact an XSS vulnerability. For detailed explanations on XSS, see - https://www.google.com/about/appsecurity/learning/xss/. - CLEAR_TEXT_PASSWORD (int): An application appears to be transmitting a password field in clear text. - An attacker can eavesdrop network traffic and sniff the password field. - INVALID_CONTENT_TYPE (int): An application returns sensitive content with an invalid content type, - or without an 'X-Content-Type-Options: nosniff' header. - XSS_ANGULAR_CALLBACK (int): A cross-site scripting (XSS) vulnerability in AngularJS module that - occurs when a user-provided string is interpolated by Angular. - INVALID_HEADER (int): A malformed or invalid valued header. - MISSPELLED_SECURITY_HEADER_NAME (int): Misspelled security header name. - MISMATCHING_SECURITY_HEADER_VALUES (int): Mismatching values in a duplicate security header. - """ - - FINDING_TYPE_UNSPECIFIED = 0 - MIXED_CONTENT = 1 - OUTDATED_LIBRARY = 2 - ROSETTA_FLASH = 5 - XSS_CALLBACK = 3 - XSS_ERROR = 4 - CLEAR_TEXT_PASSWORD = 6 - INVALID_CONTENT_TYPE = 7 - XSS_ANGULAR_CALLBACK = 8 - INVALID_HEADER = 9 - MISSPELLED_SECURITY_HEADER_NAME = 10 - MISMATCHING_SECURITY_HEADER_VALUES = 11 - - -class ScanConfig(object): - class TargetPlatform(enum.IntEnum): - """ - Cloud platforms supported by Cloud Web Security Scanner. - - Attributes: - TARGET_PLATFORM_UNSPECIFIED (int): The target platform is unknown. Requests with this enum value will be - rejected with INVALID\_ARGUMENT error. - APP_ENGINE (int): Google App Engine service. - COMPUTE (int): Google Compute Engine service. - """ - - TARGET_PLATFORM_UNSPECIFIED = 0 - APP_ENGINE = 1 - COMPUTE = 2 - - class UserAgent(enum.IntEnum): - """ - Type of user agents used for scanning. - - Attributes: - USER_AGENT_UNSPECIFIED (int): The user agent is unknown. Service will default to CHROME\_LINUX. - CHROME_LINUX (int): Chrome on Linux. This is the service default if unspecified. - CHROME_ANDROID (int): Chrome on Android. - SAFARI_IPHONE (int): Safari on IPhone. - """ - - USER_AGENT_UNSPECIFIED = 0 - CHROME_LINUX = 1 - CHROME_ANDROID = 2 - SAFARI_IPHONE = 3 - - -class ScanRun(object): - class ExecutionState(enum.IntEnum): - """ - Types of ScanRun execution state. - - Attributes: - EXECUTION_STATE_UNSPECIFIED (int): Represents an invalid state caused by internal server error. This value - should never be returned. - QUEUED (int): The scan is waiting in the queue. - SCANNING (int): The scan is in progress. - FINISHED (int): The scan is either finished or stopped by user. - """ - - EXECUTION_STATE_UNSPECIFIED = 0 - QUEUED = 1 - SCANNING = 2 - FINISHED = 3 - - class ResultState(enum.IntEnum): - """ - Types of ScanRun result state. - - Attributes: - RESULT_STATE_UNSPECIFIED (int): Default value. This value is returned when the ScanRun is not yet - finished. - SUCCESS (int): The scan finished without errors. - ERROR (int): The scan finished with errors. - KILLED (int): The scan was terminated by user. - """ - - RESULT_STATE_UNSPECIFIED = 0 - SUCCESS = 1 - ERROR = 2 - KILLED = 3 diff --git a/google/cloud/websecurityscanner_v1alpha/gapic/transports/web_security_scanner_grpc_transport.py b/google/cloud/websecurityscanner_v1alpha/gapic/transports/web_security_scanner_grpc_transport.py deleted file mode 100644 index 05a7d16..0000000 --- a/google/cloud/websecurityscanner_v1alpha/gapic/transports/web_security_scanner_grpc_transport.py +++ /dev/null @@ -1,283 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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 google.api_core.grpc_helpers - -from google.cloud.websecurityscanner_v1alpha.proto import web_security_scanner_pb2_grpc - - -class WebSecurityScannerGrpcTransport(object): - """gRPC transport class providing stubs for - google.cloud.websecurityscanner.v1alpha WebSecurityScanner API. - - The transport provides access to the raw gRPC stubs, - which can be used to take advantage of advanced - features of gRPC. - """ - - # The scopes needed to make gRPC calls to all of the methods defined - # in this service. - _OAUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) - - def __init__( - self, - channel=None, - credentials=None, - address="websecurityscanner.googleapis.com:443", - ): - """Instantiate the transport class. - - Args: - channel (grpc.Channel): A ``Channel`` instance through - which to make calls. This argument is mutually exclusive - with ``credentials``; providing both will raise an exception. - credentials (google.auth.credentials.Credentials): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If none - are specified, the client will attempt to ascertain the - credentials from the environment. - address (str): The address where the service is hosted. - """ - # If both `channel` and `credentials` are specified, raise an - # exception (channels come with credentials baked in already). - if channel is not None and credentials is not None: - raise ValueError( - "The `channel` and `credentials` arguments are mutually " "exclusive." - ) - - # Create the channel. - if channel is None: - channel = self.create_channel( - address=address, - credentials=credentials, - options={ - "grpc.max_send_message_length": -1, - "grpc.max_receive_message_length": -1, - }.items(), - ) - - self._channel = channel - - # gRPC uses objects called "stubs" that are bound to the - # channel and provide a basic method for each RPC. - self._stubs = { - "web_security_scanner_stub": web_security_scanner_pb2_grpc.WebSecurityScannerStub( - channel - ) - } - - @classmethod - def create_channel( - cls, address="websecurityscanner.googleapis.com:443", credentials=None, **kwargs - ): - """Create and return a gRPC channel object. - - Args: - address (str): The host for the channel to use. - credentials (~.Credentials): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - kwargs (dict): Keyword arguments, which are passed to the - channel creation. - - Returns: - grpc.Channel: A gRPC channel object. - """ - return google.api_core.grpc_helpers.create_channel( - address, credentials=credentials, scopes=cls._OAUTH_SCOPES, **kwargs - ) - - @property - def channel(self): - """The gRPC channel used by the transport. - - Returns: - grpc.Channel: A gRPC channel object. - """ - return self._channel - - @property - def create_scan_config(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.create_scan_config`. - - Creates a new ScanConfig. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].CreateScanConfig - - @property - def delete_scan_config(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.delete_scan_config`. - - Deletes an existing ScanConfig and its child resources. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].DeleteScanConfig - - @property - def get_scan_config(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.get_scan_config`. - - Gets a ScanConfig. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].GetScanConfig - - @property - def list_scan_configs(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.list_scan_configs`. - - Lists ScanConfigs under a given project. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].ListScanConfigs - - @property - def update_scan_config(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.update_scan_config`. - - Updates a ScanConfig. This method support partial update of a ScanConfig. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].UpdateScanConfig - - @property - def start_scan_run(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.start_scan_run`. - - Start a ScanRun according to the given ScanConfig. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].StartScanRun - - @property - def get_scan_run(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.get_scan_run`. - - Gets a ScanRun. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].GetScanRun - - @property - def list_scan_runs(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.list_scan_runs`. - - Lists ScanRuns under a given ScanConfig, in descending order of ScanRun - stop time. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].ListScanRuns - - @property - def stop_scan_run(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.stop_scan_run`. - - Stops a ScanRun. The stopped ScanRun is returned. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].StopScanRun - - @property - def list_crawled_urls(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.list_crawled_urls`. - - List CrawledUrls under a given ScanRun. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].ListCrawledUrls - - @property - def get_finding(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.get_finding`. - - Gets a Finding. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].GetFinding - - @property - def list_findings(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.list_findings`. - - List Findings under a given ScanRun. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].ListFindings - - @property - def list_finding_type_stats(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.list_finding_type_stats`. - - List all FindingTypeStats under a given ScanRun. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].ListFindingTypeStats diff --git a/google/cloud/websecurityscanner_v1alpha/gapic/web_security_scanner_client.py b/google/cloud/websecurityscanner_v1alpha/gapic/web_security_scanner_client.py deleted file mode 100644 index 6ab946b..0000000 --- a/google/cloud/websecurityscanner_v1alpha/gapic/web_security_scanner_client.py +++ /dev/null @@ -1,1320 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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. - -"""Accesses the google.cloud.websecurityscanner.v1alpha WebSecurityScanner API.""" - -import functools -import pkg_resources -import warnings - -from google.oauth2 import service_account -import google.api_core.client_options -import google.api_core.gapic_v1.client_info -import google.api_core.gapic_v1.config -import google.api_core.gapic_v1.method -import google.api_core.gapic_v1.routing_header -import google.api_core.grpc_helpers -import google.api_core.page_iterator -import google.api_core.path_template -import grpc - -from google.cloud.websecurityscanner_v1alpha.gapic import enums -from google.cloud.websecurityscanner_v1alpha.gapic import ( - web_security_scanner_client_config, -) -from google.cloud.websecurityscanner_v1alpha.gapic.transports import ( - web_security_scanner_grpc_transport, -) -from google.cloud.websecurityscanner_v1alpha.proto import finding_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import scan_config_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import scan_run_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import web_security_scanner_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import web_security_scanner_pb2_grpc -from google.protobuf import empty_pb2 -from google.protobuf import field_mask_pb2 - - -_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution( - "google-cloud-websecurityscanner" -).version - - -class WebSecurityScannerClient(object): - """ - Cloud Web Security Scanner Service identifies security vulnerabilities in web - applications hosted on Google Cloud Platform. It crawls your application, and - attempts to exercise as many user inputs and event handlers as possible. - """ - - SERVICE_ADDRESS = "websecurityscanner.googleapis.com:443" - """The default address of the service.""" - - # The name of the interface for this client. This is the key used to - # find the method configuration in the client_config dictionary. - _INTERFACE_NAME = "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner" - - @classmethod - def from_service_account_file(cls, filename, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - WebSecurityScannerClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_file(filename) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - from_service_account_json = from_service_account_file - - @classmethod - def finding_path(cls, project, scan_config, scan_run, finding): - """Return a fully-qualified finding string.""" - return google.api_core.path_template.expand( - "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}", - project=project, - scan_config=scan_config, - scan_run=scan_run, - finding=finding, - ) - - @classmethod - def project_path(cls, project): - """Return a fully-qualified project string.""" - return google.api_core.path_template.expand( - "projects/{project}", project=project - ) - - @classmethod - def scan_config_path(cls, project, scan_config): - """Return a fully-qualified scan_config string.""" - return google.api_core.path_template.expand( - "projects/{project}/scanConfigs/{scan_config}", - project=project, - scan_config=scan_config, - ) - - @classmethod - def scan_run_path(cls, project, scan_config, scan_run): - """Return a fully-qualified scan_run string.""" - return google.api_core.path_template.expand( - "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}", - project=project, - scan_config=scan_config, - scan_run=scan_run, - ) - - def __init__( - self, - transport=None, - channel=None, - credentials=None, - client_config=None, - client_info=None, - client_options=None, - ): - """Constructor. - - Args: - transport (Union[~.WebSecurityScannerGrpcTransport, - Callable[[~.Credentials, type], ~.WebSecurityScannerGrpcTransport]): A transport - instance, responsible for actually making the API calls. - The default transport uses the gRPC protocol. - This argument may also be a callable which returns a - transport instance. Callables will be sent the credentials - as the first argument and the default transport class as - the second argument. - channel (grpc.Channel): DEPRECATED. A ``Channel`` instance - through which to make calls. This argument is mutually exclusive - with ``credentials``; providing both will raise an exception. - credentials (google.auth.credentials.Credentials): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is mutually exclusive with providing a - transport instance to ``transport``; doing so will raise - an exception. - client_config (dict): DEPRECATED. A dictionary of call options for - each method. If not specified, the default configuration is used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - client_options (Union[dict, google.api_core.client_options.ClientOptions]): - Client options used to set user options on the client. API Endpoint - should be set through client_options. - """ - # Raise deprecation warnings for things we want to go away. - if client_config is not None: - warnings.warn( - "The `client_config` argument is deprecated.", - PendingDeprecationWarning, - stacklevel=2, - ) - else: - client_config = web_security_scanner_client_config.config - - if channel: - warnings.warn( - "The `channel` argument is deprecated; use " "`transport` instead.", - PendingDeprecationWarning, - stacklevel=2, - ) - - api_endpoint = self.SERVICE_ADDRESS - if client_options: - if type(client_options) == dict: - client_options = google.api_core.client_options.from_dict( - client_options - ) - if client_options.api_endpoint: - api_endpoint = client_options.api_endpoint - - # Instantiate the transport. - # The transport is responsible for handling serialization and - # deserialization and actually sending data to the service. - if transport: - if callable(transport): - self.transport = transport( - credentials=credentials, - default_class=web_security_scanner_grpc_transport.WebSecurityScannerGrpcTransport, - address=api_endpoint, - ) - else: - if credentials: - raise ValueError( - "Received both a transport instance and " - "credentials; these are mutually exclusive." - ) - self.transport = transport - else: - self.transport = web_security_scanner_grpc_transport.WebSecurityScannerGrpcTransport( - address=api_endpoint, channel=channel, credentials=credentials - ) - - if client_info is None: - client_info = google.api_core.gapic_v1.client_info.ClientInfo( - gapic_version=_GAPIC_LIBRARY_VERSION - ) - else: - client_info.gapic_version = _GAPIC_LIBRARY_VERSION - self._client_info = client_info - - # Parse out the default settings for retry and timeout for each RPC - # from the client configuration. - # (Ordinarily, these are the defaults specified in the `*_config.py` - # file next to this one.) - self._method_configs = google.api_core.gapic_v1.config.parse_method_configs( - client_config["interfaces"][self._INTERFACE_NAME] - ) - - # Save a dictionary of cached API call functions. - # These are the actual callables which invoke the proper - # transport methods, wrapped with `wrap_method` to add retry, - # timeout, and the like. - self._inner_api_calls = {} - - # Service calls - def create_scan_config( - self, - parent, - scan_config, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Creates a new ScanConfig. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> parent = client.project_path('[PROJECT]') - >>> - >>> # TODO: Initialize `scan_config`: - >>> scan_config = {} - >>> - >>> response = client.create_scan_config(parent, scan_config) - - Args: - parent (str): Required. The parent resource name where the scan is created, which should be a - project resource name in the format 'projects/{projectId}'. - scan_config (Union[dict, ~google.cloud.websecurityscanner_v1alpha.types.ScanConfig]): Required. The ScanConfig to be created. - - If a dict is provided, it must be of the same form as the protobuf - message :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig` - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "create_scan_config" not in self._inner_api_calls: - self._inner_api_calls[ - "create_scan_config" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.create_scan_config, - default_retry=self._method_configs["CreateScanConfig"].retry, - default_timeout=self._method_configs["CreateScanConfig"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.CreateScanConfigRequest( - parent=parent, scan_config=scan_config - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["create_scan_config"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def delete_scan_config( - self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Deletes an existing ScanConfig and its child resources. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> name = client.scan_config_path('[PROJECT]', '[SCAN_CONFIG]') - >>> - >>> client.delete_scan_config(name) - - Args: - name (str): Required. The resource name of the ScanConfig to be deleted. The name follows the - format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "delete_scan_config" not in self._inner_api_calls: - self._inner_api_calls[ - "delete_scan_config" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.delete_scan_config, - default_retry=self._method_configs["DeleteScanConfig"].retry, - default_timeout=self._method_configs["DeleteScanConfig"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.DeleteScanConfigRequest(name=name) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("name", name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - self._inner_api_calls["delete_scan_config"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def get_scan_config( - self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Gets a ScanConfig. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> name = client.scan_config_path('[PROJECT]', '[SCAN_CONFIG]') - >>> - >>> response = client.get_scan_config(name) - - Args: - name (str): Required. The resource name of the ScanConfig to be returned. The name follows the - format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "get_scan_config" not in self._inner_api_calls: - self._inner_api_calls[ - "get_scan_config" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.get_scan_config, - default_retry=self._method_configs["GetScanConfig"].retry, - default_timeout=self._method_configs["GetScanConfig"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.GetScanConfigRequest(name=name) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("name", name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["get_scan_config"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def list_scan_configs( - self, - parent, - page_size=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Lists ScanConfigs under a given project. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> parent = client.project_path('[PROJECT]') - >>> - >>> # Iterate over all results - >>> for element in client.list_scan_configs(parent): - ... # process element - ... pass - >>> - >>> - >>> # Alternatively: - >>> - >>> # Iterate over results one page at a time - >>> for page in client.list_scan_configs(parent).pages: - ... for element in page: - ... # process element - ... pass - - Args: - parent (str): Required. The parent resource name, which should be a project resource name in the - format 'projects/{projectId}'. - page_size (int): The maximum number of resources contained in the - underlying API response. If page streaming is performed per- - resource, this parameter does not affect the return value. If page - streaming is performed per-page, this determines the maximum number - of resources in a page. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.api_core.page_iterator.PageIterator` instance. - An iterable of :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig` instances. - You can also iterate over the pages of the response - using its `pages` property. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "list_scan_configs" not in self._inner_api_calls: - self._inner_api_calls[ - "list_scan_configs" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.list_scan_configs, - default_retry=self._method_configs["ListScanConfigs"].retry, - default_timeout=self._method_configs["ListScanConfigs"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.ListScanConfigsRequest( - parent=parent, page_size=page_size - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - iterator = google.api_core.page_iterator.GRPCIterator( - client=None, - method=functools.partial( - self._inner_api_calls["list_scan_configs"], - retry=retry, - timeout=timeout, - metadata=metadata, - ), - request=request, - items_field="scan_configs", - request_token_field="page_token", - response_token_field="next_page_token", - ) - return iterator - - def update_scan_config( - self, - scan_config, - update_mask, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Updates a ScanConfig. This method support partial update of a ScanConfig. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> # TODO: Initialize `scan_config`: - >>> scan_config = {} - >>> - >>> # TODO: Initialize `update_mask`: - >>> update_mask = {} - >>> - >>> response = client.update_scan_config(scan_config, update_mask) - - Args: - scan_config (Union[dict, ~google.cloud.websecurityscanner_v1alpha.types.ScanConfig]): Required. The ScanConfig to be updated. The name field must be set to identify the - resource to be updated. The values of fields not covered by the mask - will be ignored. - - If a dict is provided, it must be of the same form as the protobuf - message :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig` - update_mask (Union[dict, ~google.cloud.websecurityscanner_v1alpha.types.FieldMask]): Required. The update mask applies to the resource. For the ``FieldMask`` - definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - If a dict is provided, it must be of the same form as the protobuf - message :class:`~google.cloud.websecurityscanner_v1alpha.types.FieldMask` - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "update_scan_config" not in self._inner_api_calls: - self._inner_api_calls[ - "update_scan_config" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.update_scan_config, - default_retry=self._method_configs["UpdateScanConfig"].retry, - default_timeout=self._method_configs["UpdateScanConfig"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.UpdateScanConfigRequest( - scan_config=scan_config, update_mask=update_mask - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("scan_config.name", scan_config.name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["update_scan_config"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def start_scan_run( - self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Start a ScanRun according to the given ScanConfig. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> name = client.scan_config_path('[PROJECT]', '[SCAN_CONFIG]') - >>> - >>> response = client.start_scan_run(name) - - Args: - name (str): Required. The resource name of the ScanConfig to be used. The name follows the - format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanRun` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "start_scan_run" not in self._inner_api_calls: - self._inner_api_calls[ - "start_scan_run" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.start_scan_run, - default_retry=self._method_configs["StartScanRun"].retry, - default_timeout=self._method_configs["StartScanRun"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.StartScanRunRequest(name=name) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("name", name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["start_scan_run"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def get_scan_run( - self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Gets a ScanRun. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> name = client.scan_run_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]') - >>> - >>> response = client.get_scan_run(name) - - Args: - name (str): Required. The resource name of the ScanRun to be returned. The name follows the - format of - 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanRun` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "get_scan_run" not in self._inner_api_calls: - self._inner_api_calls[ - "get_scan_run" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.get_scan_run, - default_retry=self._method_configs["GetScanRun"].retry, - default_timeout=self._method_configs["GetScanRun"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.GetScanRunRequest(name=name) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("name", name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["get_scan_run"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def list_scan_runs( - self, - parent, - page_size=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Lists ScanRuns under a given ScanConfig, in descending order of ScanRun - stop time. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> parent = client.scan_config_path('[PROJECT]', '[SCAN_CONFIG]') - >>> - >>> # Iterate over all results - >>> for element in client.list_scan_runs(parent): - ... # process element - ... pass - >>> - >>> - >>> # Alternatively: - >>> - >>> # Iterate over results one page at a time - >>> for page in client.list_scan_runs(parent).pages: - ... for element in page: - ... # process element - ... pass - - Args: - parent (str): Required. The parent resource name, which should be a scan resource name in the - format 'projects/{projectId}/scanConfigs/{scanConfigId}'. - page_size (int): The maximum number of resources contained in the - underlying API response. If page streaming is performed per- - resource, this parameter does not affect the return value. If page - streaming is performed per-page, this determines the maximum number - of resources in a page. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.api_core.page_iterator.PageIterator` instance. - An iterable of :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanRun` instances. - You can also iterate over the pages of the response - using its `pages` property. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "list_scan_runs" not in self._inner_api_calls: - self._inner_api_calls[ - "list_scan_runs" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.list_scan_runs, - default_retry=self._method_configs["ListScanRuns"].retry, - default_timeout=self._method_configs["ListScanRuns"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.ListScanRunsRequest( - parent=parent, page_size=page_size - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - iterator = google.api_core.page_iterator.GRPCIterator( - client=None, - method=functools.partial( - self._inner_api_calls["list_scan_runs"], - retry=retry, - timeout=timeout, - metadata=metadata, - ), - request=request, - items_field="scan_runs", - request_token_field="page_token", - response_token_field="next_page_token", - ) - return iterator - - def stop_scan_run( - self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Stops a ScanRun. The stopped ScanRun is returned. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> name = client.scan_run_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]') - >>> - >>> response = client.stop_scan_run(name) - - Args: - name (str): Required. The resource name of the ScanRun to be stopped. The name follows the - format of - 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanRun` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "stop_scan_run" not in self._inner_api_calls: - self._inner_api_calls[ - "stop_scan_run" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.stop_scan_run, - default_retry=self._method_configs["StopScanRun"].retry, - default_timeout=self._method_configs["StopScanRun"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.StopScanRunRequest(name=name) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("name", name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["stop_scan_run"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def list_crawled_urls( - self, - parent, - page_size=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - List CrawledUrls under a given ScanRun. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> parent = client.scan_run_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]') - >>> - >>> # Iterate over all results - >>> for element in client.list_crawled_urls(parent): - ... # process element - ... pass - >>> - >>> - >>> # Alternatively: - >>> - >>> # Iterate over results one page at a time - >>> for page in client.list_crawled_urls(parent).pages: - ... for element in page: - ... # process element - ... pass - - Args: - parent (str): Required. The parent resource name, which should be a scan run resource name in the - format - 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. - page_size (int): The maximum number of resources contained in the - underlying API response. If page streaming is performed per- - resource, this parameter does not affect the return value. If page - streaming is performed per-page, this determines the maximum number - of resources in a page. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.api_core.page_iterator.PageIterator` instance. - An iterable of :class:`~google.cloud.websecurityscanner_v1alpha.types.CrawledUrl` instances. - You can also iterate over the pages of the response - using its `pages` property. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "list_crawled_urls" not in self._inner_api_calls: - self._inner_api_calls[ - "list_crawled_urls" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.list_crawled_urls, - default_retry=self._method_configs["ListCrawledUrls"].retry, - default_timeout=self._method_configs["ListCrawledUrls"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.ListCrawledUrlsRequest( - parent=parent, page_size=page_size - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - iterator = google.api_core.page_iterator.GRPCIterator( - client=None, - method=functools.partial( - self._inner_api_calls["list_crawled_urls"], - retry=retry, - timeout=timeout, - metadata=metadata, - ), - request=request, - items_field="crawled_urls", - request_token_field="page_token", - response_token_field="next_page_token", - ) - return iterator - - def get_finding( - self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Gets a Finding. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> name = client.finding_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]', '[FINDING]') - >>> - >>> response = client.get_finding(name) - - Args: - name (str): Required. The resource name of the Finding to be returned. The name follows the - format of - 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1alpha.types.Finding` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "get_finding" not in self._inner_api_calls: - self._inner_api_calls[ - "get_finding" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.get_finding, - default_retry=self._method_configs["GetFinding"].retry, - default_timeout=self._method_configs["GetFinding"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.GetFindingRequest(name=name) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("name", name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["get_finding"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def list_findings( - self, - parent, - filter_, - page_size=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - List Findings under a given ScanRun. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> parent = client.scan_run_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]') - >>> - >>> # TODO: Initialize `filter_`: - >>> filter_ = '' - >>> - >>> # Iterate over all results - >>> for element in client.list_findings(parent, filter_): - ... # process element - ... pass - >>> - >>> - >>> # Alternatively: - >>> - >>> # Iterate over results one page at a time - >>> for page in client.list_findings(parent, filter_).pages: - ... for element in page: - ... # process element - ... pass - - Args: - parent (str): Required. The parent resource name, which should be a scan run resource name in the - format - 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. - filter_ (str): Required. The filter expression. The expression must be in the format: . - Supported field: 'finding\_type'. Supported operator: '='. - page_size (int): The maximum number of resources contained in the - underlying API response. If page streaming is performed per- - resource, this parameter does not affect the return value. If page - streaming is performed per-page, this determines the maximum number - of resources in a page. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.api_core.page_iterator.PageIterator` instance. - An iterable of :class:`~google.cloud.websecurityscanner_v1alpha.types.Finding` instances. - You can also iterate over the pages of the response - using its `pages` property. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "list_findings" not in self._inner_api_calls: - self._inner_api_calls[ - "list_findings" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.list_findings, - default_retry=self._method_configs["ListFindings"].retry, - default_timeout=self._method_configs["ListFindings"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.ListFindingsRequest( - parent=parent, filter=filter_, page_size=page_size - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - iterator = google.api_core.page_iterator.GRPCIterator( - client=None, - method=functools.partial( - self._inner_api_calls["list_findings"], - retry=retry, - timeout=timeout, - metadata=metadata, - ), - request=request, - items_field="findings", - request_token_field="page_token", - response_token_field="next_page_token", - ) - return iterator - - def list_finding_type_stats( - self, - parent, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - List all FindingTypeStats under a given ScanRun. - - Example: - >>> from google.cloud import websecurityscanner_v1alpha - >>> - >>> client = websecurityscanner_v1alpha.WebSecurityScannerClient() - >>> - >>> parent = client.scan_run_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]') - >>> - >>> response = client.list_finding_type_stats(parent) - - Args: - parent (str): Required. The parent resource name, which should be a scan run resource name in the - format - 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1alpha.types.ListFindingTypeStatsResponse` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "list_finding_type_stats" not in self._inner_api_calls: - self._inner_api_calls[ - "list_finding_type_stats" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.list_finding_type_stats, - default_retry=self._method_configs["ListFindingTypeStats"].retry, - default_timeout=self._method_configs["ListFindingTypeStats"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.ListFindingTypeStatsRequest(parent=parent) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["list_finding_type_stats"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) diff --git a/google/cloud/websecurityscanner_v1alpha/gapic/web_security_scanner_client_config.py b/google/cloud/websecurityscanner_v1alpha/gapic/web_security_scanner_client_config.py deleted file mode 100644 index e155015..0000000 --- a/google/cloud/websecurityscanner_v1alpha/gapic/web_security_scanner_client_config.py +++ /dev/null @@ -1,88 +0,0 @@ -config = { - "interfaces": { - "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner": { - "retry_codes": { - "idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"], - "non_idempotent": [], - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000, - } - }, - "methods": { - "CreateScanConfig": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default", - }, - "DeleteScanConfig": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "GetScanConfig": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "ListScanConfigs": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "UpdateScanConfig": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default", - }, - "StartScanRun": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default", - }, - "GetScanRun": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "ListScanRuns": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "StopScanRun": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default", - }, - "ListCrawledUrls": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "GetFinding": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "ListFindings": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "ListFindingTypeStats": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - }, - } - } -} diff --git a/google/cloud/websecurityscanner_v1alpha/proto/__init__.py b/google/cloud/websecurityscanner_v1alpha/proto/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/google/cloud/websecurityscanner_v1alpha/proto/crawled_url_pb2.py b/google/cloud/websecurityscanner_v1alpha/proto/crawled_url_pb2.py deleted file mode 100644 index 10e8680..0000000 --- a/google/cloud/websecurityscanner_v1alpha/proto/crawled_url_pb2.py +++ /dev/null @@ -1,137 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1alpha/proto/crawled_url.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1alpha/proto/crawled_url.proto", - package="google.cloud.websecurityscanner.v1alpha", - syntax="proto3", - serialized_options=_b( - "\n+com.google.cloud.websecurityscanner.v1alphaB\017CrawledUrlProtoP\001ZYgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscanner" - ), - serialized_pb=_b( - "\n?google/cloud/websecurityscanner_v1alpha/proto/crawled_url.proto\x12'google.cloud.websecurityscanner.v1alpha\"<\n\nCrawledUrl\x12\x13\n\x0bhttp_method\x18\x01 \x01(\t\x12\x0b\n\x03url\x18\x02 \x01(\t\x12\x0c\n\x04\x62ody\x18\x03 \x01(\tB\x9b\x01\n+com.google.cloud.websecurityscanner.v1alphaB\x0f\x43rawledUrlProtoP\x01ZYgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscannerb\x06proto3" - ), -) - - -_CRAWLEDURL = _descriptor.Descriptor( - name="CrawledUrl", - full_name="google.cloud.websecurityscanner.v1alpha.CrawledUrl", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="http_method", - full_name="google.cloud.websecurityscanner.v1alpha.CrawledUrl.http_method", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="url", - full_name="google.cloud.websecurityscanner.v1alpha.CrawledUrl.url", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="body", - full_name="google.cloud.websecurityscanner.v1alpha.CrawledUrl.body", - index=2, - number=3, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=108, - serialized_end=168, -) - -DESCRIPTOR.message_types_by_name["CrawledUrl"] = _CRAWLEDURL -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -CrawledUrl = _reflection.GeneratedProtocolMessageType( - "CrawledUrl", - (_message.Message,), - dict( - DESCRIPTOR=_CRAWLEDURL, - __module__="google.cloud.websecurityscanner_v1alpha.proto.crawled_url_pb2", - __doc__="""A CrawledUrl resource represents a URL that was crawled - during a ScanRun. Web Security Scanner Service crawls the web - applications, following all links within the scope of sites, to find the - URLs to test against. - - - Attributes: - http_method: - Output only. The http method of the request that was used to - visit the URL, in uppercase. - url: - Output only. The URL that was crawled. - body: - Output only. The body of the request that was used to visit - the URL. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.CrawledUrl) - ), -) -_sym_db.RegisterMessage(CrawledUrl) - - -DESCRIPTOR._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1alpha/proto/crawled_url_pb2_grpc.py b/google/cloud/websecurityscanner_v1alpha/proto/crawled_url_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1alpha/proto/crawled_url_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1alpha/proto/finding_addon_pb2.py b/google/cloud/websecurityscanner_v1alpha/proto/finding_addon_pb2.py deleted file mode 100644 index e74e0c8..0000000 --- a/google/cloud/websecurityscanner_v1alpha/proto/finding_addon_pb2.py +++ /dev/null @@ -1,506 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1alpha/proto/finding_addon.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1alpha/proto/finding_addon.proto", - package="google.cloud.websecurityscanner.v1alpha", - syntax="proto3", - serialized_options=_b( - "\n+com.google.cloud.websecurityscanner.v1alphaB\021FindingAddonProtoP\001ZYgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscanner" - ), - serialized_pb=_b( - '\nAgoogle/cloud/websecurityscanner_v1alpha/proto/finding_addon.proto\x12\'google.cloud.websecurityscanner.v1alpha"Q\n\x0fOutdatedLibrary\x12\x14\n\x0clibrary_name\x18\x01 \x01(\t\x12\x0f\n\x07version\x18\x02 \x01(\t\x12\x17\n\x0flearn_more_urls\x18\x03 \x03(\t"?\n\x11ViolatingResource\x12\x14\n\x0c\x63ontent_type\x18\x01 \x01(\t\x12\x14\n\x0cresource_url\x18\x02 \x01(\t"/\n\x14VulnerableParameters\x12\x17\n\x0fparameter_names\x18\x01 \x03(\t"\xea\x01\n\x11VulnerableHeaders\x12R\n\x07headers\x18\x01 \x03(\x0b\x32\x41.google.cloud.websecurityscanner.v1alpha.VulnerableHeaders.Header\x12Z\n\x0fmissing_headers\x18\x02 \x03(\x0b\x32\x41.google.cloud.websecurityscanner.v1alpha.VulnerableHeaders.Header\x1a%\n\x06Header\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t"2\n\x03Xss\x12\x14\n\x0cstack_traces\x18\x01 \x03(\t\x12\x15\n\rerror_message\x18\x02 \x01(\tB\x9d\x01\n+com.google.cloud.websecurityscanner.v1alphaB\x11\x46indingAddonProtoP\x01ZYgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscannerb\x06proto3' - ), -) - - -_OUTDATEDLIBRARY = _descriptor.Descriptor( - name="OutdatedLibrary", - full_name="google.cloud.websecurityscanner.v1alpha.OutdatedLibrary", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="library_name", - full_name="google.cloud.websecurityscanner.v1alpha.OutdatedLibrary.library_name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="version", - full_name="google.cloud.websecurityscanner.v1alpha.OutdatedLibrary.version", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="learn_more_urls", - full_name="google.cloud.websecurityscanner.v1alpha.OutdatedLibrary.learn_more_urls", - index=2, - number=3, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=110, - serialized_end=191, -) - - -_VIOLATINGRESOURCE = _descriptor.Descriptor( - name="ViolatingResource", - full_name="google.cloud.websecurityscanner.v1alpha.ViolatingResource", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="content_type", - full_name="google.cloud.websecurityscanner.v1alpha.ViolatingResource.content_type", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="resource_url", - full_name="google.cloud.websecurityscanner.v1alpha.ViolatingResource.resource_url", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=193, - serialized_end=256, -) - - -_VULNERABLEPARAMETERS = _descriptor.Descriptor( - name="VulnerableParameters", - full_name="google.cloud.websecurityscanner.v1alpha.VulnerableParameters", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parameter_names", - full_name="google.cloud.websecurityscanner.v1alpha.VulnerableParameters.parameter_names", - index=0, - number=1, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=258, - serialized_end=305, -) - - -_VULNERABLEHEADERS_HEADER = _descriptor.Descriptor( - name="Header", - full_name="google.cloud.websecurityscanner.v1alpha.VulnerableHeaders.Header", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1alpha.VulnerableHeaders.Header.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="value", - full_name="google.cloud.websecurityscanner.v1alpha.VulnerableHeaders.Header.value", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=505, - serialized_end=542, -) - -_VULNERABLEHEADERS = _descriptor.Descriptor( - name="VulnerableHeaders", - full_name="google.cloud.websecurityscanner.v1alpha.VulnerableHeaders", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="headers", - full_name="google.cloud.websecurityscanner.v1alpha.VulnerableHeaders.headers", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="missing_headers", - full_name="google.cloud.websecurityscanner.v1alpha.VulnerableHeaders.missing_headers", - index=1, - number=2, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[_VULNERABLEHEADERS_HEADER], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=308, - serialized_end=542, -) - - -_XSS = _descriptor.Descriptor( - name="Xss", - full_name="google.cloud.websecurityscanner.v1alpha.Xss", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="stack_traces", - full_name="google.cloud.websecurityscanner.v1alpha.Xss.stack_traces", - index=0, - number=1, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="error_message", - full_name="google.cloud.websecurityscanner.v1alpha.Xss.error_message", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=544, - serialized_end=594, -) - -_VULNERABLEHEADERS_HEADER.containing_type = _VULNERABLEHEADERS -_VULNERABLEHEADERS.fields_by_name["headers"].message_type = _VULNERABLEHEADERS_HEADER -_VULNERABLEHEADERS.fields_by_name[ - "missing_headers" -].message_type = _VULNERABLEHEADERS_HEADER -DESCRIPTOR.message_types_by_name["OutdatedLibrary"] = _OUTDATEDLIBRARY -DESCRIPTOR.message_types_by_name["ViolatingResource"] = _VIOLATINGRESOURCE -DESCRIPTOR.message_types_by_name["VulnerableParameters"] = _VULNERABLEPARAMETERS -DESCRIPTOR.message_types_by_name["VulnerableHeaders"] = _VULNERABLEHEADERS -DESCRIPTOR.message_types_by_name["Xss"] = _XSS -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -OutdatedLibrary = _reflection.GeneratedProtocolMessageType( - "OutdatedLibrary", - (_message.Message,), - dict( - DESCRIPTOR=_OUTDATEDLIBRARY, - __module__="google.cloud.websecurityscanner_v1alpha.proto.finding_addon_pb2", - __doc__="""Information reported for an outdated library. - - - Attributes: - library_name: - The name of the outdated library. - version: - The version number. - learn_more_urls: - URLs to learn more information about the vulnerabilities in - the library. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.OutdatedLibrary) - ), -) -_sym_db.RegisterMessage(OutdatedLibrary) - -ViolatingResource = _reflection.GeneratedProtocolMessageType( - "ViolatingResource", - (_message.Message,), - dict( - DESCRIPTOR=_VIOLATINGRESOURCE, - __module__="google.cloud.websecurityscanner_v1alpha.proto.finding_addon_pb2", - __doc__="""Information regarding any resource causing the - vulnerability such as JavaScript sources, image, audio files, etc. - - - Attributes: - content_type: - The MIME type of this resource. - resource_url: - URL of this violating resource. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.ViolatingResource) - ), -) -_sym_db.RegisterMessage(ViolatingResource) - -VulnerableParameters = _reflection.GeneratedProtocolMessageType( - "VulnerableParameters", - (_message.Message,), - dict( - DESCRIPTOR=_VULNERABLEPARAMETERS, - __module__="google.cloud.websecurityscanner_v1alpha.proto.finding_addon_pb2", - __doc__="""Information about vulnerable request parameters. - - - Attributes: - parameter_names: - The vulnerable parameter names. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.VulnerableParameters) - ), -) -_sym_db.RegisterMessage(VulnerableParameters) - -VulnerableHeaders = _reflection.GeneratedProtocolMessageType( - "VulnerableHeaders", - (_message.Message,), - dict( - Header=_reflection.GeneratedProtocolMessageType( - "Header", - (_message.Message,), - dict( - DESCRIPTOR=_VULNERABLEHEADERS_HEADER, - __module__="google.cloud.websecurityscanner_v1alpha.proto.finding_addon_pb2", - __doc__="""Describes a HTTP Header. - - - Attributes: - name: - Header name. - value: - Header value. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.VulnerableHeaders.Header) - ), - ), - DESCRIPTOR=_VULNERABLEHEADERS, - __module__="google.cloud.websecurityscanner_v1alpha.proto.finding_addon_pb2", - __doc__="""Information about vulnerable or missing HTTP Headers. - - - Attributes: - headers: - List of vulnerable headers. - missing_headers: - List of missing headers. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.VulnerableHeaders) - ), -) -_sym_db.RegisterMessage(VulnerableHeaders) -_sym_db.RegisterMessage(VulnerableHeaders.Header) - -Xss = _reflection.GeneratedProtocolMessageType( - "Xss", - (_message.Message,), - dict( - DESCRIPTOR=_XSS, - __module__="google.cloud.websecurityscanner_v1alpha.proto.finding_addon_pb2", - __doc__="""Information reported for an XSS. - - - Attributes: - stack_traces: - Stack traces leading to the point where the XSS occurred. - error_message: - An error message generated by a javascript breakage. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.Xss) - ), -) -_sym_db.RegisterMessage(Xss) - - -DESCRIPTOR._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1alpha/proto/finding_addon_pb2_grpc.py b/google/cloud/websecurityscanner_v1alpha/proto/finding_addon_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1alpha/proto/finding_addon_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1alpha/proto/finding_pb2.py b/google/cloud/websecurityscanner_v1alpha/proto/finding_pb2.py deleted file mode 100644 index a93f61b..0000000 --- a/google/cloud/websecurityscanner_v1alpha/proto/finding_pb2.py +++ /dev/null @@ -1,505 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1alpha/proto/finding.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 -from google.cloud.websecurityscanner_v1alpha.proto import ( - finding_addon_pb2 as google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__addon__pb2, -) - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1alpha/proto/finding.proto", - package="google.cloud.websecurityscanner.v1alpha", - syntax="proto3", - serialized_options=_b( - "\n+com.google.cloud.websecurityscanner.v1alphaB\014FindingProtoP\001ZYgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscanner" - ), - serialized_pb=_b( - '\n;google/cloud/websecurityscanner_v1alpha/proto/finding.proto\x12\'google.cloud.websecurityscanner.v1alpha\x1a\x19google/api/resource.proto\x1a\x41google/cloud/websecurityscanner_v1alpha/proto/finding_addon.proto"\xe9\x08\n\x07\x46inding\x12\x0c\n\x04name\x18\x01 \x01(\t\x12R\n\x0c\x66inding_type\x18\x02 \x01(\x0e\x32<.google.cloud.websecurityscanner.v1alpha.Finding.FindingType\x12\x13\n\x0bhttp_method\x18\x03 \x01(\t\x12\x12\n\nfuzzed_url\x18\x04 \x01(\t\x12\x0c\n\x04\x62ody\x18\x05 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x06 \x01(\t\x12\x18\n\x10reproduction_url\x18\x07 \x01(\t\x12\x11\n\tframe_url\x18\x08 \x01(\t\x12\x11\n\tfinal_url\x18\t \x01(\t\x12\x13\n\x0btracking_id\x18\n \x01(\t\x12R\n\x10outdated_library\x18\x0b \x01(\x0b\x32\x38.google.cloud.websecurityscanner.v1alpha.OutdatedLibrary\x12V\n\x12violating_resource\x18\x0c \x01(\x0b\x32:.google.cloud.websecurityscanner.v1alpha.ViolatingResource\x12V\n\x12vulnerable_headers\x18\x0f \x01(\x0b\x32:.google.cloud.websecurityscanner.v1alpha.VulnerableHeaders\x12\\\n\x15vulnerable_parameters\x18\r \x01(\x0b\x32=.google.cloud.websecurityscanner.v1alpha.VulnerableParameters\x12\x39\n\x03xss\x18\x0e \x01(\x0b\x32,.google.cloud.websecurityscanner.v1alpha.Xss"\xb6\x02\n\x0b\x46indingType\x12\x1c\n\x18\x46INDING_TYPE_UNSPECIFIED\x10\x00\x12\x11\n\rMIXED_CONTENT\x10\x01\x12\x14\n\x10OUTDATED_LIBRARY\x10\x02\x12\x11\n\rROSETTA_FLASH\x10\x05\x12\x10\n\x0cXSS_CALLBACK\x10\x03\x12\r\n\tXSS_ERROR\x10\x04\x12\x17\n\x13\x43LEAR_TEXT_PASSWORD\x10\x06\x12\x18\n\x14INVALID_CONTENT_TYPE\x10\x07\x12\x18\n\x14XSS_ANGULAR_CALLBACK\x10\x08\x12\x12\n\x0eINVALID_HEADER\x10\t\x12#\n\x1fMISSPELLED_SECURITY_HEADER_NAME\x10\n\x12&\n"MISMATCHING_SECURITY_HEADER_VALUES\x10\x0b:\x84\x01\xea\x41\x80\x01\n)websecurityscanner.googleapis.com/Finding\x12Sprojects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}B\x98\x01\n+com.google.cloud.websecurityscanner.v1alphaB\x0c\x46indingProtoP\x01ZYgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscannerb\x06proto3' - ), - dependencies=[ - google_dot_api_dot_resource__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__addon__pb2.DESCRIPTOR, - ], -) - - -_FINDING_FINDINGTYPE = _descriptor.EnumDescriptor( - name="FindingType", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.FindingType", - filename=None, - file=DESCRIPTOR, - values=[ - _descriptor.EnumValueDescriptor( - name="FINDING_TYPE_UNSPECIFIED", - index=0, - number=0, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="MIXED_CONTENT", index=1, number=1, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="OUTDATED_LIBRARY", - index=2, - number=2, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="ROSETTA_FLASH", index=3, number=5, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="XSS_CALLBACK", index=4, number=3, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="XSS_ERROR", index=5, number=4, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="CLEAR_TEXT_PASSWORD", - index=6, - number=6, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="INVALID_CONTENT_TYPE", - index=7, - number=7, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="XSS_ANGULAR_CALLBACK", - index=8, - number=8, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="INVALID_HEADER", index=9, number=9, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="MISSPELLED_SECURITY_HEADER_NAME", - index=10, - number=10, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="MISMATCHING_SECURITY_HEADER_VALUES", - index=11, - number=11, - serialized_options=None, - type=None, - ), - ], - containing_type=None, - serialized_options=None, - serialized_start=883, - serialized_end=1193, -) -_sym_db.RegisterEnumDescriptor(_FINDING_FINDINGTYPE) - - -_FINDING = _descriptor.Descriptor( - name="Finding", - full_name="google.cloud.websecurityscanner.v1alpha.Finding", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="finding_type", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.finding_type", - index=1, - number=2, - type=14, - cpp_type=8, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="http_method", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.http_method", - index=2, - number=3, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="fuzzed_url", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.fuzzed_url", - index=3, - number=4, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="body", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.body", - index=4, - number=5, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="description", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.description", - index=5, - number=6, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="reproduction_url", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.reproduction_url", - index=6, - number=7, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="frame_url", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.frame_url", - index=7, - number=8, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="final_url", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.final_url", - index=8, - number=9, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="tracking_id", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.tracking_id", - index=9, - number=10, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="outdated_library", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.outdated_library", - index=10, - number=11, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="violating_resource", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.violating_resource", - index=11, - number=12, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="vulnerable_headers", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.vulnerable_headers", - index=12, - number=15, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="vulnerable_parameters", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.vulnerable_parameters", - index=13, - number=13, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="xss", - full_name="google.cloud.websecurityscanner.v1alpha.Finding.xss", - index=14, - number=14, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[_FINDING_FINDINGTYPE], - serialized_options=_b( - "\352A\200\001\n)websecurityscanner.googleapis.com/Finding\022Sprojects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}" - ), - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=199, - serialized_end=1328, -) - -_FINDING.fields_by_name["finding_type"].enum_type = _FINDING_FINDINGTYPE -_FINDING.fields_by_name[ - "outdated_library" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__addon__pb2._OUTDATEDLIBRARY -) -_FINDING.fields_by_name[ - "violating_resource" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__addon__pb2._VIOLATINGRESOURCE -) -_FINDING.fields_by_name[ - "vulnerable_headers" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__addon__pb2._VULNERABLEHEADERS -) -_FINDING.fields_by_name[ - "vulnerable_parameters" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__addon__pb2._VULNERABLEPARAMETERS -) -_FINDING.fields_by_name[ - "xss" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__addon__pb2._XSS -) -_FINDING_FINDINGTYPE.containing_type = _FINDING -DESCRIPTOR.message_types_by_name["Finding"] = _FINDING -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -Finding = _reflection.GeneratedProtocolMessageType( - "Finding", - (_message.Message,), - dict( - DESCRIPTOR=_FINDING, - __module__="google.cloud.websecurityscanner_v1alpha.proto.finding_pb2", - __doc__="""A Finding resource represents a vulnerability instance - identified during a ScanRun. - - - Attributes: - name: - The resource name of the Finding. The name follows the format - of 'projects/{projectId}/scanConfigs/{scanConfigId}/scanruns/{ - scanRunId}/findings/{findingId}'. The finding IDs are - generated by the system. - finding_type: - The type of the Finding. - http_method: - The http method of the request that triggered the - vulnerability, in uppercase. - fuzzed_url: - The URL produced by the server-side fuzzer and used in the - request that triggered the vulnerability. - body: - The body of the request that triggered the vulnerability. - description: - The description of the vulnerability. - reproduction_url: - The URL containing human-readable payload that user can - leverage to reproduce the vulnerability. - frame_url: - If the vulnerability was originated from nested IFrame, the - immediate parent IFrame is reported. - final_url: - The URL where the browser lands when the vulnerability is - detected. - tracking_id: - The tracking ID uniquely identifies a vulnerability instance - across multiple ScanRuns. - outdated_library: - An addon containing information about outdated libraries. - violating_resource: - An addon containing detailed information regarding any - resource causing the vulnerability such as JavaScript sources, - image, audio files, etc. - vulnerable_headers: - An addon containing information about vulnerable or missing - HTTP headers. - vulnerable_parameters: - An addon containing information about request parameters which - were found to be vulnerable. - xss: - An addon containing information reported for an XSS, if any. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.Finding) - ), -) -_sym_db.RegisterMessage(Finding) - - -DESCRIPTOR._options = None -_FINDING._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1alpha/proto/finding_pb2_grpc.py b/google/cloud/websecurityscanner_v1alpha/proto/finding_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1alpha/proto/finding_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1alpha/proto/finding_type_stats_pb2.py b/google/cloud/websecurityscanner_v1alpha/proto/finding_type_stats_pb2.py deleted file mode 100644 index d132206..0000000 --- a/google/cloud/websecurityscanner_v1alpha/proto/finding_type_stats_pb2.py +++ /dev/null @@ -1,126 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1alpha/proto/finding_type_stats.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.cloud.websecurityscanner_v1alpha.proto import ( - finding_pb2 as google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__pb2, -) - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1alpha/proto/finding_type_stats.proto", - package="google.cloud.websecurityscanner.v1alpha", - syntax="proto3", - serialized_options=_b( - "\n+com.google.cloud.websecurityscanner.v1alphaB\025FindingTypeStatsProtoP\001ZYgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscanner" - ), - serialized_pb=_b( - "\nFgoogle/cloud/websecurityscanner_v1alpha/proto/finding_type_stats.proto\x12'google.cloud.websecurityscanner.v1alpha\x1a;google/cloud/websecurityscanner_v1alpha/proto/finding.proto\"}\n\x10\x46indingTypeStats\x12R\n\x0c\x66inding_type\x18\x01 \x01(\x0e\x32<.google.cloud.websecurityscanner.v1alpha.Finding.FindingType\x12\x15\n\rfinding_count\x18\x02 \x01(\x05\x42\xa1\x01\n+com.google.cloud.websecurityscanner.v1alphaB\x15\x46indingTypeStatsProtoP\x01ZYgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscannerb\x06proto3" - ), - dependencies=[ - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__pb2.DESCRIPTOR - ], -) - - -_FINDINGTYPESTATS = _descriptor.Descriptor( - name="FindingTypeStats", - full_name="google.cloud.websecurityscanner.v1alpha.FindingTypeStats", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="finding_type", - full_name="google.cloud.websecurityscanner.v1alpha.FindingTypeStats.finding_type", - index=0, - number=1, - type=14, - cpp_type=8, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="finding_count", - full_name="google.cloud.websecurityscanner.v1alpha.FindingTypeStats.finding_count", - index=1, - number=2, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=176, - serialized_end=301, -) - -_FINDINGTYPESTATS.fields_by_name[ - "finding_type" -].enum_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__pb2._FINDING_FINDINGTYPE -) -DESCRIPTOR.message_types_by_name["FindingTypeStats"] = _FINDINGTYPESTATS -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -FindingTypeStats = _reflection.GeneratedProtocolMessageType( - "FindingTypeStats", - (_message.Message,), - dict( - DESCRIPTOR=_FINDINGTYPESTATS, - __module__="google.cloud.websecurityscanner_v1alpha.proto.finding_type_stats_pb2", - __doc__="""A FindingTypeStats resource represents stats regarding a - specific FindingType of Findings under a given ScanRun. - - - Attributes: - finding_type: - The finding type associated with the stats. - finding_count: - The count of findings belonging to this finding type. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.FindingTypeStats) - ), -) -_sym_db.RegisterMessage(FindingTypeStats) - - -DESCRIPTOR._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1alpha/proto/finding_type_stats_pb2_grpc.py b/google/cloud/websecurityscanner_v1alpha/proto/finding_type_stats_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1alpha/proto/finding_type_stats_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1alpha/proto/scan_config_pb2.py b/google/cloud/websecurityscanner_v1alpha/proto/scan_config_pb2.py deleted file mode 100644 index ca936fb..0000000 --- a/google/cloud/websecurityscanner_v1alpha/proto/scan_config_pb2.py +++ /dev/null @@ -1,743 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1alpha/proto/scan_config.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 -from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 -from google.cloud.websecurityscanner_v1alpha.proto import ( - scan_run_pb2 as google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2, -) -from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1alpha/proto/scan_config.proto", - package="google.cloud.websecurityscanner.v1alpha", - syntax="proto3", - serialized_options=_b( - "\n+com.google.cloud.websecurityscanner.v1alphaB\017ScanConfigProtoP\001ZYgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscanner" - ), - serialized_pb=_b( - '\n?google/cloud/websecurityscanner_v1alpha/proto/scan_config.proto\x12\'google.cloud.websecurityscanner.v1alpha\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a/v1alpha/{name=projects/*/scanConfigs/*/scanRuns/*/findings/*}\xda\x41\x04name\x12\xe3\x01\n\x0cListFindings\x12<.google.cloud.websecurityscanner.v1alpha.ListFindingsRequest\x1a=.google.cloud.websecurityscanner.v1alpha.ListFindingsResponse"V\x82\xd3\xe4\x93\x02@\x12>/v1alpha/{parent=projects/*/scanConfigs/*/scanRuns/*}/findings\xda\x41\rparent,filter\x12\xfc\x01\n\x14ListFindingTypeStats\x12\x44.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsRequest\x1a\x45.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsResponse"W\x82\xd3\xe4\x93\x02H\x12\x46/v1alpha/{parent=projects/*/scanConfigs/*/scanRuns/*}/findingTypeStats\xda\x41\x06parent\x1aU\xca\x41!websecurityscanner.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xa3\x01\n+com.google.cloud.websecurityscanner.v1alphaB\x17WebSecurityScannerProtoP\x01ZYgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscannerb\x06proto3' - ), - dependencies=[ - google_dot_api_dot_annotations__pb2.DESCRIPTOR, - google_dot_api_dot_client__pb2.DESCRIPTOR, - google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, - google_dot_api_dot_resource__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_crawled__url__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__type__stats__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2.DESCRIPTOR, - google_dot_protobuf_dot_empty__pb2.DESCRIPTOR, - google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR, - ], -) - - -_CREATESCANCONFIGREQUEST = _descriptor.Descriptor( - name="CreateScanConfigRequest", - full_name="google.cloud.websecurityscanner.v1alpha.CreateScanConfigRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.websecurityscanner.v1alpha.CreateScanConfigRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A-\n+cloudresourcemanager.googleapis.com/Project" - ), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="scan_config", - full_name="google.cloud.websecurityscanner.v1alpha.CreateScanConfigRequest.scan_config", - index=1, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=621, - serialized_end=794, -) - - -_DELETESCANCONFIGREQUEST = _descriptor.Descriptor( - name="DeleteScanConfigRequest", - full_name="google.cloud.websecurityscanner.v1alpha.DeleteScanConfigRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1alpha.DeleteScanConfigRequest.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A.\n,websecurityscanner.googleapis.com/ScanConfig" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=796, - serialized_end=889, -) - - -_GETSCANCONFIGREQUEST = _descriptor.Descriptor( - name="GetScanConfigRequest", - full_name="google.cloud.websecurityscanner.v1alpha.GetScanConfigRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1alpha.GetScanConfigRequest.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A.\n,websecurityscanner.googleapis.com/ScanConfig" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=891, - serialized_end=981, -) - - -_LISTSCANCONFIGSREQUEST = _descriptor.Descriptor( - name="ListScanConfigsRequest", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A-\n+cloudresourcemanager.googleapis.com/Project" - ), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_token", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest.page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_size", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest.page_size", - index=2, - number=3, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=984, - serialized_end=1116, -) - - -_UPDATESCANCONFIGREQUEST = _descriptor.Descriptor( - name="UpdateScanConfigRequest", - full_name="google.cloud.websecurityscanner.v1alpha.UpdateScanConfigRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="scan_config", - full_name="google.cloud.websecurityscanner.v1alpha.UpdateScanConfigRequest.scan_config", - index=0, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="update_mask", - full_name="google.cloud.websecurityscanner.v1alpha.UpdateScanConfigRequest.update_mask", - index=1, - number=3, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1119, - serialized_end=1277, -) - - -_LISTSCANCONFIGSRESPONSE = _descriptor.Descriptor( - name="ListScanConfigsResponse", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanConfigsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="scan_configs", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanConfigsResponse.scan_configs", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="next_page_token", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanConfigsResponse.next_page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1279, - serialized_end=1404, -) - - -_STARTSCANRUNREQUEST = _descriptor.Descriptor( - name="StartScanRunRequest", - full_name="google.cloud.websecurityscanner.v1alpha.StartScanRunRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1alpha.StartScanRunRequest.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A.\n,websecurityscanner.googleapis.com/ScanConfig" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1406, - serialized_end=1495, -) - - -_GETSCANRUNREQUEST = _descriptor.Descriptor( - name="GetScanRunRequest", - full_name="google.cloud.websecurityscanner.v1alpha.GetScanRunRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1alpha.GetScanRunRequest.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A+\n)websecurityscanner.googleapis.com/ScanRun" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1497, - serialized_end=1581, -) - - -_LISTSCANRUNSREQUEST = _descriptor.Descriptor( - name="ListScanRunsRequest", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A.\n,websecurityscanner.googleapis.com/ScanConfig" - ), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_token", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest.page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_size", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest.page_size", - index=2, - number=3, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1584, - serialized_end=1714, -) - - -_LISTSCANRUNSRESPONSE = _descriptor.Descriptor( - name="ListScanRunsResponse", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanRunsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="scan_runs", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanRunsResponse.scan_runs", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="next_page_token", - full_name="google.cloud.websecurityscanner.v1alpha.ListScanRunsResponse.next_page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1716, - serialized_end=1832, -) - - -_STOPSCANRUNREQUEST = _descriptor.Descriptor( - name="StopScanRunRequest", - full_name="google.cloud.websecurityscanner.v1alpha.StopScanRunRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1alpha.StopScanRunRequest.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A+\n)websecurityscanner.googleapis.com/ScanRun" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1834, - serialized_end=1919, -) - - -_LISTCRAWLEDURLSREQUEST = _descriptor.Descriptor( - name="ListCrawledUrlsRequest", - full_name="google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A+\n)websecurityscanner.googleapis.com/ScanRun" - ), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_token", - full_name="google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest.page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_size", - full_name="google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest.page_size", - index=2, - number=3, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1922, - serialized_end=2052, -) - - -_LISTCRAWLEDURLSRESPONSE = _descriptor.Descriptor( - name="ListCrawledUrlsResponse", - full_name="google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="crawled_urls", - full_name="google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsResponse.crawled_urls", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="next_page_token", - full_name="google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsResponse.next_page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2054, - serialized_end=2179, -) - - -_GETFINDINGREQUEST = _descriptor.Descriptor( - name="GetFindingRequest", - full_name="google.cloud.websecurityscanner.v1alpha.GetFindingRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1alpha.GetFindingRequest.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A+\n)websecurityscanner.googleapis.com/Finding" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2181, - serialized_end=2265, -) - - -_LISTFINDINGSREQUEST = _descriptor.Descriptor( - name="ListFindingsRequest", - full_name="google.cloud.websecurityscanner.v1alpha.ListFindingsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.websecurityscanner.v1alpha.ListFindingsRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A+\n)websecurityscanner.googleapis.com/ScanRun" - ), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="filter", - full_name="google.cloud.websecurityscanner.v1alpha.ListFindingsRequest.filter", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_token", - full_name="google.cloud.websecurityscanner.v1alpha.ListFindingsRequest.page_token", - index=2, - number=3, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_size", - full_name="google.cloud.websecurityscanner.v1alpha.ListFindingsRequest.page_size", - index=3, - number=4, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2268, - serialized_end=2416, -) - - -_LISTFINDINGSRESPONSE = _descriptor.Descriptor( - name="ListFindingsResponse", - full_name="google.cloud.websecurityscanner.v1alpha.ListFindingsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="findings", - full_name="google.cloud.websecurityscanner.v1alpha.ListFindingsResponse.findings", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="next_page_token", - full_name="google.cloud.websecurityscanner.v1alpha.ListFindingsResponse.next_page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2418, - serialized_end=2533, -) - - -_LISTFINDINGTYPESTATSREQUEST = _descriptor.Descriptor( - name="ListFindingTypeStatsRequest", - full_name="google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A+\n)websecurityscanner.googleapis.com/ScanRun" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2535, - serialized_end=2631, -) - - -_LISTFINDINGTYPESTATSRESPONSE = _descriptor.Descriptor( - name="ListFindingTypeStatsResponse", - full_name="google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="finding_type_stats", - full_name="google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsResponse.finding_type_stats", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2633, - serialized_end=2750, -) - -_CREATESCANCONFIGREQUEST.fields_by_name[ - "scan_config" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2._SCANCONFIG -) -_UPDATESCANCONFIGREQUEST.fields_by_name[ - "scan_config" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2._SCANCONFIG -) -_UPDATESCANCONFIGREQUEST.fields_by_name[ - "update_mask" -].message_type = google_dot_protobuf_dot_field__mask__pb2._FIELDMASK -_LISTSCANCONFIGSRESPONSE.fields_by_name[ - "scan_configs" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2._SCANCONFIG -) -_LISTSCANRUNSRESPONSE.fields_by_name[ - "scan_runs" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2._SCANRUN -) -_LISTCRAWLEDURLSRESPONSE.fields_by_name[ - "crawled_urls" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_crawled__url__pb2._CRAWLEDURL -) -_LISTFINDINGSRESPONSE.fields_by_name[ - "findings" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__pb2._FINDING -) -_LISTFINDINGTYPESTATSRESPONSE.fields_by_name[ - "finding_type_stats" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__type__stats__pb2._FINDINGTYPESTATS -) -DESCRIPTOR.message_types_by_name["CreateScanConfigRequest"] = _CREATESCANCONFIGREQUEST -DESCRIPTOR.message_types_by_name["DeleteScanConfigRequest"] = _DELETESCANCONFIGREQUEST -DESCRIPTOR.message_types_by_name["GetScanConfigRequest"] = _GETSCANCONFIGREQUEST -DESCRIPTOR.message_types_by_name["ListScanConfigsRequest"] = _LISTSCANCONFIGSREQUEST -DESCRIPTOR.message_types_by_name["UpdateScanConfigRequest"] = _UPDATESCANCONFIGREQUEST -DESCRIPTOR.message_types_by_name["ListScanConfigsResponse"] = _LISTSCANCONFIGSRESPONSE -DESCRIPTOR.message_types_by_name["StartScanRunRequest"] = _STARTSCANRUNREQUEST -DESCRIPTOR.message_types_by_name["GetScanRunRequest"] = _GETSCANRUNREQUEST -DESCRIPTOR.message_types_by_name["ListScanRunsRequest"] = _LISTSCANRUNSREQUEST -DESCRIPTOR.message_types_by_name["ListScanRunsResponse"] = _LISTSCANRUNSRESPONSE -DESCRIPTOR.message_types_by_name["StopScanRunRequest"] = _STOPSCANRUNREQUEST -DESCRIPTOR.message_types_by_name["ListCrawledUrlsRequest"] = _LISTCRAWLEDURLSREQUEST -DESCRIPTOR.message_types_by_name["ListCrawledUrlsResponse"] = _LISTCRAWLEDURLSRESPONSE -DESCRIPTOR.message_types_by_name["GetFindingRequest"] = _GETFINDINGREQUEST -DESCRIPTOR.message_types_by_name["ListFindingsRequest"] = _LISTFINDINGSREQUEST -DESCRIPTOR.message_types_by_name["ListFindingsResponse"] = _LISTFINDINGSRESPONSE -DESCRIPTOR.message_types_by_name[ - "ListFindingTypeStatsRequest" -] = _LISTFINDINGTYPESTATSREQUEST -DESCRIPTOR.message_types_by_name[ - "ListFindingTypeStatsResponse" -] = _LISTFINDINGTYPESTATSRESPONSE -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -CreateScanConfigRequest = _reflection.GeneratedProtocolMessageType( - "CreateScanConfigRequest", - (_message.Message,), - dict( - DESCRIPTOR=_CREATESCANCONFIGREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``CreateScanConfig`` method. - - - Attributes: - parent: - Required. The parent resource name where the scan is created, - which should be a project resource name in the format - 'projects/{projectId}'. - scan_config: - Required. The ScanConfig to be created. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.CreateScanConfigRequest) - ), -) -_sym_db.RegisterMessage(CreateScanConfigRequest) - -DeleteScanConfigRequest = _reflection.GeneratedProtocolMessageType( - "DeleteScanConfigRequest", - (_message.Message,), - dict( - DESCRIPTOR=_DELETESCANCONFIGREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``DeleteScanConfig`` method. - - - Attributes: - name: - Required. The resource name of the ScanConfig to be deleted. - The name follows the format of - 'projects/{projectId}/scanConfigs/{scanConfigId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.DeleteScanConfigRequest) - ), -) -_sym_db.RegisterMessage(DeleteScanConfigRequest) - -GetScanConfigRequest = _reflection.GeneratedProtocolMessageType( - "GetScanConfigRequest", - (_message.Message,), - dict( - DESCRIPTOR=_GETSCANCONFIGREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``GetScanConfig`` method. - - - Attributes: - name: - Required. The resource name of the ScanConfig to be returned. - The name follows the format of - 'projects/{projectId}/scanConfigs/{scanConfigId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.GetScanConfigRequest) - ), -) -_sym_db.RegisterMessage(GetScanConfigRequest) - -ListScanConfigsRequest = _reflection.GeneratedProtocolMessageType( - "ListScanConfigsRequest", - (_message.Message,), - dict( - DESCRIPTOR=_LISTSCANCONFIGSREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``ListScanConfigs`` method. - - - Attributes: - parent: - Required. The parent resource name, which should be a project - resource name in the format 'projects/{projectId}'. - page_token: - A token identifying a page of results to be returned. This - should be a ``next_page_token`` value returned from a previous - List request. If unspecified, the first page of results is - returned. - page_size: - The maximum number of ScanConfigs to return, can be limited by - server. If not specified or not positive, the implementation - will select a reasonable value. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest) - ), -) -_sym_db.RegisterMessage(ListScanConfigsRequest) - -UpdateScanConfigRequest = _reflection.GeneratedProtocolMessageType( - "UpdateScanConfigRequest", - (_message.Message,), - dict( - DESCRIPTOR=_UPDATESCANCONFIGREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``UpdateScanConfigRequest`` method. - - - Attributes: - scan_config: - Required. The ScanConfig to be updated. The name field must be - set to identify the resource to be updated. The values of - fields not covered by the mask will be ignored. - update_mask: - Required. The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol- - buffers/docs/reference/google.protobuf#fieldmask - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.UpdateScanConfigRequest) - ), -) -_sym_db.RegisterMessage(UpdateScanConfigRequest) - -ListScanConfigsResponse = _reflection.GeneratedProtocolMessageType( - "ListScanConfigsResponse", - (_message.Message,), - dict( - DESCRIPTOR=_LISTSCANCONFIGSRESPONSE, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Response for the ``ListScanConfigs`` method. - - - Attributes: - scan_configs: - The list of ScanConfigs returned. - next_page_token: - Token to retrieve the next page of results, or empty if there - are no more results in the list. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.ListScanConfigsResponse) - ), -) -_sym_db.RegisterMessage(ListScanConfigsResponse) - -StartScanRunRequest = _reflection.GeneratedProtocolMessageType( - "StartScanRunRequest", - (_message.Message,), - dict( - DESCRIPTOR=_STARTSCANRUNREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``StartScanRun`` method. - - - Attributes: - name: - Required. The resource name of the ScanConfig to be used. The - name follows the format of - 'projects/{projectId}/scanConfigs/{scanConfigId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.StartScanRunRequest) - ), -) -_sym_db.RegisterMessage(StartScanRunRequest) - -GetScanRunRequest = _reflection.GeneratedProtocolMessageType( - "GetScanRunRequest", - (_message.Message,), - dict( - DESCRIPTOR=_GETSCANRUNREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``GetScanRun`` method. - - - Attributes: - name: - Required. The resource name of the ScanRun to be returned. The - name follows the format of 'projects/{projectId}/scanConfigs/{ - scanConfigId}/scanRuns/{scanRunId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.GetScanRunRequest) - ), -) -_sym_db.RegisterMessage(GetScanRunRequest) - -ListScanRunsRequest = _reflection.GeneratedProtocolMessageType( - "ListScanRunsRequest", - (_message.Message,), - dict( - DESCRIPTOR=_LISTSCANRUNSREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``ListScanRuns`` method. - - - Attributes: - parent: - Required. The parent resource name, which should be a scan - resource name in the format - 'projects/{projectId}/scanConfigs/{scanConfigId}'. - page_token: - A token identifying a page of results to be returned. This - should be a ``next_page_token`` value returned from a previous - List request. If unspecified, the first page of results is - returned. - page_size: - The maximum number of ScanRuns to return, can be limited by - server. If not specified or not positive, the implementation - will select a reasonable value. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest) - ), -) -_sym_db.RegisterMessage(ListScanRunsRequest) - -ListScanRunsResponse = _reflection.GeneratedProtocolMessageType( - "ListScanRunsResponse", - (_message.Message,), - dict( - DESCRIPTOR=_LISTSCANRUNSRESPONSE, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Response for the ``ListScanRuns`` method. - - - Attributes: - scan_runs: - The list of ScanRuns returned. - next_page_token: - Token to retrieve the next page of results, or empty if there - are no more results in the list. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.ListScanRunsResponse) - ), -) -_sym_db.RegisterMessage(ListScanRunsResponse) - -StopScanRunRequest = _reflection.GeneratedProtocolMessageType( - "StopScanRunRequest", - (_message.Message,), - dict( - DESCRIPTOR=_STOPSCANRUNREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``StopScanRun`` method. - - - Attributes: - name: - Required. The resource name of the ScanRun to be stopped. The - name follows the format of 'projects/{projectId}/scanConfigs/{ - scanConfigId}/scanRuns/{scanRunId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.StopScanRunRequest) - ), -) -_sym_db.RegisterMessage(StopScanRunRequest) - -ListCrawledUrlsRequest = _reflection.GeneratedProtocolMessageType( - "ListCrawledUrlsRequest", - (_message.Message,), - dict( - DESCRIPTOR=_LISTCRAWLEDURLSREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``ListCrawledUrls`` method. - - - Attributes: - parent: - Required. The parent resource name, which should be a scan run - resource name in the format 'projects/{projectId}/scanConfigs/ - {scanConfigId}/scanRuns/{scanRunId}'. - page_token: - A token identifying a page of results to be returned. This - should be a ``next_page_token`` value returned from a previous - List request. If unspecified, the first page of results is - returned. - page_size: - The maximum number of CrawledUrls to return, can be limited by - server. If not specified or not positive, the implementation - will select a reasonable value. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest) - ), -) -_sym_db.RegisterMessage(ListCrawledUrlsRequest) - -ListCrawledUrlsResponse = _reflection.GeneratedProtocolMessageType( - "ListCrawledUrlsResponse", - (_message.Message,), - dict( - DESCRIPTOR=_LISTCRAWLEDURLSRESPONSE, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Response for the ``ListCrawledUrls`` method. - - - Attributes: - crawled_urls: - The list of CrawledUrls returned. - next_page_token: - Token to retrieve the next page of results, or empty if there - are no more results in the list. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsResponse) - ), -) -_sym_db.RegisterMessage(ListCrawledUrlsResponse) - -GetFindingRequest = _reflection.GeneratedProtocolMessageType( - "GetFindingRequest", - (_message.Message,), - dict( - DESCRIPTOR=_GETFINDINGREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``GetFinding`` method. - - - Attributes: - name: - Required. The resource name of the Finding to be returned. The - name follows the format of 'projects/{projectId}/scanConfigs/{ - scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.GetFindingRequest) - ), -) -_sym_db.RegisterMessage(GetFindingRequest) - -ListFindingsRequest = _reflection.GeneratedProtocolMessageType( - "ListFindingsRequest", - (_message.Message,), - dict( - DESCRIPTOR=_LISTFINDINGSREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``ListFindings`` method. - - - Attributes: - parent: - Required. The parent resource name, which should be a scan run - resource name in the format 'projects/{projectId}/scanConfigs/ - {scanConfigId}/scanRuns/{scanRunId}'. - filter: - Required. The filter expression. The expression must be in the - format: . Supported field: 'finding\_type'. Supported - operator: '='. - page_token: - A token identifying a page of results to be returned. This - should be a ``next_page_token`` value returned from a previous - List request. If unspecified, the first page of results is - returned. - page_size: - The maximum number of Findings to return, can be limited by - server. If not specified or not positive, the implementation - will select a reasonable value. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.ListFindingsRequest) - ), -) -_sym_db.RegisterMessage(ListFindingsRequest) - -ListFindingsResponse = _reflection.GeneratedProtocolMessageType( - "ListFindingsResponse", - (_message.Message,), - dict( - DESCRIPTOR=_LISTFINDINGSRESPONSE, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Response for the ``ListFindings`` method. - - - Attributes: - findings: - The list of Findings returned. - next_page_token: - Token to retrieve the next page of results, or empty if there - are no more results in the list. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.ListFindingsResponse) - ), -) -_sym_db.RegisterMessage(ListFindingsResponse) - -ListFindingTypeStatsRequest = _reflection.GeneratedProtocolMessageType( - "ListFindingTypeStatsRequest", - (_message.Message,), - dict( - DESCRIPTOR=_LISTFINDINGTYPESTATSREQUEST, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Request for the ``ListFindingTypeStats`` method. - - - Attributes: - parent: - Required. The parent resource name, which should be a scan run - resource name in the format 'projects/{projectId}/scanConfigs/ - {scanConfigId}/scanRuns/{scanRunId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsRequest) - ), -) -_sym_db.RegisterMessage(ListFindingTypeStatsRequest) - -ListFindingTypeStatsResponse = _reflection.GeneratedProtocolMessageType( - "ListFindingTypeStatsResponse", - (_message.Message,), - dict( - DESCRIPTOR=_LISTFINDINGTYPESTATSRESPONSE, - __module__="google.cloud.websecurityscanner_v1alpha.proto.web_security_scanner_pb2", - __doc__="""Response for the ``ListFindingTypeStats`` method. - - - Attributes: - finding_type_stats: - The list of FindingTypeStats returned. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsResponse) - ), -) -_sym_db.RegisterMessage(ListFindingTypeStatsResponse) - - -DESCRIPTOR._options = None -_CREATESCANCONFIGREQUEST.fields_by_name["parent"]._options = None -_CREATESCANCONFIGREQUEST.fields_by_name["scan_config"]._options = None -_DELETESCANCONFIGREQUEST.fields_by_name["name"]._options = None -_GETSCANCONFIGREQUEST.fields_by_name["name"]._options = None -_LISTSCANCONFIGSREQUEST.fields_by_name["parent"]._options = None -_UPDATESCANCONFIGREQUEST.fields_by_name["scan_config"]._options = None -_UPDATESCANCONFIGREQUEST.fields_by_name["update_mask"]._options = None -_STARTSCANRUNREQUEST.fields_by_name["name"]._options = None -_GETSCANRUNREQUEST.fields_by_name["name"]._options = None -_LISTSCANRUNSREQUEST.fields_by_name["parent"]._options = None -_STOPSCANRUNREQUEST.fields_by_name["name"]._options = None -_LISTCRAWLEDURLSREQUEST.fields_by_name["parent"]._options = None -_GETFINDINGREQUEST.fields_by_name["name"]._options = None -_LISTFINDINGSREQUEST.fields_by_name["parent"]._options = None -_LISTFINDINGSREQUEST.fields_by_name["filter"]._options = None -_LISTFINDINGTYPESTATSREQUEST.fields_by_name["parent"]._options = None - -_WEBSECURITYSCANNER = _descriptor.ServiceDescriptor( - name="WebSecurityScanner", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", - file=DESCRIPTOR, - index=0, - serialized_options=_b( - "\312A!websecurityscanner.googleapis.com\322A.https://www.googleapis.com/auth/cloud-platform" - ), - serialized_start=2753, - serialized_end=5621, - methods=[ - _descriptor.MethodDescriptor( - name="CreateScanConfig", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.CreateScanConfig", - index=0, - containing_service=None, - input_type=_CREATESCANCONFIGREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2._SCANCONFIG, - serialized_options=_b( - '\202\323\344\223\0027"(/v1alpha/{parent=projects/*}/scanConfigs:\013scan_config\332A\022parent,scan_config' - ), - ), - _descriptor.MethodDescriptor( - name="DeleteScanConfig", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.DeleteScanConfig", - index=1, - containing_service=None, - input_type=_DELETESCANCONFIGREQUEST, - output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, - serialized_options=_b( - "\202\323\344\223\002**(/v1alpha/{name=projects/*/scanConfigs/*}\332A\004name" - ), - ), - _descriptor.MethodDescriptor( - name="GetScanConfig", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.GetScanConfig", - index=2, - containing_service=None, - input_type=_GETSCANCONFIGREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2._SCANCONFIG, - serialized_options=_b( - "\202\323\344\223\002*\022(/v1alpha/{name=projects/*/scanConfigs/*}\332A\004name" - ), - ), - _descriptor.MethodDescriptor( - name="ListScanConfigs", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.ListScanConfigs", - index=3, - containing_service=None, - input_type=_LISTSCANCONFIGSREQUEST, - output_type=_LISTSCANCONFIGSRESPONSE, - serialized_options=_b( - "\202\323\344\223\002*\022(/v1alpha/{parent=projects/*}/scanConfigs\332A\006parent" - ), - ), - _descriptor.MethodDescriptor( - name="UpdateScanConfig", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.UpdateScanConfig", - index=4, - containing_service=None, - input_type=_UPDATESCANCONFIGREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2._SCANCONFIG, - serialized_options=_b( - "\202\323\344\223\002C24/v1alpha/{scan_config.name=projects/*/scanConfigs/*}:\013scan_config\332A\027scan_config,update_mask" - ), - ), - _descriptor.MethodDescriptor( - name="StartScanRun", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.StartScanRun", - index=5, - containing_service=None, - input_type=_STARTSCANRUNREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2._SCANRUN, - serialized_options=_b( - '\202\323\344\223\0023"./v1alpha/{name=projects/*/scanConfigs/*}:start:\001*\332A\004name' - ), - ), - _descriptor.MethodDescriptor( - name="GetScanRun", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.GetScanRun", - index=6, - containing_service=None, - input_type=_GETSCANRUNREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2._SCANRUN, - serialized_options=_b( - "\202\323\344\223\0025\0223/v1alpha/{name=projects/*/scanConfigs/*/scanRuns/*}\332A\004name" - ), - ), - _descriptor.MethodDescriptor( - name="ListScanRuns", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.ListScanRuns", - index=7, - containing_service=None, - input_type=_LISTSCANRUNSREQUEST, - output_type=_LISTSCANRUNSRESPONSE, - serialized_options=_b( - "\202\323\344\223\0025\0223/v1alpha/{parent=projects/*/scanConfigs/*}/scanRuns\332A\006parent" - ), - ), - _descriptor.MethodDescriptor( - name="StopScanRun", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.StopScanRun", - index=8, - containing_service=None, - input_type=_STOPSCANRUNREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2._SCANRUN, - serialized_options=_b( - '\202\323\344\223\002="8/v1alpha/{name=projects/*/scanConfigs/*/scanRuns/*}:stop:\001*\332A\004name' - ), - ), - _descriptor.MethodDescriptor( - name="ListCrawledUrls", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.ListCrawledUrls", - index=9, - containing_service=None, - input_type=_LISTCRAWLEDURLSREQUEST, - output_type=_LISTCRAWLEDURLSRESPONSE, - serialized_options=_b( - "\202\323\344\223\002C\022A/v1alpha/{parent=projects/*/scanConfigs/*/scanRuns/*}/crawledUrls\332A\006parent" - ), - ), - _descriptor.MethodDescriptor( - name="GetFinding", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.GetFinding", - index=10, - containing_service=None, - input_type=_GETFINDINGREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__pb2._FINDING, - serialized_options=_b( - "\202\323\344\223\002@\022>/v1alpha/{name=projects/*/scanConfigs/*/scanRuns/*/findings/*}\332A\004name" - ), - ), - _descriptor.MethodDescriptor( - name="ListFindings", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.ListFindings", - index=11, - containing_service=None, - input_type=_LISTFINDINGSREQUEST, - output_type=_LISTFINDINGSRESPONSE, - serialized_options=_b( - "\202\323\344\223\002@\022>/v1alpha/{parent=projects/*/scanConfigs/*/scanRuns/*}/findings\332A\rparent,filter" - ), - ), - _descriptor.MethodDescriptor( - name="ListFindingTypeStats", - full_name="google.cloud.websecurityscanner.v1alpha.WebSecurityScanner.ListFindingTypeStats", - index=12, - containing_service=None, - input_type=_LISTFINDINGTYPESTATSREQUEST, - output_type=_LISTFINDINGTYPESTATSRESPONSE, - serialized_options=_b( - "\202\323\344\223\002H\022F/v1alpha/{parent=projects/*/scanConfigs/*/scanRuns/*}/findingTypeStats\332A\006parent" - ), - ), - ], -) -_sym_db.RegisterServiceDescriptor(_WEBSECURITYSCANNER) - -DESCRIPTOR.services_by_name["WebSecurityScanner"] = _WEBSECURITYSCANNER - -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1alpha/proto/web_security_scanner_pb2_grpc.py b/google/cloud/websecurityscanner_v1alpha/proto/web_security_scanner_pb2_grpc.py deleted file mode 100644 index c500690..0000000 --- a/google/cloud/websecurityscanner_v1alpha/proto/web_security_scanner_pb2_grpc.py +++ /dev/null @@ -1,269 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc - -from google.cloud.websecurityscanner_v1alpha.proto import ( - finding_pb2 as google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__pb2, -) -from google.cloud.websecurityscanner_v1alpha.proto import ( - scan_config_pb2 as google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2, -) -from google.cloud.websecurityscanner_v1alpha.proto import ( - scan_run_pb2 as google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2, -) -from google.cloud.websecurityscanner_v1alpha.proto import ( - web_security_scanner_pb2 as google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2, -) -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 - - -class WebSecurityScannerStub(object): - """Cloud Web Security Scanner Service identifies security vulnerabilities in web - applications hosted on Google Cloud Platform. It crawls your application, and - attempts to exercise as many user inputs and event handlers as possible. - """ - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.CreateScanConfig = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/CreateScanConfig", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.CreateScanConfigRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2.ScanConfig.FromString, - ) - self.DeleteScanConfig = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/DeleteScanConfig", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.DeleteScanConfigRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.GetScanConfig = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanConfig", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.GetScanConfigRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2.ScanConfig.FromString, - ) - self.ListScanConfigs = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanConfigs", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListScanConfigsRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListScanConfigsResponse.FromString, - ) - self.UpdateScanConfig = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/UpdateScanConfig", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.UpdateScanConfigRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2.ScanConfig.FromString, - ) - self.StartScanRun = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StartScanRun", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.StartScanRunRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2.ScanRun.FromString, - ) - self.GetScanRun = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanRun", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.GetScanRunRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2.ScanRun.FromString, - ) - self.ListScanRuns = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanRuns", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListScanRunsRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListScanRunsResponse.FromString, - ) - self.StopScanRun = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StopScanRun", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.StopScanRunRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2.ScanRun.FromString, - ) - self.ListCrawledUrls = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListCrawledUrls", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListCrawledUrlsRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListCrawledUrlsResponse.FromString, - ) - self.GetFinding = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetFinding", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.GetFindingRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__pb2.Finding.FromString, - ) - self.ListFindings = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindings", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListFindingsRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListFindingsResponse.FromString, - ) - self.ListFindingTypeStats = channel.unary_unary( - "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindingTypeStats", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListFindingTypeStatsRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListFindingTypeStatsResponse.FromString, - ) - - -class WebSecurityScannerServicer(object): - """Cloud Web Security Scanner Service identifies security vulnerabilities in web - applications hosted on Google Cloud Platform. It crawls your application, and - attempts to exercise as many user inputs and event handlers as possible. - """ - - def CreateScanConfig(self, request, context): - """Creates a new ScanConfig. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def DeleteScanConfig(self, request, context): - """Deletes an existing ScanConfig and its child resources. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def GetScanConfig(self, request, context): - """Gets a ScanConfig. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def ListScanConfigs(self, request, context): - """Lists ScanConfigs under a given project. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def UpdateScanConfig(self, request, context): - """Updates a ScanConfig. This method support partial update of a ScanConfig. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def StartScanRun(self, request, context): - """Start a ScanRun according to the given ScanConfig. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def GetScanRun(self, request, context): - """Gets a ScanRun. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def ListScanRuns(self, request, context): - """Lists ScanRuns under a given ScanConfig, in descending order of ScanRun - stop time. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def StopScanRun(self, request, context): - """Stops a ScanRun. The stopped ScanRun is returned. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def ListCrawledUrls(self, request, context): - """List CrawledUrls under a given ScanRun. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def GetFinding(self, request, context): - """Gets a Finding. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def ListFindings(self, request, context): - """List Findings under a given ScanRun. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def ListFindingTypeStats(self, request, context): - """List all FindingTypeStats under a given ScanRun. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - -def add_WebSecurityScannerServicer_to_server(servicer, server): - rpc_method_handlers = { - "CreateScanConfig": grpc.unary_unary_rpc_method_handler( - servicer.CreateScanConfig, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.CreateScanConfigRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2.ScanConfig.SerializeToString, - ), - "DeleteScanConfig": grpc.unary_unary_rpc_method_handler( - servicer.DeleteScanConfig, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.DeleteScanConfigRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - "GetScanConfig": grpc.unary_unary_rpc_method_handler( - servicer.GetScanConfig, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.GetScanConfigRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2.ScanConfig.SerializeToString, - ), - "ListScanConfigs": grpc.unary_unary_rpc_method_handler( - servicer.ListScanConfigs, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListScanConfigsRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListScanConfigsResponse.SerializeToString, - ), - "UpdateScanConfig": grpc.unary_unary_rpc_method_handler( - servicer.UpdateScanConfig, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.UpdateScanConfigRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__config__pb2.ScanConfig.SerializeToString, - ), - "StartScanRun": grpc.unary_unary_rpc_method_handler( - servicer.StartScanRun, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.StartScanRunRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2.ScanRun.SerializeToString, - ), - "GetScanRun": grpc.unary_unary_rpc_method_handler( - servicer.GetScanRun, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.GetScanRunRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2.ScanRun.SerializeToString, - ), - "ListScanRuns": grpc.unary_unary_rpc_method_handler( - servicer.ListScanRuns, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListScanRunsRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListScanRunsResponse.SerializeToString, - ), - "StopScanRun": grpc.unary_unary_rpc_method_handler( - servicer.StopScanRun, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.StopScanRunRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_scan__run__pb2.ScanRun.SerializeToString, - ), - "ListCrawledUrls": grpc.unary_unary_rpc_method_handler( - servicer.ListCrawledUrls, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListCrawledUrlsRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListCrawledUrlsResponse.SerializeToString, - ), - "GetFinding": grpc.unary_unary_rpc_method_handler( - servicer.GetFinding, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.GetFindingRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_finding__pb2.Finding.SerializeToString, - ), - "ListFindings": grpc.unary_unary_rpc_method_handler( - servicer.ListFindings, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListFindingsRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListFindingsResponse.SerializeToString, - ), - "ListFindingTypeStats": grpc.unary_unary_rpc_method_handler( - servicer.ListFindingTypeStats, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListFindingTypeStatsRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1alpha_dot_proto_dot_web__security__scanner__pb2.ListFindingTypeStatsResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", - rpc_method_handlers, - ) - server.add_generic_rpc_handlers((generic_handler,)) diff --git a/google/cloud/websecurityscanner_v1alpha/py.typed b/google/cloud/websecurityscanner_v1alpha/py.typed new file mode 100644 index 0000000..8cfb5d2 --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-websecurityscanner package uses inline types. diff --git a/google/__init__.py b/google/cloud/websecurityscanner_v1alpha/services/__init__.py similarity index 66% rename from google/__init__.py rename to google/cloud/websecurityscanner_v1alpha/services/__init__.py index dd3a9f4..42ffdf2 100644 --- a/google/__init__.py +++ b/google/cloud/websecurityscanner_v1alpha/services/__init__.py @@ -1,22 +1,16 @@ -# Copyright 2018 Google LLC +# -*- coding: utf-8 -*- + +# Copyright 2020 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 # -# https://www.apache.org/licenses/LICENSE-2.0 +# 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. - -try: - import pkg_resources - - pkg_resources.declare_namespace(__name__) -except ImportError: - import pkgutil - - __path__ = pkgutil.extend_path(__path__, __name__) +# diff --git a/google/cloud/websecurityscanner.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/__init__.py similarity index 62% rename from google/cloud/websecurityscanner.py rename to google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/__init__.py index c6c74f7..d841cb5 100644 --- a/google/cloud/websecurityscanner.py +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/__init__.py @@ -1,25 +1,24 @@ # -*- coding: utf-8 -*- -# + # Copyright 2020 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 # -# https://www.apache.org/licenses/LICENSE-2.0 +# 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 .client import WebSecurityScannerClient +from .async_client import WebSecurityScannerAsyncClient -from __future__ import absolute_import - -from google.cloud.websecurityscanner_v1beta import WebSecurityScannerClient -from google.cloud.websecurityscanner_v1beta import enums -from google.cloud.websecurityscanner_v1beta import types - - -__all__ = ("enums", "types", "WebSecurityScannerClient") +__all__ = ( + "WebSecurityScannerClient", + "WebSecurityScannerAsyncClient", +) diff --git a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py new file mode 100644 index 0000000..c3b628e --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py @@ -0,0 +1,1204 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 collections import OrderedDict +import functools +import re +from typing import Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.websecurityscanner_v1alpha.services.web_security_scanner import pagers +from google.cloud.websecurityscanner_v1alpha.types import crawled_url +from google.cloud.websecurityscanner_v1alpha.types import finding +from google.cloud.websecurityscanner_v1alpha.types import finding_addon +from google.cloud.websecurityscanner_v1alpha.types import finding_type_stats +from google.cloud.websecurityscanner_v1alpha.types import scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_run +from google.cloud.websecurityscanner_v1alpha.types import web_security_scanner +from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import timestamp_pb2 as timestamp # type: ignore + +from .transports.base import WebSecurityScannerTransport +from .transports.grpc_asyncio import WebSecurityScannerGrpcAsyncIOTransport +from .client import WebSecurityScannerClient + + +class WebSecurityScannerAsyncClient: + """Cloud Web Security Scanner Service identifies security + vulnerabilities in web applications hosted on Google Cloud + Platform. It crawls your application, and attempts to exercise + as many user inputs and event handlers as possible. + """ + + _client: WebSecurityScannerClient + + DEFAULT_ENDPOINT = WebSecurityScannerClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = WebSecurityScannerClient.DEFAULT_MTLS_ENDPOINT + + scan_run_path = staticmethod(WebSecurityScannerClient.scan_run_path) + + scan_config_path = staticmethod(WebSecurityScannerClient.scan_config_path) + + from_service_account_file = WebSecurityScannerClient.from_service_account_file + from_service_account_json = from_service_account_file + + get_transport_class = functools.partial( + type(WebSecurityScannerClient).get_transport_class, + type(WebSecurityScannerClient), + ) + + def __init__( + self, + *, + credentials: credentials.Credentials = None, + transport: Union[str, WebSecurityScannerTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + ) -> None: + """Instantiate the web security scanner client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.WebSecurityScannerTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint, this is the default value for + the environment variable) and "auto" (auto switch to the default + mTLS endpoint if client SSL credentials is present). However, + the ``api_endpoint`` property takes precedence if provided. + (2) The ``client_cert_source`` property is used to provide client + SSL credentials for mutual TLS transport. If not provided, the + default SSL credentials will be used if present. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + """ + + self._client = WebSecurityScannerClient( + credentials=credentials, transport=transport, client_options=client_options, + ) + + async def create_scan_config( + self, + request: web_security_scanner.CreateScanConfigRequest = None, + *, + parent: str = None, + scan_config: gcw_scan_config.ScanConfig = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gcw_scan_config.ScanConfig: + r"""Creates a new ScanConfig. + + Args: + request (:class:`~.web_security_scanner.CreateScanConfigRequest`): + The request object. Request for the `CreateScanConfig` + method. + parent (:class:`str`): + Required. The parent resource name + where the scan is created, which should + be a project resource name in the format + 'projects/{projectId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + scan_config (:class:`~.gcw_scan_config.ScanConfig`): + Required. The ScanConfig to be + created. + This corresponds to the ``scan_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.gcw_scan_config.ScanConfig: + A ScanConfig resource contains the + configurations to launch a scan. next + id: 12 + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent, scan_config]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.CreateScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if scan_config is not None: + request.scan_config = scan_config + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_scan_config, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def delete_scan_config( + self, + request: web_security_scanner.DeleteScanConfigRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an existing ScanConfig and its child + resources. + + Args: + request (:class:`~.web_security_scanner.DeleteScanConfigRequest`): + The request object. Request for the `DeleteScanConfig` + method. + name (:class:`str`): + Required. The resource name of the + ScanConfig to be deleted. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.DeleteScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_scan_config, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + await rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + async def get_scan_config( + self, + request: web_security_scanner.GetScanConfigRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_config.ScanConfig: + r"""Gets a ScanConfig. + + Args: + request (:class:`~.web_security_scanner.GetScanConfigRequest`): + The request object. Request for the `GetScanConfig` + method. + name (:class:`str`): + Required. The resource name of the + ScanConfig to be returned. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_config.ScanConfig: + A ScanConfig resource contains the + configurations to launch a scan. next + id: 12 + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.GetScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_scan_config, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_scan_configs( + self, + request: web_security_scanner.ListScanConfigsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListScanConfigsAsyncPager: + r"""Lists ScanConfigs under a given project. + + Args: + request (:class:`~.web_security_scanner.ListScanConfigsRequest`): + The request object. Request for the `ListScanConfigs` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a project resource name + in the format 'projects/{projectId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListScanConfigsAsyncPager: + Response for the ``ListScanConfigs`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListScanConfigsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_scan_configs, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListScanConfigsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_scan_config( + self, + request: web_security_scanner.UpdateScanConfigRequest = None, + *, + scan_config: gcw_scan_config.ScanConfig = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gcw_scan_config.ScanConfig: + r"""Updates a ScanConfig. This method support partial + update of a ScanConfig. + + Args: + request (:class:`~.web_security_scanner.UpdateScanConfigRequest`): + The request object. Request for the + `UpdateScanConfigRequest` method. + scan_config (:class:`~.gcw_scan_config.ScanConfig`): + Required. The ScanConfig to be + updated. The name field must be set to + identify the resource to be updated. The + values of fields not covered by the mask + will be ignored. + This corresponds to the ``scan_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`~.field_mask.FieldMask`): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.gcw_scan_config.ScanConfig: + A ScanConfig resource contains the + configurations to launch a scan. next + id: 12 + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([scan_config, update_mask]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.UpdateScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if scan_config is not None: + request.scan_config = scan_config + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_scan_config, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("scan_config.name", request.scan_config.name),) + ), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def start_scan_run( + self, + request: web_security_scanner.StartScanRunRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_run.ScanRun: + r"""Start a ScanRun according to the given ScanConfig. + + Args: + request (:class:`~.web_security_scanner.StartScanRunRequest`): + The request object. Request for the `StartScanRun` + method. + name (:class:`str`): + Required. The resource name of the + ScanConfig to be used. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_run.ScanRun: + A ScanRun is a output-only resource + representing an actual run of the scan. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.StartScanRunRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.start_scan_run, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def get_scan_run( + self, + request: web_security_scanner.GetScanRunRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_run.ScanRun: + r"""Gets a ScanRun. + + Args: + request (:class:`~.web_security_scanner.GetScanRunRequest`): + The request object. Request for the `GetScanRun` method. + name (:class:`str`): + Required. The resource name of the + ScanRun to be returned. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_run.ScanRun: + A ScanRun is a output-only resource + representing an actual run of the scan. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.GetScanRunRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_scan_run, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_scan_runs( + self, + request: web_security_scanner.ListScanRunsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListScanRunsAsyncPager: + r"""Lists ScanRuns under a given ScanConfig, in + descending order of ScanRun stop time. + + Args: + request (:class:`~.web_security_scanner.ListScanRunsRequest`): + The request object. Request for the `ListScanRuns` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan resource name in + the format + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListScanRunsAsyncPager: + Response for the ``ListScanRuns`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListScanRunsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_scan_runs, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListScanRunsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def stop_scan_run( + self, + request: web_security_scanner.StopScanRunRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_run.ScanRun: + r"""Stops a ScanRun. The stopped ScanRun is returned. + + Args: + request (:class:`~.web_security_scanner.StopScanRunRequest`): + The request object. Request for the `StopScanRun` + method. + name (:class:`str`): + Required. The resource name of the + ScanRun to be stopped. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_run.ScanRun: + A ScanRun is a output-only resource + representing an actual run of the scan. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.StopScanRunRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.stop_scan_run, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_crawled_urls( + self, + request: web_security_scanner.ListCrawledUrlsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCrawledUrlsAsyncPager: + r"""List CrawledUrls under a given ScanRun. + + Args: + request (:class:`~.web_security_scanner.ListCrawledUrlsRequest`): + The request object. Request for the `ListCrawledUrls` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan run resource name + in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListCrawledUrlsAsyncPager: + Response for the ``ListCrawledUrls`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListCrawledUrlsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_crawled_urls, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCrawledUrlsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_finding( + self, + request: web_security_scanner.GetFindingRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> finding.Finding: + r"""Gets a Finding. + + Args: + request (:class:`~.web_security_scanner.GetFindingRequest`): + The request object. Request for the `GetFinding` method. + name (:class:`str`): + Required. The resource name of the + Finding to be returned. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.finding.Finding: + A Finding resource represents a + vulnerability instance identified during + a ScanRun. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.GetFindingRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_finding, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_findings( + self, + request: web_security_scanner.ListFindingsRequest = None, + *, + parent: str = None, + filter: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFindingsAsyncPager: + r"""List Findings under a given ScanRun. + + Args: + request (:class:`~.web_security_scanner.ListFindingsRequest`): + The request object. Request for the `ListFindings` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan run resource name + in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + filter (:class:`str`): + Required. The filter expression. The expression must be + in the format: . Supported field: 'finding_type'. + Supported operator: '='. + This corresponds to the ``filter`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListFindingsAsyncPager: + Response for the ``ListFindings`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent, filter]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListFindingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_findings, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListFindingsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_finding_type_stats( + self, + request: web_security_scanner.ListFindingTypeStatsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> web_security_scanner.ListFindingTypeStatsResponse: + r"""List all FindingTypeStats under a given ScanRun. + + Args: + request (:class:`~.web_security_scanner.ListFindingTypeStatsRequest`): + The request object. Request for the + `ListFindingTypeStats` method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan run resource name + in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.web_security_scanner.ListFindingTypeStatsResponse: + Response for the ``ListFindingTypeStats`` method. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListFindingTypeStatsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_finding_type_stats, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + +try: + _client_info = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-websecurityscanner", + ).version, + ) +except pkg_resources.DistributionNotFound: + _client_info = gapic_v1.client_info.ClientInfo() + + +__all__ = ("WebSecurityScannerAsyncClient",) diff --git a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py new file mode 100644 index 0000000..7674177 --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py @@ -0,0 +1,1358 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 collections import OrderedDict +import os +import re +from typing import Callable, Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.websecurityscanner_v1alpha.services.web_security_scanner import pagers +from google.cloud.websecurityscanner_v1alpha.types import crawled_url +from google.cloud.websecurityscanner_v1alpha.types import finding +from google.cloud.websecurityscanner_v1alpha.types import finding_addon +from google.cloud.websecurityscanner_v1alpha.types import finding_type_stats +from google.cloud.websecurityscanner_v1alpha.types import scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_run +from google.cloud.websecurityscanner_v1alpha.types import web_security_scanner +from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import timestamp_pb2 as timestamp # type: ignore + +from .transports.base import WebSecurityScannerTransport +from .transports.grpc import WebSecurityScannerGrpcTransport +from .transports.grpc_asyncio import WebSecurityScannerGrpcAsyncIOTransport + + +class WebSecurityScannerClientMeta(type): + """Metaclass for the WebSecurityScanner client. + + This provides class-level methods for building and retrieving + support objects (e.g. transport) without polluting the client instance + objects. + """ + + _transport_registry = ( + OrderedDict() + ) # type: Dict[str, Type[WebSecurityScannerTransport]] + _transport_registry["grpc"] = WebSecurityScannerGrpcTransport + _transport_registry["grpc_asyncio"] = WebSecurityScannerGrpcAsyncIOTransport + + def get_transport_class( + cls, label: str = None, + ) -> Type[WebSecurityScannerTransport]: + """Return an appropriate transport class. + + Args: + label: The name of the desired transport. If none is + provided, then the first transport in the registry is used. + + Returns: + The transport class to use. + """ + # If a specific transport is requested, return that one. + if label: + return cls._transport_registry[label] + + # No transport is requested; return the default (that is, the first one + # in the dictionary). + return next(iter(cls._transport_registry.values())) + + +class WebSecurityScannerClient(metaclass=WebSecurityScannerClientMeta): + """Cloud Web Security Scanner Service identifies security + vulnerabilities in web applications hosted on Google Cloud + Platform. It crawls your application, and attempts to exercise + as many user inputs and event handlers as possible. + """ + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Convert api endpoint to mTLS endpoint. + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to + "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. + Args: + api_endpoint (Optional[str]): the api endpoint to convert. + Returns: + str: converted mTLS api endpoint. + """ + if not api_endpoint: + return api_endpoint + + mtls_endpoint_re = re.compile( + r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" + ) + + m = mtls_endpoint_re.match(api_endpoint) + name, mtls, sandbox, googledomain = m.groups() + if mtls or not googledomain: + return api_endpoint + + if sandbox: + return api_endpoint.replace( + "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" + ) + + return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") + + DEFAULT_ENDPOINT = "websecurityscanner.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + {@api.name}: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file(filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @staticmethod + def scan_config_path(project: str, scan_config: str,) -> str: + """Return a fully-qualified scan_config string.""" + return "projects/{project}/scanConfigs/{scan_config}".format( + project=project, scan_config=scan_config, + ) + + @staticmethod + def parse_scan_config_path(path: str) -> Dict[str, str]: + """Parse a scan_config path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/scanConfigs/(?P.+?)$", path + ) + return m.groupdict() if m else {} + + @staticmethod + def scan_run_path(project: str, scan_config: str, scan_run: str,) -> str: + """Return a fully-qualified scan_run string.""" + return "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}".format( + project=project, scan_config=scan_config, scan_run=scan_run, + ) + + @staticmethod + def parse_scan_run_path(path: str) -> Dict[str, str]: + """Parse a scan_run path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/scanConfigs/(?P.+?)/scanRuns/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + def __init__( + self, + *, + credentials: credentials.Credentials = None, + transport: Union[str, WebSecurityScannerTransport] = None, + client_options: ClientOptions = None, + ) -> None: + """Instantiate the web security scanner client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.WebSecurityScannerTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint, this is the default value for + the environment variable) and "auto" (auto switch to the default + mTLS endpoint if client SSL credentials is present). However, + the ``api_endpoint`` property takes precedence if provided. + (2) The ``client_cert_source`` property is used to provide client + SSL credentials for mutual TLS transport. If not provided, the + default SSL credentials will be used if present. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = ClientOptions.from_dict(client_options) + if client_options is None: + client_options = ClientOptions.ClientOptions() + + if client_options.api_endpoint is None: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS", "never") + if use_mtls_env == "never": + client_options.api_endpoint = self.DEFAULT_ENDPOINT + elif use_mtls_env == "always": + client_options.api_endpoint = self.DEFAULT_MTLS_ENDPOINT + elif use_mtls_env == "auto": + has_client_cert_source = ( + client_options.client_cert_source is not None + or mtls.has_default_client_cert_source() + ) + client_options.api_endpoint = ( + self.DEFAULT_MTLS_ENDPOINT + if has_client_cert_source + else self.DEFAULT_ENDPOINT + ) + else: + raise MutualTLSChannelError( + "Unsupported GOOGLE_API_USE_MTLS value. Accepted values: never, auto, always" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, WebSecurityScannerTransport): + # transport is a WebSecurityScannerTransport instance. + if credentials or client_options.credentials_file: + raise ValueError( + "When providing a transport instance, " + "provide its credentials directly." + ) + if client_options.scopes: + raise ValueError( + "When providing a transport instance, " + "provide its scopes directly." + ) + self._transport = transport + else: + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=client_options.api_endpoint, + scopes=client_options.scopes, + api_mtls_endpoint=client_options.api_endpoint, + client_cert_source=client_options.client_cert_source, + quota_project_id=client_options.quota_project_id, + ) + + def create_scan_config( + self, + request: web_security_scanner.CreateScanConfigRequest = None, + *, + parent: str = None, + scan_config: gcw_scan_config.ScanConfig = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gcw_scan_config.ScanConfig: + r"""Creates a new ScanConfig. + + Args: + request (:class:`~.web_security_scanner.CreateScanConfigRequest`): + The request object. Request for the `CreateScanConfig` + method. + parent (:class:`str`): + Required. The parent resource name + where the scan is created, which should + be a project resource name in the format + 'projects/{projectId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + scan_config (:class:`~.gcw_scan_config.ScanConfig`): + Required. The ScanConfig to be + created. + This corresponds to the ``scan_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.gcw_scan_config.ScanConfig: + A ScanConfig resource contains the + configurations to launch a scan. next + id: 12 + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent, scan_config]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.CreateScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if scan_config is not None: + request.scan_config = scan_config + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.create_scan_config, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def delete_scan_config( + self, + request: web_security_scanner.DeleteScanConfigRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an existing ScanConfig and its child + resources. + + Args: + request (:class:`~.web_security_scanner.DeleteScanConfigRequest`): + The request object. Request for the `DeleteScanConfig` + method. + name (:class:`str`): + Required. The resource name of the + ScanConfig to be deleted. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.DeleteScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.delete_scan_config, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + def get_scan_config( + self, + request: web_security_scanner.GetScanConfigRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_config.ScanConfig: + r"""Gets a ScanConfig. + + Args: + request (:class:`~.web_security_scanner.GetScanConfigRequest`): + The request object. Request for the `GetScanConfig` + method. + name (:class:`str`): + Required. The resource name of the + ScanConfig to be returned. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_config.ScanConfig: + A ScanConfig resource contains the + configurations to launch a scan. next + id: 12 + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.GetScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_scan_config, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_scan_configs( + self, + request: web_security_scanner.ListScanConfigsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListScanConfigsPager: + r"""Lists ScanConfigs under a given project. + + Args: + request (:class:`~.web_security_scanner.ListScanConfigsRequest`): + The request object. Request for the `ListScanConfigs` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a project resource name + in the format 'projects/{projectId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListScanConfigsPager: + Response for the ``ListScanConfigs`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListScanConfigsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_scan_configs, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListScanConfigsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def update_scan_config( + self, + request: web_security_scanner.UpdateScanConfigRequest = None, + *, + scan_config: gcw_scan_config.ScanConfig = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gcw_scan_config.ScanConfig: + r"""Updates a ScanConfig. This method support partial + update of a ScanConfig. + + Args: + request (:class:`~.web_security_scanner.UpdateScanConfigRequest`): + The request object. Request for the + `UpdateScanConfigRequest` method. + scan_config (:class:`~.gcw_scan_config.ScanConfig`): + Required. The ScanConfig to be + updated. The name field must be set to + identify the resource to be updated. The + values of fields not covered by the mask + will be ignored. + This corresponds to the ``scan_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`~.field_mask.FieldMask`): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.gcw_scan_config.ScanConfig: + A ScanConfig resource contains the + configurations to launch a scan. next + id: 12 + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([scan_config, update_mask]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.UpdateScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if scan_config is not None: + request.scan_config = scan_config + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.update_scan_config, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("scan_config.name", request.scan_config.name),) + ), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def start_scan_run( + self, + request: web_security_scanner.StartScanRunRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_run.ScanRun: + r"""Start a ScanRun according to the given ScanConfig. + + Args: + request (:class:`~.web_security_scanner.StartScanRunRequest`): + The request object. Request for the `StartScanRun` + method. + name (:class:`str`): + Required. The resource name of the + ScanConfig to be used. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_run.ScanRun: + A ScanRun is a output-only resource + representing an actual run of the scan. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.StartScanRunRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.start_scan_run, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def get_scan_run( + self, + request: web_security_scanner.GetScanRunRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_run.ScanRun: + r"""Gets a ScanRun. + + Args: + request (:class:`~.web_security_scanner.GetScanRunRequest`): + The request object. Request for the `GetScanRun` method. + name (:class:`str`): + Required. The resource name of the + ScanRun to be returned. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_run.ScanRun: + A ScanRun is a output-only resource + representing an actual run of the scan. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.GetScanRunRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_scan_run, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_scan_runs( + self, + request: web_security_scanner.ListScanRunsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListScanRunsPager: + r"""Lists ScanRuns under a given ScanConfig, in + descending order of ScanRun stop time. + + Args: + request (:class:`~.web_security_scanner.ListScanRunsRequest`): + The request object. Request for the `ListScanRuns` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan resource name in + the format + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListScanRunsPager: + Response for the ``ListScanRuns`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListScanRunsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_scan_runs, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListScanRunsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def stop_scan_run( + self, + request: web_security_scanner.StopScanRunRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_run.ScanRun: + r"""Stops a ScanRun. The stopped ScanRun is returned. + + Args: + request (:class:`~.web_security_scanner.StopScanRunRequest`): + The request object. Request for the `StopScanRun` + method. + name (:class:`str`): + Required. The resource name of the + ScanRun to be stopped. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_run.ScanRun: + A ScanRun is a output-only resource + representing an actual run of the scan. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.StopScanRunRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.stop_scan_run, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_crawled_urls( + self, + request: web_security_scanner.ListCrawledUrlsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCrawledUrlsPager: + r"""List CrawledUrls under a given ScanRun. + + Args: + request (:class:`~.web_security_scanner.ListCrawledUrlsRequest`): + The request object. Request for the `ListCrawledUrls` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan run resource name + in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListCrawledUrlsPager: + Response for the ``ListCrawledUrls`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListCrawledUrlsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_crawled_urls, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListCrawledUrlsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def get_finding( + self, + request: web_security_scanner.GetFindingRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> finding.Finding: + r"""Gets a Finding. + + Args: + request (:class:`~.web_security_scanner.GetFindingRequest`): + The request object. Request for the `GetFinding` method. + name (:class:`str`): + Required. The resource name of the + Finding to be returned. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.finding.Finding: + A Finding resource represents a + vulnerability instance identified during + a ScanRun. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.GetFindingRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_finding, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_findings( + self, + request: web_security_scanner.ListFindingsRequest = None, + *, + parent: str = None, + filter: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFindingsPager: + r"""List Findings under a given ScanRun. + + Args: + request (:class:`~.web_security_scanner.ListFindingsRequest`): + The request object. Request for the `ListFindings` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan run resource name + in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + filter (:class:`str`): + Required. The filter expression. The expression must be + in the format: . Supported field: 'finding_type'. + Supported operator: '='. + This corresponds to the ``filter`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListFindingsPager: + Response for the ``ListFindings`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent, filter]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListFindingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_findings, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListFindingsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def list_finding_type_stats( + self, + request: web_security_scanner.ListFindingTypeStatsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> web_security_scanner.ListFindingTypeStatsResponse: + r"""List all FindingTypeStats under a given ScanRun. + + Args: + request (:class:`~.web_security_scanner.ListFindingTypeStatsRequest`): + The request object. Request for the + `ListFindingTypeStats` method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan run resource name + in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.web_security_scanner.ListFindingTypeStatsResponse: + Response for the ``ListFindingTypeStats`` method. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListFindingTypeStatsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_finding_type_stats, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + +try: + _client_info = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-websecurityscanner", + ).version, + ) +except pkg_resources.DistributionNotFound: + _client_info = gapic_v1.client_info.ClientInfo() + + +__all__ = ("WebSecurityScannerClient",) diff --git a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/pagers.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/pagers.py new file mode 100644 index 0000000..ab4cd2b --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/pagers.py @@ -0,0 +1,540 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple + +from google.cloud.websecurityscanner_v1alpha.types import crawled_url +from google.cloud.websecurityscanner_v1alpha.types import finding +from google.cloud.websecurityscanner_v1alpha.types import scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_run +from google.cloud.websecurityscanner_v1alpha.types import web_security_scanner + + +class ListScanConfigsPager: + """A pager for iterating through ``list_scan_configs`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListScanConfigsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``scan_configs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListScanConfigs`` requests and continue to iterate + through the ``scan_configs`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListScanConfigsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., web_security_scanner.ListScanConfigsResponse], + request: web_security_scanner.ListScanConfigsRequest, + response: web_security_scanner.ListScanConfigsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListScanConfigsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListScanConfigsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListScanConfigsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[web_security_scanner.ListScanConfigsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[scan_config.ScanConfig]: + for page in self.pages: + yield from page.scan_configs + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListScanConfigsAsyncPager: + """A pager for iterating through ``list_scan_configs`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListScanConfigsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``scan_configs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListScanConfigs`` requests and continue to iterate + through the ``scan_configs`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListScanConfigsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[web_security_scanner.ListScanConfigsResponse]], + request: web_security_scanner.ListScanConfigsRequest, + response: web_security_scanner.ListScanConfigsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListScanConfigsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListScanConfigsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListScanConfigsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterable[web_security_scanner.ListScanConfigsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[scan_config.ScanConfig]: + async def async_generator(): + async for page in self.pages: + for response in page.scan_configs: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListScanRunsPager: + """A pager for iterating through ``list_scan_runs`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListScanRunsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``scan_runs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListScanRuns`` requests and continue to iterate + through the ``scan_runs`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListScanRunsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., web_security_scanner.ListScanRunsResponse], + request: web_security_scanner.ListScanRunsRequest, + response: web_security_scanner.ListScanRunsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListScanRunsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListScanRunsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListScanRunsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[web_security_scanner.ListScanRunsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[scan_run.ScanRun]: + for page in self.pages: + yield from page.scan_runs + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListScanRunsAsyncPager: + """A pager for iterating through ``list_scan_runs`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListScanRunsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``scan_runs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListScanRuns`` requests and continue to iterate + through the ``scan_runs`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListScanRunsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[web_security_scanner.ListScanRunsResponse]], + request: web_security_scanner.ListScanRunsRequest, + response: web_security_scanner.ListScanRunsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListScanRunsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListScanRunsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListScanRunsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[web_security_scanner.ListScanRunsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[scan_run.ScanRun]: + async def async_generator(): + async for page in self.pages: + for response in page.scan_runs: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListCrawledUrlsPager: + """A pager for iterating through ``list_crawled_urls`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListCrawledUrlsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``crawled_urls`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCrawledUrls`` requests and continue to iterate + through the ``crawled_urls`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListCrawledUrlsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., web_security_scanner.ListCrawledUrlsResponse], + request: web_security_scanner.ListCrawledUrlsRequest, + response: web_security_scanner.ListCrawledUrlsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListCrawledUrlsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListCrawledUrlsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListCrawledUrlsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[web_security_scanner.ListCrawledUrlsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[crawled_url.CrawledUrl]: + for page in self.pages: + yield from page.crawled_urls + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListCrawledUrlsAsyncPager: + """A pager for iterating through ``list_crawled_urls`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListCrawledUrlsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``crawled_urls`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCrawledUrls`` requests and continue to iterate + through the ``crawled_urls`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListCrawledUrlsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[web_security_scanner.ListCrawledUrlsResponse]], + request: web_security_scanner.ListCrawledUrlsRequest, + response: web_security_scanner.ListCrawledUrlsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListCrawledUrlsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListCrawledUrlsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListCrawledUrlsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterable[web_security_scanner.ListCrawledUrlsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[crawled_url.CrawledUrl]: + async def async_generator(): + async for page in self.pages: + for response in page.crawled_urls: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListFindingsPager: + """A pager for iterating through ``list_findings`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListFindingsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``findings`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListFindings`` requests and continue to iterate + through the ``findings`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListFindingsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., web_security_scanner.ListFindingsResponse], + request: web_security_scanner.ListFindingsRequest, + response: web_security_scanner.ListFindingsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListFindingsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListFindingsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListFindingsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[web_security_scanner.ListFindingsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[finding.Finding]: + for page in self.pages: + yield from page.findings + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListFindingsAsyncPager: + """A pager for iterating through ``list_findings`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListFindingsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``findings`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListFindings`` requests and continue to iterate + through the ``findings`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListFindingsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[web_security_scanner.ListFindingsResponse]], + request: web_security_scanner.ListFindingsRequest, + response: web_security_scanner.ListFindingsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListFindingsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListFindingsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListFindingsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[web_security_scanner.ListFindingsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[finding.Finding]: + async def async_generator(): + async for page in self.pages: + for response in page.findings: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/__init__.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/__init__.py new file mode 100644 index 0000000..788b2b3 --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/__init__.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 collections import OrderedDict +from typing import Dict, Type + +from .base import WebSecurityScannerTransport +from .grpc import WebSecurityScannerGrpcTransport +from .grpc_asyncio import WebSecurityScannerGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = ( + OrderedDict() +) # type: Dict[str, Type[WebSecurityScannerTransport]] +_transport_registry["grpc"] = WebSecurityScannerGrpcTransport +_transport_registry["grpc_asyncio"] = WebSecurityScannerGrpcAsyncIOTransport + + +__all__ = ( + "WebSecurityScannerTransport", + "WebSecurityScannerGrpcTransport", + "WebSecurityScannerGrpcAsyncIOTransport", +) diff --git a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/base.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/base.py new file mode 100644 index 0000000..b7c0460 --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/base.py @@ -0,0 +1,226 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 abc +import typing + +from google import auth +from google.api_core import exceptions # type: ignore +from google.auth import credentials # type: ignore + +from google.cloud.websecurityscanner_v1alpha.types import finding +from google.cloud.websecurityscanner_v1alpha.types import scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_run +from google.cloud.websecurityscanner_v1alpha.types import web_security_scanner +from google.protobuf import empty_pb2 as empty # type: ignore + + +class WebSecurityScannerTransport(abc.ABC): + """Abstract transport class for WebSecurityScanner.""" + + AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + + def __init__( + self, + *, + host: str = "websecurityscanner.googleapis.com", + credentials: credentials.Credentials = None, + credentials_file: typing.Optional[str] = None, + scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, + quota_project_id: typing.Optional[str] = None, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scope (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise exceptions.DuplicateCredentialArgs( + "'credentials_file' and 'credentials' are mutually exclusive" + ) + + if credentials_file is not None: + credentials, _ = auth.load_credentials_from_file( + credentials_file, scopes=scopes, quota_project_id=quota_project_id + ) + + elif credentials is None: + credentials, _ = auth.default( + scopes=scopes, quota_project_id=quota_project_id + ) + + # Save the credentials. + self._credentials = credentials + + @property + def create_scan_config( + self, + ) -> typing.Callable[ + [web_security_scanner.CreateScanConfigRequest], + typing.Union[ + gcw_scan_config.ScanConfig, typing.Awaitable[gcw_scan_config.ScanConfig] + ], + ]: + raise NotImplementedError() + + @property + def delete_scan_config( + self, + ) -> typing.Callable[ + [web_security_scanner.DeleteScanConfigRequest], + typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + ]: + raise NotImplementedError() + + @property + def get_scan_config( + self, + ) -> typing.Callable[ + [web_security_scanner.GetScanConfigRequest], + typing.Union[scan_config.ScanConfig, typing.Awaitable[scan_config.ScanConfig]], + ]: + raise NotImplementedError() + + @property + def list_scan_configs( + self, + ) -> typing.Callable[ + [web_security_scanner.ListScanConfigsRequest], + typing.Union[ + web_security_scanner.ListScanConfigsResponse, + typing.Awaitable[web_security_scanner.ListScanConfigsResponse], + ], + ]: + raise NotImplementedError() + + @property + def update_scan_config( + self, + ) -> typing.Callable[ + [web_security_scanner.UpdateScanConfigRequest], + typing.Union[ + gcw_scan_config.ScanConfig, typing.Awaitable[gcw_scan_config.ScanConfig] + ], + ]: + raise NotImplementedError() + + @property + def start_scan_run( + self, + ) -> typing.Callable[ + [web_security_scanner.StartScanRunRequest], + typing.Union[scan_run.ScanRun, typing.Awaitable[scan_run.ScanRun]], + ]: + raise NotImplementedError() + + @property + def get_scan_run( + self, + ) -> typing.Callable[ + [web_security_scanner.GetScanRunRequest], + typing.Union[scan_run.ScanRun, typing.Awaitable[scan_run.ScanRun]], + ]: + raise NotImplementedError() + + @property + def list_scan_runs( + self, + ) -> typing.Callable[ + [web_security_scanner.ListScanRunsRequest], + typing.Union[ + web_security_scanner.ListScanRunsResponse, + typing.Awaitable[web_security_scanner.ListScanRunsResponse], + ], + ]: + raise NotImplementedError() + + @property + def stop_scan_run( + self, + ) -> typing.Callable[ + [web_security_scanner.StopScanRunRequest], + typing.Union[scan_run.ScanRun, typing.Awaitable[scan_run.ScanRun]], + ]: + raise NotImplementedError() + + @property + def list_crawled_urls( + self, + ) -> typing.Callable[ + [web_security_scanner.ListCrawledUrlsRequest], + typing.Union[ + web_security_scanner.ListCrawledUrlsResponse, + typing.Awaitable[web_security_scanner.ListCrawledUrlsResponse], + ], + ]: + raise NotImplementedError() + + @property + def get_finding( + self, + ) -> typing.Callable[ + [web_security_scanner.GetFindingRequest], + typing.Union[finding.Finding, typing.Awaitable[finding.Finding]], + ]: + raise NotImplementedError() + + @property + def list_findings( + self, + ) -> typing.Callable[ + [web_security_scanner.ListFindingsRequest], + typing.Union[ + web_security_scanner.ListFindingsResponse, + typing.Awaitable[web_security_scanner.ListFindingsResponse], + ], + ]: + raise NotImplementedError() + + @property + def list_finding_type_stats( + self, + ) -> typing.Callable[ + [web_security_scanner.ListFindingTypeStatsRequest], + typing.Union[ + web_security_scanner.ListFindingTypeStatsResponse, + typing.Awaitable[web_security_scanner.ListFindingTypeStatsResponse], + ], + ]: + raise NotImplementedError() + + +__all__ = ("WebSecurityScannerTransport",) diff --git a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py new file mode 100644 index 0000000..9b9d989 --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py @@ -0,0 +1,575 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 typing import Callable, Dict, Optional, Sequence, Tuple + +from google.api_core import grpc_helpers # type: ignore +from google import auth # type: ignore +from google.auth import credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + + +import grpc # type: ignore + +from google.cloud.websecurityscanner_v1alpha.types import finding +from google.cloud.websecurityscanner_v1alpha.types import scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_run +from google.cloud.websecurityscanner_v1alpha.types import web_security_scanner +from google.protobuf import empty_pb2 as empty # type: ignore + +from .base import WebSecurityScannerTransport + + +class WebSecurityScannerGrpcTransport(WebSecurityScannerTransport): + """gRPC backend transport for WebSecurityScanner. + + Cloud Web Security Scanner Service identifies security + vulnerabilities in web applications hosted on Google Cloud + Platform. It crawls your application, and attempts to exercise + as many user inputs and event handlers as possible. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _stubs: Dict[str, Callable] + + def __init__( + self, + *, + host: str = "websecurityscanner.googleapis.com", + credentials: credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): The mutual TLS endpoint. If + provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): A + callback to provide client SSL certificate bytes and private key + bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` + is None. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + if channel: + # Sanity check: Ensure that channel and credentials are not both + # provided. + credentials = False + + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + elif api_mtls_endpoint: + host = ( + api_mtls_endpoint + if ":" in api_mtls_endpoint + else api_mtls_endpoint + ":443" + ) + + if credentials is None: + credentials, _ = auth.default( + scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id + ) + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + ssl_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + ssl_credentials = SslCredentials().ssl_credentials + + # create a new channel. The provided one is ignored. + self._grpc_channel = type(self).create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + ssl_credentials=ssl_credentials, + scopes=scopes or self.AUTH_SCOPES, + quota_project_id=quota_project_id, + ) + + # Run the base constructor. + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes or self.AUTH_SCOPES, + quota_project_id=quota_project_id, + ) + + self._stubs = {} # type: Dict[str, Callable] + + @classmethod + def create_channel( + cls, + host: str = "websecurityscanner.googleapis.com", + credentials: credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs + ) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + address (Optionsl[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + scopes = scopes or cls.AUTH_SCOPES + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Sanity check: Only create a new channel if we do not already + # have one. + if not hasattr(self, "_grpc_channel"): + self._grpc_channel = self.create_channel( + self._host, credentials=self._credentials, + ) + + # Return the channel from cache. + return self._grpc_channel + + @property + def create_scan_config( + self, + ) -> Callable[ + [web_security_scanner.CreateScanConfigRequest], gcw_scan_config.ScanConfig + ]: + r"""Return a callable for the create scan config method over gRPC. + + Creates a new ScanConfig. + + Returns: + Callable[[~.CreateScanConfigRequest], + ~.ScanConfig]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_scan_config" not in self._stubs: + self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/CreateScanConfig", + request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, + response_deserializer=gcw_scan_config.ScanConfig.deserialize, + ) + return self._stubs["create_scan_config"] + + @property + def delete_scan_config( + self, + ) -> Callable[[web_security_scanner.DeleteScanConfigRequest], empty.Empty]: + r"""Return a callable for the delete scan config method over gRPC. + + Deletes an existing ScanConfig and its child + resources. + + Returns: + Callable[[~.DeleteScanConfigRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_scan_config" not in self._stubs: + self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/DeleteScanConfig", + request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs["delete_scan_config"] + + @property + def get_scan_config( + self, + ) -> Callable[[web_security_scanner.GetScanConfigRequest], scan_config.ScanConfig]: + r"""Return a callable for the get scan config method over gRPC. + + Gets a ScanConfig. + + Returns: + Callable[[~.GetScanConfigRequest], + ~.ScanConfig]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_scan_config" not in self._stubs: + self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanConfig", + request_serializer=web_security_scanner.GetScanConfigRequest.serialize, + response_deserializer=scan_config.ScanConfig.deserialize, + ) + return self._stubs["get_scan_config"] + + @property + def list_scan_configs( + self, + ) -> Callable[ + [web_security_scanner.ListScanConfigsRequest], + web_security_scanner.ListScanConfigsResponse, + ]: + r"""Return a callable for the list scan configs method over gRPC. + + Lists ScanConfigs under a given project. + + Returns: + Callable[[~.ListScanConfigsRequest], + ~.ListScanConfigsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_scan_configs" not in self._stubs: + self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanConfigs", + request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, + response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, + ) + return self._stubs["list_scan_configs"] + + @property + def update_scan_config( + self, + ) -> Callable[ + [web_security_scanner.UpdateScanConfigRequest], gcw_scan_config.ScanConfig + ]: + r"""Return a callable for the update scan config method over gRPC. + + Updates a ScanConfig. This method support partial + update of a ScanConfig. + + Returns: + Callable[[~.UpdateScanConfigRequest], + ~.ScanConfig]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_scan_config" not in self._stubs: + self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/UpdateScanConfig", + request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, + response_deserializer=gcw_scan_config.ScanConfig.deserialize, + ) + return self._stubs["update_scan_config"] + + @property + def start_scan_run( + self, + ) -> Callable[[web_security_scanner.StartScanRunRequest], scan_run.ScanRun]: + r"""Return a callable for the start scan run method over gRPC. + + Start a ScanRun according to the given ScanConfig. + + Returns: + Callable[[~.StartScanRunRequest], + ~.ScanRun]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "start_scan_run" not in self._stubs: + self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StartScanRun", + request_serializer=web_security_scanner.StartScanRunRequest.serialize, + response_deserializer=scan_run.ScanRun.deserialize, + ) + return self._stubs["start_scan_run"] + + @property + def get_scan_run( + self, + ) -> Callable[[web_security_scanner.GetScanRunRequest], scan_run.ScanRun]: + r"""Return a callable for the get scan run method over gRPC. + + Gets a ScanRun. + + Returns: + Callable[[~.GetScanRunRequest], + ~.ScanRun]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_scan_run" not in self._stubs: + self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanRun", + request_serializer=web_security_scanner.GetScanRunRequest.serialize, + response_deserializer=scan_run.ScanRun.deserialize, + ) + return self._stubs["get_scan_run"] + + @property + def list_scan_runs( + self, + ) -> Callable[ + [web_security_scanner.ListScanRunsRequest], + web_security_scanner.ListScanRunsResponse, + ]: + r"""Return a callable for the list scan runs method over gRPC. + + Lists ScanRuns under a given ScanConfig, in + descending order of ScanRun stop time. + + Returns: + Callable[[~.ListScanRunsRequest], + ~.ListScanRunsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_scan_runs" not in self._stubs: + self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanRuns", + request_serializer=web_security_scanner.ListScanRunsRequest.serialize, + response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, + ) + return self._stubs["list_scan_runs"] + + @property + def stop_scan_run( + self, + ) -> Callable[[web_security_scanner.StopScanRunRequest], scan_run.ScanRun]: + r"""Return a callable for the stop scan run method over gRPC. + + Stops a ScanRun. The stopped ScanRun is returned. + + Returns: + Callable[[~.StopScanRunRequest], + ~.ScanRun]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "stop_scan_run" not in self._stubs: + self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StopScanRun", + request_serializer=web_security_scanner.StopScanRunRequest.serialize, + response_deserializer=scan_run.ScanRun.deserialize, + ) + return self._stubs["stop_scan_run"] + + @property + def list_crawled_urls( + self, + ) -> Callable[ + [web_security_scanner.ListCrawledUrlsRequest], + web_security_scanner.ListCrawledUrlsResponse, + ]: + r"""Return a callable for the list crawled urls method over gRPC. + + List CrawledUrls under a given ScanRun. + + Returns: + Callable[[~.ListCrawledUrlsRequest], + ~.ListCrawledUrlsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_crawled_urls" not in self._stubs: + self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListCrawledUrls", + request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, + response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, + ) + return self._stubs["list_crawled_urls"] + + @property + def get_finding( + self, + ) -> Callable[[web_security_scanner.GetFindingRequest], finding.Finding]: + r"""Return a callable for the get finding method over gRPC. + + Gets a Finding. + + Returns: + Callable[[~.GetFindingRequest], + ~.Finding]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_finding" not in self._stubs: + self._stubs["get_finding"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetFinding", + request_serializer=web_security_scanner.GetFindingRequest.serialize, + response_deserializer=finding.Finding.deserialize, + ) + return self._stubs["get_finding"] + + @property + def list_findings( + self, + ) -> Callable[ + [web_security_scanner.ListFindingsRequest], + web_security_scanner.ListFindingsResponse, + ]: + r"""Return a callable for the list findings method over gRPC. + + List Findings under a given ScanRun. + + Returns: + Callable[[~.ListFindingsRequest], + ~.ListFindingsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_findings" not in self._stubs: + self._stubs["list_findings"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindings", + request_serializer=web_security_scanner.ListFindingsRequest.serialize, + response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, + ) + return self._stubs["list_findings"] + + @property + def list_finding_type_stats( + self, + ) -> Callable[ + [web_security_scanner.ListFindingTypeStatsRequest], + web_security_scanner.ListFindingTypeStatsResponse, + ]: + r"""Return a callable for the list finding type stats method over gRPC. + + List all FindingTypeStats under a given ScanRun. + + Returns: + Callable[[~.ListFindingTypeStatsRequest], + ~.ListFindingTypeStatsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_finding_type_stats" not in self._stubs: + self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindingTypeStats", + request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, + response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, + ) + return self._stubs["list_finding_type_stats"] + + +__all__ = ("WebSecurityScannerGrpcTransport",) diff --git a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py new file mode 100644 index 0000000..d08441d --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py @@ -0,0 +1,580 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple + +from google.api_core import grpc_helpers_async # type: ignore +from google.auth import credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.websecurityscanner_v1alpha.types import finding +from google.cloud.websecurityscanner_v1alpha.types import scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_run +from google.cloud.websecurityscanner_v1alpha.types import web_security_scanner +from google.protobuf import empty_pb2 as empty # type: ignore + +from .base import WebSecurityScannerTransport +from .grpc import WebSecurityScannerGrpcTransport + + +class WebSecurityScannerGrpcAsyncIOTransport(WebSecurityScannerTransport): + """gRPC AsyncIO backend transport for WebSecurityScanner. + + Cloud Web Security Scanner Service identifies security + vulnerabilities in web applications hosted on Google Cloud + Platform. It crawls your application, and attempts to exercise + as many user inputs and event handlers as possible. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _grpc_channel: aio.Channel + _stubs: Dict[str, Callable] = {} + + @classmethod + def create_channel( + cls, + host: str = "websecurityscanner.googleapis.com", + credentials: credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + address (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + scopes = scopes or cls.AUTH_SCOPES + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + **kwargs, + ) + + def __init__( + self, + *, + host: str = "websecurityscanner.googleapis.com", + credentials: credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): The mutual TLS endpoint. If + provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): A + callback to provide client SSL certificate bytes and private key + bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` + is None. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + if channel: + # Sanity check: Ensure that channel and credentials are not both + # provided. + credentials = False + + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + elif api_mtls_endpoint: + host = ( + api_mtls_endpoint + if ":" in api_mtls_endpoint + else api_mtls_endpoint + ":443" + ) + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + ssl_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + ssl_credentials = SslCredentials().ssl_credentials + + # create a new channel. The provided one is ignored. + self._grpc_channel = type(self).create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + ssl_credentials=ssl_credentials, + scopes=scopes or self.AUTH_SCOPES, + quota_project_id=quota_project_id, + ) + + # Run the base constructor. + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes or self.AUTH_SCOPES, + quota_project_id=quota_project_id, + ) + + self._stubs = {} + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Sanity check: Only create a new channel if we do not already + # have one. + if not hasattr(self, "_grpc_channel"): + self._grpc_channel = self.create_channel( + self._host, credentials=self._credentials, + ) + + # Return the channel from cache. + return self._grpc_channel + + @property + def create_scan_config( + self, + ) -> Callable[ + [web_security_scanner.CreateScanConfigRequest], + Awaitable[gcw_scan_config.ScanConfig], + ]: + r"""Return a callable for the create scan config method over gRPC. + + Creates a new ScanConfig. + + Returns: + Callable[[~.CreateScanConfigRequest], + Awaitable[~.ScanConfig]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_scan_config" not in self._stubs: + self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/CreateScanConfig", + request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, + response_deserializer=gcw_scan_config.ScanConfig.deserialize, + ) + return self._stubs["create_scan_config"] + + @property + def delete_scan_config( + self, + ) -> Callable[ + [web_security_scanner.DeleteScanConfigRequest], Awaitable[empty.Empty] + ]: + r"""Return a callable for the delete scan config method over gRPC. + + Deletes an existing ScanConfig and its child + resources. + + Returns: + Callable[[~.DeleteScanConfigRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_scan_config" not in self._stubs: + self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/DeleteScanConfig", + request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs["delete_scan_config"] + + @property + def get_scan_config( + self, + ) -> Callable[ + [web_security_scanner.GetScanConfigRequest], Awaitable[scan_config.ScanConfig] + ]: + r"""Return a callable for the get scan config method over gRPC. + + Gets a ScanConfig. + + Returns: + Callable[[~.GetScanConfigRequest], + Awaitable[~.ScanConfig]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_scan_config" not in self._stubs: + self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanConfig", + request_serializer=web_security_scanner.GetScanConfigRequest.serialize, + response_deserializer=scan_config.ScanConfig.deserialize, + ) + return self._stubs["get_scan_config"] + + @property + def list_scan_configs( + self, + ) -> Callable[ + [web_security_scanner.ListScanConfigsRequest], + Awaitable[web_security_scanner.ListScanConfigsResponse], + ]: + r"""Return a callable for the list scan configs method over gRPC. + + Lists ScanConfigs under a given project. + + Returns: + Callable[[~.ListScanConfigsRequest], + Awaitable[~.ListScanConfigsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_scan_configs" not in self._stubs: + self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanConfigs", + request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, + response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, + ) + return self._stubs["list_scan_configs"] + + @property + def update_scan_config( + self, + ) -> Callable[ + [web_security_scanner.UpdateScanConfigRequest], + Awaitable[gcw_scan_config.ScanConfig], + ]: + r"""Return a callable for the update scan config method over gRPC. + + Updates a ScanConfig. This method support partial + update of a ScanConfig. + + Returns: + Callable[[~.UpdateScanConfigRequest], + Awaitable[~.ScanConfig]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_scan_config" not in self._stubs: + self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/UpdateScanConfig", + request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, + response_deserializer=gcw_scan_config.ScanConfig.deserialize, + ) + return self._stubs["update_scan_config"] + + @property + def start_scan_run( + self, + ) -> Callable[ + [web_security_scanner.StartScanRunRequest], Awaitable[scan_run.ScanRun] + ]: + r"""Return a callable for the start scan run method over gRPC. + + Start a ScanRun according to the given ScanConfig. + + Returns: + Callable[[~.StartScanRunRequest], + Awaitable[~.ScanRun]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "start_scan_run" not in self._stubs: + self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StartScanRun", + request_serializer=web_security_scanner.StartScanRunRequest.serialize, + response_deserializer=scan_run.ScanRun.deserialize, + ) + return self._stubs["start_scan_run"] + + @property + def get_scan_run( + self, + ) -> Callable[ + [web_security_scanner.GetScanRunRequest], Awaitable[scan_run.ScanRun] + ]: + r"""Return a callable for the get scan run method over gRPC. + + Gets a ScanRun. + + Returns: + Callable[[~.GetScanRunRequest], + Awaitable[~.ScanRun]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_scan_run" not in self._stubs: + self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanRun", + request_serializer=web_security_scanner.GetScanRunRequest.serialize, + response_deserializer=scan_run.ScanRun.deserialize, + ) + return self._stubs["get_scan_run"] + + @property + def list_scan_runs( + self, + ) -> Callable[ + [web_security_scanner.ListScanRunsRequest], + Awaitable[web_security_scanner.ListScanRunsResponse], + ]: + r"""Return a callable for the list scan runs method over gRPC. + + Lists ScanRuns under a given ScanConfig, in + descending order of ScanRun stop time. + + Returns: + Callable[[~.ListScanRunsRequest], + Awaitable[~.ListScanRunsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_scan_runs" not in self._stubs: + self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanRuns", + request_serializer=web_security_scanner.ListScanRunsRequest.serialize, + response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, + ) + return self._stubs["list_scan_runs"] + + @property + def stop_scan_run( + self, + ) -> Callable[ + [web_security_scanner.StopScanRunRequest], Awaitable[scan_run.ScanRun] + ]: + r"""Return a callable for the stop scan run method over gRPC. + + Stops a ScanRun. The stopped ScanRun is returned. + + Returns: + Callable[[~.StopScanRunRequest], + Awaitable[~.ScanRun]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "stop_scan_run" not in self._stubs: + self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StopScanRun", + request_serializer=web_security_scanner.StopScanRunRequest.serialize, + response_deserializer=scan_run.ScanRun.deserialize, + ) + return self._stubs["stop_scan_run"] + + @property + def list_crawled_urls( + self, + ) -> Callable[ + [web_security_scanner.ListCrawledUrlsRequest], + Awaitable[web_security_scanner.ListCrawledUrlsResponse], + ]: + r"""Return a callable for the list crawled urls method over gRPC. + + List CrawledUrls under a given ScanRun. + + Returns: + Callable[[~.ListCrawledUrlsRequest], + Awaitable[~.ListCrawledUrlsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_crawled_urls" not in self._stubs: + self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListCrawledUrls", + request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, + response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, + ) + return self._stubs["list_crawled_urls"] + + @property + def get_finding( + self, + ) -> Callable[[web_security_scanner.GetFindingRequest], Awaitable[finding.Finding]]: + r"""Return a callable for the get finding method over gRPC. + + Gets a Finding. + + Returns: + Callable[[~.GetFindingRequest], + Awaitable[~.Finding]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_finding" not in self._stubs: + self._stubs["get_finding"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetFinding", + request_serializer=web_security_scanner.GetFindingRequest.serialize, + response_deserializer=finding.Finding.deserialize, + ) + return self._stubs["get_finding"] + + @property + def list_findings( + self, + ) -> Callable[ + [web_security_scanner.ListFindingsRequest], + Awaitable[web_security_scanner.ListFindingsResponse], + ]: + r"""Return a callable for the list findings method over gRPC. + + List Findings under a given ScanRun. + + Returns: + Callable[[~.ListFindingsRequest], + Awaitable[~.ListFindingsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_findings" not in self._stubs: + self._stubs["list_findings"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindings", + request_serializer=web_security_scanner.ListFindingsRequest.serialize, + response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, + ) + return self._stubs["list_findings"] + + @property + def list_finding_type_stats( + self, + ) -> Callable[ + [web_security_scanner.ListFindingTypeStatsRequest], + Awaitable[web_security_scanner.ListFindingTypeStatsResponse], + ]: + r"""Return a callable for the list finding type stats method over gRPC. + + List all FindingTypeStats under a given ScanRun. + + Returns: + Callable[[~.ListFindingTypeStatsRequest], + Awaitable[~.ListFindingTypeStatsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_finding_type_stats" not in self._stubs: + self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindingTypeStats", + request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, + response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, + ) + return self._stubs["list_finding_type_stats"] + + +__all__ = ("WebSecurityScannerGrpcAsyncIOTransport",) diff --git a/google/cloud/websecurityscanner_v1alpha/types.py b/google/cloud/websecurityscanner_v1alpha/types.py deleted file mode 100644 index aef8624..0000000 --- a/google/cloud/websecurityscanner_v1alpha/types.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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 __future__ import absolute_import -import sys - -from google.api_core.protobuf_helpers import get_messages - -from google.cloud.websecurityscanner_v1alpha.proto import crawled_url_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import finding_addon_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import finding_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import finding_type_stats_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import scan_config_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import scan_run_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import web_security_scanner_pb2 -from google.protobuf import empty_pb2 -from google.protobuf import field_mask_pb2 -from google.protobuf import timestamp_pb2 - - -_shared_modules = [empty_pb2, field_mask_pb2, timestamp_pb2] - -_local_modules = [ - crawled_url_pb2, - finding_addon_pb2, - finding_pb2, - finding_type_stats_pb2, - scan_config_pb2, - scan_run_pb2, - web_security_scanner_pb2, -] - -names = [] - -for module in _shared_modules: # pragma: NO COVER - for name, message in get_messages(module).items(): - setattr(sys.modules[__name__], name, message) - names.append(name) -for module in _local_modules: - for name, message in get_messages(module).items(): - message.__module__ = "google.cloud.websecurityscanner_v1alpha.types" - setattr(sys.modules[__name__], name, message) - names.append(name) - - -__all__ = tuple(sorted(names)) diff --git a/google/cloud/websecurityscanner_v1alpha/types/__init__.py b/google/cloud/websecurityscanner_v1alpha/types/__init__.py new file mode 100644 index 0000000..747bf33 --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/types/__init__.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 .crawled_url import CrawledUrl +from .finding_addon import ( + OutdatedLibrary, + ViolatingResource, + VulnerableParameters, + VulnerableHeaders, + Xss, +) +from .finding import Finding +from .finding_type_stats import FindingTypeStats +from .scan_run import ScanRun +from .scan_config import ScanConfig +from .web_security_scanner import ( + CreateScanConfigRequest, + DeleteScanConfigRequest, + GetScanConfigRequest, + ListScanConfigsRequest, + UpdateScanConfigRequest, + ListScanConfigsResponse, + StartScanRunRequest, + GetScanRunRequest, + ListScanRunsRequest, + ListScanRunsResponse, + StopScanRunRequest, + ListCrawledUrlsRequest, + ListCrawledUrlsResponse, + GetFindingRequest, + ListFindingsRequest, + ListFindingsResponse, + ListFindingTypeStatsRequest, + ListFindingTypeStatsResponse, +) + + +__all__ = ( + "CrawledUrl", + "OutdatedLibrary", + "ViolatingResource", + "VulnerableParameters", + "VulnerableHeaders", + "Xss", + "Finding", + "FindingTypeStats", + "ScanRun", + "ScanConfig", + "CreateScanConfigRequest", + "DeleteScanConfigRequest", + "GetScanConfigRequest", + "ListScanConfigsRequest", + "UpdateScanConfigRequest", + "ListScanConfigsResponse", + "StartScanRunRequest", + "GetScanRunRequest", + "ListScanRunsRequest", + "ListScanRunsResponse", + "StopScanRunRequest", + "ListCrawledUrlsRequest", + "ListCrawledUrlsResponse", + "GetFindingRequest", + "ListFindingsRequest", + "ListFindingsResponse", + "ListFindingTypeStatsRequest", + "ListFindingTypeStatsResponse", +) diff --git a/google/cloud/websecurityscanner_v1alpha/types/crawled_url.py b/google/cloud/websecurityscanner_v1alpha/types/crawled_url.py new file mode 100644 index 0000000..92b27b0 --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/types/crawled_url.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1alpha", manifest={"CrawledUrl",}, +) + + +class CrawledUrl(proto.Message): + r"""A CrawledUrl resource represents a URL that was crawled + during a ScanRun. Web Security Scanner Service crawls the web + applications, following all links within the scope of sites, to + find the URLs to test against. + + Attributes: + http_method (str): + Output only. The http method of the request + that was used to visit the URL, in uppercase. + url (str): + Output only. The URL that was crawled. + body (str): + Output only. The body of the request that was + used to visit the URL. + """ + + http_method = proto.Field(proto.STRING, number=1) + + url = proto.Field(proto.STRING, number=2) + + body = proto.Field(proto.STRING, number=3) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1alpha/types/finding.py b/google/cloud/websecurityscanner_v1alpha/types/finding.py new file mode 100644 index 0000000..8fb31b0 --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/types/finding.py @@ -0,0 +1,140 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +from google.cloud.websecurityscanner_v1alpha.types import finding_addon + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1alpha", manifest={"Finding",}, +) + + +class Finding(proto.Message): + r"""A Finding resource represents a vulnerability instance + identified during a ScanRun. + + Attributes: + name (str): + The resource name of the Finding. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanruns/{scanRunId}/findings/{findingId}'. + The finding IDs are generated by the system. + finding_type (~.finding.Finding.FindingType): + The type of the Finding. + http_method (str): + The http method of the request that triggered + the vulnerability, in uppercase. + fuzzed_url (str): + The URL produced by the server-side fuzzer + and used in the request that triggered the + vulnerability. + body (str): + The body of the request that triggered the + vulnerability. + description (str): + The description of the vulnerability. + reproduction_url (str): + The URL containing human-readable payload + that user can leverage to reproduce the + vulnerability. + frame_url (str): + If the vulnerability was originated from + nested IFrame, the immediate parent IFrame is + reported. + final_url (str): + The URL where the browser lands when the + vulnerability is detected. + tracking_id (str): + The tracking ID uniquely identifies a + vulnerability instance across multiple ScanRuns. + outdated_library (~.finding_addon.OutdatedLibrary): + An addon containing information about + outdated libraries. + violating_resource (~.finding_addon.ViolatingResource): + An addon containing detailed information + regarding any resource causing the vulnerability + such as JavaScript sources, image, audio files, + etc. + vulnerable_headers (~.finding_addon.VulnerableHeaders): + An addon containing information about + vulnerable or missing HTTP headers. + vulnerable_parameters (~.finding_addon.VulnerableParameters): + An addon containing information about request + parameters which were found to be vulnerable. + xss (~.finding_addon.Xss): + An addon containing information reported for + an XSS, if any. + """ + + class FindingType(proto.Enum): + r"""Types of Findings.""" + FINDING_TYPE_UNSPECIFIED = 0 + MIXED_CONTENT = 1 + OUTDATED_LIBRARY = 2 + ROSETTA_FLASH = 5 + XSS_CALLBACK = 3 + XSS_ERROR = 4 + CLEAR_TEXT_PASSWORD = 6 + INVALID_CONTENT_TYPE = 7 + XSS_ANGULAR_CALLBACK = 8 + INVALID_HEADER = 9 + MISSPELLED_SECURITY_HEADER_NAME = 10 + MISMATCHING_SECURITY_HEADER_VALUES = 11 + + name = proto.Field(proto.STRING, number=1) + + finding_type = proto.Field(proto.ENUM, number=2, enum=FindingType,) + + http_method = proto.Field(proto.STRING, number=3) + + fuzzed_url = proto.Field(proto.STRING, number=4) + + body = proto.Field(proto.STRING, number=5) + + description = proto.Field(proto.STRING, number=6) + + reproduction_url = proto.Field(proto.STRING, number=7) + + frame_url = proto.Field(proto.STRING, number=8) + + final_url = proto.Field(proto.STRING, number=9) + + tracking_id = proto.Field(proto.STRING, number=10) + + outdated_library = proto.Field( + proto.MESSAGE, number=11, message=finding_addon.OutdatedLibrary, + ) + + violating_resource = proto.Field( + proto.MESSAGE, number=12, message=finding_addon.ViolatingResource, + ) + + vulnerable_headers = proto.Field( + proto.MESSAGE, number=15, message=finding_addon.VulnerableHeaders, + ) + + vulnerable_parameters = proto.Field( + proto.MESSAGE, number=13, message=finding_addon.VulnerableParameters, + ) + + xss = proto.Field(proto.MESSAGE, number=14, message=finding_addon.Xss,) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1alpha/types/finding_addon.py b/google/cloud/websecurityscanner_v1alpha/types/finding_addon.py new file mode 100644 index 0000000..4a0731c --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/types/finding_addon.py @@ -0,0 +1,126 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1alpha", + manifest={ + "OutdatedLibrary", + "ViolatingResource", + "VulnerableParameters", + "VulnerableHeaders", + "Xss", + }, +) + + +class OutdatedLibrary(proto.Message): + r"""Information reported for an outdated library. + + Attributes: + library_name (str): + The name of the outdated library. + version (str): + The version number. + learn_more_urls (Sequence[str]): + URLs to learn more information about the + vulnerabilities in the library. + """ + + library_name = proto.Field(proto.STRING, number=1) + + version = proto.Field(proto.STRING, number=2) + + learn_more_urls = proto.RepeatedField(proto.STRING, number=3) + + +class ViolatingResource(proto.Message): + r"""Information regarding any resource causing the vulnerability + such as JavaScript sources, image, audio files, etc. + + Attributes: + content_type (str): + The MIME type of this resource. + resource_url (str): + URL of this violating resource. + """ + + content_type = proto.Field(proto.STRING, number=1) + + resource_url = proto.Field(proto.STRING, number=2) + + +class VulnerableParameters(proto.Message): + r"""Information about vulnerable request parameters. + + Attributes: + parameter_names (Sequence[str]): + The vulnerable parameter names. + """ + + parameter_names = proto.RepeatedField(proto.STRING, number=1) + + +class VulnerableHeaders(proto.Message): + r"""Information about vulnerable or missing HTTP Headers. + + Attributes: + headers (Sequence[~.finding_addon.VulnerableHeaders.Header]): + List of vulnerable headers. + missing_headers (Sequence[~.finding_addon.VulnerableHeaders.Header]): + List of missing headers. + """ + + class Header(proto.Message): + r"""Describes a HTTP Header. + + Attributes: + name (str): + Header name. + value (str): + Header value. + """ + + name = proto.Field(proto.STRING, number=1) + + value = proto.Field(proto.STRING, number=2) + + headers = proto.RepeatedField(proto.MESSAGE, number=1, message=Header,) + + missing_headers = proto.RepeatedField(proto.MESSAGE, number=2, message=Header,) + + +class Xss(proto.Message): + r"""Information reported for an XSS. + + Attributes: + stack_traces (Sequence[str]): + Stack traces leading to the point where the + XSS occurred. + error_message (str): + An error message generated by a javascript + breakage. + """ + + stack_traces = proto.RepeatedField(proto.STRING, number=1) + + error_message = proto.Field(proto.STRING, number=2) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1alpha/types/finding_type_stats.py b/google/cloud/websecurityscanner_v1alpha/types/finding_type_stats.py new file mode 100644 index 0000000..f60eb38 --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/types/finding_type_stats.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +from google.cloud.websecurityscanner_v1alpha.types import finding + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1alpha", manifest={"FindingTypeStats",}, +) + + +class FindingTypeStats(proto.Message): + r"""A FindingTypeStats resource represents stats regarding a + specific FindingType of Findings under a given ScanRun. + + Attributes: + finding_type (~.finding.Finding.FindingType): + The finding type associated with the stats. + finding_count (int): + The count of findings belonging to this + finding type. + """ + + finding_type = proto.Field(proto.ENUM, number=1, enum=finding.Finding.FindingType,) + + finding_count = proto.Field(proto.INT32, number=2) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1alpha/types/scan_config.py b/google/cloud/websecurityscanner_v1alpha/types/scan_config.py new file mode 100644 index 0000000..c55cd87 --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/types/scan_config.py @@ -0,0 +1,191 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +from google.cloud.websecurityscanner_v1alpha.types import scan_run +from google.protobuf import timestamp_pb2 as timestamp # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1alpha", manifest={"ScanConfig",}, +) + + +class ScanConfig(proto.Message): + r"""A ScanConfig resource contains the configurations to launch a + scan. next id: 12 + + Attributes: + name (str): + The resource name of the ScanConfig. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + The ScanConfig IDs are generated by the system. + display_name (str): + Required. The user provided display name of + the ScanConfig. + max_qps (int): + The maximum QPS during scanning. A valid value ranges from 5 + to 20 inclusively. If the field is unspecified or its value + is set 0, server will default to 15. Other values outside of + [5, 20] range will be rejected with INVALID_ARGUMENT error. + starting_urls (Sequence[str]): + Required. The starting URLs from which the + scanner finds site pages. + authentication (~.scan_config.ScanConfig.Authentication): + The authentication configuration. If + specified, service will use the authentication + configuration during scanning. + user_agent (~.scan_config.ScanConfig.UserAgent): + The user agent used during scanning. + blacklist_patterns (Sequence[str]): + The blacklist URL patterns as described in + https://cloud.google.com/security- + scanner/docs/excluded-urls + schedule (~.scan_config.ScanConfig.Schedule): + The schedule of the ScanConfig. + target_platforms (Sequence[~.scan_config.ScanConfig.TargetPlatform]): + Set of Cloud Platforms targeted by the scan. If empty, + APP_ENGINE will be used as a default. + latest_run (~.scan_run.ScanRun): + Latest ScanRun if available. + """ + + class UserAgent(proto.Enum): + r"""Type of user agents used for scanning.""" + USER_AGENT_UNSPECIFIED = 0 + CHROME_LINUX = 1 + CHROME_ANDROID = 2 + SAFARI_IPHONE = 3 + + class TargetPlatform(proto.Enum): + r"""Cloud platforms supported by Cloud Web Security Scanner.""" + TARGET_PLATFORM_UNSPECIFIED = 0 + APP_ENGINE = 1 + COMPUTE = 2 + + class Authentication(proto.Message): + r"""Scan authentication configuration. + + Attributes: + google_account (~.scan_config.ScanConfig.Authentication.GoogleAccount): + Authentication using a Google account. + custom_account (~.scan_config.ScanConfig.Authentication.CustomAccount): + Authentication using a custom account. + """ + + class GoogleAccount(proto.Message): + r"""Describes authentication configuration that uses a Google + account. + + Attributes: + username (str): + Required. The user name of the Google + account. + password (str): + Required. Input only. The password of the + Google account. The credential is stored + encrypted and not returned in any response nor + included in audit logs. + """ + + username = proto.Field(proto.STRING, number=1) + + password = proto.Field(proto.STRING, number=2) + + class CustomAccount(proto.Message): + r"""Describes authentication configuration that uses a custom + account. + + Attributes: + username (str): + Required. The user name of the custom + account. + password (str): + Required. Input only. The password of the + custom account. The credential is stored + encrypted and not returned in any response nor + included in audit logs. + login_url (str): + Required. The login form URL of the website. + """ + + username = proto.Field(proto.STRING, number=1) + + password = proto.Field(proto.STRING, number=2) + + login_url = proto.Field(proto.STRING, number=3) + + google_account = proto.Field( + proto.MESSAGE, + number=1, + oneof="authentication", + message="ScanConfig.Authentication.GoogleAccount", + ) + + custom_account = proto.Field( + proto.MESSAGE, + number=2, + oneof="authentication", + message="ScanConfig.Authentication.CustomAccount", + ) + + class Schedule(proto.Message): + r"""Scan schedule configuration. + + Attributes: + schedule_time (~.timestamp.Timestamp): + A timestamp indicates when the next run will + be scheduled. The value is refreshed by the + server after each run. If unspecified, it will + default to current server time, which means the + scan will be scheduled to start immediately. + interval_duration_days (int): + Required. The duration of time between + executions in days. + """ + + schedule_time = proto.Field( + proto.MESSAGE, number=1, message=timestamp.Timestamp, + ) + + interval_duration_days = proto.Field(proto.INT32, number=2) + + name = proto.Field(proto.STRING, number=1) + + display_name = proto.Field(proto.STRING, number=2) + + max_qps = proto.Field(proto.INT32, number=3) + + starting_urls = proto.RepeatedField(proto.STRING, number=4) + + authentication = proto.Field(proto.MESSAGE, number=5, message=Authentication,) + + user_agent = proto.Field(proto.ENUM, number=6, enum=UserAgent,) + + blacklist_patterns = proto.RepeatedField(proto.STRING, number=7) + + schedule = proto.Field(proto.MESSAGE, number=8, message=Schedule,) + + target_platforms = proto.RepeatedField(proto.ENUM, number=9, enum=TargetPlatform,) + + latest_run = proto.Field(proto.MESSAGE, number=11, message=scan_run.ScanRun,) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1alpha/types/scan_run.py b/google/cloud/websecurityscanner_v1alpha/types/scan_run.py new file mode 100644 index 0000000..6739d8b --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/types/scan_run.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +from google.protobuf import timestamp_pb2 as timestamp # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1alpha", manifest={"ScanRun",}, +) + + +class ScanRun(proto.Message): + r"""A ScanRun is a output-only resource representing an actual + run of the scan. + + Attributes: + name (str): + The resource name of the ScanRun. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + The ScanRun IDs are generated by the system. + execution_state (~.scan_run.ScanRun.ExecutionState): + The execution state of the ScanRun. + result_state (~.scan_run.ScanRun.ResultState): + The result state of the ScanRun. This field + is only available after the execution state + reaches "FINISHED". + start_time (~.timestamp.Timestamp): + The time at which the ScanRun started. + end_time (~.timestamp.Timestamp): + The time at which the ScanRun reached + termination state - that the ScanRun is either + finished or stopped by user. + urls_crawled_count (int): + The number of URLs crawled during this + ScanRun. If the scan is in progress, the value + represents the number of URLs crawled up to now. + urls_tested_count (int): + The number of URLs tested during this + ScanRun. If the scan is in progress, the value + represents the number of URLs tested up to now. + The number of URLs tested is usually larger than + the number URLS crawled because typically a + crawled URL is tested with multiple test + payloads. + has_vulnerabilities (bool): + Whether the scan run has found any + vulnerabilities. + progress_percent (int): + The percentage of total completion ranging + from 0 to 100. If the scan is in queue, the + value is 0. If the scan is running, the value + ranges from 0 to 100. If the scan is finished, + the value is 100. + """ + + class ExecutionState(proto.Enum): + r"""Types of ScanRun execution state.""" + EXECUTION_STATE_UNSPECIFIED = 0 + QUEUED = 1 + SCANNING = 2 + FINISHED = 3 + + class ResultState(proto.Enum): + r"""Types of ScanRun result state.""" + RESULT_STATE_UNSPECIFIED = 0 + SUCCESS = 1 + ERROR = 2 + KILLED = 3 + + name = proto.Field(proto.STRING, number=1) + + execution_state = proto.Field(proto.ENUM, number=2, enum=ExecutionState,) + + result_state = proto.Field(proto.ENUM, number=3, enum=ResultState,) + + start_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) + + end_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) + + urls_crawled_count = proto.Field(proto.INT64, number=6) + + urls_tested_count = proto.Field(proto.INT64, number=7) + + has_vulnerabilities = proto.Field(proto.BOOL, number=8) + + progress_percent = proto.Field(proto.INT32, number=9) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1alpha/types/web_security_scanner.py b/google/cloud/websecurityscanner_v1alpha/types/web_security_scanner.py new file mode 100644 index 0000000..ec2c7dd --- /dev/null +++ b/google/cloud/websecurityscanner_v1alpha/types/web_security_scanner.py @@ -0,0 +1,404 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +from google.cloud.websecurityscanner_v1alpha.types import crawled_url +from google.cloud.websecurityscanner_v1alpha.types import finding +from google.cloud.websecurityscanner_v1alpha.types import ( + finding_type_stats as gcw_finding_type_stats, +) +from google.cloud.websecurityscanner_v1alpha.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_run +from google.protobuf import field_mask_pb2 as field_mask # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1alpha", + manifest={ + "CreateScanConfigRequest", + "DeleteScanConfigRequest", + "GetScanConfigRequest", + "ListScanConfigsRequest", + "UpdateScanConfigRequest", + "ListScanConfigsResponse", + "StartScanRunRequest", + "GetScanRunRequest", + "ListScanRunsRequest", + "ListScanRunsResponse", + "StopScanRunRequest", + "ListCrawledUrlsRequest", + "ListCrawledUrlsResponse", + "GetFindingRequest", + "ListFindingsRequest", + "ListFindingsResponse", + "ListFindingTypeStatsRequest", + "ListFindingTypeStatsResponse", + }, +) + + +class CreateScanConfigRequest(proto.Message): + r"""Request for the ``CreateScanConfig`` method. + + Attributes: + parent (str): + Required. The parent resource name where the + scan is created, which should be a project + resource name in the format + 'projects/{projectId}'. + scan_config (~.gcw_scan_config.ScanConfig): + Required. The ScanConfig to be created. + """ + + parent = proto.Field(proto.STRING, number=1) + + scan_config = proto.Field( + proto.MESSAGE, number=2, message=gcw_scan_config.ScanConfig, + ) + + +class DeleteScanConfigRequest(proto.Message): + r"""Request for the ``DeleteScanConfig`` method. + + Attributes: + name (str): + Required. The resource name of the ScanConfig + to be deleted. The name follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + """ + + name = proto.Field(proto.STRING, number=1) + + +class GetScanConfigRequest(proto.Message): + r"""Request for the ``GetScanConfig`` method. + + Attributes: + name (str): + Required. The resource name of the ScanConfig + to be returned. The name follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListScanConfigsRequest(proto.Message): + r"""Request for the ``ListScanConfigs`` method. + + Attributes: + parent (str): + Required. The parent resource name, which + should be a project resource name in the format + 'projects/{projectId}'. + page_token (str): + A token identifying a page of results to be returned. This + should be a ``next_page_token`` value returned from a + previous List request. If unspecified, the first page of + results is returned. + page_size (int): + The maximum number of ScanConfigs to return, + can be limited by server. If not specified or + not positive, the implementation will select a + reasonable value. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_token = proto.Field(proto.STRING, number=2) + + page_size = proto.Field(proto.INT32, number=3) + + +class UpdateScanConfigRequest(proto.Message): + r"""Request for the ``UpdateScanConfigRequest`` method. + + Attributes: + scan_config (~.gcw_scan_config.ScanConfig): + Required. The ScanConfig to be updated. The + name field must be set to identify the resource + to be updated. The values of fields not covered + by the mask will be ignored. + update_mask (~.field_mask.FieldMask): + Required. The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + """ + + scan_config = proto.Field( + proto.MESSAGE, number=2, message=gcw_scan_config.ScanConfig, + ) + + update_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask.FieldMask,) + + +class ListScanConfigsResponse(proto.Message): + r"""Response for the ``ListScanConfigs`` method. + + Attributes: + scan_configs (Sequence[~.gcw_scan_config.ScanConfig]): + The list of ScanConfigs returned. + next_page_token (str): + Token to retrieve the next page of results, + or empty if there are no more results in the + list. + """ + + @property + def raw_page(self): + return self + + scan_configs = proto.RepeatedField( + proto.MESSAGE, number=1, message=gcw_scan_config.ScanConfig, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class StartScanRunRequest(proto.Message): + r"""Request for the ``StartScanRun`` method. + + Attributes: + name (str): + Required. The resource name of the ScanConfig + to be used. The name follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + """ + + name = proto.Field(proto.STRING, number=1) + + +class GetScanRunRequest(proto.Message): + r"""Request for the ``GetScanRun`` method. + + Attributes: + name (str): + Required. The resource name of the ScanRun to + be returned. The name follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListScanRunsRequest(proto.Message): + r"""Request for the ``ListScanRuns`` method. + + Attributes: + parent (str): + Required. The parent resource name, which + should be a scan resource name in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + page_token (str): + A token identifying a page of results to be returned. This + should be a ``next_page_token`` value returned from a + previous List request. If unspecified, the first page of + results is returned. + page_size (int): + The maximum number of ScanRuns to return, can + be limited by server. If not specified or not + positive, the implementation will select a + reasonable value. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_token = proto.Field(proto.STRING, number=2) + + page_size = proto.Field(proto.INT32, number=3) + + +class ListScanRunsResponse(proto.Message): + r"""Response for the ``ListScanRuns`` method. + + Attributes: + scan_runs (Sequence[~.scan_run.ScanRun]): + The list of ScanRuns returned. + next_page_token (str): + Token to retrieve the next page of results, + or empty if there are no more results in the + list. + """ + + @property + def raw_page(self): + return self + + scan_runs = proto.RepeatedField(proto.MESSAGE, number=1, message=scan_run.ScanRun,) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class StopScanRunRequest(proto.Message): + r"""Request for the ``StopScanRun`` method. + + Attributes: + name (str): + Required. The resource name of the ScanRun to + be stopped. The name follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListCrawledUrlsRequest(proto.Message): + r"""Request for the ``ListCrawledUrls`` method. + + Attributes: + parent (str): + Required. The parent resource name, which + should be a scan run resource name in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + page_token (str): + A token identifying a page of results to be returned. This + should be a ``next_page_token`` value returned from a + previous List request. If unspecified, the first page of + results is returned. + page_size (int): + The maximum number of CrawledUrls to return, + can be limited by server. If not specified or + not positive, the implementation will select a + reasonable value. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_token = proto.Field(proto.STRING, number=2) + + page_size = proto.Field(proto.INT32, number=3) + + +class ListCrawledUrlsResponse(proto.Message): + r"""Response for the ``ListCrawledUrls`` method. + + Attributes: + crawled_urls (Sequence[~.crawled_url.CrawledUrl]): + The list of CrawledUrls returned. + next_page_token (str): + Token to retrieve the next page of results, + or empty if there are no more results in the + list. + """ + + @property + def raw_page(self): + return self + + crawled_urls = proto.RepeatedField( + proto.MESSAGE, number=1, message=crawled_url.CrawledUrl, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class GetFindingRequest(proto.Message): + r"""Request for the ``GetFinding`` method. + + Attributes: + name (str): + Required. The resource name of the Finding to + be returned. The name follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListFindingsRequest(proto.Message): + r"""Request for the ``ListFindings`` method. + + Attributes: + parent (str): + Required. The parent resource name, which + should be a scan run resource name in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + filter (str): + Required. The filter expression. The expression must be in + the format: . Supported field: 'finding_type'. Supported + operator: '='. + page_token (str): + A token identifying a page of results to be returned. This + should be a ``next_page_token`` value returned from a + previous List request. If unspecified, the first page of + results is returned. + page_size (int): + The maximum number of Findings to return, can + be limited by server. If not specified or not + positive, the implementation will select a + reasonable value. + """ + + parent = proto.Field(proto.STRING, number=1) + + filter = proto.Field(proto.STRING, number=2) + + page_token = proto.Field(proto.STRING, number=3) + + page_size = proto.Field(proto.INT32, number=4) + + +class ListFindingsResponse(proto.Message): + r"""Response for the ``ListFindings`` method. + + Attributes: + findings (Sequence[~.finding.Finding]): + The list of Findings returned. + next_page_token (str): + Token to retrieve the next page of results, + or empty if there are no more results in the + list. + """ + + @property + def raw_page(self): + return self + + findings = proto.RepeatedField(proto.MESSAGE, number=1, message=finding.Finding,) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class ListFindingTypeStatsRequest(proto.Message): + r"""Request for the ``ListFindingTypeStats`` method. + + Attributes: + parent (str): + Required. The parent resource name, which + should be a scan run resource name in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + """ + + parent = proto.Field(proto.STRING, number=1) + + +class ListFindingTypeStatsResponse(proto.Message): + r"""Response for the ``ListFindingTypeStats`` method. + + Attributes: + finding_type_stats (Sequence[~.gcw_finding_type_stats.FindingTypeStats]): + The list of FindingTypeStats returned. + """ + + finding_type_stats = proto.RepeatedField( + proto.MESSAGE, number=1, message=gcw_finding_type_stats.FindingTypeStats, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1beta/__init__.py b/google/cloud/websecurityscanner_v1beta/__init__.py index c018838..c5228bc 100644 --- a/google/cloud/websecurityscanner_v1beta/__init__.py +++ b/google/cloud/websecurityscanner_v1beta/__init__.py @@ -1,41 +1,87 @@ # -*- coding: utf-8 -*- -# + # Copyright 2020 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 # -# https://www.apache.org/licenses/LICENSE-2.0 +# 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 __future__ import absolute_import -import sys -import warnings - -from google.cloud.websecurityscanner_v1beta import types -from google.cloud.websecurityscanner_v1beta.gapic import enums -from google.cloud.websecurityscanner_v1beta.gapic import web_security_scanner_client - - -if sys.version_info[:2] == (2, 7): - message = ( - "A future version of this library will drop support for Python 2.7." - "More details about Python 2 support for Google Cloud Client Libraries" - "can be found at https://cloud.google.com/python/docs/python2-sunset/" - ) - warnings.warn(message, DeprecationWarning) - - -class WebSecurityScannerClient(web_security_scanner_client.WebSecurityScannerClient): - __doc__ = web_security_scanner_client.WebSecurityScannerClient.__doc__ - enums = enums +from .services.web_security_scanner import WebSecurityScannerClient +from .types.crawled_url import CrawledUrl +from .types.finding import Finding +from .types.finding_addon import Form +from .types.finding_addon import OutdatedLibrary +from .types.finding_addon import ViolatingResource +from .types.finding_addon import VulnerableHeaders +from .types.finding_addon import VulnerableParameters +from .types.finding_addon import Xss +from .types.finding_type_stats import FindingTypeStats +from .types.scan_config import ScanConfig +from .types.scan_config_error import ScanConfigError +from .types.scan_run import ScanRun +from .types.scan_run_error_trace import ScanRunErrorTrace +from .types.scan_run_warning_trace import ScanRunWarningTrace +from .types.web_security_scanner import CreateScanConfigRequest +from .types.web_security_scanner import DeleteScanConfigRequest +from .types.web_security_scanner import GetFindingRequest +from .types.web_security_scanner import GetScanConfigRequest +from .types.web_security_scanner import GetScanRunRequest +from .types.web_security_scanner import ListCrawledUrlsRequest +from .types.web_security_scanner import ListCrawledUrlsResponse +from .types.web_security_scanner import ListFindingTypeStatsRequest +from .types.web_security_scanner import ListFindingTypeStatsResponse +from .types.web_security_scanner import ListFindingsRequest +from .types.web_security_scanner import ListFindingsResponse +from .types.web_security_scanner import ListScanConfigsRequest +from .types.web_security_scanner import ListScanConfigsResponse +from .types.web_security_scanner import ListScanRunsRequest +from .types.web_security_scanner import ListScanRunsResponse +from .types.web_security_scanner import StartScanRunRequest +from .types.web_security_scanner import StopScanRunRequest +from .types.web_security_scanner import UpdateScanConfigRequest -__all__ = ("enums", "types", "WebSecurityScannerClient") +__all__ = ( + "CrawledUrl", + "CreateScanConfigRequest", + "DeleteScanConfigRequest", + "Finding", + "FindingTypeStats", + "Form", + "GetFindingRequest", + "GetScanConfigRequest", + "GetScanRunRequest", + "ListCrawledUrlsRequest", + "ListCrawledUrlsResponse", + "ListFindingTypeStatsRequest", + "ListFindingTypeStatsResponse", + "ListFindingsRequest", + "ListFindingsResponse", + "ListScanConfigsRequest", + "ListScanConfigsResponse", + "ListScanRunsRequest", + "ListScanRunsResponse", + "OutdatedLibrary", + "ScanConfig", + "ScanConfigError", + "ScanRun", + "ScanRunErrorTrace", + "ScanRunWarningTrace", + "StartScanRunRequest", + "StopScanRunRequest", + "UpdateScanConfigRequest", + "ViolatingResource", + "VulnerableHeaders", + "VulnerableParameters", + "Xss", + "WebSecurityScannerClient", +) diff --git a/google/cloud/websecurityscanner_v1beta/gapic/__init__.py b/google/cloud/websecurityscanner_v1beta/gapic/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/google/cloud/websecurityscanner_v1beta/gapic/enums.py b/google/cloud/websecurityscanner_v1beta/gapic/enums.py deleted file mode 100644 index 11c8118..0000000 --- a/google/cloud/websecurityscanner_v1beta/gapic/enums.py +++ /dev/null @@ -1,289 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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. - -"""Wrappers for protocol buffer enum types.""" - -import enum - - -class ScanConfig(object): - class ExportToSecurityCommandCenter(enum.IntEnum): - """ - Controls export of scan configurations and results to Cloud Security - Command Center. - - Attributes: - EXPORT_TO_SECURITY_COMMAND_CENTER_UNSPECIFIED (int): Use default, which is ENABLED. - ENABLED (int): Export results of this scan to Cloud Security Command Center. - DISABLED (int): Do not export results of this scan to Cloud Security Command Center. - """ - - EXPORT_TO_SECURITY_COMMAND_CENTER_UNSPECIFIED = 0 - ENABLED = 1 - DISABLED = 2 - - class RiskLevel(enum.IntEnum): - """ - Scan risk levels supported by Cloud Web Security Scanner. LOW impact - scanning will minimize requests with the potential to modify data. To - achieve the maximum scan coverage, NORMAL risk level is recommended. - - Attributes: - RISK_LEVEL_UNSPECIFIED (int): Use default, which is NORMAL. - NORMAL (int): Normal scanning (Recommended) - LOW (int): Lower impact scanning - """ - - RISK_LEVEL_UNSPECIFIED = 0 - NORMAL = 1 - LOW = 2 - - class TargetPlatform(enum.IntEnum): - """ - Cloud platforms supported by Cloud Web Security Scanner. - - Attributes: - TARGET_PLATFORM_UNSPECIFIED (int): The target platform is unknown. Requests with this enum value will be - rejected with INVALID\_ARGUMENT error. - APP_ENGINE (int): Google App Engine service. - COMPUTE (int): Google Compute Engine service. - """ - - TARGET_PLATFORM_UNSPECIFIED = 0 - APP_ENGINE = 1 - COMPUTE = 2 - - class UserAgent(enum.IntEnum): - """ - Type of user agents used for scanning. - - Attributes: - USER_AGENT_UNSPECIFIED (int): The user agent is unknown. Service will default to CHROME\_LINUX. - CHROME_LINUX (int): Chrome on Linux. This is the service default if unspecified. - CHROME_ANDROID (int): Chrome on Android. - SAFARI_IPHONE (int): Safari on IPhone. - """ - - USER_AGENT_UNSPECIFIED = 0 - CHROME_LINUX = 1 - CHROME_ANDROID = 2 - SAFARI_IPHONE = 3 - - -class ScanConfigError(object): - class Code(enum.IntEnum): - """ - Output only. - Defines an error reason code. - Next id: 44 - - Attributes: - CODE_UNSPECIFIED (int): There is no error. - OK (int): There is no error. - INTERNAL_ERROR (int): Indicates an internal server error. - Please DO NOT USE THIS ERROR CODE unless the root cause is truly unknown. - APPENGINE_API_BACKEND_ERROR (int): One of the seed URLs is an App Engine URL but we cannot validate the scan - settings due to an App Engine API backend error. - APPENGINE_API_NOT_ACCESSIBLE (int): One of the seed URLs is an App Engine URL but we cannot access the - App Engine API to validate scan settings. - APPENGINE_DEFAULT_HOST_MISSING (int): One of the seed URLs is an App Engine URL but the Default Host of the - App Engine is not set. - CANNOT_USE_GOOGLE_COM_ACCOUNT (int): Google corporate accounts can not be used for scanning. - CANNOT_USE_OWNER_ACCOUNT (int): The account of the scan creator can not be used for scanning. - COMPUTE_API_BACKEND_ERROR (int): This scan targets Compute Engine, but we cannot validate scan settings - due to a Compute Engine API backend error. - COMPUTE_API_NOT_ACCESSIBLE (int): This scan targets Compute Engine, but we cannot access the Compute Engine - API to validate the scan settings. - CUSTOM_LOGIN_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT (int): The Custom Login URL does not belong to the current project. - CUSTOM_LOGIN_URL_MALFORMED (int): The Custom Login URL is malformed (can not be parsed). - CUSTOM_LOGIN_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS (int): The Custom Login URL is mapped to a non-routable IP address in DNS. - CUSTOM_LOGIN_URL_MAPPED_TO_UNRESERVED_ADDRESS (int): The Custom Login URL is mapped to an IP address which is not reserved for - the current project. - CUSTOM_LOGIN_URL_HAS_NON_ROUTABLE_IP_ADDRESS (int): The Custom Login URL has a non-routable IP address. - CUSTOM_LOGIN_URL_HAS_UNRESERVED_IP_ADDRESS (int): The Custom Login URL has an IP address which is not reserved for the - current project. - DUPLICATE_SCAN_NAME (int): Another scan with the same name (case-sensitive) already exists. - INVALID_FIELD_VALUE (int): A field is set to an invalid value. - FAILED_TO_AUTHENTICATE_TO_TARGET (int): There was an error trying to authenticate to the scan target. - FINDING_TYPE_UNSPECIFIED (int): Finding type value is not specified in the list findings request. - FORBIDDEN_TO_SCAN_COMPUTE (int): Scan targets Compute Engine, yet current project was not whitelisted for - Google Compute Engine Scanning Alpha access. - FORBIDDEN_UPDATE_TO_MANAGED_SCAN (int): User tries to update managed scan - MALFORMED_FILTER (int): The supplied filter is malformed. For example, it can not be parsed, does - not have a filter type in expression, or the same filter type appears - more than once. - MALFORMED_RESOURCE_NAME (int): The supplied resource name is malformed (can not be parsed). - PROJECT_INACTIVE (int): The current project is not in an active state. - REQUIRED_FIELD (int): A required field is not set. - RESOURCE_NAME_INCONSISTENT (int): Project id, scanconfig id, scanrun id, or finding id are not consistent - with each other in resource name. - SCAN_ALREADY_RUNNING (int): The scan being requested to start is already running. - SCAN_NOT_RUNNING (int): The scan that was requested to be stopped is not running. - SEED_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT (int): One of the seed URLs does not belong to the current project. - SEED_URL_MALFORMED (int): One of the seed URLs is malformed (can not be parsed). - SEED_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS (int): One of the seed URLs is mapped to a non-routable IP address in DNS. - SEED_URL_MAPPED_TO_UNRESERVED_ADDRESS (int): One of the seed URLs is mapped to an IP address which is not reserved - for the current project. - SEED_URL_HAS_NON_ROUTABLE_IP_ADDRESS (int): One of the seed URLs has on-routable IP address. - SEED_URL_HAS_UNRESERVED_IP_ADDRESS (int): One of the seed URLs has an IP address that is not reserved - for the current project. - SERVICE_ACCOUNT_NOT_CONFIGURED (int): The Cloud Security Scanner service account is not configured under the - project. - TOO_MANY_SCANS (int): A project has reached the maximum number of scans. - UNABLE_TO_RESOLVE_PROJECT_INFO (int): Resolving the details of the current project fails. - UNSUPPORTED_BLACKLIST_PATTERN_FORMAT (int): One or more blacklist patterns were in the wrong format. - UNSUPPORTED_FILTER (int): The supplied filter is not supported. - UNSUPPORTED_FINDING_TYPE (int): The supplied finding type is not supported. For example, we do not - provide findings of the given finding type. - UNSUPPORTED_URL_SCHEME (int): The URL scheme of one or more of the supplied URLs is not supported. - """ - - CODE_UNSPECIFIED = 0 - OK = 0 - INTERNAL_ERROR = 1 - APPENGINE_API_BACKEND_ERROR = 2 - APPENGINE_API_NOT_ACCESSIBLE = 3 - APPENGINE_DEFAULT_HOST_MISSING = 4 - CANNOT_USE_GOOGLE_COM_ACCOUNT = 6 - CANNOT_USE_OWNER_ACCOUNT = 7 - COMPUTE_API_BACKEND_ERROR = 8 - COMPUTE_API_NOT_ACCESSIBLE = 9 - CUSTOM_LOGIN_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT = 10 - CUSTOM_LOGIN_URL_MALFORMED = 11 - CUSTOM_LOGIN_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS = 12 - CUSTOM_LOGIN_URL_MAPPED_TO_UNRESERVED_ADDRESS = 13 - CUSTOM_LOGIN_URL_HAS_NON_ROUTABLE_IP_ADDRESS = 14 - CUSTOM_LOGIN_URL_HAS_UNRESERVED_IP_ADDRESS = 15 - DUPLICATE_SCAN_NAME = 16 - INVALID_FIELD_VALUE = 18 - FAILED_TO_AUTHENTICATE_TO_TARGET = 19 - FINDING_TYPE_UNSPECIFIED = 20 - FORBIDDEN_TO_SCAN_COMPUTE = 21 - FORBIDDEN_UPDATE_TO_MANAGED_SCAN = 43 - MALFORMED_FILTER = 22 - MALFORMED_RESOURCE_NAME = 23 - PROJECT_INACTIVE = 24 - REQUIRED_FIELD = 25 - RESOURCE_NAME_INCONSISTENT = 26 - SCAN_ALREADY_RUNNING = 27 - SCAN_NOT_RUNNING = 28 - SEED_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT = 29 - SEED_URL_MALFORMED = 30 - SEED_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS = 31 - SEED_URL_MAPPED_TO_UNRESERVED_ADDRESS = 32 - SEED_URL_HAS_NON_ROUTABLE_IP_ADDRESS = 33 - SEED_URL_HAS_UNRESERVED_IP_ADDRESS = 35 - SERVICE_ACCOUNT_NOT_CONFIGURED = 36 - TOO_MANY_SCANS = 37 - UNABLE_TO_RESOLVE_PROJECT_INFO = 38 - UNSUPPORTED_BLACKLIST_PATTERN_FORMAT = 39 - UNSUPPORTED_FILTER = 40 - UNSUPPORTED_FINDING_TYPE = 41 - UNSUPPORTED_URL_SCHEME = 42 - - -class ScanRun(object): - class ExecutionState(enum.IntEnum): - """ - Types of ScanRun execution state. - - Attributes: - EXECUTION_STATE_UNSPECIFIED (int): Represents an invalid state caused by internal server error. This value - should never be returned. - QUEUED (int): The scan is waiting in the queue. - SCANNING (int): The scan is in progress. - FINISHED (int): The scan is either finished or stopped by user. - """ - - EXECUTION_STATE_UNSPECIFIED = 0 - QUEUED = 1 - SCANNING = 2 - FINISHED = 3 - - class ResultState(enum.IntEnum): - """ - Types of ScanRun result state. - - Attributes: - RESULT_STATE_UNSPECIFIED (int): Default value. This value is returned when the ScanRun is not yet - finished. - SUCCESS (int): The scan finished without errors. - ERROR (int): The scan finished with errors. - KILLED (int): The scan was terminated by user. - """ - - RESULT_STATE_UNSPECIFIED = 0 - SUCCESS = 1 - ERROR = 2 - KILLED = 3 - - -class ScanRunErrorTrace(object): - class Code(enum.IntEnum): - """ - Output only. - Defines an error reason code. - Next id: 7 - - Attributes: - CODE_UNSPECIFIED (int): Default value is never used. - INTERNAL_ERROR (int): Indicates that the scan run failed due to an internal server error. - SCAN_CONFIG_ISSUE (int): Indicates a scan configuration error, usually due to outdated ScanConfig - settings, such as starting\_urls or the DNS configuration. - AUTHENTICATION_CONFIG_ISSUE (int): Indicates an authentication error, usually due to outdated ScanConfig - authentication settings. - TIMED_OUT_WHILE_SCANNING (int): Indicates a scan operation timeout, usually caused by a very large site. - TOO_MANY_REDIRECTS (int): Indicates that a scan encountered excessive redirects, either to - authentication or some other page outside of the scan scope. - TOO_MANY_HTTP_ERRORS (int): Indicates that a scan encountered numerous errors from the web site - pages. When available, most\_common\_http\_error\_code field indicates - the most common HTTP error code encountered during the scan. - """ - - CODE_UNSPECIFIED = 0 - INTERNAL_ERROR = 1 - SCAN_CONFIG_ISSUE = 2 - AUTHENTICATION_CONFIG_ISSUE = 3 - TIMED_OUT_WHILE_SCANNING = 4 - TOO_MANY_REDIRECTS = 5 - TOO_MANY_HTTP_ERRORS = 6 - - -class ScanRunWarningTrace(object): - class Code(enum.IntEnum): - """ - Output only. - Defines a warning message code. - Next id: 6 - - Attributes: - CODE_UNSPECIFIED (int): Default value is never used. - INSUFFICIENT_CRAWL_RESULTS (int): Indicates that a scan discovered an unexpectedly low number of URLs. This - is sometimes caused by complex navigation features or by using a single - URL for numerous pages. - TOO_MANY_CRAWL_RESULTS (int): Indicates that a scan discovered too many URLs to test, or excessive - redundant URLs. - TOO_MANY_FUZZ_TASKS (int): Indicates that too many tests have been generated for the scan. Customer - should try reducing the number of starting URLs, increasing the QPS rate, - or narrowing down the scope of the scan using the excluded patterns. - BLOCKED_BY_IAP (int): Indicates that a scan is blocked by IAP. - """ - - CODE_UNSPECIFIED = 0 - INSUFFICIENT_CRAWL_RESULTS = 1 - TOO_MANY_CRAWL_RESULTS = 2 - TOO_MANY_FUZZ_TASKS = 3 - BLOCKED_BY_IAP = 4 diff --git a/google/cloud/websecurityscanner_v1beta/gapic/transports/__init__.py b/google/cloud/websecurityscanner_v1beta/gapic/transports/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/google/cloud/websecurityscanner_v1beta/gapic/transports/web_security_scanner_grpc_transport.py b/google/cloud/websecurityscanner_v1beta/gapic/transports/web_security_scanner_grpc_transport.py deleted file mode 100644 index a8475f9..0000000 --- a/google/cloud/websecurityscanner_v1beta/gapic/transports/web_security_scanner_grpc_transport.py +++ /dev/null @@ -1,283 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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 google.api_core.grpc_helpers - -from google.cloud.websecurityscanner_v1beta.proto import web_security_scanner_pb2_grpc - - -class WebSecurityScannerGrpcTransport(object): - """gRPC transport class providing stubs for - google.cloud.websecurityscanner.v1beta WebSecurityScanner API. - - The transport provides access to the raw gRPC stubs, - which can be used to take advantage of advanced - features of gRPC. - """ - - # The scopes needed to make gRPC calls to all of the methods defined - # in this service. - _OAUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) - - def __init__( - self, - channel=None, - credentials=None, - address="websecurityscanner.googleapis.com:443", - ): - """Instantiate the transport class. - - Args: - channel (grpc.Channel): A ``Channel`` instance through - which to make calls. This argument is mutually exclusive - with ``credentials``; providing both will raise an exception. - credentials (google.auth.credentials.Credentials): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If none - are specified, the client will attempt to ascertain the - credentials from the environment. - address (str): The address where the service is hosted. - """ - # If both `channel` and `credentials` are specified, raise an - # exception (channels come with credentials baked in already). - if channel is not None and credentials is not None: - raise ValueError( - "The `channel` and `credentials` arguments are mutually " "exclusive." - ) - - # Create the channel. - if channel is None: - channel = self.create_channel( - address=address, - credentials=credentials, - options={ - "grpc.max_send_message_length": -1, - "grpc.max_receive_message_length": -1, - }.items(), - ) - - self._channel = channel - - # gRPC uses objects called "stubs" that are bound to the - # channel and provide a basic method for each RPC. - self._stubs = { - "web_security_scanner_stub": web_security_scanner_pb2_grpc.WebSecurityScannerStub( - channel - ) - } - - @classmethod - def create_channel( - cls, address="websecurityscanner.googleapis.com:443", credentials=None, **kwargs - ): - """Create and return a gRPC channel object. - - Args: - address (str): The host for the channel to use. - credentials (~.Credentials): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - kwargs (dict): Keyword arguments, which are passed to the - channel creation. - - Returns: - grpc.Channel: A gRPC channel object. - """ - return google.api_core.grpc_helpers.create_channel( - address, credentials=credentials, scopes=cls._OAUTH_SCOPES, **kwargs - ) - - @property - def channel(self): - """The gRPC channel used by the transport. - - Returns: - grpc.Channel: A gRPC channel object. - """ - return self._channel - - @property - def create_scan_config(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.create_scan_config`. - - Creates a new ScanConfig. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].CreateScanConfig - - @property - def delete_scan_config(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.delete_scan_config`. - - Deletes an existing ScanConfig and its child resources. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].DeleteScanConfig - - @property - def get_scan_config(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.get_scan_config`. - - Gets a ScanConfig. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].GetScanConfig - - @property - def list_scan_configs(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.list_scan_configs`. - - Lists ScanConfigs under a given project. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].ListScanConfigs - - @property - def update_scan_config(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.update_scan_config`. - - Updates a ScanConfig. This method support partial update of a ScanConfig. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].UpdateScanConfig - - @property - def start_scan_run(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.start_scan_run`. - - Start a ScanRun according to the given ScanConfig. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].StartScanRun - - @property - def get_scan_run(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.get_scan_run`. - - Gets a ScanRun. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].GetScanRun - - @property - def list_scan_runs(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.list_scan_runs`. - - Lists ScanRuns under a given ScanConfig, in descending order of ScanRun - stop time. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].ListScanRuns - - @property - def stop_scan_run(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.stop_scan_run`. - - Stops a ScanRun. The stopped ScanRun is returned. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].StopScanRun - - @property - def list_crawled_urls(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.list_crawled_urls`. - - List CrawledUrls under a given ScanRun. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].ListCrawledUrls - - @property - def get_finding(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.get_finding`. - - Gets a Finding. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].GetFinding - - @property - def list_findings(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.list_findings`. - - List Findings under a given ScanRun. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].ListFindings - - @property - def list_finding_type_stats(self): - """Return the gRPC stub for :meth:`WebSecurityScannerClient.list_finding_type_stats`. - - List all FindingTypeStats under a given ScanRun. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["web_security_scanner_stub"].ListFindingTypeStats diff --git a/google/cloud/websecurityscanner_v1beta/gapic/web_security_scanner_client.py b/google/cloud/websecurityscanner_v1beta/gapic/web_security_scanner_client.py deleted file mode 100644 index fdf2b67..0000000 --- a/google/cloud/websecurityscanner_v1beta/gapic/web_security_scanner_client.py +++ /dev/null @@ -1,1320 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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. - -"""Accesses the google.cloud.websecurityscanner.v1beta WebSecurityScanner API.""" - -import functools -import pkg_resources -import warnings - -from google.oauth2 import service_account -import google.api_core.client_options -import google.api_core.gapic_v1.client_info -import google.api_core.gapic_v1.config -import google.api_core.gapic_v1.method -import google.api_core.gapic_v1.routing_header -import google.api_core.grpc_helpers -import google.api_core.page_iterator -import google.api_core.path_template -import grpc - -from google.cloud.websecurityscanner_v1beta.gapic import enums -from google.cloud.websecurityscanner_v1beta.gapic import ( - web_security_scanner_client_config, -) -from google.cloud.websecurityscanner_v1beta.gapic.transports import ( - web_security_scanner_grpc_transport, -) -from google.cloud.websecurityscanner_v1beta.proto import finding_pb2 -from google.cloud.websecurityscanner_v1beta.proto import scan_config_pb2 -from google.cloud.websecurityscanner_v1beta.proto import scan_run_pb2 -from google.cloud.websecurityscanner_v1beta.proto import web_security_scanner_pb2 -from google.cloud.websecurityscanner_v1beta.proto import web_security_scanner_pb2_grpc -from google.protobuf import empty_pb2 -from google.protobuf import field_mask_pb2 - - -_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution( - "google-cloud-websecurityscanner" -).version - - -class WebSecurityScannerClient(object): - """ - Cloud Web Security Scanner Service identifies security vulnerabilities in web - applications hosted on Google Cloud Platform. It crawls your application, and - attempts to exercise as many user inputs and event handlers as possible. - """ - - SERVICE_ADDRESS = "websecurityscanner.googleapis.com:443" - """The default address of the service.""" - - # The name of the interface for this client. This is the key used to - # find the method configuration in the client_config dictionary. - _INTERFACE_NAME = "google.cloud.websecurityscanner.v1beta.WebSecurityScanner" - - @classmethod - def from_service_account_file(cls, filename, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - WebSecurityScannerClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_file(filename) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - from_service_account_json = from_service_account_file - - @classmethod - def finding_path(cls, project, scan_config, scan_run, finding): - """Return a fully-qualified finding string.""" - return google.api_core.path_template.expand( - "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}", - project=project, - scan_config=scan_config, - scan_run=scan_run, - finding=finding, - ) - - @classmethod - def project_path(cls, project): - """Return a fully-qualified project string.""" - return google.api_core.path_template.expand( - "projects/{project}", project=project - ) - - @classmethod - def scan_config_path(cls, project, scan_config): - """Return a fully-qualified scan_config string.""" - return google.api_core.path_template.expand( - "projects/{project}/scanConfigs/{scan_config}", - project=project, - scan_config=scan_config, - ) - - @classmethod - def scan_run_path(cls, project, scan_config, scan_run): - """Return a fully-qualified scan_run string.""" - return google.api_core.path_template.expand( - "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}", - project=project, - scan_config=scan_config, - scan_run=scan_run, - ) - - def __init__( - self, - transport=None, - channel=None, - credentials=None, - client_config=None, - client_info=None, - client_options=None, - ): - """Constructor. - - Args: - transport (Union[~.WebSecurityScannerGrpcTransport, - Callable[[~.Credentials, type], ~.WebSecurityScannerGrpcTransport]): A transport - instance, responsible for actually making the API calls. - The default transport uses the gRPC protocol. - This argument may also be a callable which returns a - transport instance. Callables will be sent the credentials - as the first argument and the default transport class as - the second argument. - channel (grpc.Channel): DEPRECATED. A ``Channel`` instance - through which to make calls. This argument is mutually exclusive - with ``credentials``; providing both will raise an exception. - credentials (google.auth.credentials.Credentials): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is mutually exclusive with providing a - transport instance to ``transport``; doing so will raise - an exception. - client_config (dict): DEPRECATED. A dictionary of call options for - each method. If not specified, the default configuration is used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - client_options (Union[dict, google.api_core.client_options.ClientOptions]): - Client options used to set user options on the client. API Endpoint - should be set through client_options. - """ - # Raise deprecation warnings for things we want to go away. - if client_config is not None: - warnings.warn( - "The `client_config` argument is deprecated.", - PendingDeprecationWarning, - stacklevel=2, - ) - else: - client_config = web_security_scanner_client_config.config - - if channel: - warnings.warn( - "The `channel` argument is deprecated; use " "`transport` instead.", - PendingDeprecationWarning, - stacklevel=2, - ) - - api_endpoint = self.SERVICE_ADDRESS - if client_options: - if type(client_options) == dict: - client_options = google.api_core.client_options.from_dict( - client_options - ) - if client_options.api_endpoint: - api_endpoint = client_options.api_endpoint - - # Instantiate the transport. - # The transport is responsible for handling serialization and - # deserialization and actually sending data to the service. - if transport: - if callable(transport): - self.transport = transport( - credentials=credentials, - default_class=web_security_scanner_grpc_transport.WebSecurityScannerGrpcTransport, - address=api_endpoint, - ) - else: - if credentials: - raise ValueError( - "Received both a transport instance and " - "credentials; these are mutually exclusive." - ) - self.transport = transport - else: - self.transport = web_security_scanner_grpc_transport.WebSecurityScannerGrpcTransport( - address=api_endpoint, channel=channel, credentials=credentials - ) - - if client_info is None: - client_info = google.api_core.gapic_v1.client_info.ClientInfo( - gapic_version=_GAPIC_LIBRARY_VERSION - ) - else: - client_info.gapic_version = _GAPIC_LIBRARY_VERSION - self._client_info = client_info - - # Parse out the default settings for retry and timeout for each RPC - # from the client configuration. - # (Ordinarily, these are the defaults specified in the `*_config.py` - # file next to this one.) - self._method_configs = google.api_core.gapic_v1.config.parse_method_configs( - client_config["interfaces"][self._INTERFACE_NAME] - ) - - # Save a dictionary of cached API call functions. - # These are the actual callables which invoke the proper - # transport methods, wrapped with `wrap_method` to add retry, - # timeout, and the like. - self._inner_api_calls = {} - - # Service calls - def create_scan_config( - self, - parent, - scan_config, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Creates a new ScanConfig. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> parent = client.project_path('[PROJECT]') - >>> - >>> # TODO: Initialize `scan_config`: - >>> scan_config = {} - >>> - >>> response = client.create_scan_config(parent, scan_config) - - Args: - parent (str): Required. The parent resource name where the scan is created, which should be a - project resource name in the format 'projects/{projectId}'. - scan_config (Union[dict, ~google.cloud.websecurityscanner_v1beta.types.ScanConfig]): Required. The ScanConfig to be created. - - If a dict is provided, it must be of the same form as the protobuf - message :class:`~google.cloud.websecurityscanner_v1beta.types.ScanConfig` - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1beta.types.ScanConfig` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "create_scan_config" not in self._inner_api_calls: - self._inner_api_calls[ - "create_scan_config" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.create_scan_config, - default_retry=self._method_configs["CreateScanConfig"].retry, - default_timeout=self._method_configs["CreateScanConfig"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.CreateScanConfigRequest( - parent=parent, scan_config=scan_config - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["create_scan_config"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def delete_scan_config( - self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Deletes an existing ScanConfig and its child resources. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> name = client.scan_config_path('[PROJECT]', '[SCAN_CONFIG]') - >>> - >>> client.delete_scan_config(name) - - Args: - name (str): Required. The resource name of the ScanConfig to be deleted. The name follows the - format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "delete_scan_config" not in self._inner_api_calls: - self._inner_api_calls[ - "delete_scan_config" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.delete_scan_config, - default_retry=self._method_configs["DeleteScanConfig"].retry, - default_timeout=self._method_configs["DeleteScanConfig"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.DeleteScanConfigRequest(name=name) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("name", name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - self._inner_api_calls["delete_scan_config"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def get_scan_config( - self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Gets a ScanConfig. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> name = client.scan_config_path('[PROJECT]', '[SCAN_CONFIG]') - >>> - >>> response = client.get_scan_config(name) - - Args: - name (str): Required. The resource name of the ScanConfig to be returned. The name follows the - format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1beta.types.ScanConfig` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "get_scan_config" not in self._inner_api_calls: - self._inner_api_calls[ - "get_scan_config" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.get_scan_config, - default_retry=self._method_configs["GetScanConfig"].retry, - default_timeout=self._method_configs["GetScanConfig"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.GetScanConfigRequest(name=name) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("name", name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["get_scan_config"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def list_scan_configs( - self, - parent, - page_size=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Lists ScanConfigs under a given project. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> parent = client.project_path('[PROJECT]') - >>> - >>> # Iterate over all results - >>> for element in client.list_scan_configs(parent): - ... # process element - ... pass - >>> - >>> - >>> # Alternatively: - >>> - >>> # Iterate over results one page at a time - >>> for page in client.list_scan_configs(parent).pages: - ... for element in page: - ... # process element - ... pass - - Args: - parent (str): Required. The parent resource name, which should be a project resource name in the - format 'projects/{projectId}'. - page_size (int): The maximum number of resources contained in the - underlying API response. If page streaming is performed per- - resource, this parameter does not affect the return value. If page - streaming is performed per-page, this determines the maximum number - of resources in a page. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.api_core.page_iterator.PageIterator` instance. - An iterable of :class:`~google.cloud.websecurityscanner_v1beta.types.ScanConfig` instances. - You can also iterate over the pages of the response - using its `pages` property. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "list_scan_configs" not in self._inner_api_calls: - self._inner_api_calls[ - "list_scan_configs" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.list_scan_configs, - default_retry=self._method_configs["ListScanConfigs"].retry, - default_timeout=self._method_configs["ListScanConfigs"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.ListScanConfigsRequest( - parent=parent, page_size=page_size - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - iterator = google.api_core.page_iterator.GRPCIterator( - client=None, - method=functools.partial( - self._inner_api_calls["list_scan_configs"], - retry=retry, - timeout=timeout, - metadata=metadata, - ), - request=request, - items_field="scan_configs", - request_token_field="page_token", - response_token_field="next_page_token", - ) - return iterator - - def update_scan_config( - self, - scan_config, - update_mask, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Updates a ScanConfig. This method support partial update of a ScanConfig. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> # TODO: Initialize `scan_config`: - >>> scan_config = {} - >>> - >>> # TODO: Initialize `update_mask`: - >>> update_mask = {} - >>> - >>> response = client.update_scan_config(scan_config, update_mask) - - Args: - scan_config (Union[dict, ~google.cloud.websecurityscanner_v1beta.types.ScanConfig]): Required. The ScanConfig to be updated. The name field must be set to identify the - resource to be updated. The values of fields not covered by the mask - will be ignored. - - If a dict is provided, it must be of the same form as the protobuf - message :class:`~google.cloud.websecurityscanner_v1beta.types.ScanConfig` - update_mask (Union[dict, ~google.cloud.websecurityscanner_v1beta.types.FieldMask]): Required. The update mask applies to the resource. For the ``FieldMask`` - definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - If a dict is provided, it must be of the same form as the protobuf - message :class:`~google.cloud.websecurityscanner_v1beta.types.FieldMask` - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1beta.types.ScanConfig` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "update_scan_config" not in self._inner_api_calls: - self._inner_api_calls[ - "update_scan_config" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.update_scan_config, - default_retry=self._method_configs["UpdateScanConfig"].retry, - default_timeout=self._method_configs["UpdateScanConfig"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.UpdateScanConfigRequest( - scan_config=scan_config, update_mask=update_mask - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("scan_config.name", scan_config.name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["update_scan_config"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def start_scan_run( - self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Start a ScanRun according to the given ScanConfig. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> name = client.scan_config_path('[PROJECT]', '[SCAN_CONFIG]') - >>> - >>> response = client.start_scan_run(name) - - Args: - name (str): Required. The resource name of the ScanConfig to be used. The name follows the - format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1beta.types.ScanRun` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "start_scan_run" not in self._inner_api_calls: - self._inner_api_calls[ - "start_scan_run" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.start_scan_run, - default_retry=self._method_configs["StartScanRun"].retry, - default_timeout=self._method_configs["StartScanRun"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.StartScanRunRequest(name=name) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("name", name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["start_scan_run"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def get_scan_run( - self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Gets a ScanRun. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> name = client.scan_run_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]') - >>> - >>> response = client.get_scan_run(name) - - Args: - name (str): Required. The resource name of the ScanRun to be returned. The name follows the - format of - 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1beta.types.ScanRun` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "get_scan_run" not in self._inner_api_calls: - self._inner_api_calls[ - "get_scan_run" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.get_scan_run, - default_retry=self._method_configs["GetScanRun"].retry, - default_timeout=self._method_configs["GetScanRun"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.GetScanRunRequest(name=name) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("name", name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["get_scan_run"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def list_scan_runs( - self, - parent, - page_size=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Lists ScanRuns under a given ScanConfig, in descending order of ScanRun - stop time. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> parent = client.scan_config_path('[PROJECT]', '[SCAN_CONFIG]') - >>> - >>> # Iterate over all results - >>> for element in client.list_scan_runs(parent): - ... # process element - ... pass - >>> - >>> - >>> # Alternatively: - >>> - >>> # Iterate over results one page at a time - >>> for page in client.list_scan_runs(parent).pages: - ... for element in page: - ... # process element - ... pass - - Args: - parent (str): Required. The parent resource name, which should be a scan resource name in the - format 'projects/{projectId}/scanConfigs/{scanConfigId}'. - page_size (int): The maximum number of resources contained in the - underlying API response. If page streaming is performed per- - resource, this parameter does not affect the return value. If page - streaming is performed per-page, this determines the maximum number - of resources in a page. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.api_core.page_iterator.PageIterator` instance. - An iterable of :class:`~google.cloud.websecurityscanner_v1beta.types.ScanRun` instances. - You can also iterate over the pages of the response - using its `pages` property. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "list_scan_runs" not in self._inner_api_calls: - self._inner_api_calls[ - "list_scan_runs" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.list_scan_runs, - default_retry=self._method_configs["ListScanRuns"].retry, - default_timeout=self._method_configs["ListScanRuns"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.ListScanRunsRequest( - parent=parent, page_size=page_size - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - iterator = google.api_core.page_iterator.GRPCIterator( - client=None, - method=functools.partial( - self._inner_api_calls["list_scan_runs"], - retry=retry, - timeout=timeout, - metadata=metadata, - ), - request=request, - items_field="scan_runs", - request_token_field="page_token", - response_token_field="next_page_token", - ) - return iterator - - def stop_scan_run( - self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Stops a ScanRun. The stopped ScanRun is returned. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> name = client.scan_run_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]') - >>> - >>> response = client.stop_scan_run(name) - - Args: - name (str): Required. The resource name of the ScanRun to be stopped. The name follows the - format of - 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1beta.types.ScanRun` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "stop_scan_run" not in self._inner_api_calls: - self._inner_api_calls[ - "stop_scan_run" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.stop_scan_run, - default_retry=self._method_configs["StopScanRun"].retry, - default_timeout=self._method_configs["StopScanRun"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.StopScanRunRequest(name=name) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("name", name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["stop_scan_run"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def list_crawled_urls( - self, - parent, - page_size=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - List CrawledUrls under a given ScanRun. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> parent = client.scan_run_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]') - >>> - >>> # Iterate over all results - >>> for element in client.list_crawled_urls(parent): - ... # process element - ... pass - >>> - >>> - >>> # Alternatively: - >>> - >>> # Iterate over results one page at a time - >>> for page in client.list_crawled_urls(parent).pages: - ... for element in page: - ... # process element - ... pass - - Args: - parent (str): Required. The parent resource name, which should be a scan run resource name in the - format - 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. - page_size (int): The maximum number of resources contained in the - underlying API response. If page streaming is performed per- - resource, this parameter does not affect the return value. If page - streaming is performed per-page, this determines the maximum number - of resources in a page. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.api_core.page_iterator.PageIterator` instance. - An iterable of :class:`~google.cloud.websecurityscanner_v1beta.types.CrawledUrl` instances. - You can also iterate over the pages of the response - using its `pages` property. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "list_crawled_urls" not in self._inner_api_calls: - self._inner_api_calls[ - "list_crawled_urls" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.list_crawled_urls, - default_retry=self._method_configs["ListCrawledUrls"].retry, - default_timeout=self._method_configs["ListCrawledUrls"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.ListCrawledUrlsRequest( - parent=parent, page_size=page_size - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - iterator = google.api_core.page_iterator.GRPCIterator( - client=None, - method=functools.partial( - self._inner_api_calls["list_crawled_urls"], - retry=retry, - timeout=timeout, - metadata=metadata, - ), - request=request, - items_field="crawled_urls", - request_token_field="page_token", - response_token_field="next_page_token", - ) - return iterator - - def get_finding( - self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Gets a Finding. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> name = client.finding_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]', '[FINDING]') - >>> - >>> response = client.get_finding(name) - - Args: - name (str): Required. The resource name of the Finding to be returned. The name follows the - format of - 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1beta.types.Finding` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "get_finding" not in self._inner_api_calls: - self._inner_api_calls[ - "get_finding" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.get_finding, - default_retry=self._method_configs["GetFinding"].retry, - default_timeout=self._method_configs["GetFinding"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.GetFindingRequest(name=name) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("name", name)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["get_finding"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - - def list_findings( - self, - parent, - filter_, - page_size=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - List Findings under a given ScanRun. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> parent = client.scan_run_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]') - >>> - >>> # TODO: Initialize `filter_`: - >>> filter_ = '' - >>> - >>> # Iterate over all results - >>> for element in client.list_findings(parent, filter_): - ... # process element - ... pass - >>> - >>> - >>> # Alternatively: - >>> - >>> # Iterate over results one page at a time - >>> for page in client.list_findings(parent, filter_).pages: - ... for element in page: - ... # process element - ... pass - - Args: - parent (str): Required. The parent resource name, which should be a scan run resource name in the - format - 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. - filter_ (str): Required. The filter expression. The expression must be in the format: . - Supported field: 'finding\_type'. Supported operator: '='. - page_size (int): The maximum number of resources contained in the - underlying API response. If page streaming is performed per- - resource, this parameter does not affect the return value. If page - streaming is performed per-page, this determines the maximum number - of resources in a page. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.api_core.page_iterator.PageIterator` instance. - An iterable of :class:`~google.cloud.websecurityscanner_v1beta.types.Finding` instances. - You can also iterate over the pages of the response - using its `pages` property. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "list_findings" not in self._inner_api_calls: - self._inner_api_calls[ - "list_findings" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.list_findings, - default_retry=self._method_configs["ListFindings"].retry, - default_timeout=self._method_configs["ListFindings"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.ListFindingsRequest( - parent=parent, filter=filter_, page_size=page_size - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - iterator = google.api_core.page_iterator.GRPCIterator( - client=None, - method=functools.partial( - self._inner_api_calls["list_findings"], - retry=retry, - timeout=timeout, - metadata=metadata, - ), - request=request, - items_field="findings", - request_token_field="page_token", - response_token_field="next_page_token", - ) - return iterator - - def list_finding_type_stats( - self, - parent, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - List all FindingTypeStats under a given ScanRun. - - Example: - >>> from google.cloud import websecurityscanner_v1beta - >>> - >>> client = websecurityscanner_v1beta.WebSecurityScannerClient() - >>> - >>> parent = client.scan_run_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]') - >>> - >>> response = client.list_finding_type_stats(parent) - - Args: - parent (str): Required. The parent resource name, which should be a scan run resource name in the - format - 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.websecurityscanner_v1beta.types.ListFindingTypeStatsResponse` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "list_finding_type_stats" not in self._inner_api_calls: - self._inner_api_calls[ - "list_finding_type_stats" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.list_finding_type_stats, - default_retry=self._method_configs["ListFindingTypeStats"].retry, - default_timeout=self._method_configs["ListFindingTypeStats"].timeout, - client_info=self._client_info, - ) - - request = web_security_scanner_pb2.ListFindingTypeStatsRequest(parent=parent) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["list_finding_type_stats"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) diff --git a/google/cloud/websecurityscanner_v1beta/gapic/web_security_scanner_client_config.py b/google/cloud/websecurityscanner_v1beta/gapic/web_security_scanner_client_config.py deleted file mode 100644 index 61dafbb..0000000 --- a/google/cloud/websecurityscanner_v1beta/gapic/web_security_scanner_client_config.py +++ /dev/null @@ -1,88 +0,0 @@ -config = { - "interfaces": { - "google.cloud.websecurityscanner.v1beta.WebSecurityScanner": { - "retry_codes": { - "idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"], - "non_idempotent": [], - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000, - } - }, - "methods": { - "CreateScanConfig": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default", - }, - "DeleteScanConfig": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default", - }, - "GetScanConfig": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "ListScanConfigs": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "UpdateScanConfig": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default", - }, - "StartScanRun": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default", - }, - "GetScanRun": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "ListScanRuns": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "StopScanRun": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default", - }, - "ListCrawledUrls": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "GetFinding": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "ListFindings": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "ListFindingTypeStats": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - }, - } - } -} diff --git a/google/cloud/websecurityscanner_v1beta/proto/__init__.py b/google/cloud/websecurityscanner_v1beta/proto/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/google/cloud/websecurityscanner_v1beta/proto/crawled_url_pb2.py b/google/cloud/websecurityscanner_v1beta/proto/crawled_url_pb2.py deleted file mode 100644 index 02dd955..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/crawled_url_pb2.py +++ /dev/null @@ -1,136 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1beta/proto/crawled_url.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1beta/proto/crawled_url.proto", - package="google.cloud.websecurityscanner.v1beta", - syntax="proto3", - serialized_options=_b( - "\n*com.google.cloud.websecurityscanner.v1betaB\017CrawledUrlProtoP\001ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\312\002&Google\\Cloud\\WebSecurityScanner\\V1beta" - ), - serialized_pb=_b( - '\n>google/cloud/websecurityscanner_v1beta/proto/crawled_url.proto\x12&google.cloud.websecurityscanner.v1beta"<\n\nCrawledUrl\x12\x13\n\x0bhttp_method\x18\x01 \x01(\t\x12\x0b\n\x03url\x18\x02 \x01(\t\x12\x0c\n\x04\x62ody\x18\x03 \x01(\tB\xc2\x01\n*com.google.cloud.websecurityscanner.v1betaB\x0f\x43rawledUrlProtoP\x01ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\xca\x02&Google\\Cloud\\WebSecurityScanner\\V1betab\x06proto3' - ), -) - - -_CRAWLEDURL = _descriptor.Descriptor( - name="CrawledUrl", - full_name="google.cloud.websecurityscanner.v1beta.CrawledUrl", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="http_method", - full_name="google.cloud.websecurityscanner.v1beta.CrawledUrl.http_method", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="url", - full_name="google.cloud.websecurityscanner.v1beta.CrawledUrl.url", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="body", - full_name="google.cloud.websecurityscanner.v1beta.CrawledUrl.body", - index=2, - number=3, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=106, - serialized_end=166, -) - -DESCRIPTOR.message_types_by_name["CrawledUrl"] = _CRAWLEDURL -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -CrawledUrl = _reflection.GeneratedProtocolMessageType( - "CrawledUrl", - (_message.Message,), - dict( - DESCRIPTOR=_CRAWLEDURL, - __module__="google.cloud.websecurityscanner_v1beta.proto.crawled_url_pb2", - __doc__="""A CrawledUrl resource represents a URL that was crawled - during a ScanRun. Web Security Scanner Service crawls the web - applications, following all links within the scope of sites, to find the - URLs to test against. - - - Attributes: - http_method: - The http method of the request that was used to visit the URL, - in uppercase. - url: - The URL that was crawled. - body: - The body of the request that was used to visit the URL. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.CrawledUrl) - ), -) -_sym_db.RegisterMessage(CrawledUrl) - - -DESCRIPTOR._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1beta/proto/crawled_url_pb2_grpc.py b/google/cloud/websecurityscanner_v1beta/proto/crawled_url_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/crawled_url_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1beta/proto/finding_addon_pb2.py b/google/cloud/websecurityscanner_v1beta/proto/finding_addon_pb2.py deleted file mode 100644 index c9eeda7..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/finding_addon_pb2.py +++ /dev/null @@ -1,584 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1beta/proto/finding_addon.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1beta/proto/finding_addon.proto", - package="google.cloud.websecurityscanner.v1beta", - syntax="proto3", - serialized_options=_b( - "\n*com.google.cloud.websecurityscanner.v1betaB\021FindingAddonProtoP\001ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\312\002&Google\\Cloud\\WebSecurityScanner\\V1beta" - ), - serialized_pb=_b( - '\n@google/cloud/websecurityscanner_v1beta/proto/finding_addon.proto\x12&google.cloud.websecurityscanner.v1beta"*\n\x04\x46orm\x12\x12\n\naction_uri\x18\x01 \x01(\t\x12\x0e\n\x06\x66ields\x18\x02 \x03(\t"Q\n\x0fOutdatedLibrary\x12\x14\n\x0clibrary_name\x18\x01 \x01(\t\x12\x0f\n\x07version\x18\x02 \x01(\t\x12\x17\n\x0flearn_more_urls\x18\x03 \x03(\t"?\n\x11ViolatingResource\x12\x14\n\x0c\x63ontent_type\x18\x01 \x01(\t\x12\x14\n\x0cresource_url\x18\x02 \x01(\t"/\n\x14VulnerableParameters\x12\x17\n\x0fparameter_names\x18\x01 \x03(\t"\xe8\x01\n\x11VulnerableHeaders\x12Q\n\x07headers\x18\x01 \x03(\x0b\x32@.google.cloud.websecurityscanner.v1beta.VulnerableHeaders.Header\x12Y\n\x0fmissing_headers\x18\x02 \x03(\x0b\x32@.google.cloud.websecurityscanner.v1beta.VulnerableHeaders.Header\x1a%\n\x06Header\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t"2\n\x03Xss\x12\x14\n\x0cstack_traces\x18\x01 \x03(\t\x12\x15\n\rerror_message\x18\x02 \x01(\tB\xc4\x01\n*com.google.cloud.websecurityscanner.v1betaB\x11\x46indingAddonProtoP\x01ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\xca\x02&Google\\Cloud\\WebSecurityScanner\\V1betab\x06proto3' - ), -) - - -_FORM = _descriptor.Descriptor( - name="Form", - full_name="google.cloud.websecurityscanner.v1beta.Form", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="action_uri", - full_name="google.cloud.websecurityscanner.v1beta.Form.action_uri", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="fields", - full_name="google.cloud.websecurityscanner.v1beta.Form.fields", - index=1, - number=2, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=108, - serialized_end=150, -) - - -_OUTDATEDLIBRARY = _descriptor.Descriptor( - name="OutdatedLibrary", - full_name="google.cloud.websecurityscanner.v1beta.OutdatedLibrary", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="library_name", - full_name="google.cloud.websecurityscanner.v1beta.OutdatedLibrary.library_name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="version", - full_name="google.cloud.websecurityscanner.v1beta.OutdatedLibrary.version", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="learn_more_urls", - full_name="google.cloud.websecurityscanner.v1beta.OutdatedLibrary.learn_more_urls", - index=2, - number=3, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=152, - serialized_end=233, -) - - -_VIOLATINGRESOURCE = _descriptor.Descriptor( - name="ViolatingResource", - full_name="google.cloud.websecurityscanner.v1beta.ViolatingResource", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="content_type", - full_name="google.cloud.websecurityscanner.v1beta.ViolatingResource.content_type", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="resource_url", - full_name="google.cloud.websecurityscanner.v1beta.ViolatingResource.resource_url", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=235, - serialized_end=298, -) - - -_VULNERABLEPARAMETERS = _descriptor.Descriptor( - name="VulnerableParameters", - full_name="google.cloud.websecurityscanner.v1beta.VulnerableParameters", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parameter_names", - full_name="google.cloud.websecurityscanner.v1beta.VulnerableParameters.parameter_names", - index=0, - number=1, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=300, - serialized_end=347, -) - - -_VULNERABLEHEADERS_HEADER = _descriptor.Descriptor( - name="Header", - full_name="google.cloud.websecurityscanner.v1beta.VulnerableHeaders.Header", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1beta.VulnerableHeaders.Header.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="value", - full_name="google.cloud.websecurityscanner.v1beta.VulnerableHeaders.Header.value", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=545, - serialized_end=582, -) - -_VULNERABLEHEADERS = _descriptor.Descriptor( - name="VulnerableHeaders", - full_name="google.cloud.websecurityscanner.v1beta.VulnerableHeaders", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="headers", - full_name="google.cloud.websecurityscanner.v1beta.VulnerableHeaders.headers", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="missing_headers", - full_name="google.cloud.websecurityscanner.v1beta.VulnerableHeaders.missing_headers", - index=1, - number=2, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[_VULNERABLEHEADERS_HEADER], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=350, - serialized_end=582, -) - - -_XSS = _descriptor.Descriptor( - name="Xss", - full_name="google.cloud.websecurityscanner.v1beta.Xss", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="stack_traces", - full_name="google.cloud.websecurityscanner.v1beta.Xss.stack_traces", - index=0, - number=1, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="error_message", - full_name="google.cloud.websecurityscanner.v1beta.Xss.error_message", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=584, - serialized_end=634, -) - -_VULNERABLEHEADERS_HEADER.containing_type = _VULNERABLEHEADERS -_VULNERABLEHEADERS.fields_by_name["headers"].message_type = _VULNERABLEHEADERS_HEADER -_VULNERABLEHEADERS.fields_by_name[ - "missing_headers" -].message_type = _VULNERABLEHEADERS_HEADER -DESCRIPTOR.message_types_by_name["Form"] = _FORM -DESCRIPTOR.message_types_by_name["OutdatedLibrary"] = _OUTDATEDLIBRARY -DESCRIPTOR.message_types_by_name["ViolatingResource"] = _VIOLATINGRESOURCE -DESCRIPTOR.message_types_by_name["VulnerableParameters"] = _VULNERABLEPARAMETERS -DESCRIPTOR.message_types_by_name["VulnerableHeaders"] = _VULNERABLEHEADERS -DESCRIPTOR.message_types_by_name["Xss"] = _XSS -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -Form = _reflection.GeneratedProtocolMessageType( - "Form", - (_message.Message,), - dict( - DESCRIPTOR=_FORM, - __module__="google.cloud.websecurityscanner_v1beta.proto.finding_addon_pb2", - __doc__="""! Information about a vulnerability with an HTML. - - - Attributes: - action_uri: - ! The URI where to send the form when it's submitted. - fields: - ! The names of form fields related to the vulnerability. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.Form) - ), -) -_sym_db.RegisterMessage(Form) - -OutdatedLibrary = _reflection.GeneratedProtocolMessageType( - "OutdatedLibrary", - (_message.Message,), - dict( - DESCRIPTOR=_OUTDATEDLIBRARY, - __module__="google.cloud.websecurityscanner_v1beta.proto.finding_addon_pb2", - __doc__="""Information reported for an outdated library. - - - Attributes: - library_name: - The name of the outdated library. - version: - The version number. - learn_more_urls: - URLs to learn more information about the vulnerabilities in - the library. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.OutdatedLibrary) - ), -) -_sym_db.RegisterMessage(OutdatedLibrary) - -ViolatingResource = _reflection.GeneratedProtocolMessageType( - "ViolatingResource", - (_message.Message,), - dict( - DESCRIPTOR=_VIOLATINGRESOURCE, - __module__="google.cloud.websecurityscanner_v1beta.proto.finding_addon_pb2", - __doc__="""Information regarding any resource causing the - vulnerability such as JavaScript sources, image, audio files, etc. - - - Attributes: - content_type: - The MIME type of this resource. - resource_url: - URL of this violating resource. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ViolatingResource) - ), -) -_sym_db.RegisterMessage(ViolatingResource) - -VulnerableParameters = _reflection.GeneratedProtocolMessageType( - "VulnerableParameters", - (_message.Message,), - dict( - DESCRIPTOR=_VULNERABLEPARAMETERS, - __module__="google.cloud.websecurityscanner_v1beta.proto.finding_addon_pb2", - __doc__="""Information about vulnerable request parameters. - - - Attributes: - parameter_names: - The vulnerable parameter names. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.VulnerableParameters) - ), -) -_sym_db.RegisterMessage(VulnerableParameters) - -VulnerableHeaders = _reflection.GeneratedProtocolMessageType( - "VulnerableHeaders", - (_message.Message,), - dict( - Header=_reflection.GeneratedProtocolMessageType( - "Header", - (_message.Message,), - dict( - DESCRIPTOR=_VULNERABLEHEADERS_HEADER, - __module__="google.cloud.websecurityscanner_v1beta.proto.finding_addon_pb2", - __doc__="""Describes a HTTP Header. - - - Attributes: - name: - Header name. - value: - Header value. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.VulnerableHeaders.Header) - ), - ), - DESCRIPTOR=_VULNERABLEHEADERS, - __module__="google.cloud.websecurityscanner_v1beta.proto.finding_addon_pb2", - __doc__="""Information about vulnerable or missing HTTP Headers. - - - Attributes: - headers: - List of vulnerable headers. - missing_headers: - List of missing headers. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.VulnerableHeaders) - ), -) -_sym_db.RegisterMessage(VulnerableHeaders) -_sym_db.RegisterMessage(VulnerableHeaders.Header) - -Xss = _reflection.GeneratedProtocolMessageType( - "Xss", - (_message.Message,), - dict( - DESCRIPTOR=_XSS, - __module__="google.cloud.websecurityscanner_v1beta.proto.finding_addon_pb2", - __doc__="""Information reported for an XSS. - - - Attributes: - stack_traces: - Stack traces leading to the point where the XSS occurred. - error_message: - An error message generated by a javascript breakage. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.Xss) - ), -) -_sym_db.RegisterMessage(Xss) - - -DESCRIPTOR._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1beta/proto/finding_addon_pb2_grpc.py b/google/cloud/websecurityscanner_v1beta/proto/finding_addon_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/finding_addon_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1beta/proto/finding_pb2.py b/google/cloud/websecurityscanner_v1beta/proto/finding_pb2.py deleted file mode 100644 index a17e7ca..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/finding_pb2.py +++ /dev/null @@ -1,453 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1beta/proto/finding.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 -from google.cloud.websecurityscanner_v1beta.proto import ( - finding_addon_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__addon__pb2, -) - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1beta/proto/finding.proto", - package="google.cloud.websecurityscanner.v1beta", - syntax="proto3", - serialized_options=_b( - "\n*com.google.cloud.websecurityscanner.v1betaB\014FindingProtoP\001ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\312\002&Google\\Cloud\\WebSecurityScanner\\V1beta" - ), - serialized_pb=_b( - '\n:google/cloud/websecurityscanner_v1beta/proto/finding.proto\x12&google.cloud.websecurityscanner.v1beta\x1a\x19google/api/resource.proto\x1a@google/cloud/websecurityscanner_v1beta/proto/finding_addon.proto"\xa9\x06\n\x07\x46inding\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0c\x66inding_type\x18\x02 \x01(\t\x12\x13\n\x0bhttp_method\x18\x03 \x01(\t\x12\x12\n\nfuzzed_url\x18\x04 \x01(\t\x12\x0c\n\x04\x62ody\x18\x05 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x06 \x01(\t\x12\x18\n\x10reproduction_url\x18\x07 \x01(\t\x12\x11\n\tframe_url\x18\x08 \x01(\t\x12\x11\n\tfinal_url\x18\t \x01(\t\x12\x13\n\x0btracking_id\x18\n \x01(\t\x12:\n\x04\x66orm\x18\x10 \x01(\x0b\x32,.google.cloud.websecurityscanner.v1beta.Form\x12Q\n\x10outdated_library\x18\x0b \x01(\x0b\x32\x37.google.cloud.websecurityscanner.v1beta.OutdatedLibrary\x12U\n\x12violating_resource\x18\x0c \x01(\x0b\x32\x39.google.cloud.websecurityscanner.v1beta.ViolatingResource\x12U\n\x12vulnerable_headers\x18\x0f \x01(\x0b\x32\x39.google.cloud.websecurityscanner.v1beta.VulnerableHeaders\x12[\n\x15vulnerable_parameters\x18\r \x01(\x0b\x32<.google.cloud.websecurityscanner.v1beta.VulnerableParameters\x12\x38\n\x03xss\x18\x0e \x01(\x0b\x32+.google.cloud.websecurityscanner.v1beta.Xss:\x84\x01\xea\x41\x80\x01\n)websecurityscanner.googleapis.com/Finding\x12Sprojects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}B\xbf\x01\n*com.google.cloud.websecurityscanner.v1betaB\x0c\x46indingProtoP\x01ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\xca\x02&Google\\Cloud\\WebSecurityScanner\\V1betab\x06proto3' - ), - dependencies=[ - google_dot_api_dot_resource__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__addon__pb2.DESCRIPTOR, - ], -) - - -_FINDING = _descriptor.Descriptor( - name="Finding", - full_name="google.cloud.websecurityscanner.v1beta.Finding", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1beta.Finding.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="finding_type", - full_name="google.cloud.websecurityscanner.v1beta.Finding.finding_type", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="http_method", - full_name="google.cloud.websecurityscanner.v1beta.Finding.http_method", - index=2, - number=3, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="fuzzed_url", - full_name="google.cloud.websecurityscanner.v1beta.Finding.fuzzed_url", - index=3, - number=4, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="body", - full_name="google.cloud.websecurityscanner.v1beta.Finding.body", - index=4, - number=5, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="description", - full_name="google.cloud.websecurityscanner.v1beta.Finding.description", - index=5, - number=6, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="reproduction_url", - full_name="google.cloud.websecurityscanner.v1beta.Finding.reproduction_url", - index=6, - number=7, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="frame_url", - full_name="google.cloud.websecurityscanner.v1beta.Finding.frame_url", - index=7, - number=8, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="final_url", - full_name="google.cloud.websecurityscanner.v1beta.Finding.final_url", - index=8, - number=9, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="tracking_id", - full_name="google.cloud.websecurityscanner.v1beta.Finding.tracking_id", - index=9, - number=10, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="form", - full_name="google.cloud.websecurityscanner.v1beta.Finding.form", - index=10, - number=16, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="outdated_library", - full_name="google.cloud.websecurityscanner.v1beta.Finding.outdated_library", - index=11, - number=11, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="violating_resource", - full_name="google.cloud.websecurityscanner.v1beta.Finding.violating_resource", - index=12, - number=12, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="vulnerable_headers", - full_name="google.cloud.websecurityscanner.v1beta.Finding.vulnerable_headers", - index=13, - number=15, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="vulnerable_parameters", - full_name="google.cloud.websecurityscanner.v1beta.Finding.vulnerable_parameters", - index=14, - number=13, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="xss", - full_name="google.cloud.websecurityscanner.v1beta.Finding.xss", - index=15, - number=14, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=_b( - "\352A\200\001\n)websecurityscanner.googleapis.com/Finding\022Sprojects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}" - ), - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=196, - serialized_end=1005, -) - -_FINDING.fields_by_name[ - "form" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__addon__pb2._FORM -) -_FINDING.fields_by_name[ - "outdated_library" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__addon__pb2._OUTDATEDLIBRARY -) -_FINDING.fields_by_name[ - "violating_resource" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__addon__pb2._VIOLATINGRESOURCE -) -_FINDING.fields_by_name[ - "vulnerable_headers" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__addon__pb2._VULNERABLEHEADERS -) -_FINDING.fields_by_name[ - "vulnerable_parameters" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__addon__pb2._VULNERABLEPARAMETERS -) -_FINDING.fields_by_name[ - "xss" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__addon__pb2._XSS -) -DESCRIPTOR.message_types_by_name["Finding"] = _FINDING -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -Finding = _reflection.GeneratedProtocolMessageType( - "Finding", - (_message.Message,), - dict( - DESCRIPTOR=_FINDING, - __module__="google.cloud.websecurityscanner_v1beta.proto.finding_pb2", - __doc__="""A Finding resource represents a vulnerability instance - identified during a ScanRun. - - - Attributes: - name: - The resource name of the Finding. The name follows the format - of 'projects/{projectId}/scanConfigs/{scanConfigId}/scanruns/{ - scanRunId}/findings/{findingId}'. The finding IDs are - generated by the system. - finding_type: - The type of the Finding. Detailed and up-to-date information - on findings can be found here: - https://cloud.google.com/security-scanner/docs/scan-result- - details - http_method: - The http method of the request that triggered the - vulnerability, in uppercase. - fuzzed_url: - The URL produced by the server-side fuzzer and used in the - request that triggered the vulnerability. - body: - The body of the request that triggered the vulnerability. - description: - The description of the vulnerability. - reproduction_url: - The URL containing human-readable payload that user can - leverage to reproduce the vulnerability. - frame_url: - If the vulnerability was originated from nested IFrame, the - immediate parent IFrame is reported. - final_url: - The URL where the browser lands when the vulnerability is - detected. - tracking_id: - The tracking ID uniquely identifies a vulnerability instance - across multiple ScanRuns. - form: - An addon containing information reported for a vulnerability - with an HTML form, if any. - outdated_library: - An addon containing information about outdated libraries. - violating_resource: - An addon containing detailed information regarding any - resource causing the vulnerability such as JavaScript sources, - image, audio files, etc. - vulnerable_headers: - An addon containing information about vulnerable or missing - HTTP headers. - vulnerable_parameters: - An addon containing information about request parameters which - were found to be vulnerable. - xss: - An addon containing information reported for an XSS, if any. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.Finding) - ), -) -_sym_db.RegisterMessage(Finding) - - -DESCRIPTOR._options = None -_FINDING._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1beta/proto/finding_pb2_grpc.py b/google/cloud/websecurityscanner_v1beta/proto/finding_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/finding_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1beta/proto/finding_type_stats_pb2.py b/google/cloud/websecurityscanner_v1beta/proto/finding_type_stats_pb2.py deleted file mode 100644 index dd944cb..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/finding_type_stats_pb2.py +++ /dev/null @@ -1,113 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1beta/proto/finding_type_stats.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1beta/proto/finding_type_stats.proto", - package="google.cloud.websecurityscanner.v1beta", - syntax="proto3", - serialized_options=_b( - "\n*com.google.cloud.websecurityscanner.v1betaB\025FindingTypeStatsProtoP\001ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\312\002&Google\\Cloud\\WebSecurityScanner\\V1beta" - ), - serialized_pb=_b( - '\nEgoogle/cloud/websecurityscanner_v1beta/proto/finding_type_stats.proto\x12&google.cloud.websecurityscanner.v1beta"?\n\x10\x46indingTypeStats\x12\x14\n\x0c\x66inding_type\x18\x01 \x01(\t\x12\x15\n\rfinding_count\x18\x02 \x01(\x05\x42\xc8\x01\n*com.google.cloud.websecurityscanner.v1betaB\x15\x46indingTypeStatsProtoP\x01ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\xca\x02&Google\\Cloud\\WebSecurityScanner\\V1betab\x06proto3' - ), -) - - -_FINDINGTYPESTATS = _descriptor.Descriptor( - name="FindingTypeStats", - full_name="google.cloud.websecurityscanner.v1beta.FindingTypeStats", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="finding_type", - full_name="google.cloud.websecurityscanner.v1beta.FindingTypeStats.finding_type", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="finding_count", - full_name="google.cloud.websecurityscanner.v1beta.FindingTypeStats.finding_count", - index=1, - number=2, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=113, - serialized_end=176, -) - -DESCRIPTOR.message_types_by_name["FindingTypeStats"] = _FINDINGTYPESTATS -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -FindingTypeStats = _reflection.GeneratedProtocolMessageType( - "FindingTypeStats", - (_message.Message,), - dict( - DESCRIPTOR=_FINDINGTYPESTATS, - __module__="google.cloud.websecurityscanner_v1beta.proto.finding_type_stats_pb2", - __doc__="""A FindingTypeStats resource represents stats regarding a - specific FindingType of Findings under a given ScanRun. - - - Attributes: - finding_type: - The finding type associated with the stats. - finding_count: - The count of findings belonging to this finding type. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.FindingTypeStats) - ), -) -_sym_db.RegisterMessage(FindingTypeStats) - - -DESCRIPTOR._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1beta/proto/finding_type_stats_pb2_grpc.py b/google/cloud/websecurityscanner_v1beta/proto/finding_type_stats_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/finding_type_stats_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1beta/proto/scan_config_error_pb2.py b/google/cloud/websecurityscanner_v1beta/proto/scan_config_error_pb2.py deleted file mode 100644 index ce90e7d..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/scan_config_error_pb2.py +++ /dev/null @@ -1,422 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1beta/proto/scan_config_error.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1beta/proto/scan_config_error.proto", - package="google.cloud.websecurityscanner.v1beta", - syntax="proto3", - serialized_options=_b( - "\n*com.google.cloud.websecurityscanner.v1betaB\024ScanConfigErrorProtoP\001ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\312\002&Google\\Cloud\\WebSecurityScanner\\V1beta" - ), - serialized_pb=_b( - '\nDgoogle/cloud/websecurityscanner_v1beta/proto/scan_config_error.proto\x12&google.cloud.websecurityscanner.v1beta"\xed\x0b\n\x0fScanConfigError\x12J\n\x04\x63ode\x18\x01 \x01(\x0e\x32<.google.cloud.websecurityscanner.v1beta.ScanConfigError.Code\x12\x12\n\nfield_name\x18\x02 \x01(\t"\xf9\n\n\x04\x43ode\x12\x14\n\x10\x43ODE_UNSPECIFIED\x10\x00\x12\x06\n\x02OK\x10\x00\x12\x12\n\x0eINTERNAL_ERROR\x10\x01\x12\x1f\n\x1b\x41PPENGINE_API_BACKEND_ERROR\x10\x02\x12 \n\x1c\x41PPENGINE_API_NOT_ACCESSIBLE\x10\x03\x12"\n\x1e\x41PPENGINE_DEFAULT_HOST_MISSING\x10\x04\x12!\n\x1d\x43\x41NNOT_USE_GOOGLE_COM_ACCOUNT\x10\x06\x12\x1c\n\x18\x43\x41NNOT_USE_OWNER_ACCOUNT\x10\x07\x12\x1d\n\x19\x43OMPUTE_API_BACKEND_ERROR\x10\x08\x12\x1e\n\x1a\x43OMPUTE_API_NOT_ACCESSIBLE\x10\t\x12\x37\n3CUSTOM_LOGIN_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT\x10\n\x12\x1e\n\x1a\x43USTOM_LOGIN_URL_MALFORMED\x10\x0b\x12\x33\n/CUSTOM_LOGIN_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS\x10\x0c\x12\x31\n-CUSTOM_LOGIN_URL_MAPPED_TO_UNRESERVED_ADDRESS\x10\r\x12\x30\n,CUSTOM_LOGIN_URL_HAS_NON_ROUTABLE_IP_ADDRESS\x10\x0e\x12.\n*CUSTOM_LOGIN_URL_HAS_UNRESERVED_IP_ADDRESS\x10\x0f\x12\x17\n\x13\x44UPLICATE_SCAN_NAME\x10\x10\x12\x17\n\x13INVALID_FIELD_VALUE\x10\x12\x12$\n FAILED_TO_AUTHENTICATE_TO_TARGET\x10\x13\x12\x1c\n\x18\x46INDING_TYPE_UNSPECIFIED\x10\x14\x12\x1d\n\x19\x46ORBIDDEN_TO_SCAN_COMPUTE\x10\x15\x12$\n FORBIDDEN_UPDATE_TO_MANAGED_SCAN\x10+\x12\x14\n\x10MALFORMED_FILTER\x10\x16\x12\x1b\n\x17MALFORMED_RESOURCE_NAME\x10\x17\x12\x14\n\x10PROJECT_INACTIVE\x10\x18\x12\x12\n\x0eREQUIRED_FIELD\x10\x19\x12\x1e\n\x1aRESOURCE_NAME_INCONSISTENT\x10\x1a\x12\x18\n\x14SCAN_ALREADY_RUNNING\x10\x1b\x12\x14\n\x10SCAN_NOT_RUNNING\x10\x1c\x12/\n+SEED_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT\x10\x1d\x12\x16\n\x12SEED_URL_MALFORMED\x10\x1e\x12+\n\'SEED_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS\x10\x1f\x12)\n%SEED_URL_MAPPED_TO_UNRESERVED_ADDRESS\x10 \x12(\n$SEED_URL_HAS_NON_ROUTABLE_IP_ADDRESS\x10!\x12&\n"SEED_URL_HAS_UNRESERVED_IP_ADDRESS\x10#\x12"\n\x1eSERVICE_ACCOUNT_NOT_CONFIGURED\x10$\x12\x12\n\x0eTOO_MANY_SCANS\x10%\x12"\n\x1eUNABLE_TO_RESOLVE_PROJECT_INFO\x10&\x12(\n$UNSUPPORTED_BLACKLIST_PATTERN_FORMAT\x10\'\x12\x16\n\x12UNSUPPORTED_FILTER\x10(\x12\x1c\n\x18UNSUPPORTED_FINDING_TYPE\x10)\x12\x1a\n\x16UNSUPPORTED_URL_SCHEME\x10*\x1a\x02\x10\x01\x42\xc7\x01\n*com.google.cloud.websecurityscanner.v1betaB\x14ScanConfigErrorProtoP\x01ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\xca\x02&Google\\Cloud\\WebSecurityScanner\\V1betab\x06proto3' - ), -) - - -_SCANCONFIGERROR_CODE = _descriptor.EnumDescriptor( - name="Code", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfigError.Code", - filename=None, - file=DESCRIPTOR, - values=[ - _descriptor.EnumValueDescriptor( - name="CODE_UNSPECIFIED", - index=0, - number=0, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="OK", index=1, number=0, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="INTERNAL_ERROR", index=2, number=1, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="APPENGINE_API_BACKEND_ERROR", - index=3, - number=2, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="APPENGINE_API_NOT_ACCESSIBLE", - index=4, - number=3, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="APPENGINE_DEFAULT_HOST_MISSING", - index=5, - number=4, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="CANNOT_USE_GOOGLE_COM_ACCOUNT", - index=6, - number=6, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="CANNOT_USE_OWNER_ACCOUNT", - index=7, - number=7, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="COMPUTE_API_BACKEND_ERROR", - index=8, - number=8, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="COMPUTE_API_NOT_ACCESSIBLE", - index=9, - number=9, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="CUSTOM_LOGIN_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT", - index=10, - number=10, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="CUSTOM_LOGIN_URL_MALFORMED", - index=11, - number=11, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="CUSTOM_LOGIN_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS", - index=12, - number=12, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="CUSTOM_LOGIN_URL_MAPPED_TO_UNRESERVED_ADDRESS", - index=13, - number=13, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="CUSTOM_LOGIN_URL_HAS_NON_ROUTABLE_IP_ADDRESS", - index=14, - number=14, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="CUSTOM_LOGIN_URL_HAS_UNRESERVED_IP_ADDRESS", - index=15, - number=15, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="DUPLICATE_SCAN_NAME", - index=16, - number=16, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="INVALID_FIELD_VALUE", - index=17, - number=18, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="FAILED_TO_AUTHENTICATE_TO_TARGET", - index=18, - number=19, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="FINDING_TYPE_UNSPECIFIED", - index=19, - number=20, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="FORBIDDEN_TO_SCAN_COMPUTE", - index=20, - number=21, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="FORBIDDEN_UPDATE_TO_MANAGED_SCAN", - index=21, - number=43, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="MALFORMED_FILTER", - index=22, - number=22, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="MALFORMED_RESOURCE_NAME", - index=23, - number=23, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="PROJECT_INACTIVE", - index=24, - number=24, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="REQUIRED_FIELD", - index=25, - number=25, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="RESOURCE_NAME_INCONSISTENT", - index=26, - number=26, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="SCAN_ALREADY_RUNNING", - index=27, - number=27, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="SCAN_NOT_RUNNING", - index=28, - number=28, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="SEED_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT", - index=29, - number=29, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="SEED_URL_MALFORMED", - index=30, - number=30, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="SEED_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS", - index=31, - number=31, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="SEED_URL_MAPPED_TO_UNRESERVED_ADDRESS", - index=32, - number=32, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="SEED_URL_HAS_NON_ROUTABLE_IP_ADDRESS", - index=33, - number=33, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="SEED_URL_HAS_UNRESERVED_IP_ADDRESS", - index=34, - number=35, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="SERVICE_ACCOUNT_NOT_CONFIGURED", - index=35, - number=36, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="TOO_MANY_SCANS", - index=36, - number=37, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="UNABLE_TO_RESOLVE_PROJECT_INFO", - index=37, - number=38, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="UNSUPPORTED_BLACKLIST_PATTERN_FORMAT", - index=38, - number=39, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="UNSUPPORTED_FILTER", - index=39, - number=40, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="UNSUPPORTED_FINDING_TYPE", - index=40, - number=41, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="UNSUPPORTED_URL_SCHEME", - index=41, - number=42, - serialized_options=None, - type=None, - ), - ], - containing_type=None, - serialized_options=_b("\020\001"), - serialized_start=229, - serialized_end=1630, -) -_sym_db.RegisterEnumDescriptor(_SCANCONFIGERROR_CODE) - - -_SCANCONFIGERROR = _descriptor.Descriptor( - name="ScanConfigError", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfigError", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="code", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfigError.code", - index=0, - number=1, - type=14, - cpp_type=8, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="field_name", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfigError.field_name", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[_SCANCONFIGERROR_CODE], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=113, - serialized_end=1630, -) - -_SCANCONFIGERROR.fields_by_name["code"].enum_type = _SCANCONFIGERROR_CODE -_SCANCONFIGERROR_CODE.containing_type = _SCANCONFIGERROR -DESCRIPTOR.message_types_by_name["ScanConfigError"] = _SCANCONFIGERROR -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -ScanConfigError = _reflection.GeneratedProtocolMessageType( - "ScanConfigError", - (_message.Message,), - dict( - DESCRIPTOR=_SCANCONFIGERROR, - __module__="google.cloud.websecurityscanner_v1beta.proto.scan_config_error_pb2", - __doc__="""Defines a custom error message used by CreateScanConfig - and UpdateScanConfig APIs when scan configuration validation fails. It - is also reported as part of a ScanRunErrorTrace message if scan - validation fails due to a scan configuration error. - - - Attributes: - code: - Indicates the reason code for a configuration failure. - field_name: - Indicates the full name of the ScanConfig field that triggers - this error, for example "scan\_config.max\_qps". This field is - provided for troubleshooting purposes only and its actual - value can change in the future. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ScanConfigError) - ), -) -_sym_db.RegisterMessage(ScanConfigError) - - -DESCRIPTOR._options = None -_SCANCONFIGERROR_CODE._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1beta/proto/scan_config_error_pb2_grpc.py b/google/cloud/websecurityscanner_v1beta/proto/scan_config_error_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/scan_config_error_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1beta/proto/scan_config_pb2.py b/google/cloud/websecurityscanner_v1beta/proto/scan_config_pb2.py deleted file mode 100644 index dadf657..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/scan_config_pb2.py +++ /dev/null @@ -1,848 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1beta/proto/scan_config.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 -from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 -from google.cloud.websecurityscanner_v1beta.proto import ( - scan_run_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2, -) -from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1beta/proto/scan_config.proto", - package="google.cloud.websecurityscanner.v1beta", - syntax="proto3", - serialized_options=_b( - "\n*com.google.cloud.websecurityscanner.v1betaB\017ScanConfigProtoP\001ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\312\002&Google\\Cloud\\WebSecurityScanner\\V1beta" - ), - serialized_pb=_b( - '\n>google/cloud/websecurityscanner_v1beta/proto/scan_config.proto\x12&google.cloud.websecurityscanner.v1beta\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a;google/cloud/websecurityscanner_v1beta/proto/scan_run.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xa6\r\n\nScanConfig\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x19\n\x0c\x64isplay_name\x18\x02 \x01(\tB\x03\xe0\x41\x02\x12\x0f\n\x07max_qps\x18\x03 \x01(\x05\x12\x1a\n\rstarting_urls\x18\x04 \x03(\tB\x03\xe0\x41\x02\x12Y\n\x0e\x61uthentication\x18\x05 \x01(\x0b\x32\x41.google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication\x12P\n\nuser_agent\x18\x06 \x01(\x0e\x32<.google.cloud.websecurityscanner.v1beta.ScanConfig.UserAgent\x12\x1a\n\x12\x62lacklist_patterns\x18\x07 \x03(\t\x12M\n\x08schedule\x18\x08 \x01(\x0b\x32;.google.cloud.websecurityscanner.v1beta.ScanConfig.Schedule\x12[\n\x10target_platforms\x18\t \x03(\x0e\x32\x41.google.cloud.websecurityscanner.v1beta.ScanConfig.TargetPlatform\x12{\n!export_to_security_command_center\x18\n \x01(\x0e\x32P.google.cloud.websecurityscanner.v1beta.ScanConfig.ExportToSecurityCommandCenter\x12\x43\n\nlatest_run\x18\x0b \x01(\x0b\x32/.google.cloud.websecurityscanner.v1beta.ScanRun\x12P\n\nrisk_level\x18\x0c \x01(\x0e\x32<.google.cloud.websecurityscanner.v1beta.ScanConfig.RiskLevel\x1a\x94\x03\n\x0e\x41uthentication\x12i\n\x0egoogle_account\x18\x01 \x01(\x0b\x32O.google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.GoogleAccountH\x00\x12i\n\x0e\x63ustom_account\x18\x02 \x01(\x0b\x32O.google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.CustomAccountH\x00\x1a@\n\rGoogleAccount\x12\x15\n\x08username\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x18\n\x08password\x18\x02 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x04\x1aX\n\rCustomAccount\x12\x15\n\x08username\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x18\n\x08password\x18\x02 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x04\x12\x16\n\tlogin_url\x18\x03 \x01(\tB\x03\xe0\x41\x02\x42\x10\n\x0e\x61uthentication\x1a\x62\n\x08Schedule\x12\x31\n\rschedule_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12#\n\x16interval_duration_days\x18\x02 \x01(\x05\x42\x03\xe0\x41\x02"`\n\tUserAgent\x12\x1a\n\x16USER_AGENT_UNSPECIFIED\x10\x00\x12\x10\n\x0c\x43HROME_LINUX\x10\x01\x12\x12\n\x0e\x43HROME_ANDROID\x10\x02\x12\x11\n\rSAFARI_IPHONE\x10\x03"N\n\x0eTargetPlatform\x12\x1f\n\x1bTARGET_PLATFORM_UNSPECIFIED\x10\x00\x12\x0e\n\nAPP_ENGINE\x10\x01\x12\x0b\n\x07\x43OMPUTE\x10\x02"<\n\tRiskLevel\x12\x1a\n\x16RISK_LEVEL_UNSPECIFIED\x10\x00\x12\n\n\x06NORMAL\x10\x01\x12\x07\n\x03LOW\x10\x02"m\n\x1d\x45xportToSecurityCommandCenter\x12\x31\n-EXPORT_TO_SECURITY_COMMAND_CENTER_UNSPECIFIED\x10\x00\x12\x0b\n\x07\x45NABLED\x10\x01\x12\x0c\n\x08\x44ISABLED\x10\x02:_\xea\x41\\\n,websecurityscanner.googleapis.com/ScanConfig\x12,projects/{project}/scanConfigs/{scan_config}B\xc2\x01\n*com.google.cloud.websecurityscanner.v1betaB\x0fScanConfigProtoP\x01ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\xca\x02&Google\\Cloud\\WebSecurityScanner\\V1betab\x06proto3' - ), - dependencies=[ - google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, - google_dot_api_dot_resource__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2.DESCRIPTOR, - google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, - ], -) - - -_SCANCONFIG_USERAGENT = _descriptor.EnumDescriptor( - name="UserAgent", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.UserAgent", - filename=None, - file=DESCRIPTOR, - values=[ - _descriptor.EnumValueDescriptor( - name="USER_AGENT_UNSPECIFIED", - index=0, - number=0, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="CHROME_LINUX", index=1, number=1, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="CHROME_ANDROID", index=2, number=2, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="SAFARI_IPHONE", index=3, number=3, serialized_options=None, type=None - ), - ], - containing_type=None, - serialized_options=None, - serialized_start=1517, - serialized_end=1613, -) -_sym_db.RegisterEnumDescriptor(_SCANCONFIG_USERAGENT) - -_SCANCONFIG_TARGETPLATFORM = _descriptor.EnumDescriptor( - name="TargetPlatform", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.TargetPlatform", - filename=None, - file=DESCRIPTOR, - values=[ - _descriptor.EnumValueDescriptor( - name="TARGET_PLATFORM_UNSPECIFIED", - index=0, - number=0, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="APP_ENGINE", index=1, number=1, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="COMPUTE", index=2, number=2, serialized_options=None, type=None - ), - ], - containing_type=None, - serialized_options=None, - serialized_start=1615, - serialized_end=1693, -) -_sym_db.RegisterEnumDescriptor(_SCANCONFIG_TARGETPLATFORM) - -_SCANCONFIG_RISKLEVEL = _descriptor.EnumDescriptor( - name="RiskLevel", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.RiskLevel", - filename=None, - file=DESCRIPTOR, - values=[ - _descriptor.EnumValueDescriptor( - name="RISK_LEVEL_UNSPECIFIED", - index=0, - number=0, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="NORMAL", index=1, number=1, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="LOW", index=2, number=2, serialized_options=None, type=None - ), - ], - containing_type=None, - serialized_options=None, - serialized_start=1695, - serialized_end=1755, -) -_sym_db.RegisterEnumDescriptor(_SCANCONFIG_RISKLEVEL) - -_SCANCONFIG_EXPORTTOSECURITYCOMMANDCENTER = _descriptor.EnumDescriptor( - name="ExportToSecurityCommandCenter", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.ExportToSecurityCommandCenter", - filename=None, - file=DESCRIPTOR, - values=[ - _descriptor.EnumValueDescriptor( - name="EXPORT_TO_SECURITY_COMMAND_CENTER_UNSPECIFIED", - index=0, - number=0, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="ENABLED", index=1, number=1, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="DISABLED", index=2, number=2, serialized_options=None, type=None - ), - ], - containing_type=None, - serialized_options=None, - serialized_start=1757, - serialized_end=1866, -) -_sym_db.RegisterEnumDescriptor(_SCANCONFIG_EXPORTTOSECURITYCOMMANDCENTER) - - -_SCANCONFIG_AUTHENTICATION_GOOGLEACCOUNT = _descriptor.Descriptor( - name="GoogleAccount", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.GoogleAccount", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="username", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.GoogleAccount.username", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="password", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.GoogleAccount.password", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002\340A\004"), - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1243, - serialized_end=1307, -) - -_SCANCONFIG_AUTHENTICATION_CUSTOMACCOUNT = _descriptor.Descriptor( - name="CustomAccount", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.CustomAccount", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="username", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.CustomAccount.username", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="password", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.CustomAccount.password", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002\340A\004"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="login_url", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.CustomAccount.login_url", - index=2, - number=3, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1309, - serialized_end=1397, -) - -_SCANCONFIG_AUTHENTICATION = _descriptor.Descriptor( - name="Authentication", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="google_account", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.google_account", - index=0, - number=1, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="custom_account", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.custom_account", - index=1, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[ - _SCANCONFIG_AUTHENTICATION_GOOGLEACCOUNT, - _SCANCONFIG_AUTHENTICATION_CUSTOMACCOUNT, - ], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[ - _descriptor.OneofDescriptor( - name="authentication", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.authentication", - index=0, - containing_type=None, - fields=[], - ) - ], - serialized_start=1011, - serialized_end=1415, -) - -_SCANCONFIG_SCHEDULE = _descriptor.Descriptor( - name="Schedule", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Schedule", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="schedule_time", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Schedule.schedule_time", - index=0, - number=1, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="interval_duration_days", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.Schedule.interval_duration_days", - index=1, - number=2, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1417, - serialized_end=1515, -) - -_SCANCONFIG = _descriptor.Descriptor( - name="ScanConfig", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="display_name", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.display_name", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="max_qps", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.max_qps", - index=2, - number=3, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="starting_urls", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.starting_urls", - index=3, - number=4, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="authentication", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.authentication", - index=4, - number=5, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="user_agent", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.user_agent", - index=5, - number=6, - type=14, - cpp_type=8, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="blacklist_patterns", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.blacklist_patterns", - index=6, - number=7, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="schedule", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.schedule", - index=7, - number=8, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="target_platforms", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.target_platforms", - index=8, - number=9, - type=14, - cpp_type=8, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="export_to_security_command_center", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.export_to_security_command_center", - index=9, - number=10, - type=14, - cpp_type=8, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="latest_run", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.latest_run", - index=10, - number=11, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="risk_level", - full_name="google.cloud.websecurityscanner.v1beta.ScanConfig.risk_level", - index=11, - number=12, - type=14, - cpp_type=8, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[_SCANCONFIG_AUTHENTICATION, _SCANCONFIG_SCHEDULE], - enum_types=[ - _SCANCONFIG_USERAGENT, - _SCANCONFIG_TARGETPLATFORM, - _SCANCONFIG_RISKLEVEL, - _SCANCONFIG_EXPORTTOSECURITYCOMMANDCENTER, - ], - serialized_options=_b( - "\352A\\\n,websecurityscanner.googleapis.com/ScanConfig\022,projects/{project}/scanConfigs/{scan_config}" - ), - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=261, - serialized_end=1963, -) - -_SCANCONFIG_AUTHENTICATION_GOOGLEACCOUNT.containing_type = _SCANCONFIG_AUTHENTICATION -_SCANCONFIG_AUTHENTICATION_CUSTOMACCOUNT.containing_type = _SCANCONFIG_AUTHENTICATION -_SCANCONFIG_AUTHENTICATION.fields_by_name[ - "google_account" -].message_type = _SCANCONFIG_AUTHENTICATION_GOOGLEACCOUNT -_SCANCONFIG_AUTHENTICATION.fields_by_name[ - "custom_account" -].message_type = _SCANCONFIG_AUTHENTICATION_CUSTOMACCOUNT -_SCANCONFIG_AUTHENTICATION.containing_type = _SCANCONFIG -_SCANCONFIG_AUTHENTICATION.oneofs_by_name["authentication"].fields.append( - _SCANCONFIG_AUTHENTICATION.fields_by_name["google_account"] -) -_SCANCONFIG_AUTHENTICATION.fields_by_name[ - "google_account" -].containing_oneof = _SCANCONFIG_AUTHENTICATION.oneofs_by_name["authentication"] -_SCANCONFIG_AUTHENTICATION.oneofs_by_name["authentication"].fields.append( - _SCANCONFIG_AUTHENTICATION.fields_by_name["custom_account"] -) -_SCANCONFIG_AUTHENTICATION.fields_by_name[ - "custom_account" -].containing_oneof = _SCANCONFIG_AUTHENTICATION.oneofs_by_name["authentication"] -_SCANCONFIG_SCHEDULE.fields_by_name[ - "schedule_time" -].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP -_SCANCONFIG_SCHEDULE.containing_type = _SCANCONFIG -_SCANCONFIG.fields_by_name["authentication"].message_type = _SCANCONFIG_AUTHENTICATION -_SCANCONFIG.fields_by_name["user_agent"].enum_type = _SCANCONFIG_USERAGENT -_SCANCONFIG.fields_by_name["schedule"].message_type = _SCANCONFIG_SCHEDULE -_SCANCONFIG.fields_by_name["target_platforms"].enum_type = _SCANCONFIG_TARGETPLATFORM -_SCANCONFIG.fields_by_name[ - "export_to_security_command_center" -].enum_type = _SCANCONFIG_EXPORTTOSECURITYCOMMANDCENTER -_SCANCONFIG.fields_by_name[ - "latest_run" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2._SCANRUN -) -_SCANCONFIG.fields_by_name["risk_level"].enum_type = _SCANCONFIG_RISKLEVEL -_SCANCONFIG_USERAGENT.containing_type = _SCANCONFIG -_SCANCONFIG_TARGETPLATFORM.containing_type = _SCANCONFIG -_SCANCONFIG_RISKLEVEL.containing_type = _SCANCONFIG -_SCANCONFIG_EXPORTTOSECURITYCOMMANDCENTER.containing_type = _SCANCONFIG -DESCRIPTOR.message_types_by_name["ScanConfig"] = _SCANCONFIG -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -ScanConfig = _reflection.GeneratedProtocolMessageType( - "ScanConfig", - (_message.Message,), - dict( - Authentication=_reflection.GeneratedProtocolMessageType( - "Authentication", - (_message.Message,), - dict( - GoogleAccount=_reflection.GeneratedProtocolMessageType( - "GoogleAccount", - (_message.Message,), - dict( - DESCRIPTOR=_SCANCONFIG_AUTHENTICATION_GOOGLEACCOUNT, - __module__="google.cloud.websecurityscanner_v1beta.proto.scan_config_pb2", - __doc__="""Describes authentication configuration that uses a Google account. - - - Attributes: - username: - Required. The user name of the Google account. - password: - Required. Input only. The password of the Google account. The - credential is stored encrypted and not returned in any - response nor included in audit logs. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.GoogleAccount) - ), - ), - CustomAccount=_reflection.GeneratedProtocolMessageType( - "CustomAccount", - (_message.Message,), - dict( - DESCRIPTOR=_SCANCONFIG_AUTHENTICATION_CUSTOMACCOUNT, - __module__="google.cloud.websecurityscanner_v1beta.proto.scan_config_pb2", - __doc__="""Describes authentication configuration that uses a custom - account. - - - Attributes: - username: - Required. The user name of the custom account. - password: - Required. Input only. The password of the custom account. The - credential is stored encrypted and not returned in any - response nor included in audit logs. - login_url: - Required. The login form URL of the website. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication.CustomAccount) - ), - ), - DESCRIPTOR=_SCANCONFIG_AUTHENTICATION, - __module__="google.cloud.websecurityscanner_v1beta.proto.scan_config_pb2", - __doc__="""Scan authentication configuration. - - - Attributes: - authentication: - Required. Authentication configuration - google_account: - Authentication using a Google account. - custom_account: - Authentication using a custom account. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ScanConfig.Authentication) - ), - ), - Schedule=_reflection.GeneratedProtocolMessageType( - "Schedule", - (_message.Message,), - dict( - DESCRIPTOR=_SCANCONFIG_SCHEDULE, - __module__="google.cloud.websecurityscanner_v1beta.proto.scan_config_pb2", - __doc__="""Scan schedule configuration. - - - Attributes: - schedule_time: - A timestamp indicates when the next run will be scheduled. The - value is refreshed by the server after each run. If - unspecified, it will default to current server time, which - means the scan will be scheduled to start immediately. - interval_duration_days: - Required. The duration of time between executions in days. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ScanConfig.Schedule) - ), - ), - DESCRIPTOR=_SCANCONFIG, - __module__="google.cloud.websecurityscanner_v1beta.proto.scan_config_pb2", - __doc__="""A ScanConfig resource contains the configurations to - launch a scan. - - - Attributes: - name: - The resource name of the ScanConfig. The name follows the - format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. - The ScanConfig IDs are generated by the system. - display_name: - Required. The user provided display name of the ScanConfig. - max_qps: - The maximum QPS during scanning. A valid value ranges from 5 - to 20 inclusively. If the field is unspecified or its value is - set 0, server will default to 15. Other values outside of [5, - 20] range will be rejected with INVALID\_ARGUMENT error. - starting_urls: - Required. The starting URLs from which the scanner finds site - pages. - authentication: - The authentication configuration. If specified, service will - use the authentication configuration during scanning. - user_agent: - The user agent used during scanning. - blacklist_patterns: - The blacklist URL patterns as described in - https://cloud.google.com/security-scanner/docs/excluded-urls - schedule: - The schedule of the ScanConfig. - target_platforms: - Set of Cloud Platforms targeted by the scan. If empty, - APP\_ENGINE will be used as a default. - export_to_security_command_center: - Controls export of scan configurations and results to Cloud - Security Command Center. - latest_run: - Latest ScanRun if available. - risk_level: - The risk level selected for the scan - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ScanConfig) - ), -) -_sym_db.RegisterMessage(ScanConfig) -_sym_db.RegisterMessage(ScanConfig.Authentication) -_sym_db.RegisterMessage(ScanConfig.Authentication.GoogleAccount) -_sym_db.RegisterMessage(ScanConfig.Authentication.CustomAccount) -_sym_db.RegisterMessage(ScanConfig.Schedule) - - -DESCRIPTOR._options = None -_SCANCONFIG_AUTHENTICATION_GOOGLEACCOUNT.fields_by_name["username"]._options = None -_SCANCONFIG_AUTHENTICATION_GOOGLEACCOUNT.fields_by_name["password"]._options = None -_SCANCONFIG_AUTHENTICATION_CUSTOMACCOUNT.fields_by_name["username"]._options = None -_SCANCONFIG_AUTHENTICATION_CUSTOMACCOUNT.fields_by_name["password"]._options = None -_SCANCONFIG_AUTHENTICATION_CUSTOMACCOUNT.fields_by_name["login_url"]._options = None -_SCANCONFIG_SCHEDULE.fields_by_name["interval_duration_days"]._options = None -_SCANCONFIG.fields_by_name["display_name"]._options = None -_SCANCONFIG.fields_by_name["starting_urls"]._options = None -_SCANCONFIG._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1beta/proto/scan_config_pb2_grpc.py b/google/cloud/websecurityscanner_v1beta/proto/scan_config_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/scan_config_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1beta/proto/scan_run_error_trace_pb2.py b/google/cloud/websecurityscanner_v1beta/proto/scan_run_error_trace_pb2.py deleted file mode 100644 index b5975a7..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/scan_run_error_trace_pb2.py +++ /dev/null @@ -1,212 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1beta/proto/scan_run_error_trace.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.cloud.websecurityscanner_v1beta.proto import ( - scan_config_error_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__error__pb2, -) - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1beta/proto/scan_run_error_trace.proto", - package="google.cloud.websecurityscanner.v1beta", - syntax="proto3", - serialized_options=_b( - "\n*com.google.cloud.websecurityscanner.v1betaB\026ScanRunErrorTraceProtoP\001ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\312\002&Google\\Cloud\\WebSecurityScanner\\V1beta" - ), - serialized_pb=_b( - '\nGgoogle/cloud/websecurityscanner_v1beta/proto/scan_run_error_trace.proto\x12&google.cloud.websecurityscanner.v1beta\x1a\x44google/cloud/websecurityscanner_v1beta/proto/scan_config_error.proto"\x95\x03\n\x11ScanRunErrorTrace\x12L\n\x04\x63ode\x18\x01 \x01(\x0e\x32>.google.cloud.websecurityscanner.v1beta.ScanRunErrorTrace.Code\x12R\n\x11scan_config_error\x18\x02 \x01(\x0b\x32\x37.google.cloud.websecurityscanner.v1beta.ScanConfigError\x12#\n\x1bmost_common_http_error_code\x18\x03 \x01(\x05"\xb8\x01\n\x04\x43ode\x12\x14\n\x10\x43ODE_UNSPECIFIED\x10\x00\x12\x12\n\x0eINTERNAL_ERROR\x10\x01\x12\x15\n\x11SCAN_CONFIG_ISSUE\x10\x02\x12\x1f\n\x1b\x41UTHENTICATION_CONFIG_ISSUE\x10\x03\x12\x1c\n\x18TIMED_OUT_WHILE_SCANNING\x10\x04\x12\x16\n\x12TOO_MANY_REDIRECTS\x10\x05\x12\x18\n\x14TOO_MANY_HTTP_ERRORS\x10\x06\x42\xc9\x01\n*com.google.cloud.websecurityscanner.v1betaB\x16ScanRunErrorTraceProtoP\x01ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\xca\x02&Google\\Cloud\\WebSecurityScanner\\V1betab\x06proto3' - ), - dependencies=[ - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__error__pb2.DESCRIPTOR - ], -) - - -_SCANRUNERRORTRACE_CODE = _descriptor.EnumDescriptor( - name="Code", - full_name="google.cloud.websecurityscanner.v1beta.ScanRunErrorTrace.Code", - filename=None, - file=DESCRIPTOR, - values=[ - _descriptor.EnumValueDescriptor( - name="CODE_UNSPECIFIED", - index=0, - number=0, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="INTERNAL_ERROR", index=1, number=1, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="SCAN_CONFIG_ISSUE", - index=2, - number=2, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="AUTHENTICATION_CONFIG_ISSUE", - index=3, - number=3, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="TIMED_OUT_WHILE_SCANNING", - index=4, - number=4, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="TOO_MANY_REDIRECTS", - index=5, - number=5, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="TOO_MANY_HTTP_ERRORS", - index=6, - number=6, - serialized_options=None, - type=None, - ), - ], - containing_type=None, - serialized_options=None, - serialized_start=407, - serialized_end=591, -) -_sym_db.RegisterEnumDescriptor(_SCANRUNERRORTRACE_CODE) - - -_SCANRUNERRORTRACE = _descriptor.Descriptor( - name="ScanRunErrorTrace", - full_name="google.cloud.websecurityscanner.v1beta.ScanRunErrorTrace", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="code", - full_name="google.cloud.websecurityscanner.v1beta.ScanRunErrorTrace.code", - index=0, - number=1, - type=14, - cpp_type=8, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="scan_config_error", - full_name="google.cloud.websecurityscanner.v1beta.ScanRunErrorTrace.scan_config_error", - index=1, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="most_common_http_error_code", - full_name="google.cloud.websecurityscanner.v1beta.ScanRunErrorTrace.most_common_http_error_code", - index=2, - number=3, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[_SCANRUNERRORTRACE_CODE], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=186, - serialized_end=591, -) - -_SCANRUNERRORTRACE.fields_by_name["code"].enum_type = _SCANRUNERRORTRACE_CODE -_SCANRUNERRORTRACE.fields_by_name[ - "scan_config_error" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__error__pb2._SCANCONFIGERROR -) -_SCANRUNERRORTRACE_CODE.containing_type = _SCANRUNERRORTRACE -DESCRIPTOR.message_types_by_name["ScanRunErrorTrace"] = _SCANRUNERRORTRACE -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -ScanRunErrorTrace = _reflection.GeneratedProtocolMessageType( - "ScanRunErrorTrace", - (_message.Message,), - dict( - DESCRIPTOR=_SCANRUNERRORTRACE, - __module__="google.cloud.websecurityscanner_v1beta.proto.scan_run_error_trace_pb2", - __doc__="""Output only. Defines an error trace message for a ScanRun. - - - Attributes: - code: - Indicates the error reason code. - scan_config_error: - If the scan encounters SCAN\_CONFIG\_ISSUE error, this field - has the error message encountered during scan configuration - validation that is performed before each scan run. - most_common_http_error_code: - If the scan encounters TOO\_MANY\_HTTP\_ERRORS, this field - indicates the most common HTTP error code, if such is - available. For example, if this code is 404, the scan has - encountered too many NOT\_FOUND responses. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ScanRunErrorTrace) - ), -) -_sym_db.RegisterMessage(ScanRunErrorTrace) - - -DESCRIPTOR._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1beta/proto/scan_run_error_trace_pb2_grpc.py b/google/cloud/websecurityscanner_v1beta/proto/scan_run_error_trace_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/scan_run_error_trace_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1beta/proto/scan_run_pb2.py b/google/cloud/websecurityscanner_v1beta/proto/scan_run_pb2.py deleted file mode 100644 index bfea80e..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/scan_run_pb2.py +++ /dev/null @@ -1,409 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1beta/proto/scan_run.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 -from google.cloud.websecurityscanner_v1beta.proto import ( - scan_run_error_trace_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__error__trace__pb2, -) -from google.cloud.websecurityscanner_v1beta.proto import ( - scan_run_warning_trace_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__warning__trace__pb2, -) -from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1beta/proto/scan_run.proto", - package="google.cloud.websecurityscanner.v1beta", - syntax="proto3", - serialized_options=_b( - "\n*com.google.cloud.websecurityscanner.v1betaB\014ScanRunProtoP\001ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\312\002&Google\\Cloud\\WebSecurityScanner\\V1beta" - ), - serialized_pb=_b( - '\n;google/cloud/websecurityscanner_v1beta/proto/scan_run.proto\x12&google.cloud.websecurityscanner.v1beta\x1a\x19google/api/resource.proto\x1aGgoogle/cloud/websecurityscanner_v1beta/proto/scan_run_error_trace.proto\x1aIgoogle/cloud/websecurityscanner_v1beta/proto/scan_run_warning_trace.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xd2\x06\n\x07ScanRun\x12\x0c\n\x04name\x18\x01 \x01(\t\x12W\n\x0f\x65xecution_state\x18\x02 \x01(\x0e\x32>.google.cloud.websecurityscanner.v1beta.ScanRun.ExecutionState\x12Q\n\x0cresult_state\x18\x03 \x01(\x0e\x32;.google.cloud.websecurityscanner.v1beta.ScanRun.ResultState\x12.\n\nstart_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1a\n\x12urls_crawled_count\x18\x06 \x01(\x03\x12\x19\n\x11urls_tested_count\x18\x07 \x01(\x03\x12\x1b\n\x13has_vulnerabilities\x18\x08 \x01(\x08\x12\x18\n\x10progress_percent\x18\t \x01(\x05\x12N\n\x0b\x65rror_trace\x18\n \x01(\x0b\x32\x39.google.cloud.websecurityscanner.v1beta.ScanRunErrorTrace\x12S\n\x0ewarning_traces\x18\x0b \x03(\x0b\x32;.google.cloud.websecurityscanner.v1beta.ScanRunWarningTrace"Y\n\x0e\x45xecutionState\x12\x1f\n\x1b\x45XECUTION_STATE_UNSPECIFIED\x10\x00\x12\n\n\x06QUEUED\x10\x01\x12\x0c\n\x08SCANNING\x10\x02\x12\x0c\n\x08\x46INISHED\x10\x03"O\n\x0bResultState\x12\x1c\n\x18RESULT_STATE_UNSPECIFIED\x10\x00\x12\x0b\n\x07SUCCESS\x10\x01\x12\t\n\x05\x45RROR\x10\x02\x12\n\n\x06KILLED\x10\x03:p\xea\x41m\n)websecurityscanner.googleapis.com/ScanRun\x12@projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}B\xbf\x01\n*com.google.cloud.websecurityscanner.v1betaB\x0cScanRunProtoP\x01ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\xca\x02&Google\\Cloud\\WebSecurityScanner\\V1betab\x06proto3' - ), - dependencies=[ - google_dot_api_dot_resource__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__error__trace__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__warning__trace__pb2.DESCRIPTOR, - google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, - ], -) - - -_SCANRUN_EXECUTIONSTATE = _descriptor.EnumDescriptor( - name="ExecutionState", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.ExecutionState", - filename=None, - file=DESCRIPTOR, - values=[ - _descriptor.EnumValueDescriptor( - name="EXECUTION_STATE_UNSPECIFIED", - index=0, - number=0, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="QUEUED", index=1, number=1, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="SCANNING", index=2, number=2, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="FINISHED", index=3, number=3, serialized_options=None, type=None - ), - ], - containing_type=None, - serialized_options=None, - serialized_start=878, - serialized_end=967, -) -_sym_db.RegisterEnumDescriptor(_SCANRUN_EXECUTIONSTATE) - -_SCANRUN_RESULTSTATE = _descriptor.EnumDescriptor( - name="ResultState", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.ResultState", - filename=None, - file=DESCRIPTOR, - values=[ - _descriptor.EnumValueDescriptor( - name="RESULT_STATE_UNSPECIFIED", - index=0, - number=0, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="SUCCESS", index=1, number=1, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="ERROR", index=2, number=2, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="KILLED", index=3, number=3, serialized_options=None, type=None - ), - ], - containing_type=None, - serialized_options=None, - serialized_start=969, - serialized_end=1048, -) -_sym_db.RegisterEnumDescriptor(_SCANRUN_RESULTSTATE) - - -_SCANRUN = _descriptor.Descriptor( - name="ScanRun", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="execution_state", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.execution_state", - index=1, - number=2, - type=14, - cpp_type=8, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="result_state", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.result_state", - index=2, - number=3, - type=14, - cpp_type=8, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="start_time", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.start_time", - index=3, - number=4, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="end_time", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.end_time", - index=4, - number=5, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="urls_crawled_count", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.urls_crawled_count", - index=5, - number=6, - type=3, - cpp_type=2, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="urls_tested_count", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.urls_tested_count", - index=6, - number=7, - type=3, - cpp_type=2, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="has_vulnerabilities", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.has_vulnerabilities", - index=7, - number=8, - type=8, - cpp_type=7, - label=1, - has_default_value=False, - default_value=False, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="progress_percent", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.progress_percent", - index=8, - number=9, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="error_trace", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.error_trace", - index=9, - number=10, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="warning_traces", - full_name="google.cloud.websecurityscanner.v1beta.ScanRun.warning_traces", - index=10, - number=11, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[_SCANRUN_EXECUTIONSTATE, _SCANRUN_RESULTSTATE], - serialized_options=_b( - "\352Am\n)websecurityscanner.googleapis.com/ScanRun\022@projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}" - ), - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=312, - serialized_end=1162, -) - -_SCANRUN.fields_by_name["execution_state"].enum_type = _SCANRUN_EXECUTIONSTATE -_SCANRUN.fields_by_name["result_state"].enum_type = _SCANRUN_RESULTSTATE -_SCANRUN.fields_by_name[ - "start_time" -].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP -_SCANRUN.fields_by_name[ - "end_time" -].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP -_SCANRUN.fields_by_name[ - "error_trace" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__error__trace__pb2._SCANRUNERRORTRACE -) -_SCANRUN.fields_by_name[ - "warning_traces" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__warning__trace__pb2._SCANRUNWARNINGTRACE -) -_SCANRUN_EXECUTIONSTATE.containing_type = _SCANRUN -_SCANRUN_RESULTSTATE.containing_type = _SCANRUN -DESCRIPTOR.message_types_by_name["ScanRun"] = _SCANRUN -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -ScanRun = _reflection.GeneratedProtocolMessageType( - "ScanRun", - (_message.Message,), - dict( - DESCRIPTOR=_SCANRUN, - __module__="google.cloud.websecurityscanner_v1beta.proto.scan_run_pb2", - __doc__="""A ScanRun is a output-only resource representing an actual - run of the scan. Next id: 12 - - - Attributes: - name: - The resource name of the ScanRun. The name follows the format - of 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{ - scanRunId}'. The ScanRun IDs are generated by the system. - execution_state: - The execution state of the ScanRun. - result_state: - The result state of the ScanRun. This field is only available - after the execution state reaches "FINISHED". - start_time: - The time at which the ScanRun started. - end_time: - The time at which the ScanRun reached termination state - that - the ScanRun is either finished or stopped by user. - urls_crawled_count: - The number of URLs crawled during this ScanRun. If the scan is - in progress, the value represents the number of URLs crawled - up to now. - urls_tested_count: - The number of URLs tested during this ScanRun. If the scan is - in progress, the value represents the number of URLs tested up - to now. The number of URLs tested is usually larger than the - number URLS crawled because typically a crawled URL is tested - with multiple test payloads. - has_vulnerabilities: - Whether the scan run has found any vulnerabilities. - progress_percent: - The percentage of total completion ranging from 0 to 100. If - the scan is in queue, the value is 0. If the scan is running, - the value ranges from 0 to 100. If the scan is finished, the - value is 100. - error_trace: - If result\_state is an ERROR, this field provides the primary - reason for scan's termination and more details, if such are - available. - warning_traces: - A list of warnings, if such are encountered during this scan - run. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ScanRun) - ), -) -_sym_db.RegisterMessage(ScanRun) - - -DESCRIPTOR._options = None -_SCANRUN._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1beta/proto/scan_run_pb2_grpc.py b/google/cloud/websecurityscanner_v1beta/proto/scan_run_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/scan_run_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1beta/proto/scan_run_warning_trace_pb2.py b/google/cloud/websecurityscanner_v1beta/proto/scan_run_warning_trace_pb2.py deleted file mode 100644 index a225ecc..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/scan_run_warning_trace_pb2.py +++ /dev/null @@ -1,142 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1beta/proto/scan_run_warning_trace.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1beta/proto/scan_run_warning_trace.proto", - package="google.cloud.websecurityscanner.v1beta", - syntax="proto3", - serialized_options=_b( - "\n*com.google.cloud.websecurityscanner.v1betaB\030ScanRunWarningTraceProtoP\001ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\312\002&Google\\Cloud\\WebSecurityScanner\\V1beta" - ), - serialized_pb=_b( - '\nIgoogle/cloud/websecurityscanner_v1beta/proto/scan_run_warning_trace.proto\x12&google.cloud.websecurityscanner.v1beta"\xed\x01\n\x13ScanRunWarningTrace\x12N\n\x04\x63ode\x18\x01 \x01(\x0e\x32@.google.cloud.websecurityscanner.v1beta.ScanRunWarningTrace.Code"\x85\x01\n\x04\x43ode\x12\x14\n\x10\x43ODE_UNSPECIFIED\x10\x00\x12\x1e\n\x1aINSUFFICIENT_CRAWL_RESULTS\x10\x01\x12\x1a\n\x16TOO_MANY_CRAWL_RESULTS\x10\x02\x12\x17\n\x13TOO_MANY_FUZZ_TASKS\x10\x03\x12\x12\n\x0e\x42LOCKED_BY_IAP\x10\x04\x42\xcb\x01\n*com.google.cloud.websecurityscanner.v1betaB\x18ScanRunWarningTraceProtoP\x01ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\xca\x02&Google\\Cloud\\WebSecurityScanner\\V1betab\x06proto3' - ), -) - - -_SCANRUNWARNINGTRACE_CODE = _descriptor.EnumDescriptor( - name="Code", - full_name="google.cloud.websecurityscanner.v1beta.ScanRunWarningTrace.Code", - filename=None, - file=DESCRIPTOR, - values=[ - _descriptor.EnumValueDescriptor( - name="CODE_UNSPECIFIED", - index=0, - number=0, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="INSUFFICIENT_CRAWL_RESULTS", - index=1, - number=1, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="TOO_MANY_CRAWL_RESULTS", - index=2, - number=2, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="TOO_MANY_FUZZ_TASKS", - index=3, - number=3, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="BLOCKED_BY_IAP", index=4, number=4, serialized_options=None, type=None - ), - ], - containing_type=None, - serialized_options=None, - serialized_start=222, - serialized_end=355, -) -_sym_db.RegisterEnumDescriptor(_SCANRUNWARNINGTRACE_CODE) - - -_SCANRUNWARNINGTRACE = _descriptor.Descriptor( - name="ScanRunWarningTrace", - full_name="google.cloud.websecurityscanner.v1beta.ScanRunWarningTrace", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="code", - full_name="google.cloud.websecurityscanner.v1beta.ScanRunWarningTrace.code", - index=0, - number=1, - type=14, - cpp_type=8, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[_SCANRUNWARNINGTRACE_CODE], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=118, - serialized_end=355, -) - -_SCANRUNWARNINGTRACE.fields_by_name["code"].enum_type = _SCANRUNWARNINGTRACE_CODE -_SCANRUNWARNINGTRACE_CODE.containing_type = _SCANRUNWARNINGTRACE -DESCRIPTOR.message_types_by_name["ScanRunWarningTrace"] = _SCANRUNWARNINGTRACE -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -ScanRunWarningTrace = _reflection.GeneratedProtocolMessageType( - "ScanRunWarningTrace", - (_message.Message,), - dict( - DESCRIPTOR=_SCANRUNWARNINGTRACE, - __module__="google.cloud.websecurityscanner_v1beta.proto.scan_run_warning_trace_pb2", - __doc__="""Output only. Defines a warning trace message for ScanRun. - Warning traces provide customers with useful information that helps make - the scanning process more effective. - - - Attributes: - code: - Indicates the warning code. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ScanRunWarningTrace) - ), -) -_sym_db.RegisterMessage(ScanRunWarningTrace) - - -DESCRIPTOR._options = None -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1beta/proto/scan_run_warning_trace_pb2_grpc.py b/google/cloud/websecurityscanner_v1beta/proto/scan_run_warning_trace_pb2_grpc.py deleted file mode 100644 index 07cb78f..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/scan_run_warning_trace_pb2_grpc.py +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc diff --git a/google/cloud/websecurityscanner_v1beta/proto/web_security_scanner_pb2.py b/google/cloud/websecurityscanner_v1beta/proto/web_security_scanner_pb2.py deleted file mode 100644 index ad3f1d8..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/web_security_scanner_pb2.py +++ /dev/null @@ -1,1711 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/websecurityscanner_v1beta/proto/web_security_scanner.proto - -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 -from google.api import client_pb2 as google_dot_api_dot_client__pb2 -from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 -from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 -from google.cloud.websecurityscanner_v1beta.proto import ( - crawled_url_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_crawled__url__pb2, -) -from google.cloud.websecurityscanner_v1beta.proto import ( - finding_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__pb2, -) -from google.cloud.websecurityscanner_v1beta.proto import ( - finding_type_stats_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__type__stats__pb2, -) -from google.cloud.websecurityscanner_v1beta.proto import ( - scan_config_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2, -) -from google.cloud.websecurityscanner_v1beta.proto import ( - scan_run_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2, -) -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from google.protobuf import field_mask_pb2 as google_dot_protobuf_dot_field__mask__pb2 - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="google/cloud/websecurityscanner_v1beta/proto/web_security_scanner.proto", - package="google.cloud.websecurityscanner.v1beta", - syntax="proto3", - serialized_options=_b( - "\n*com.google.cloud.websecurityscanner.v1betaB\027WebSecurityScannerProtoP\001ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\312\002&Google\\Cloud\\WebSecurityScanner\\V1beta" - ), - serialized_pb=_b( - '\nGgoogle/cloud/websecurityscanner_v1beta/proto/web_security_scanner.proto\x12&google.cloud.websecurityscanner.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a>google/cloud/websecurityscanner_v1beta/proto/crawled_url.proto\x1a:google/cloud/websecurityscanner_v1beta/proto/finding.proto\x1a\x45google/cloud/websecurityscanner_v1beta/proto/finding_type_stats.proto\x1a>google/cloud/websecurityscanner_v1beta/proto/scan_config.proto\x1a;google/cloud/websecurityscanner_v1beta/proto/scan_run.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto"\xac\x01\n\x17\x43reateScanConfigRequest\x12\x43\n\x06parent\x18\x01 \x01(\tB3\xe0\x41\x02\xfa\x41-\n+cloudresourcemanager.googleapis.com/Project\x12L\n\x0bscan_config\x18\x02 \x01(\x0b\x32\x32.google.cloud.websecurityscanner.v1beta.ScanConfigB\x03\xe0\x41\x02"]\n\x17\x44\x65leteScanConfigRequest\x12\x42\n\x04name\x18\x01 \x01(\tB4\xe0\x41\x02\xfa\x41.\n,websecurityscanner.googleapis.com/ScanConfig"Z\n\x14GetScanConfigRequest\x12\x42\n\x04name\x18\x01 \x01(\tB4\xe0\x41\x02\xfa\x41.\n,websecurityscanner.googleapis.com/ScanConfig"\x84\x01\n\x16ListScanConfigsRequest\x12\x43\n\x06parent\x18\x01 \x01(\tB3\xe0\x41\x02\xfa\x41-\n+cloudresourcemanager.googleapis.com/Project\x12\x12\n\npage_token\x18\x02 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05"\x9d\x01\n\x17UpdateScanConfigRequest\x12L\n\x0bscan_config\x18\x02 \x01(\x0b\x32\x32.google.cloud.websecurityscanner.v1beta.ScanConfigB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x02"|\n\x17ListScanConfigsResponse\x12H\n\x0cscan_configs\x18\x01 \x03(\x0b\x32\x32.google.cloud.websecurityscanner.v1beta.ScanConfig\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"Y\n\x13StartScanRunRequest\x12\x42\n\x04name\x18\x01 \x01(\tB4\xe0\x41\x02\xfa\x41.\n,websecurityscanner.googleapis.com/ScanConfig"T\n\x11GetScanRunRequest\x12?\n\x04name\x18\x01 \x01(\tB1\xe0\x41\x02\xfa\x41+\n)websecurityscanner.googleapis.com/ScanRun"\x82\x01\n\x13ListScanRunsRequest\x12\x44\n\x06parent\x18\x01 \x01(\tB4\xe0\x41\x02\xfa\x41.\n,websecurityscanner.googleapis.com/ScanConfig\x12\x12\n\npage_token\x18\x02 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05"s\n\x14ListScanRunsResponse\x12\x42\n\tscan_runs\x18\x01 \x03(\x0b\x32/.google.cloud.websecurityscanner.v1beta.ScanRun\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"U\n\x12StopScanRunRequest\x12?\n\x04name\x18\x01 \x01(\tB1\xe0\x41\x02\xfa\x41+\n)websecurityscanner.googleapis.com/ScanRun"\x82\x01\n\x16ListCrawledUrlsRequest\x12\x41\n\x06parent\x18\x01 \x01(\tB1\xe0\x41\x02\xfa\x41+\n)websecurityscanner.googleapis.com/ScanRun\x12\x12\n\npage_token\x18\x02 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05"|\n\x17ListCrawledUrlsResponse\x12H\n\x0c\x63rawled_urls\x18\x01 \x03(\x0b\x32\x32.google.cloud.websecurityscanner.v1beta.CrawledUrl\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"T\n\x11GetFindingRequest\x12?\n\x04name\x18\x01 \x01(\tB1\xe0\x41\x02\xfa\x41+\n)websecurityscanner.googleapis.com/Finding"\x94\x01\n\x13ListFindingsRequest\x12\x41\n\x06parent\x18\x01 \x01(\tB1\xe0\x41\x02\xfa\x41+\n)websecurityscanner.googleapis.com/ScanRun\x12\x13\n\x06\x66ilter\x18\x02 \x01(\tB\x03\xe0\x41\x02\x12\x12\n\npage_token\x18\x03 \x01(\t\x12\x11\n\tpage_size\x18\x04 \x01(\x05"r\n\x14ListFindingsResponse\x12\x41\n\x08\x66indings\x18\x01 \x03(\x0b\x32/.google.cloud.websecurityscanner.v1beta.Finding\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"`\n\x1bListFindingTypeStatsRequest\x12\x41\n\x06parent\x18\x01 \x01(\tB1\xe0\x41\x02\xfa\x41+\n)websecurityscanner.googleapis.com/ScanRun"t\n\x1cListFindingTypeStatsResponse\x12T\n\x12\x66inding_type_stats\x18\x01 \x03(\x0b\x32\x38.google.cloud.websecurityscanner.v1beta.FindingTypeStats2\x8e\x16\n\x12WebSecurityScanner\x12\xda\x01\n\x10\x43reateScanConfig\x12?.google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest\x1a\x32.google.cloud.websecurityscanner.v1beta.ScanConfig"Q\x82\xd3\xe4\x93\x02\x36"\'/v1beta/{parent=projects/*}/scanConfigs:\x0bscan_config\xda\x41\x12parent,scan_config\x12\xa3\x01\n\x10\x44\x65leteScanConfig\x12?.google.cloud.websecurityscanner.v1beta.DeleteScanConfigRequest\x1a\x16.google.protobuf.Empty"6\x82\xd3\xe4\x93\x02)*\'/v1beta/{name=projects/*/scanConfigs/*}\xda\x41\x04name\x12\xb9\x01\n\rGetScanConfig\x12<.google.cloud.websecurityscanner.v1beta.GetScanConfigRequest\x1a\x32.google.cloud.websecurityscanner.v1beta.ScanConfig"6\x82\xd3\xe4\x93\x02)\x12\'/v1beta/{name=projects/*/scanConfigs/*}\xda\x41\x04name\x12\xcc\x01\n\x0fListScanConfigs\x12>.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest\x1a?.google.cloud.websecurityscanner.v1beta.ListScanConfigsResponse"8\x82\xd3\xe4\x93\x02)\x12\'/v1beta/{parent=projects/*}/scanConfigs\xda\x41\x06parent\x12\xeb\x01\n\x10UpdateScanConfig\x12?.google.cloud.websecurityscanner.v1beta.UpdateScanConfigRequest\x1a\x32.google.cloud.websecurityscanner.v1beta.ScanConfig"b\x82\xd3\xe4\x93\x02\x42\x32\x33/v1beta/{scan_config.name=projects/*/scanConfigs/*}:\x0bscan_config\xda\x41\x17scan_config,update_mask\x12\xbd\x01\n\x0cStartScanRun\x12;.google.cloud.websecurityscanner.v1beta.StartScanRunRequest\x1a/.google.cloud.websecurityscanner.v1beta.ScanRun"?\x82\xd3\xe4\x93\x02\x32"-/v1beta/{name=projects/*/scanConfigs/*}:start:\x01*\xda\x41\x04name\x12\xbb\x01\n\nGetScanRun\x12\x39.google.cloud.websecurityscanner.v1beta.GetScanRunRequest\x1a/.google.cloud.websecurityscanner.v1beta.ScanRun"A\x82\xd3\xe4\x93\x02\x34\x12\x32/v1beta/{name=projects/*/scanConfigs/*/scanRuns/*}\xda\x41\x04name\x12\xce\x01\n\x0cListScanRuns\x12;.google.cloud.websecurityscanner.v1beta.ListScanRunsRequest\x1a<.google.cloud.websecurityscanner.v1beta.ListScanRunsResponse"C\x82\xd3\xe4\x93\x02\x34\x12\x32/v1beta/{parent=projects/*/scanConfigs/*}/scanRuns\xda\x41\x06parent\x12\xc5\x01\n\x0bStopScanRun\x12:.google.cloud.websecurityscanner.v1beta.StopScanRunRequest\x1a/.google.cloud.websecurityscanner.v1beta.ScanRun"I\x82\xd3\xe4\x93\x02<"7/v1beta/{name=projects/*/scanConfigs/*/scanRuns/*}:stop:\x01*\xda\x41\x04name\x12\xe5\x01\n\x0fListCrawledUrls\x12>.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest\x1a?.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsResponse"Q\x82\xd3\xe4\x93\x02\x42\x12@/v1beta/{parent=projects/*/scanConfigs/*/scanRuns/*}/crawledUrls\xda\x41\x06parent\x12\xc6\x01\n\nGetFinding\x12\x39.google.cloud.websecurityscanner.v1beta.GetFindingRequest\x1a/.google.cloud.websecurityscanner.v1beta.Finding"L\x82\xd3\xe4\x93\x02?\x12=/v1beta/{name=projects/*/scanConfigs/*/scanRuns/*/findings/*}\xda\x41\x04name\x12\xe0\x01\n\x0cListFindings\x12;.google.cloud.websecurityscanner.v1beta.ListFindingsRequest\x1a<.google.cloud.websecurityscanner.v1beta.ListFindingsResponse"U\x82\xd3\xe4\x93\x02?\x12=/v1beta/{parent=projects/*/scanConfigs/*/scanRuns/*}/findings\xda\x41\rparent,filter\x12\xf9\x01\n\x14ListFindingTypeStats\x12\x43.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsRequest\x1a\x44.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsResponse"V\x82\xd3\xe4\x93\x02G\x12\x45/v1beta/{parent=projects/*/scanConfigs/*/scanRuns/*}/findingTypeStats\xda\x41\x06parent\x1aU\xca\x41!websecurityscanner.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xca\x01\n*com.google.cloud.websecurityscanner.v1betaB\x17WebSecurityScannerProtoP\x01ZXgoogle.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner\xca\x02&Google\\Cloud\\WebSecurityScanner\\V1betab\x06proto3' - ), - dependencies=[ - google_dot_api_dot_annotations__pb2.DESCRIPTOR, - google_dot_api_dot_client__pb2.DESCRIPTOR, - google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, - google_dot_api_dot_resource__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_crawled__url__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__type__stats__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2.DESCRIPTOR, - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2.DESCRIPTOR, - google_dot_protobuf_dot_empty__pb2.DESCRIPTOR, - google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR, - ], -) - - -_CREATESCANCONFIGREQUEST = _descriptor.Descriptor( - name="CreateScanConfigRequest", - full_name="google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A-\n+cloudresourcemanager.googleapis.com/Project" - ), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="scan_config", - full_name="google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest.scan_config", - index=1, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=614, - serialized_end=786, -) - - -_DELETESCANCONFIGREQUEST = _descriptor.Descriptor( - name="DeleteScanConfigRequest", - full_name="google.cloud.websecurityscanner.v1beta.DeleteScanConfigRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1beta.DeleteScanConfigRequest.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A.\n,websecurityscanner.googleapis.com/ScanConfig" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=788, - serialized_end=881, -) - - -_GETSCANCONFIGREQUEST = _descriptor.Descriptor( - name="GetScanConfigRequest", - full_name="google.cloud.websecurityscanner.v1beta.GetScanConfigRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1beta.GetScanConfigRequest.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A.\n,websecurityscanner.googleapis.com/ScanConfig" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=883, - serialized_end=973, -) - - -_LISTSCANCONFIGSREQUEST = _descriptor.Descriptor( - name="ListScanConfigsRequest", - full_name="google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A-\n+cloudresourcemanager.googleapis.com/Project" - ), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_token", - full_name="google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest.page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_size", - full_name="google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest.page_size", - index=2, - number=3, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=976, - serialized_end=1108, -) - - -_UPDATESCANCONFIGREQUEST = _descriptor.Descriptor( - name="UpdateScanConfigRequest", - full_name="google.cloud.websecurityscanner.v1beta.UpdateScanConfigRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="scan_config", - full_name="google.cloud.websecurityscanner.v1beta.UpdateScanConfigRequest.scan_config", - index=0, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="update_mask", - full_name="google.cloud.websecurityscanner.v1beta.UpdateScanConfigRequest.update_mask", - index=1, - number=3, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1111, - serialized_end=1268, -) - - -_LISTSCANCONFIGSRESPONSE = _descriptor.Descriptor( - name="ListScanConfigsResponse", - full_name="google.cloud.websecurityscanner.v1beta.ListScanConfigsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="scan_configs", - full_name="google.cloud.websecurityscanner.v1beta.ListScanConfigsResponse.scan_configs", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="next_page_token", - full_name="google.cloud.websecurityscanner.v1beta.ListScanConfigsResponse.next_page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1270, - serialized_end=1394, -) - - -_STARTSCANRUNREQUEST = _descriptor.Descriptor( - name="StartScanRunRequest", - full_name="google.cloud.websecurityscanner.v1beta.StartScanRunRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1beta.StartScanRunRequest.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A.\n,websecurityscanner.googleapis.com/ScanConfig" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1396, - serialized_end=1485, -) - - -_GETSCANRUNREQUEST = _descriptor.Descriptor( - name="GetScanRunRequest", - full_name="google.cloud.websecurityscanner.v1beta.GetScanRunRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1beta.GetScanRunRequest.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A+\n)websecurityscanner.googleapis.com/ScanRun" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1487, - serialized_end=1571, -) - - -_LISTSCANRUNSREQUEST = _descriptor.Descriptor( - name="ListScanRunsRequest", - full_name="google.cloud.websecurityscanner.v1beta.ListScanRunsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.websecurityscanner.v1beta.ListScanRunsRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A.\n,websecurityscanner.googleapis.com/ScanConfig" - ), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_token", - full_name="google.cloud.websecurityscanner.v1beta.ListScanRunsRequest.page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_size", - full_name="google.cloud.websecurityscanner.v1beta.ListScanRunsRequest.page_size", - index=2, - number=3, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1574, - serialized_end=1704, -) - - -_LISTSCANRUNSRESPONSE = _descriptor.Descriptor( - name="ListScanRunsResponse", - full_name="google.cloud.websecurityscanner.v1beta.ListScanRunsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="scan_runs", - full_name="google.cloud.websecurityscanner.v1beta.ListScanRunsResponse.scan_runs", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="next_page_token", - full_name="google.cloud.websecurityscanner.v1beta.ListScanRunsResponse.next_page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1706, - serialized_end=1821, -) - - -_STOPSCANRUNREQUEST = _descriptor.Descriptor( - name="StopScanRunRequest", - full_name="google.cloud.websecurityscanner.v1beta.StopScanRunRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1beta.StopScanRunRequest.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A+\n)websecurityscanner.googleapis.com/ScanRun" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1823, - serialized_end=1908, -) - - -_LISTCRAWLEDURLSREQUEST = _descriptor.Descriptor( - name="ListCrawledUrlsRequest", - full_name="google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A+\n)websecurityscanner.googleapis.com/ScanRun" - ), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_token", - full_name="google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest.page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_size", - full_name="google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest.page_size", - index=2, - number=3, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1911, - serialized_end=2041, -) - - -_LISTCRAWLEDURLSRESPONSE = _descriptor.Descriptor( - name="ListCrawledUrlsResponse", - full_name="google.cloud.websecurityscanner.v1beta.ListCrawledUrlsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="crawled_urls", - full_name="google.cloud.websecurityscanner.v1beta.ListCrawledUrlsResponse.crawled_urls", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="next_page_token", - full_name="google.cloud.websecurityscanner.v1beta.ListCrawledUrlsResponse.next_page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2043, - serialized_end=2167, -) - - -_GETFINDINGREQUEST = _descriptor.Descriptor( - name="GetFindingRequest", - full_name="google.cloud.websecurityscanner.v1beta.GetFindingRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="name", - full_name="google.cloud.websecurityscanner.v1beta.GetFindingRequest.name", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A+\n)websecurityscanner.googleapis.com/Finding" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2169, - serialized_end=2253, -) - - -_LISTFINDINGSREQUEST = _descriptor.Descriptor( - name="ListFindingsRequest", - full_name="google.cloud.websecurityscanner.v1beta.ListFindingsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.websecurityscanner.v1beta.ListFindingsRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A+\n)websecurityscanner.googleapis.com/ScanRun" - ), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="filter", - full_name="google.cloud.websecurityscanner.v1beta.ListFindingsRequest.filter", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_token", - full_name="google.cloud.websecurityscanner.v1beta.ListFindingsRequest.page_token", - index=2, - number=3, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_size", - full_name="google.cloud.websecurityscanner.v1beta.ListFindingsRequest.page_size", - index=3, - number=4, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2256, - serialized_end=2404, -) - - -_LISTFINDINGSRESPONSE = _descriptor.Descriptor( - name="ListFindingsResponse", - full_name="google.cloud.websecurityscanner.v1beta.ListFindingsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="findings", - full_name="google.cloud.websecurityscanner.v1beta.ListFindingsResponse.findings", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="next_page_token", - full_name="google.cloud.websecurityscanner.v1beta.ListFindingsResponse.next_page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2406, - serialized_end=2520, -) - - -_LISTFINDINGTYPESTATSREQUEST = _descriptor.Descriptor( - name="ListFindingTypeStatsRequest", - full_name="google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b( - "\340A\002\372A+\n)websecurityscanner.googleapis.com/ScanRun" - ), - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2522, - serialized_end=2618, -) - - -_LISTFINDINGTYPESTATSRESPONSE = _descriptor.Descriptor( - name="ListFindingTypeStatsResponse", - full_name="google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="finding_type_stats", - full_name="google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsResponse.finding_type_stats", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2620, - serialized_end=2736, -) - -_CREATESCANCONFIGREQUEST.fields_by_name[ - "scan_config" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2._SCANCONFIG -) -_UPDATESCANCONFIGREQUEST.fields_by_name[ - "scan_config" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2._SCANCONFIG -) -_UPDATESCANCONFIGREQUEST.fields_by_name[ - "update_mask" -].message_type = google_dot_protobuf_dot_field__mask__pb2._FIELDMASK -_LISTSCANCONFIGSRESPONSE.fields_by_name[ - "scan_configs" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2._SCANCONFIG -) -_LISTSCANRUNSRESPONSE.fields_by_name[ - "scan_runs" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2._SCANRUN -) -_LISTCRAWLEDURLSRESPONSE.fields_by_name[ - "crawled_urls" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_crawled__url__pb2._CRAWLEDURL -) -_LISTFINDINGSRESPONSE.fields_by_name[ - "findings" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__pb2._FINDING -) -_LISTFINDINGTYPESTATSRESPONSE.fields_by_name[ - "finding_type_stats" -].message_type = ( - google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__type__stats__pb2._FINDINGTYPESTATS -) -DESCRIPTOR.message_types_by_name["CreateScanConfigRequest"] = _CREATESCANCONFIGREQUEST -DESCRIPTOR.message_types_by_name["DeleteScanConfigRequest"] = _DELETESCANCONFIGREQUEST -DESCRIPTOR.message_types_by_name["GetScanConfigRequest"] = _GETSCANCONFIGREQUEST -DESCRIPTOR.message_types_by_name["ListScanConfigsRequest"] = _LISTSCANCONFIGSREQUEST -DESCRIPTOR.message_types_by_name["UpdateScanConfigRequest"] = _UPDATESCANCONFIGREQUEST -DESCRIPTOR.message_types_by_name["ListScanConfigsResponse"] = _LISTSCANCONFIGSRESPONSE -DESCRIPTOR.message_types_by_name["StartScanRunRequest"] = _STARTSCANRUNREQUEST -DESCRIPTOR.message_types_by_name["GetScanRunRequest"] = _GETSCANRUNREQUEST -DESCRIPTOR.message_types_by_name["ListScanRunsRequest"] = _LISTSCANRUNSREQUEST -DESCRIPTOR.message_types_by_name["ListScanRunsResponse"] = _LISTSCANRUNSRESPONSE -DESCRIPTOR.message_types_by_name["StopScanRunRequest"] = _STOPSCANRUNREQUEST -DESCRIPTOR.message_types_by_name["ListCrawledUrlsRequest"] = _LISTCRAWLEDURLSREQUEST -DESCRIPTOR.message_types_by_name["ListCrawledUrlsResponse"] = _LISTCRAWLEDURLSRESPONSE -DESCRIPTOR.message_types_by_name["GetFindingRequest"] = _GETFINDINGREQUEST -DESCRIPTOR.message_types_by_name["ListFindingsRequest"] = _LISTFINDINGSREQUEST -DESCRIPTOR.message_types_by_name["ListFindingsResponse"] = _LISTFINDINGSRESPONSE -DESCRIPTOR.message_types_by_name[ - "ListFindingTypeStatsRequest" -] = _LISTFINDINGTYPESTATSREQUEST -DESCRIPTOR.message_types_by_name[ - "ListFindingTypeStatsResponse" -] = _LISTFINDINGTYPESTATSRESPONSE -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -CreateScanConfigRequest = _reflection.GeneratedProtocolMessageType( - "CreateScanConfigRequest", - (_message.Message,), - dict( - DESCRIPTOR=_CREATESCANCONFIGREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``CreateScanConfig`` method. - - - Attributes: - parent: - Required. The parent resource name where the scan is created, - which should be a project resource name in the format - 'projects/{projectId}'. - scan_config: - Required. The ScanConfig to be created. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest) - ), -) -_sym_db.RegisterMessage(CreateScanConfigRequest) - -DeleteScanConfigRequest = _reflection.GeneratedProtocolMessageType( - "DeleteScanConfigRequest", - (_message.Message,), - dict( - DESCRIPTOR=_DELETESCANCONFIGREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``DeleteScanConfig`` method. - - - Attributes: - name: - Required. The resource name of the ScanConfig to be deleted. - The name follows the format of - 'projects/{projectId}/scanConfigs/{scanConfigId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.DeleteScanConfigRequest) - ), -) -_sym_db.RegisterMessage(DeleteScanConfigRequest) - -GetScanConfigRequest = _reflection.GeneratedProtocolMessageType( - "GetScanConfigRequest", - (_message.Message,), - dict( - DESCRIPTOR=_GETSCANCONFIGREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``GetScanConfig`` method. - - - Attributes: - name: - Required. The resource name of the ScanConfig to be returned. - The name follows the format of - 'projects/{projectId}/scanConfigs/{scanConfigId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.GetScanConfigRequest) - ), -) -_sym_db.RegisterMessage(GetScanConfigRequest) - -ListScanConfigsRequest = _reflection.GeneratedProtocolMessageType( - "ListScanConfigsRequest", - (_message.Message,), - dict( - DESCRIPTOR=_LISTSCANCONFIGSREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``ListScanConfigs`` method. - - - Attributes: - parent: - Required. The parent resource name, which should be a project - resource name in the format 'projects/{projectId}'. - page_token: - A token identifying a page of results to be returned. This - should be a ``next_page_token`` value returned from a previous - List request. If unspecified, the first page of results is - returned. - page_size: - The maximum number of ScanConfigs to return, can be limited by - server. If not specified or not positive, the implementation - will select a reasonable value. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest) - ), -) -_sym_db.RegisterMessage(ListScanConfigsRequest) - -UpdateScanConfigRequest = _reflection.GeneratedProtocolMessageType( - "UpdateScanConfigRequest", - (_message.Message,), - dict( - DESCRIPTOR=_UPDATESCANCONFIGREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``UpdateScanConfigRequest`` method. - - - Attributes: - scan_config: - Required. The ScanConfig to be updated. The name field must be - set to identify the resource to be updated. The values of - fields not covered by the mask will be ignored. - update_mask: - Required. The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol- - buffers/docs/reference/google.protobuf#fieldmask - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.UpdateScanConfigRequest) - ), -) -_sym_db.RegisterMessage(UpdateScanConfigRequest) - -ListScanConfigsResponse = _reflection.GeneratedProtocolMessageType( - "ListScanConfigsResponse", - (_message.Message,), - dict( - DESCRIPTOR=_LISTSCANCONFIGSRESPONSE, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Response for the ``ListScanConfigs`` method. - - - Attributes: - scan_configs: - The list of ScanConfigs returned. - next_page_token: - Token to retrieve the next page of results, or empty if there - are no more results in the list. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ListScanConfigsResponse) - ), -) -_sym_db.RegisterMessage(ListScanConfigsResponse) - -StartScanRunRequest = _reflection.GeneratedProtocolMessageType( - "StartScanRunRequest", - (_message.Message,), - dict( - DESCRIPTOR=_STARTSCANRUNREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``StartScanRun`` method. - - - Attributes: - name: - Required. The resource name of the ScanConfig to be used. The - name follows the format of - 'projects/{projectId}/scanConfigs/{scanConfigId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.StartScanRunRequest) - ), -) -_sym_db.RegisterMessage(StartScanRunRequest) - -GetScanRunRequest = _reflection.GeneratedProtocolMessageType( - "GetScanRunRequest", - (_message.Message,), - dict( - DESCRIPTOR=_GETSCANRUNREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``GetScanRun`` method. - - - Attributes: - name: - Required. The resource name of the ScanRun to be returned. The - name follows the format of 'projects/{projectId}/scanConfigs/{ - scanConfigId}/scanRuns/{scanRunId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.GetScanRunRequest) - ), -) -_sym_db.RegisterMessage(GetScanRunRequest) - -ListScanRunsRequest = _reflection.GeneratedProtocolMessageType( - "ListScanRunsRequest", - (_message.Message,), - dict( - DESCRIPTOR=_LISTSCANRUNSREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``ListScanRuns`` method. - - - Attributes: - parent: - Required. The parent resource name, which should be a scan - resource name in the format - 'projects/{projectId}/scanConfigs/{scanConfigId}'. - page_token: - A token identifying a page of results to be returned. This - should be a ``next_page_token`` value returned from a previous - List request. If unspecified, the first page of results is - returned. - page_size: - The maximum number of ScanRuns to return, can be limited by - server. If not specified or not positive, the implementation - will select a reasonable value. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ListScanRunsRequest) - ), -) -_sym_db.RegisterMessage(ListScanRunsRequest) - -ListScanRunsResponse = _reflection.GeneratedProtocolMessageType( - "ListScanRunsResponse", - (_message.Message,), - dict( - DESCRIPTOR=_LISTSCANRUNSRESPONSE, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Response for the ``ListScanRuns`` method. - - - Attributes: - scan_runs: - The list of ScanRuns returned. - next_page_token: - Token to retrieve the next page of results, or empty if there - are no more results in the list. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ListScanRunsResponse) - ), -) -_sym_db.RegisterMessage(ListScanRunsResponse) - -StopScanRunRequest = _reflection.GeneratedProtocolMessageType( - "StopScanRunRequest", - (_message.Message,), - dict( - DESCRIPTOR=_STOPSCANRUNREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``StopScanRun`` method. - - - Attributes: - name: - Required. The resource name of the ScanRun to be stopped. The - name follows the format of 'projects/{projectId}/scanConfigs/{ - scanConfigId}/scanRuns/{scanRunId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.StopScanRunRequest) - ), -) -_sym_db.RegisterMessage(StopScanRunRequest) - -ListCrawledUrlsRequest = _reflection.GeneratedProtocolMessageType( - "ListCrawledUrlsRequest", - (_message.Message,), - dict( - DESCRIPTOR=_LISTCRAWLEDURLSREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``ListCrawledUrls`` method. - - - Attributes: - parent: - Required. The parent resource name, which should be a scan run - resource name in the format 'projects/{projectId}/scanConfigs/ - {scanConfigId}/scanRuns/{scanRunId}'. - page_token: - A token identifying a page of results to be returned. This - should be a ``next_page_token`` value returned from a previous - List request. If unspecified, the first page of results is - returned. - page_size: - The maximum number of CrawledUrls to return, can be limited by - server. If not specified or not positive, the implementation - will select a reasonable value. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest) - ), -) -_sym_db.RegisterMessage(ListCrawledUrlsRequest) - -ListCrawledUrlsResponse = _reflection.GeneratedProtocolMessageType( - "ListCrawledUrlsResponse", - (_message.Message,), - dict( - DESCRIPTOR=_LISTCRAWLEDURLSRESPONSE, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Response for the ``ListCrawledUrls`` method. - - - Attributes: - crawled_urls: - The list of CrawledUrls returned. - next_page_token: - Token to retrieve the next page of results, or empty if there - are no more results in the list. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ListCrawledUrlsResponse) - ), -) -_sym_db.RegisterMessage(ListCrawledUrlsResponse) - -GetFindingRequest = _reflection.GeneratedProtocolMessageType( - "GetFindingRequest", - (_message.Message,), - dict( - DESCRIPTOR=_GETFINDINGREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``GetFinding`` method. - - - Attributes: - name: - Required. The resource name of the Finding to be returned. The - name follows the format of 'projects/{projectId}/scanConfigs/{ - scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.GetFindingRequest) - ), -) -_sym_db.RegisterMessage(GetFindingRequest) - -ListFindingsRequest = _reflection.GeneratedProtocolMessageType( - "ListFindingsRequest", - (_message.Message,), - dict( - DESCRIPTOR=_LISTFINDINGSREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``ListFindings`` method. - - - Attributes: - parent: - Required. The parent resource name, which should be a scan run - resource name in the format 'projects/{projectId}/scanConfigs/ - {scanConfigId}/scanRuns/{scanRunId}'. - filter: - Required. The filter expression. The expression must be in the - format: . Supported field: 'finding\_type'. Supported - operator: '='. - page_token: - A token identifying a page of results to be returned. This - should be a ``next_page_token`` value returned from a previous - List request. If unspecified, the first page of results is - returned. - page_size: - The maximum number of Findings to return, can be limited by - server. If not specified or not positive, the implementation - will select a reasonable value. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ListFindingsRequest) - ), -) -_sym_db.RegisterMessage(ListFindingsRequest) - -ListFindingsResponse = _reflection.GeneratedProtocolMessageType( - "ListFindingsResponse", - (_message.Message,), - dict( - DESCRIPTOR=_LISTFINDINGSRESPONSE, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Response for the ``ListFindings`` method. - - - Attributes: - findings: - The list of Findings returned. - next_page_token: - Token to retrieve the next page of results, or empty if there - are no more results in the list. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ListFindingsResponse) - ), -) -_sym_db.RegisterMessage(ListFindingsResponse) - -ListFindingTypeStatsRequest = _reflection.GeneratedProtocolMessageType( - "ListFindingTypeStatsRequest", - (_message.Message,), - dict( - DESCRIPTOR=_LISTFINDINGTYPESTATSREQUEST, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Request for the ``ListFindingTypeStats`` method. - - - Attributes: - parent: - Required. The parent resource name, which should be a scan run - resource name in the format 'projects/{projectId}/scanConfigs/ - {scanConfigId}/scanRuns/{scanRunId}'. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsRequest) - ), -) -_sym_db.RegisterMessage(ListFindingTypeStatsRequest) - -ListFindingTypeStatsResponse = _reflection.GeneratedProtocolMessageType( - "ListFindingTypeStatsResponse", - (_message.Message,), - dict( - DESCRIPTOR=_LISTFINDINGTYPESTATSRESPONSE, - __module__="google.cloud.websecurityscanner_v1beta.proto.web_security_scanner_pb2", - __doc__="""Response for the ``ListFindingTypeStats`` method. - - - Attributes: - finding_type_stats: - The list of FindingTypeStats returned. - """, - # @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsResponse) - ), -) -_sym_db.RegisterMessage(ListFindingTypeStatsResponse) - - -DESCRIPTOR._options = None -_CREATESCANCONFIGREQUEST.fields_by_name["parent"]._options = None -_CREATESCANCONFIGREQUEST.fields_by_name["scan_config"]._options = None -_DELETESCANCONFIGREQUEST.fields_by_name["name"]._options = None -_GETSCANCONFIGREQUEST.fields_by_name["name"]._options = None -_LISTSCANCONFIGSREQUEST.fields_by_name["parent"]._options = None -_UPDATESCANCONFIGREQUEST.fields_by_name["scan_config"]._options = None -_UPDATESCANCONFIGREQUEST.fields_by_name["update_mask"]._options = None -_STARTSCANRUNREQUEST.fields_by_name["name"]._options = None -_GETSCANRUNREQUEST.fields_by_name["name"]._options = None -_LISTSCANRUNSREQUEST.fields_by_name["parent"]._options = None -_STOPSCANRUNREQUEST.fields_by_name["name"]._options = None -_LISTCRAWLEDURLSREQUEST.fields_by_name["parent"]._options = None -_GETFINDINGREQUEST.fields_by_name["name"]._options = None -_LISTFINDINGSREQUEST.fields_by_name["parent"]._options = None -_LISTFINDINGSREQUEST.fields_by_name["filter"]._options = None -_LISTFINDINGTYPESTATSREQUEST.fields_by_name["parent"]._options = None - -_WEBSECURITYSCANNER = _descriptor.ServiceDescriptor( - name="WebSecurityScanner", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner", - file=DESCRIPTOR, - index=0, - serialized_options=_b( - "\312A!websecurityscanner.googleapis.com\322A.https://www.googleapis.com/auth/cloud-platform" - ), - serialized_start=2739, - serialized_end=5569, - methods=[ - _descriptor.MethodDescriptor( - name="CreateScanConfig", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.CreateScanConfig", - index=0, - containing_service=None, - input_type=_CREATESCANCONFIGREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2._SCANCONFIG, - serialized_options=_b( - "\202\323\344\223\0026\"'/v1beta/{parent=projects/*}/scanConfigs:\013scan_config\332A\022parent,scan_config" - ), - ), - _descriptor.MethodDescriptor( - name="DeleteScanConfig", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.DeleteScanConfig", - index=1, - containing_service=None, - input_type=_DELETESCANCONFIGREQUEST, - output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, - serialized_options=_b( - "\202\323\344\223\002)*'/v1beta/{name=projects/*/scanConfigs/*}\332A\004name" - ), - ), - _descriptor.MethodDescriptor( - name="GetScanConfig", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.GetScanConfig", - index=2, - containing_service=None, - input_type=_GETSCANCONFIGREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2._SCANCONFIG, - serialized_options=_b( - "\202\323\344\223\002)\022'/v1beta/{name=projects/*/scanConfigs/*}\332A\004name" - ), - ), - _descriptor.MethodDescriptor( - name="ListScanConfigs", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.ListScanConfigs", - index=3, - containing_service=None, - input_type=_LISTSCANCONFIGSREQUEST, - output_type=_LISTSCANCONFIGSRESPONSE, - serialized_options=_b( - "\202\323\344\223\002)\022'/v1beta/{parent=projects/*}/scanConfigs\332A\006parent" - ), - ), - _descriptor.MethodDescriptor( - name="UpdateScanConfig", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.UpdateScanConfig", - index=4, - containing_service=None, - input_type=_UPDATESCANCONFIGREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2._SCANCONFIG, - serialized_options=_b( - "\202\323\344\223\002B23/v1beta/{scan_config.name=projects/*/scanConfigs/*}:\013scan_config\332A\027scan_config,update_mask" - ), - ), - _descriptor.MethodDescriptor( - name="StartScanRun", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.StartScanRun", - index=5, - containing_service=None, - input_type=_STARTSCANRUNREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2._SCANRUN, - serialized_options=_b( - '\202\323\344\223\0022"-/v1beta/{name=projects/*/scanConfigs/*}:start:\001*\332A\004name' - ), - ), - _descriptor.MethodDescriptor( - name="GetScanRun", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.GetScanRun", - index=6, - containing_service=None, - input_type=_GETSCANRUNREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2._SCANRUN, - serialized_options=_b( - "\202\323\344\223\0024\0222/v1beta/{name=projects/*/scanConfigs/*/scanRuns/*}\332A\004name" - ), - ), - _descriptor.MethodDescriptor( - name="ListScanRuns", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.ListScanRuns", - index=7, - containing_service=None, - input_type=_LISTSCANRUNSREQUEST, - output_type=_LISTSCANRUNSRESPONSE, - serialized_options=_b( - "\202\323\344\223\0024\0222/v1beta/{parent=projects/*/scanConfigs/*}/scanRuns\332A\006parent" - ), - ), - _descriptor.MethodDescriptor( - name="StopScanRun", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.StopScanRun", - index=8, - containing_service=None, - input_type=_STOPSCANRUNREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2._SCANRUN, - serialized_options=_b( - '\202\323\344\223\002<"7/v1beta/{name=projects/*/scanConfigs/*/scanRuns/*}:stop:\001*\332A\004name' - ), - ), - _descriptor.MethodDescriptor( - name="ListCrawledUrls", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.ListCrawledUrls", - index=9, - containing_service=None, - input_type=_LISTCRAWLEDURLSREQUEST, - output_type=_LISTCRAWLEDURLSRESPONSE, - serialized_options=_b( - "\202\323\344\223\002B\022@/v1beta/{parent=projects/*/scanConfigs/*/scanRuns/*}/crawledUrls\332A\006parent" - ), - ), - _descriptor.MethodDescriptor( - name="GetFinding", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.GetFinding", - index=10, - containing_service=None, - input_type=_GETFINDINGREQUEST, - output_type=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__pb2._FINDING, - serialized_options=_b( - "\202\323\344\223\002?\022=/v1beta/{name=projects/*/scanConfigs/*/scanRuns/*/findings/*}\332A\004name" - ), - ), - _descriptor.MethodDescriptor( - name="ListFindings", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.ListFindings", - index=11, - containing_service=None, - input_type=_LISTFINDINGSREQUEST, - output_type=_LISTFINDINGSRESPONSE, - serialized_options=_b( - "\202\323\344\223\002?\022=/v1beta/{parent=projects/*/scanConfigs/*/scanRuns/*}/findings\332A\rparent,filter" - ), - ), - _descriptor.MethodDescriptor( - name="ListFindingTypeStats", - full_name="google.cloud.websecurityscanner.v1beta.WebSecurityScanner.ListFindingTypeStats", - index=12, - containing_service=None, - input_type=_LISTFINDINGTYPESTATSREQUEST, - output_type=_LISTFINDINGTYPESTATSRESPONSE, - serialized_options=_b( - "\202\323\344\223\002G\022E/v1beta/{parent=projects/*/scanConfigs/*/scanRuns/*}/findingTypeStats\332A\006parent" - ), - ), - ], -) -_sym_db.RegisterServiceDescriptor(_WEBSECURITYSCANNER) - -DESCRIPTOR.services_by_name["WebSecurityScanner"] = _WEBSECURITYSCANNER - -# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/websecurityscanner_v1beta/proto/web_security_scanner_pb2_grpc.py b/google/cloud/websecurityscanner_v1beta/proto/web_security_scanner_pb2_grpc.py deleted file mode 100644 index 172dfb8..0000000 --- a/google/cloud/websecurityscanner_v1beta/proto/web_security_scanner_pb2_grpc.py +++ /dev/null @@ -1,268 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc - -from google.cloud.websecurityscanner_v1beta.proto import ( - finding_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__pb2, -) -from google.cloud.websecurityscanner_v1beta.proto import ( - scan_config_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2, -) -from google.cloud.websecurityscanner_v1beta.proto import ( - scan_run_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2, -) -from google.cloud.websecurityscanner_v1beta.proto import ( - web_security_scanner_pb2 as google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2, -) -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 - - -class WebSecurityScannerStub(object): - """Cloud Web Security Scanner Service identifies security vulnerabilities in web - applications hosted on Google Cloud Platform. It crawls your application, and - attempts to exercise as many user inputs and event handlers as possible. - """ - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.CreateScanConfig = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/CreateScanConfig", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.CreateScanConfigRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2.ScanConfig.FromString, - ) - self.DeleteScanConfig = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/DeleteScanConfig", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.DeleteScanConfigRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.GetScanConfig = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanConfig", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.GetScanConfigRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2.ScanConfig.FromString, - ) - self.ListScanConfigs = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanConfigs", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListScanConfigsRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListScanConfigsResponse.FromString, - ) - self.UpdateScanConfig = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/UpdateScanConfig", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.UpdateScanConfigRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2.ScanConfig.FromString, - ) - self.StartScanRun = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StartScanRun", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.StartScanRunRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2.ScanRun.FromString, - ) - self.GetScanRun = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanRun", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.GetScanRunRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2.ScanRun.FromString, - ) - self.ListScanRuns = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanRuns", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListScanRunsRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListScanRunsResponse.FromString, - ) - self.StopScanRun = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StopScanRun", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.StopScanRunRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2.ScanRun.FromString, - ) - self.ListCrawledUrls = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListCrawledUrls", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListCrawledUrlsRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListCrawledUrlsResponse.FromString, - ) - self.GetFinding = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetFinding", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.GetFindingRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__pb2.Finding.FromString, - ) - self.ListFindings = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindings", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListFindingsRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListFindingsResponse.FromString, - ) - self.ListFindingTypeStats = channel.unary_unary( - "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindingTypeStats", - request_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListFindingTypeStatsRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListFindingTypeStatsResponse.FromString, - ) - - -class WebSecurityScannerServicer(object): - """Cloud Web Security Scanner Service identifies security vulnerabilities in web - applications hosted on Google Cloud Platform. It crawls your application, and - attempts to exercise as many user inputs and event handlers as possible. - """ - - def CreateScanConfig(self, request, context): - """Creates a new ScanConfig. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def DeleteScanConfig(self, request, context): - """Deletes an existing ScanConfig and its child resources. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def GetScanConfig(self, request, context): - """Gets a ScanConfig. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def ListScanConfigs(self, request, context): - """Lists ScanConfigs under a given project. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def UpdateScanConfig(self, request, context): - """Updates a ScanConfig. This method support partial update of a ScanConfig. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def StartScanRun(self, request, context): - """Start a ScanRun according to the given ScanConfig. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def GetScanRun(self, request, context): - """Gets a ScanRun. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def ListScanRuns(self, request, context): - """Lists ScanRuns under a given ScanConfig, in descending order of ScanRun - stop time. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def StopScanRun(self, request, context): - """Stops a ScanRun. The stopped ScanRun is returned. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def ListCrawledUrls(self, request, context): - """List CrawledUrls under a given ScanRun. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def GetFinding(self, request, context): - """Gets a Finding. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def ListFindings(self, request, context): - """List Findings under a given ScanRun. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def ListFindingTypeStats(self, request, context): - """List all FindingTypeStats under a given ScanRun. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - -def add_WebSecurityScannerServicer_to_server(servicer, server): - rpc_method_handlers = { - "CreateScanConfig": grpc.unary_unary_rpc_method_handler( - servicer.CreateScanConfig, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.CreateScanConfigRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2.ScanConfig.SerializeToString, - ), - "DeleteScanConfig": grpc.unary_unary_rpc_method_handler( - servicer.DeleteScanConfig, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.DeleteScanConfigRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - "GetScanConfig": grpc.unary_unary_rpc_method_handler( - servicer.GetScanConfig, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.GetScanConfigRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2.ScanConfig.SerializeToString, - ), - "ListScanConfigs": grpc.unary_unary_rpc_method_handler( - servicer.ListScanConfigs, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListScanConfigsRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListScanConfigsResponse.SerializeToString, - ), - "UpdateScanConfig": grpc.unary_unary_rpc_method_handler( - servicer.UpdateScanConfig, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.UpdateScanConfigRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__config__pb2.ScanConfig.SerializeToString, - ), - "StartScanRun": grpc.unary_unary_rpc_method_handler( - servicer.StartScanRun, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.StartScanRunRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2.ScanRun.SerializeToString, - ), - "GetScanRun": grpc.unary_unary_rpc_method_handler( - servicer.GetScanRun, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.GetScanRunRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2.ScanRun.SerializeToString, - ), - "ListScanRuns": grpc.unary_unary_rpc_method_handler( - servicer.ListScanRuns, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListScanRunsRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListScanRunsResponse.SerializeToString, - ), - "StopScanRun": grpc.unary_unary_rpc_method_handler( - servicer.StopScanRun, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.StopScanRunRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_scan__run__pb2.ScanRun.SerializeToString, - ), - "ListCrawledUrls": grpc.unary_unary_rpc_method_handler( - servicer.ListCrawledUrls, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListCrawledUrlsRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListCrawledUrlsResponse.SerializeToString, - ), - "GetFinding": grpc.unary_unary_rpc_method_handler( - servicer.GetFinding, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.GetFindingRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_finding__pb2.Finding.SerializeToString, - ), - "ListFindings": grpc.unary_unary_rpc_method_handler( - servicer.ListFindings, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListFindingsRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListFindingsResponse.SerializeToString, - ), - "ListFindingTypeStats": grpc.unary_unary_rpc_method_handler( - servicer.ListFindingTypeStats, - request_deserializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListFindingTypeStatsRequest.FromString, - response_serializer=google_dot_cloud_dot_websecurityscanner__v1beta_dot_proto_dot_web__security__scanner__pb2.ListFindingTypeStatsResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", rpc_method_handlers - ) - server.add_generic_rpc_handlers((generic_handler,)) diff --git a/google/cloud/websecurityscanner_v1beta/py.typed b/google/cloud/websecurityscanner_v1beta/py.typed new file mode 100644 index 0000000..8cfb5d2 --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-websecurityscanner package uses inline types. diff --git a/google/cloud/__init__.py b/google/cloud/websecurityscanner_v1beta/services/__init__.py similarity index 66% rename from google/cloud/__init__.py rename to google/cloud/websecurityscanner_v1beta/services/__init__.py index dd3a9f4..42ffdf2 100644 --- a/google/cloud/__init__.py +++ b/google/cloud/websecurityscanner_v1beta/services/__init__.py @@ -1,22 +1,16 @@ -# Copyright 2018 Google LLC +# -*- coding: utf-8 -*- + +# Copyright 2020 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 # -# https://www.apache.org/licenses/LICENSE-2.0 +# 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. - -try: - import pkg_resources - - pkg_resources.declare_namespace(__name__) -except ImportError: - import pkgutil - - __path__ = pkgutil.extend_path(__path__, __name__) +# diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/__init__.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/__init__.py new file mode 100644 index 0000000..d841cb5 --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 .client import WebSecurityScannerClient +from .async_client import WebSecurityScannerAsyncClient + +__all__ = ( + "WebSecurityScannerClient", + "WebSecurityScannerAsyncClient", +) diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py new file mode 100644 index 0000000..9f2250b --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py @@ -0,0 +1,1206 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 collections import OrderedDict +import functools +import re +from typing import Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.websecurityscanner_v1beta.services.web_security_scanner import pagers +from google.cloud.websecurityscanner_v1beta.types import crawled_url +from google.cloud.websecurityscanner_v1beta.types import finding +from google.cloud.websecurityscanner_v1beta.types import finding_addon +from google.cloud.websecurityscanner_v1beta.types import finding_type_stats +from google.cloud.websecurityscanner_v1beta.types import scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_run +from google.cloud.websecurityscanner_v1beta.types import scan_run_error_trace +from google.cloud.websecurityscanner_v1beta.types import scan_run_warning_trace +from google.cloud.websecurityscanner_v1beta.types import web_security_scanner +from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import timestamp_pb2 as timestamp # type: ignore + +from .transports.base import WebSecurityScannerTransport +from .transports.grpc_asyncio import WebSecurityScannerGrpcAsyncIOTransport +from .client import WebSecurityScannerClient + + +class WebSecurityScannerAsyncClient: + """Cloud Web Security Scanner Service identifies security + vulnerabilities in web applications hosted on Google Cloud + Platform. It crawls your application, and attempts to exercise + as many user inputs and event handlers as possible. + """ + + _client: WebSecurityScannerClient + + DEFAULT_ENDPOINT = WebSecurityScannerClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = WebSecurityScannerClient.DEFAULT_MTLS_ENDPOINT + + scan_config_path = staticmethod(WebSecurityScannerClient.scan_config_path) + + scan_run_path = staticmethod(WebSecurityScannerClient.scan_run_path) + + from_service_account_file = WebSecurityScannerClient.from_service_account_file + from_service_account_json = from_service_account_file + + get_transport_class = functools.partial( + type(WebSecurityScannerClient).get_transport_class, + type(WebSecurityScannerClient), + ) + + def __init__( + self, + *, + credentials: credentials.Credentials = None, + transport: Union[str, WebSecurityScannerTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + ) -> None: + """Instantiate the web security scanner client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.WebSecurityScannerTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint, this is the default value for + the environment variable) and "auto" (auto switch to the default + mTLS endpoint if client SSL credentials is present). However, + the ``api_endpoint`` property takes precedence if provided. + (2) The ``client_cert_source`` property is used to provide client + SSL credentials for mutual TLS transport. If not provided, the + default SSL credentials will be used if present. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + """ + + self._client = WebSecurityScannerClient( + credentials=credentials, transport=transport, client_options=client_options, + ) + + async def create_scan_config( + self, + request: web_security_scanner.CreateScanConfigRequest = None, + *, + parent: str = None, + scan_config: gcw_scan_config.ScanConfig = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gcw_scan_config.ScanConfig: + r"""Creates a new ScanConfig. + + Args: + request (:class:`~.web_security_scanner.CreateScanConfigRequest`): + The request object. Request for the `CreateScanConfig` + method. + parent (:class:`str`): + Required. The parent resource name + where the scan is created, which should + be a project resource name in the format + 'projects/{projectId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + scan_config (:class:`~.gcw_scan_config.ScanConfig`): + Required. The ScanConfig to be + created. + This corresponds to the ``scan_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.gcw_scan_config.ScanConfig: + A ScanConfig resource contains the + configurations to launch a scan. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent, scan_config]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.CreateScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if scan_config is not None: + request.scan_config = scan_config + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_scan_config, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def delete_scan_config( + self, + request: web_security_scanner.DeleteScanConfigRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an existing ScanConfig and its child + resources. + + Args: + request (:class:`~.web_security_scanner.DeleteScanConfigRequest`): + The request object. Request for the `DeleteScanConfig` + method. + name (:class:`str`): + Required. The resource name of the + ScanConfig to be deleted. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.DeleteScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_scan_config, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + await rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + async def get_scan_config( + self, + request: web_security_scanner.GetScanConfigRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_config.ScanConfig: + r"""Gets a ScanConfig. + + Args: + request (:class:`~.web_security_scanner.GetScanConfigRequest`): + The request object. Request for the `GetScanConfig` + method. + name (:class:`str`): + Required. The resource name of the + ScanConfig to be returned. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_config.ScanConfig: + A ScanConfig resource contains the + configurations to launch a scan. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.GetScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_scan_config, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_scan_configs( + self, + request: web_security_scanner.ListScanConfigsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListScanConfigsAsyncPager: + r"""Lists ScanConfigs under a given project. + + Args: + request (:class:`~.web_security_scanner.ListScanConfigsRequest`): + The request object. Request for the `ListScanConfigs` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a project resource name + in the format 'projects/{projectId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListScanConfigsAsyncPager: + Response for the ``ListScanConfigs`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListScanConfigsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_scan_configs, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListScanConfigsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_scan_config( + self, + request: web_security_scanner.UpdateScanConfigRequest = None, + *, + scan_config: gcw_scan_config.ScanConfig = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gcw_scan_config.ScanConfig: + r"""Updates a ScanConfig. This method support partial + update of a ScanConfig. + + Args: + request (:class:`~.web_security_scanner.UpdateScanConfigRequest`): + The request object. Request for the + `UpdateScanConfigRequest` method. + scan_config (:class:`~.gcw_scan_config.ScanConfig`): + Required. The ScanConfig to be + updated. The name field must be set to + identify the resource to be updated. The + values of fields not covered by the mask + will be ignored. + This corresponds to the ``scan_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`~.field_mask.FieldMask`): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.gcw_scan_config.ScanConfig: + A ScanConfig resource contains the + configurations to launch a scan. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([scan_config, update_mask]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.UpdateScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if scan_config is not None: + request.scan_config = scan_config + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_scan_config, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("scan_config.name", request.scan_config.name),) + ), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def start_scan_run( + self, + request: web_security_scanner.StartScanRunRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_run.ScanRun: + r"""Start a ScanRun according to the given ScanConfig. + + Args: + request (:class:`~.web_security_scanner.StartScanRunRequest`): + The request object. Request for the `StartScanRun` + method. + name (:class:`str`): + Required. The resource name of the + ScanConfig to be used. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_run.ScanRun: + A ScanRun is a output-only resource + representing an actual run of the scan. + Next id: 12 + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.StartScanRunRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.start_scan_run, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def get_scan_run( + self, + request: web_security_scanner.GetScanRunRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_run.ScanRun: + r"""Gets a ScanRun. + + Args: + request (:class:`~.web_security_scanner.GetScanRunRequest`): + The request object. Request for the `GetScanRun` method. + name (:class:`str`): + Required. The resource name of the + ScanRun to be returned. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_run.ScanRun: + A ScanRun is a output-only resource + representing an actual run of the scan. + Next id: 12 + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.GetScanRunRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_scan_run, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_scan_runs( + self, + request: web_security_scanner.ListScanRunsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListScanRunsAsyncPager: + r"""Lists ScanRuns under a given ScanConfig, in + descending order of ScanRun stop time. + + Args: + request (:class:`~.web_security_scanner.ListScanRunsRequest`): + The request object. Request for the `ListScanRuns` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan resource name in + the format + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListScanRunsAsyncPager: + Response for the ``ListScanRuns`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListScanRunsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_scan_runs, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListScanRunsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def stop_scan_run( + self, + request: web_security_scanner.StopScanRunRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_run.ScanRun: + r"""Stops a ScanRun. The stopped ScanRun is returned. + + Args: + request (:class:`~.web_security_scanner.StopScanRunRequest`): + The request object. Request for the `StopScanRun` + method. + name (:class:`str`): + Required. The resource name of the + ScanRun to be stopped. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_run.ScanRun: + A ScanRun is a output-only resource + representing an actual run of the scan. + Next id: 12 + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.StopScanRunRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.stop_scan_run, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_crawled_urls( + self, + request: web_security_scanner.ListCrawledUrlsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCrawledUrlsAsyncPager: + r"""List CrawledUrls under a given ScanRun. + + Args: + request (:class:`~.web_security_scanner.ListCrawledUrlsRequest`): + The request object. Request for the `ListCrawledUrls` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan run resource name + in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListCrawledUrlsAsyncPager: + Response for the ``ListCrawledUrls`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListCrawledUrlsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_crawled_urls, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCrawledUrlsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_finding( + self, + request: web_security_scanner.GetFindingRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> finding.Finding: + r"""Gets a Finding. + + Args: + request (:class:`~.web_security_scanner.GetFindingRequest`): + The request object. Request for the `GetFinding` method. + name (:class:`str`): + Required. The resource name of the + Finding to be returned. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.finding.Finding: + A Finding resource represents a + vulnerability instance identified during + a ScanRun. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.GetFindingRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_finding, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_findings( + self, + request: web_security_scanner.ListFindingsRequest = None, + *, + parent: str = None, + filter: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFindingsAsyncPager: + r"""List Findings under a given ScanRun. + + Args: + request (:class:`~.web_security_scanner.ListFindingsRequest`): + The request object. Request for the `ListFindings` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan run resource name + in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + filter (:class:`str`): + Required. The filter expression. The expression must be + in the format: . Supported field: 'finding_type'. + Supported operator: '='. + This corresponds to the ``filter`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListFindingsAsyncPager: + Response for the ``ListFindings`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent, filter]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListFindingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_findings, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListFindingsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_finding_type_stats( + self, + request: web_security_scanner.ListFindingTypeStatsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> web_security_scanner.ListFindingTypeStatsResponse: + r"""List all FindingTypeStats under a given ScanRun. + + Args: + request (:class:`~.web_security_scanner.ListFindingTypeStatsRequest`): + The request object. Request for the + `ListFindingTypeStats` method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan run resource name + in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.web_security_scanner.ListFindingTypeStatsResponse: + Response for the ``ListFindingTypeStats`` method. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListFindingTypeStatsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_finding_type_stats, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + +try: + _client_info = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-websecurityscanner", + ).version, + ) +except pkg_resources.DistributionNotFound: + _client_info = gapic_v1.client_info.ClientInfo() + + +__all__ = ("WebSecurityScannerAsyncClient",) diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py new file mode 100644 index 0000000..9f28b31 --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py @@ -0,0 +1,1360 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 collections import OrderedDict +import os +import re +from typing import Callable, Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.websecurityscanner_v1beta.services.web_security_scanner import pagers +from google.cloud.websecurityscanner_v1beta.types import crawled_url +from google.cloud.websecurityscanner_v1beta.types import finding +from google.cloud.websecurityscanner_v1beta.types import finding_addon +from google.cloud.websecurityscanner_v1beta.types import finding_type_stats +from google.cloud.websecurityscanner_v1beta.types import scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_run +from google.cloud.websecurityscanner_v1beta.types import scan_run_error_trace +from google.cloud.websecurityscanner_v1beta.types import scan_run_warning_trace +from google.cloud.websecurityscanner_v1beta.types import web_security_scanner +from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import timestamp_pb2 as timestamp # type: ignore + +from .transports.base import WebSecurityScannerTransport +from .transports.grpc import WebSecurityScannerGrpcTransport +from .transports.grpc_asyncio import WebSecurityScannerGrpcAsyncIOTransport + + +class WebSecurityScannerClientMeta(type): + """Metaclass for the WebSecurityScanner client. + + This provides class-level methods for building and retrieving + support objects (e.g. transport) without polluting the client instance + objects. + """ + + _transport_registry = ( + OrderedDict() + ) # type: Dict[str, Type[WebSecurityScannerTransport]] + _transport_registry["grpc"] = WebSecurityScannerGrpcTransport + _transport_registry["grpc_asyncio"] = WebSecurityScannerGrpcAsyncIOTransport + + def get_transport_class( + cls, label: str = None, + ) -> Type[WebSecurityScannerTransport]: + """Return an appropriate transport class. + + Args: + label: The name of the desired transport. If none is + provided, then the first transport in the registry is used. + + Returns: + The transport class to use. + """ + # If a specific transport is requested, return that one. + if label: + return cls._transport_registry[label] + + # No transport is requested; return the default (that is, the first one + # in the dictionary). + return next(iter(cls._transport_registry.values())) + + +class WebSecurityScannerClient(metaclass=WebSecurityScannerClientMeta): + """Cloud Web Security Scanner Service identifies security + vulnerabilities in web applications hosted on Google Cloud + Platform. It crawls your application, and attempts to exercise + as many user inputs and event handlers as possible. + """ + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Convert api endpoint to mTLS endpoint. + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to + "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. + Args: + api_endpoint (Optional[str]): the api endpoint to convert. + Returns: + str: converted mTLS api endpoint. + """ + if not api_endpoint: + return api_endpoint + + mtls_endpoint_re = re.compile( + r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" + ) + + m = mtls_endpoint_re.match(api_endpoint) + name, mtls, sandbox, googledomain = m.groups() + if mtls or not googledomain: + return api_endpoint + + if sandbox: + return api_endpoint.replace( + "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" + ) + + return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") + + DEFAULT_ENDPOINT = "websecurityscanner.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + {@api.name}: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file(filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @staticmethod + def scan_config_path(project: str, scan_config: str,) -> str: + """Return a fully-qualified scan_config string.""" + return "projects/{project}/scanConfigs/{scan_config}".format( + project=project, scan_config=scan_config, + ) + + @staticmethod + def parse_scan_config_path(path: str) -> Dict[str, str]: + """Parse a scan_config path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/scanConfigs/(?P.+?)$", path + ) + return m.groupdict() if m else {} + + @staticmethod + def scan_run_path(project: str, scan_config: str, scan_run: str,) -> str: + """Return a fully-qualified scan_run string.""" + return "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}".format( + project=project, scan_config=scan_config, scan_run=scan_run, + ) + + @staticmethod + def parse_scan_run_path(path: str) -> Dict[str, str]: + """Parse a scan_run path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/scanConfigs/(?P.+?)/scanRuns/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + def __init__( + self, + *, + credentials: credentials.Credentials = None, + transport: Union[str, WebSecurityScannerTransport] = None, + client_options: ClientOptions = None, + ) -> None: + """Instantiate the web security scanner client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.WebSecurityScannerTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint, this is the default value for + the environment variable) and "auto" (auto switch to the default + mTLS endpoint if client SSL credentials is present). However, + the ``api_endpoint`` property takes precedence if provided. + (2) The ``client_cert_source`` property is used to provide client + SSL credentials for mutual TLS transport. If not provided, the + default SSL credentials will be used if present. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = ClientOptions.from_dict(client_options) + if client_options is None: + client_options = ClientOptions.ClientOptions() + + if client_options.api_endpoint is None: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS", "never") + if use_mtls_env == "never": + client_options.api_endpoint = self.DEFAULT_ENDPOINT + elif use_mtls_env == "always": + client_options.api_endpoint = self.DEFAULT_MTLS_ENDPOINT + elif use_mtls_env == "auto": + has_client_cert_source = ( + client_options.client_cert_source is not None + or mtls.has_default_client_cert_source() + ) + client_options.api_endpoint = ( + self.DEFAULT_MTLS_ENDPOINT + if has_client_cert_source + else self.DEFAULT_ENDPOINT + ) + else: + raise MutualTLSChannelError( + "Unsupported GOOGLE_API_USE_MTLS value. Accepted values: never, auto, always" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, WebSecurityScannerTransport): + # transport is a WebSecurityScannerTransport instance. + if credentials or client_options.credentials_file: + raise ValueError( + "When providing a transport instance, " + "provide its credentials directly." + ) + if client_options.scopes: + raise ValueError( + "When providing a transport instance, " + "provide its scopes directly." + ) + self._transport = transport + else: + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=client_options.api_endpoint, + scopes=client_options.scopes, + api_mtls_endpoint=client_options.api_endpoint, + client_cert_source=client_options.client_cert_source, + quota_project_id=client_options.quota_project_id, + ) + + def create_scan_config( + self, + request: web_security_scanner.CreateScanConfigRequest = None, + *, + parent: str = None, + scan_config: gcw_scan_config.ScanConfig = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gcw_scan_config.ScanConfig: + r"""Creates a new ScanConfig. + + Args: + request (:class:`~.web_security_scanner.CreateScanConfigRequest`): + The request object. Request for the `CreateScanConfig` + method. + parent (:class:`str`): + Required. The parent resource name + where the scan is created, which should + be a project resource name in the format + 'projects/{projectId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + scan_config (:class:`~.gcw_scan_config.ScanConfig`): + Required. The ScanConfig to be + created. + This corresponds to the ``scan_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.gcw_scan_config.ScanConfig: + A ScanConfig resource contains the + configurations to launch a scan. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent, scan_config]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.CreateScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if scan_config is not None: + request.scan_config = scan_config + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.create_scan_config, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def delete_scan_config( + self, + request: web_security_scanner.DeleteScanConfigRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an existing ScanConfig and its child + resources. + + Args: + request (:class:`~.web_security_scanner.DeleteScanConfigRequest`): + The request object. Request for the `DeleteScanConfig` + method. + name (:class:`str`): + Required. The resource name of the + ScanConfig to be deleted. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.DeleteScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.delete_scan_config, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + def get_scan_config( + self, + request: web_security_scanner.GetScanConfigRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_config.ScanConfig: + r"""Gets a ScanConfig. + + Args: + request (:class:`~.web_security_scanner.GetScanConfigRequest`): + The request object. Request for the `GetScanConfig` + method. + name (:class:`str`): + Required. The resource name of the + ScanConfig to be returned. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_config.ScanConfig: + A ScanConfig resource contains the + configurations to launch a scan. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.GetScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_scan_config, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_scan_configs( + self, + request: web_security_scanner.ListScanConfigsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListScanConfigsPager: + r"""Lists ScanConfigs under a given project. + + Args: + request (:class:`~.web_security_scanner.ListScanConfigsRequest`): + The request object. Request for the `ListScanConfigs` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a project resource name + in the format 'projects/{projectId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListScanConfigsPager: + Response for the ``ListScanConfigs`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListScanConfigsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_scan_configs, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListScanConfigsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def update_scan_config( + self, + request: web_security_scanner.UpdateScanConfigRequest = None, + *, + scan_config: gcw_scan_config.ScanConfig = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gcw_scan_config.ScanConfig: + r"""Updates a ScanConfig. This method support partial + update of a ScanConfig. + + Args: + request (:class:`~.web_security_scanner.UpdateScanConfigRequest`): + The request object. Request for the + `UpdateScanConfigRequest` method. + scan_config (:class:`~.gcw_scan_config.ScanConfig`): + Required. The ScanConfig to be + updated. The name field must be set to + identify the resource to be updated. The + values of fields not covered by the mask + will be ignored. + This corresponds to the ``scan_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`~.field_mask.FieldMask`): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.gcw_scan_config.ScanConfig: + A ScanConfig resource contains the + configurations to launch a scan. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([scan_config, update_mask]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.UpdateScanConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if scan_config is not None: + request.scan_config = scan_config + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.update_scan_config, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("scan_config.name", request.scan_config.name),) + ), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def start_scan_run( + self, + request: web_security_scanner.StartScanRunRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_run.ScanRun: + r"""Start a ScanRun according to the given ScanConfig. + + Args: + request (:class:`~.web_security_scanner.StartScanRunRequest`): + The request object. Request for the `StartScanRun` + method. + name (:class:`str`): + Required. The resource name of the + ScanConfig to be used. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_run.ScanRun: + A ScanRun is a output-only resource + representing an actual run of the scan. + Next id: 12 + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.StartScanRunRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.start_scan_run, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def get_scan_run( + self, + request: web_security_scanner.GetScanRunRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_run.ScanRun: + r"""Gets a ScanRun. + + Args: + request (:class:`~.web_security_scanner.GetScanRunRequest`): + The request object. Request for the `GetScanRun` method. + name (:class:`str`): + Required. The resource name of the + ScanRun to be returned. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_run.ScanRun: + A ScanRun is a output-only resource + representing an actual run of the scan. + Next id: 12 + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.GetScanRunRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_scan_run, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_scan_runs( + self, + request: web_security_scanner.ListScanRunsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListScanRunsPager: + r"""Lists ScanRuns under a given ScanConfig, in + descending order of ScanRun stop time. + + Args: + request (:class:`~.web_security_scanner.ListScanRunsRequest`): + The request object. Request for the `ListScanRuns` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan resource name in + the format + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListScanRunsPager: + Response for the ``ListScanRuns`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListScanRunsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_scan_runs, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListScanRunsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def stop_scan_run( + self, + request: web_security_scanner.StopScanRunRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> scan_run.ScanRun: + r"""Stops a ScanRun. The stopped ScanRun is returned. + + Args: + request (:class:`~.web_security_scanner.StopScanRunRequest`): + The request object. Request for the `StopScanRun` + method. + name (:class:`str`): + Required. The resource name of the + ScanRun to be stopped. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.scan_run.ScanRun: + A ScanRun is a output-only resource + representing an actual run of the scan. + Next id: 12 + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.StopScanRunRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.stop_scan_run, + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_crawled_urls( + self, + request: web_security_scanner.ListCrawledUrlsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCrawledUrlsPager: + r"""List CrawledUrls under a given ScanRun. + + Args: + request (:class:`~.web_security_scanner.ListCrawledUrlsRequest`): + The request object. Request for the `ListCrawledUrls` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan run resource name + in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListCrawledUrlsPager: + Response for the ``ListCrawledUrls`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListCrawledUrlsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_crawled_urls, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListCrawledUrlsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def get_finding( + self, + request: web_security_scanner.GetFindingRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> finding.Finding: + r"""Gets a Finding. + + Args: + request (:class:`~.web_security_scanner.GetFindingRequest`): + The request object. Request for the `GetFinding` method. + name (:class:`str`): + Required. The resource name of the + Finding to be returned. The name follows + the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.finding.Finding: + A Finding resource represents a + vulnerability instance identified during + a ScanRun. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([name]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.GetFindingRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_finding, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_findings( + self, + request: web_security_scanner.ListFindingsRequest = None, + *, + parent: str = None, + filter: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFindingsPager: + r"""List Findings under a given ScanRun. + + Args: + request (:class:`~.web_security_scanner.ListFindingsRequest`): + The request object. Request for the `ListFindings` + method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan run resource name + in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + filter (:class:`str`): + Required. The filter expression. The expression must be + in the format: . Supported field: 'finding_type'. + Supported operator: '='. + This corresponds to the ``filter`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.pagers.ListFindingsPager: + Response for the ``ListFindings`` method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent, filter]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListFindingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_findings, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListFindingsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def list_finding_type_stats( + self, + request: web_security_scanner.ListFindingTypeStatsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> web_security_scanner.ListFindingTypeStatsResponse: + r"""List all FindingTypeStats under a given ScanRun. + + Args: + request (:class:`~.web_security_scanner.ListFindingTypeStatsRequest`): + The request object. Request for the + `ListFindingTypeStats` method. + parent (:class:`str`): + Required. The parent resource name, + which should be a scan run resource name + in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.web_security_scanner.ListFindingTypeStatsResponse: + Response for the ``ListFindingTypeStats`` method. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + if request is not None and any([parent]): + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = web_security_scanner.ListFindingTypeStatsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_finding_type_stats, + default_retry=retries.Retry( + initial=0.1, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + ), + ), + default_timeout=600.0, + client_info=_client_info, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + +try: + _client_info = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-websecurityscanner", + ).version, + ) +except pkg_resources.DistributionNotFound: + _client_info = gapic_v1.client_info.ClientInfo() + + +__all__ = ("WebSecurityScannerClient",) diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/pagers.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/pagers.py new file mode 100644 index 0000000..beea861 --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/pagers.py @@ -0,0 +1,540 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple + +from google.cloud.websecurityscanner_v1beta.types import crawled_url +from google.cloud.websecurityscanner_v1beta.types import finding +from google.cloud.websecurityscanner_v1beta.types import scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_run +from google.cloud.websecurityscanner_v1beta.types import web_security_scanner + + +class ListScanConfigsPager: + """A pager for iterating through ``list_scan_configs`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListScanConfigsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``scan_configs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListScanConfigs`` requests and continue to iterate + through the ``scan_configs`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListScanConfigsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., web_security_scanner.ListScanConfigsResponse], + request: web_security_scanner.ListScanConfigsRequest, + response: web_security_scanner.ListScanConfigsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListScanConfigsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListScanConfigsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListScanConfigsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[web_security_scanner.ListScanConfigsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[scan_config.ScanConfig]: + for page in self.pages: + yield from page.scan_configs + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListScanConfigsAsyncPager: + """A pager for iterating through ``list_scan_configs`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListScanConfigsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``scan_configs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListScanConfigs`` requests and continue to iterate + through the ``scan_configs`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListScanConfigsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[web_security_scanner.ListScanConfigsResponse]], + request: web_security_scanner.ListScanConfigsRequest, + response: web_security_scanner.ListScanConfigsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListScanConfigsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListScanConfigsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListScanConfigsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterable[web_security_scanner.ListScanConfigsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[scan_config.ScanConfig]: + async def async_generator(): + async for page in self.pages: + for response in page.scan_configs: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListScanRunsPager: + """A pager for iterating through ``list_scan_runs`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListScanRunsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``scan_runs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListScanRuns`` requests and continue to iterate + through the ``scan_runs`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListScanRunsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., web_security_scanner.ListScanRunsResponse], + request: web_security_scanner.ListScanRunsRequest, + response: web_security_scanner.ListScanRunsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListScanRunsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListScanRunsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListScanRunsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[web_security_scanner.ListScanRunsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[scan_run.ScanRun]: + for page in self.pages: + yield from page.scan_runs + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListScanRunsAsyncPager: + """A pager for iterating through ``list_scan_runs`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListScanRunsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``scan_runs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListScanRuns`` requests and continue to iterate + through the ``scan_runs`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListScanRunsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[web_security_scanner.ListScanRunsResponse]], + request: web_security_scanner.ListScanRunsRequest, + response: web_security_scanner.ListScanRunsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListScanRunsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListScanRunsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListScanRunsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[web_security_scanner.ListScanRunsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[scan_run.ScanRun]: + async def async_generator(): + async for page in self.pages: + for response in page.scan_runs: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListCrawledUrlsPager: + """A pager for iterating through ``list_crawled_urls`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListCrawledUrlsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``crawled_urls`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCrawledUrls`` requests and continue to iterate + through the ``crawled_urls`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListCrawledUrlsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., web_security_scanner.ListCrawledUrlsResponse], + request: web_security_scanner.ListCrawledUrlsRequest, + response: web_security_scanner.ListCrawledUrlsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListCrawledUrlsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListCrawledUrlsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListCrawledUrlsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[web_security_scanner.ListCrawledUrlsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[crawled_url.CrawledUrl]: + for page in self.pages: + yield from page.crawled_urls + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListCrawledUrlsAsyncPager: + """A pager for iterating through ``list_crawled_urls`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListCrawledUrlsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``crawled_urls`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCrawledUrls`` requests and continue to iterate + through the ``crawled_urls`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListCrawledUrlsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[web_security_scanner.ListCrawledUrlsResponse]], + request: web_security_scanner.ListCrawledUrlsRequest, + response: web_security_scanner.ListCrawledUrlsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListCrawledUrlsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListCrawledUrlsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListCrawledUrlsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterable[web_security_scanner.ListCrawledUrlsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[crawled_url.CrawledUrl]: + async def async_generator(): + async for page in self.pages: + for response in page.crawled_urls: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListFindingsPager: + """A pager for iterating through ``list_findings`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListFindingsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``findings`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListFindings`` requests and continue to iterate + through the ``findings`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListFindingsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., web_security_scanner.ListFindingsResponse], + request: web_security_scanner.ListFindingsRequest, + response: web_security_scanner.ListFindingsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListFindingsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListFindingsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListFindingsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[web_security_scanner.ListFindingsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[finding.Finding]: + for page in self.pages: + yield from page.findings + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListFindingsAsyncPager: + """A pager for iterating through ``list_findings`` requests. + + This class thinly wraps an initial + :class:`~.web_security_scanner.ListFindingsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``findings`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListFindings`` requests and continue to iterate + through the ``findings`` field on the + corresponding responses. + + All the usual :class:`~.web_security_scanner.ListFindingsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[web_security_scanner.ListFindingsResponse]], + request: web_security_scanner.ListFindingsRequest, + response: web_security_scanner.ListFindingsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (:class:`~.web_security_scanner.ListFindingsRequest`): + The initial request object. + response (:class:`~.web_security_scanner.ListFindingsResponse`): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = web_security_scanner.ListFindingsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[web_security_scanner.ListFindingsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[finding.Finding]: + async def async_generator(): + async for page in self.pages: + for response in page.findings: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/__init__.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/__init__.py new file mode 100644 index 0000000..788b2b3 --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/__init__.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 collections import OrderedDict +from typing import Dict, Type + +from .base import WebSecurityScannerTransport +from .grpc import WebSecurityScannerGrpcTransport +from .grpc_asyncio import WebSecurityScannerGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = ( + OrderedDict() +) # type: Dict[str, Type[WebSecurityScannerTransport]] +_transport_registry["grpc"] = WebSecurityScannerGrpcTransport +_transport_registry["grpc_asyncio"] = WebSecurityScannerGrpcAsyncIOTransport + + +__all__ = ( + "WebSecurityScannerTransport", + "WebSecurityScannerGrpcTransport", + "WebSecurityScannerGrpcAsyncIOTransport", +) diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/base.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/base.py new file mode 100644 index 0000000..6370070 --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/base.py @@ -0,0 +1,226 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 abc +import typing + +from google import auth +from google.api_core import exceptions # type: ignore +from google.auth import credentials # type: ignore + +from google.cloud.websecurityscanner_v1beta.types import finding +from google.cloud.websecurityscanner_v1beta.types import scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_run +from google.cloud.websecurityscanner_v1beta.types import web_security_scanner +from google.protobuf import empty_pb2 as empty # type: ignore + + +class WebSecurityScannerTransport(abc.ABC): + """Abstract transport class for WebSecurityScanner.""" + + AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + + def __init__( + self, + *, + host: str = "websecurityscanner.googleapis.com", + credentials: credentials.Credentials = None, + credentials_file: typing.Optional[str] = None, + scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, + quota_project_id: typing.Optional[str] = None, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scope (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise exceptions.DuplicateCredentialArgs( + "'credentials_file' and 'credentials' are mutually exclusive" + ) + + if credentials_file is not None: + credentials, _ = auth.load_credentials_from_file( + credentials_file, scopes=scopes, quota_project_id=quota_project_id + ) + + elif credentials is None: + credentials, _ = auth.default( + scopes=scopes, quota_project_id=quota_project_id + ) + + # Save the credentials. + self._credentials = credentials + + @property + def create_scan_config( + self, + ) -> typing.Callable[ + [web_security_scanner.CreateScanConfigRequest], + typing.Union[ + gcw_scan_config.ScanConfig, typing.Awaitable[gcw_scan_config.ScanConfig] + ], + ]: + raise NotImplementedError() + + @property + def delete_scan_config( + self, + ) -> typing.Callable[ + [web_security_scanner.DeleteScanConfigRequest], + typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + ]: + raise NotImplementedError() + + @property + def get_scan_config( + self, + ) -> typing.Callable[ + [web_security_scanner.GetScanConfigRequest], + typing.Union[scan_config.ScanConfig, typing.Awaitable[scan_config.ScanConfig]], + ]: + raise NotImplementedError() + + @property + def list_scan_configs( + self, + ) -> typing.Callable[ + [web_security_scanner.ListScanConfigsRequest], + typing.Union[ + web_security_scanner.ListScanConfigsResponse, + typing.Awaitable[web_security_scanner.ListScanConfigsResponse], + ], + ]: + raise NotImplementedError() + + @property + def update_scan_config( + self, + ) -> typing.Callable[ + [web_security_scanner.UpdateScanConfigRequest], + typing.Union[ + gcw_scan_config.ScanConfig, typing.Awaitable[gcw_scan_config.ScanConfig] + ], + ]: + raise NotImplementedError() + + @property + def start_scan_run( + self, + ) -> typing.Callable[ + [web_security_scanner.StartScanRunRequest], + typing.Union[scan_run.ScanRun, typing.Awaitable[scan_run.ScanRun]], + ]: + raise NotImplementedError() + + @property + def get_scan_run( + self, + ) -> typing.Callable[ + [web_security_scanner.GetScanRunRequest], + typing.Union[scan_run.ScanRun, typing.Awaitable[scan_run.ScanRun]], + ]: + raise NotImplementedError() + + @property + def list_scan_runs( + self, + ) -> typing.Callable[ + [web_security_scanner.ListScanRunsRequest], + typing.Union[ + web_security_scanner.ListScanRunsResponse, + typing.Awaitable[web_security_scanner.ListScanRunsResponse], + ], + ]: + raise NotImplementedError() + + @property + def stop_scan_run( + self, + ) -> typing.Callable[ + [web_security_scanner.StopScanRunRequest], + typing.Union[scan_run.ScanRun, typing.Awaitable[scan_run.ScanRun]], + ]: + raise NotImplementedError() + + @property + def list_crawled_urls( + self, + ) -> typing.Callable[ + [web_security_scanner.ListCrawledUrlsRequest], + typing.Union[ + web_security_scanner.ListCrawledUrlsResponse, + typing.Awaitable[web_security_scanner.ListCrawledUrlsResponse], + ], + ]: + raise NotImplementedError() + + @property + def get_finding( + self, + ) -> typing.Callable[ + [web_security_scanner.GetFindingRequest], + typing.Union[finding.Finding, typing.Awaitable[finding.Finding]], + ]: + raise NotImplementedError() + + @property + def list_findings( + self, + ) -> typing.Callable[ + [web_security_scanner.ListFindingsRequest], + typing.Union[ + web_security_scanner.ListFindingsResponse, + typing.Awaitable[web_security_scanner.ListFindingsResponse], + ], + ]: + raise NotImplementedError() + + @property + def list_finding_type_stats( + self, + ) -> typing.Callable[ + [web_security_scanner.ListFindingTypeStatsRequest], + typing.Union[ + web_security_scanner.ListFindingTypeStatsResponse, + typing.Awaitable[web_security_scanner.ListFindingTypeStatsResponse], + ], + ]: + raise NotImplementedError() + + +__all__ = ("WebSecurityScannerTransport",) diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py new file mode 100644 index 0000000..64ee056 --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py @@ -0,0 +1,575 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 typing import Callable, Dict, Optional, Sequence, Tuple + +from google.api_core import grpc_helpers # type: ignore +from google import auth # type: ignore +from google.auth import credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + + +import grpc # type: ignore + +from google.cloud.websecurityscanner_v1beta.types import finding +from google.cloud.websecurityscanner_v1beta.types import scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_run +from google.cloud.websecurityscanner_v1beta.types import web_security_scanner +from google.protobuf import empty_pb2 as empty # type: ignore + +from .base import WebSecurityScannerTransport + + +class WebSecurityScannerGrpcTransport(WebSecurityScannerTransport): + """gRPC backend transport for WebSecurityScanner. + + Cloud Web Security Scanner Service identifies security + vulnerabilities in web applications hosted on Google Cloud + Platform. It crawls your application, and attempts to exercise + as many user inputs and event handlers as possible. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _stubs: Dict[str, Callable] + + def __init__( + self, + *, + host: str = "websecurityscanner.googleapis.com", + credentials: credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): The mutual TLS endpoint. If + provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): A + callback to provide client SSL certificate bytes and private key + bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` + is None. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + if channel: + # Sanity check: Ensure that channel and credentials are not both + # provided. + credentials = False + + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + elif api_mtls_endpoint: + host = ( + api_mtls_endpoint + if ":" in api_mtls_endpoint + else api_mtls_endpoint + ":443" + ) + + if credentials is None: + credentials, _ = auth.default( + scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id + ) + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + ssl_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + ssl_credentials = SslCredentials().ssl_credentials + + # create a new channel. The provided one is ignored. + self._grpc_channel = type(self).create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + ssl_credentials=ssl_credentials, + scopes=scopes or self.AUTH_SCOPES, + quota_project_id=quota_project_id, + ) + + # Run the base constructor. + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes or self.AUTH_SCOPES, + quota_project_id=quota_project_id, + ) + + self._stubs = {} # type: Dict[str, Callable] + + @classmethod + def create_channel( + cls, + host: str = "websecurityscanner.googleapis.com", + credentials: credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs + ) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + address (Optionsl[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + scopes = scopes or cls.AUTH_SCOPES + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Sanity check: Only create a new channel if we do not already + # have one. + if not hasattr(self, "_grpc_channel"): + self._grpc_channel = self.create_channel( + self._host, credentials=self._credentials, + ) + + # Return the channel from cache. + return self._grpc_channel + + @property + def create_scan_config( + self, + ) -> Callable[ + [web_security_scanner.CreateScanConfigRequest], gcw_scan_config.ScanConfig + ]: + r"""Return a callable for the create scan config method over gRPC. + + Creates a new ScanConfig. + + Returns: + Callable[[~.CreateScanConfigRequest], + ~.ScanConfig]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_scan_config" not in self._stubs: + self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/CreateScanConfig", + request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, + response_deserializer=gcw_scan_config.ScanConfig.deserialize, + ) + return self._stubs["create_scan_config"] + + @property + def delete_scan_config( + self, + ) -> Callable[[web_security_scanner.DeleteScanConfigRequest], empty.Empty]: + r"""Return a callable for the delete scan config method over gRPC. + + Deletes an existing ScanConfig and its child + resources. + + Returns: + Callable[[~.DeleteScanConfigRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_scan_config" not in self._stubs: + self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/DeleteScanConfig", + request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs["delete_scan_config"] + + @property + def get_scan_config( + self, + ) -> Callable[[web_security_scanner.GetScanConfigRequest], scan_config.ScanConfig]: + r"""Return a callable for the get scan config method over gRPC. + + Gets a ScanConfig. + + Returns: + Callable[[~.GetScanConfigRequest], + ~.ScanConfig]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_scan_config" not in self._stubs: + self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanConfig", + request_serializer=web_security_scanner.GetScanConfigRequest.serialize, + response_deserializer=scan_config.ScanConfig.deserialize, + ) + return self._stubs["get_scan_config"] + + @property + def list_scan_configs( + self, + ) -> Callable[ + [web_security_scanner.ListScanConfigsRequest], + web_security_scanner.ListScanConfigsResponse, + ]: + r"""Return a callable for the list scan configs method over gRPC. + + Lists ScanConfigs under a given project. + + Returns: + Callable[[~.ListScanConfigsRequest], + ~.ListScanConfigsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_scan_configs" not in self._stubs: + self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanConfigs", + request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, + response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, + ) + return self._stubs["list_scan_configs"] + + @property + def update_scan_config( + self, + ) -> Callable[ + [web_security_scanner.UpdateScanConfigRequest], gcw_scan_config.ScanConfig + ]: + r"""Return a callable for the update scan config method over gRPC. + + Updates a ScanConfig. This method support partial + update of a ScanConfig. + + Returns: + Callable[[~.UpdateScanConfigRequest], + ~.ScanConfig]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_scan_config" not in self._stubs: + self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/UpdateScanConfig", + request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, + response_deserializer=gcw_scan_config.ScanConfig.deserialize, + ) + return self._stubs["update_scan_config"] + + @property + def start_scan_run( + self, + ) -> Callable[[web_security_scanner.StartScanRunRequest], scan_run.ScanRun]: + r"""Return a callable for the start scan run method over gRPC. + + Start a ScanRun according to the given ScanConfig. + + Returns: + Callable[[~.StartScanRunRequest], + ~.ScanRun]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "start_scan_run" not in self._stubs: + self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StartScanRun", + request_serializer=web_security_scanner.StartScanRunRequest.serialize, + response_deserializer=scan_run.ScanRun.deserialize, + ) + return self._stubs["start_scan_run"] + + @property + def get_scan_run( + self, + ) -> Callable[[web_security_scanner.GetScanRunRequest], scan_run.ScanRun]: + r"""Return a callable for the get scan run method over gRPC. + + Gets a ScanRun. + + Returns: + Callable[[~.GetScanRunRequest], + ~.ScanRun]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_scan_run" not in self._stubs: + self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanRun", + request_serializer=web_security_scanner.GetScanRunRequest.serialize, + response_deserializer=scan_run.ScanRun.deserialize, + ) + return self._stubs["get_scan_run"] + + @property + def list_scan_runs( + self, + ) -> Callable[ + [web_security_scanner.ListScanRunsRequest], + web_security_scanner.ListScanRunsResponse, + ]: + r"""Return a callable for the list scan runs method over gRPC. + + Lists ScanRuns under a given ScanConfig, in + descending order of ScanRun stop time. + + Returns: + Callable[[~.ListScanRunsRequest], + ~.ListScanRunsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_scan_runs" not in self._stubs: + self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanRuns", + request_serializer=web_security_scanner.ListScanRunsRequest.serialize, + response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, + ) + return self._stubs["list_scan_runs"] + + @property + def stop_scan_run( + self, + ) -> Callable[[web_security_scanner.StopScanRunRequest], scan_run.ScanRun]: + r"""Return a callable for the stop scan run method over gRPC. + + Stops a ScanRun. The stopped ScanRun is returned. + + Returns: + Callable[[~.StopScanRunRequest], + ~.ScanRun]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "stop_scan_run" not in self._stubs: + self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StopScanRun", + request_serializer=web_security_scanner.StopScanRunRequest.serialize, + response_deserializer=scan_run.ScanRun.deserialize, + ) + return self._stubs["stop_scan_run"] + + @property + def list_crawled_urls( + self, + ) -> Callable[ + [web_security_scanner.ListCrawledUrlsRequest], + web_security_scanner.ListCrawledUrlsResponse, + ]: + r"""Return a callable for the list crawled urls method over gRPC. + + List CrawledUrls under a given ScanRun. + + Returns: + Callable[[~.ListCrawledUrlsRequest], + ~.ListCrawledUrlsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_crawled_urls" not in self._stubs: + self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListCrawledUrls", + request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, + response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, + ) + return self._stubs["list_crawled_urls"] + + @property + def get_finding( + self, + ) -> Callable[[web_security_scanner.GetFindingRequest], finding.Finding]: + r"""Return a callable for the get finding method over gRPC. + + Gets a Finding. + + Returns: + Callable[[~.GetFindingRequest], + ~.Finding]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_finding" not in self._stubs: + self._stubs["get_finding"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetFinding", + request_serializer=web_security_scanner.GetFindingRequest.serialize, + response_deserializer=finding.Finding.deserialize, + ) + return self._stubs["get_finding"] + + @property + def list_findings( + self, + ) -> Callable[ + [web_security_scanner.ListFindingsRequest], + web_security_scanner.ListFindingsResponse, + ]: + r"""Return a callable for the list findings method over gRPC. + + List Findings under a given ScanRun. + + Returns: + Callable[[~.ListFindingsRequest], + ~.ListFindingsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_findings" not in self._stubs: + self._stubs["list_findings"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindings", + request_serializer=web_security_scanner.ListFindingsRequest.serialize, + response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, + ) + return self._stubs["list_findings"] + + @property + def list_finding_type_stats( + self, + ) -> Callable[ + [web_security_scanner.ListFindingTypeStatsRequest], + web_security_scanner.ListFindingTypeStatsResponse, + ]: + r"""Return a callable for the list finding type stats method over gRPC. + + List all FindingTypeStats under a given ScanRun. + + Returns: + Callable[[~.ListFindingTypeStatsRequest], + ~.ListFindingTypeStatsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_finding_type_stats" not in self._stubs: + self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindingTypeStats", + request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, + response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, + ) + return self._stubs["list_finding_type_stats"] + + +__all__ = ("WebSecurityScannerGrpcTransport",) diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py new file mode 100644 index 0000000..1a91005 --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py @@ -0,0 +1,580 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple + +from google.api_core import grpc_helpers_async # type: ignore +from google.auth import credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.websecurityscanner_v1beta.types import finding +from google.cloud.websecurityscanner_v1beta.types import scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_run +from google.cloud.websecurityscanner_v1beta.types import web_security_scanner +from google.protobuf import empty_pb2 as empty # type: ignore + +from .base import WebSecurityScannerTransport +from .grpc import WebSecurityScannerGrpcTransport + + +class WebSecurityScannerGrpcAsyncIOTransport(WebSecurityScannerTransport): + """gRPC AsyncIO backend transport for WebSecurityScanner. + + Cloud Web Security Scanner Service identifies security + vulnerabilities in web applications hosted on Google Cloud + Platform. It crawls your application, and attempts to exercise + as many user inputs and event handlers as possible. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _grpc_channel: aio.Channel + _stubs: Dict[str, Callable] = {} + + @classmethod + def create_channel( + cls, + host: str = "websecurityscanner.googleapis.com", + credentials: credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + address (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + scopes = scopes or cls.AUTH_SCOPES + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + **kwargs, + ) + + def __init__( + self, + *, + host: str = "websecurityscanner.googleapis.com", + credentials: credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): The mutual TLS endpoint. If + provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): A + callback to provide client SSL certificate bytes and private key + bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` + is None. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + if channel: + # Sanity check: Ensure that channel and credentials are not both + # provided. + credentials = False + + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + elif api_mtls_endpoint: + host = ( + api_mtls_endpoint + if ":" in api_mtls_endpoint + else api_mtls_endpoint + ":443" + ) + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + ssl_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + ssl_credentials = SslCredentials().ssl_credentials + + # create a new channel. The provided one is ignored. + self._grpc_channel = type(self).create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + ssl_credentials=ssl_credentials, + scopes=scopes or self.AUTH_SCOPES, + quota_project_id=quota_project_id, + ) + + # Run the base constructor. + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes or self.AUTH_SCOPES, + quota_project_id=quota_project_id, + ) + + self._stubs = {} + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Sanity check: Only create a new channel if we do not already + # have one. + if not hasattr(self, "_grpc_channel"): + self._grpc_channel = self.create_channel( + self._host, credentials=self._credentials, + ) + + # Return the channel from cache. + return self._grpc_channel + + @property + def create_scan_config( + self, + ) -> Callable[ + [web_security_scanner.CreateScanConfigRequest], + Awaitable[gcw_scan_config.ScanConfig], + ]: + r"""Return a callable for the create scan config method over gRPC. + + Creates a new ScanConfig. + + Returns: + Callable[[~.CreateScanConfigRequest], + Awaitable[~.ScanConfig]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_scan_config" not in self._stubs: + self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/CreateScanConfig", + request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, + response_deserializer=gcw_scan_config.ScanConfig.deserialize, + ) + return self._stubs["create_scan_config"] + + @property + def delete_scan_config( + self, + ) -> Callable[ + [web_security_scanner.DeleteScanConfigRequest], Awaitable[empty.Empty] + ]: + r"""Return a callable for the delete scan config method over gRPC. + + Deletes an existing ScanConfig and its child + resources. + + Returns: + Callable[[~.DeleteScanConfigRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_scan_config" not in self._stubs: + self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/DeleteScanConfig", + request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs["delete_scan_config"] + + @property + def get_scan_config( + self, + ) -> Callable[ + [web_security_scanner.GetScanConfigRequest], Awaitable[scan_config.ScanConfig] + ]: + r"""Return a callable for the get scan config method over gRPC. + + Gets a ScanConfig. + + Returns: + Callable[[~.GetScanConfigRequest], + Awaitable[~.ScanConfig]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_scan_config" not in self._stubs: + self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanConfig", + request_serializer=web_security_scanner.GetScanConfigRequest.serialize, + response_deserializer=scan_config.ScanConfig.deserialize, + ) + return self._stubs["get_scan_config"] + + @property + def list_scan_configs( + self, + ) -> Callable[ + [web_security_scanner.ListScanConfigsRequest], + Awaitable[web_security_scanner.ListScanConfigsResponse], + ]: + r"""Return a callable for the list scan configs method over gRPC. + + Lists ScanConfigs under a given project. + + Returns: + Callable[[~.ListScanConfigsRequest], + Awaitable[~.ListScanConfigsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_scan_configs" not in self._stubs: + self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanConfigs", + request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, + response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, + ) + return self._stubs["list_scan_configs"] + + @property + def update_scan_config( + self, + ) -> Callable[ + [web_security_scanner.UpdateScanConfigRequest], + Awaitable[gcw_scan_config.ScanConfig], + ]: + r"""Return a callable for the update scan config method over gRPC. + + Updates a ScanConfig. This method support partial + update of a ScanConfig. + + Returns: + Callable[[~.UpdateScanConfigRequest], + Awaitable[~.ScanConfig]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_scan_config" not in self._stubs: + self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/UpdateScanConfig", + request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, + response_deserializer=gcw_scan_config.ScanConfig.deserialize, + ) + return self._stubs["update_scan_config"] + + @property + def start_scan_run( + self, + ) -> Callable[ + [web_security_scanner.StartScanRunRequest], Awaitable[scan_run.ScanRun] + ]: + r"""Return a callable for the start scan run method over gRPC. + + Start a ScanRun according to the given ScanConfig. + + Returns: + Callable[[~.StartScanRunRequest], + Awaitable[~.ScanRun]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "start_scan_run" not in self._stubs: + self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StartScanRun", + request_serializer=web_security_scanner.StartScanRunRequest.serialize, + response_deserializer=scan_run.ScanRun.deserialize, + ) + return self._stubs["start_scan_run"] + + @property + def get_scan_run( + self, + ) -> Callable[ + [web_security_scanner.GetScanRunRequest], Awaitable[scan_run.ScanRun] + ]: + r"""Return a callable for the get scan run method over gRPC. + + Gets a ScanRun. + + Returns: + Callable[[~.GetScanRunRequest], + Awaitable[~.ScanRun]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_scan_run" not in self._stubs: + self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanRun", + request_serializer=web_security_scanner.GetScanRunRequest.serialize, + response_deserializer=scan_run.ScanRun.deserialize, + ) + return self._stubs["get_scan_run"] + + @property + def list_scan_runs( + self, + ) -> Callable[ + [web_security_scanner.ListScanRunsRequest], + Awaitable[web_security_scanner.ListScanRunsResponse], + ]: + r"""Return a callable for the list scan runs method over gRPC. + + Lists ScanRuns under a given ScanConfig, in + descending order of ScanRun stop time. + + Returns: + Callable[[~.ListScanRunsRequest], + Awaitable[~.ListScanRunsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_scan_runs" not in self._stubs: + self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanRuns", + request_serializer=web_security_scanner.ListScanRunsRequest.serialize, + response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, + ) + return self._stubs["list_scan_runs"] + + @property + def stop_scan_run( + self, + ) -> Callable[ + [web_security_scanner.StopScanRunRequest], Awaitable[scan_run.ScanRun] + ]: + r"""Return a callable for the stop scan run method over gRPC. + + Stops a ScanRun. The stopped ScanRun is returned. + + Returns: + Callable[[~.StopScanRunRequest], + Awaitable[~.ScanRun]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "stop_scan_run" not in self._stubs: + self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StopScanRun", + request_serializer=web_security_scanner.StopScanRunRequest.serialize, + response_deserializer=scan_run.ScanRun.deserialize, + ) + return self._stubs["stop_scan_run"] + + @property + def list_crawled_urls( + self, + ) -> Callable[ + [web_security_scanner.ListCrawledUrlsRequest], + Awaitable[web_security_scanner.ListCrawledUrlsResponse], + ]: + r"""Return a callable for the list crawled urls method over gRPC. + + List CrawledUrls under a given ScanRun. + + Returns: + Callable[[~.ListCrawledUrlsRequest], + Awaitable[~.ListCrawledUrlsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_crawled_urls" not in self._stubs: + self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListCrawledUrls", + request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, + response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, + ) + return self._stubs["list_crawled_urls"] + + @property + def get_finding( + self, + ) -> Callable[[web_security_scanner.GetFindingRequest], Awaitable[finding.Finding]]: + r"""Return a callable for the get finding method over gRPC. + + Gets a Finding. + + Returns: + Callable[[~.GetFindingRequest], + Awaitable[~.Finding]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_finding" not in self._stubs: + self._stubs["get_finding"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetFinding", + request_serializer=web_security_scanner.GetFindingRequest.serialize, + response_deserializer=finding.Finding.deserialize, + ) + return self._stubs["get_finding"] + + @property + def list_findings( + self, + ) -> Callable[ + [web_security_scanner.ListFindingsRequest], + Awaitable[web_security_scanner.ListFindingsResponse], + ]: + r"""Return a callable for the list findings method over gRPC. + + List Findings under a given ScanRun. + + Returns: + Callable[[~.ListFindingsRequest], + Awaitable[~.ListFindingsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_findings" not in self._stubs: + self._stubs["list_findings"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindings", + request_serializer=web_security_scanner.ListFindingsRequest.serialize, + response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, + ) + return self._stubs["list_findings"] + + @property + def list_finding_type_stats( + self, + ) -> Callable[ + [web_security_scanner.ListFindingTypeStatsRequest], + Awaitable[web_security_scanner.ListFindingTypeStatsResponse], + ]: + r"""Return a callable for the list finding type stats method over gRPC. + + List all FindingTypeStats under a given ScanRun. + + Returns: + Callable[[~.ListFindingTypeStatsRequest], + Awaitable[~.ListFindingTypeStatsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_finding_type_stats" not in self._stubs: + self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindingTypeStats", + request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, + response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, + ) + return self._stubs["list_finding_type_stats"] + + +__all__ = ("WebSecurityScannerGrpcAsyncIOTransport",) diff --git a/google/cloud/websecurityscanner_v1beta/types.py b/google/cloud/websecurityscanner_v1beta/types.py deleted file mode 100644 index ad3a32e..0000000 --- a/google/cloud/websecurityscanner_v1beta/types.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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 __future__ import absolute_import -import sys - -from google.api_core.protobuf_helpers import get_messages - -from google.cloud.websecurityscanner_v1beta.proto import crawled_url_pb2 -from google.cloud.websecurityscanner_v1beta.proto import finding_addon_pb2 -from google.cloud.websecurityscanner_v1beta.proto import finding_pb2 -from google.cloud.websecurityscanner_v1beta.proto import finding_type_stats_pb2 -from google.cloud.websecurityscanner_v1beta.proto import scan_config_error_pb2 -from google.cloud.websecurityscanner_v1beta.proto import scan_config_pb2 -from google.cloud.websecurityscanner_v1beta.proto import scan_run_error_trace_pb2 -from google.cloud.websecurityscanner_v1beta.proto import scan_run_pb2 -from google.cloud.websecurityscanner_v1beta.proto import scan_run_warning_trace_pb2 -from google.cloud.websecurityscanner_v1beta.proto import web_security_scanner_pb2 -from google.protobuf import empty_pb2 -from google.protobuf import field_mask_pb2 -from google.protobuf import timestamp_pb2 - - -_shared_modules = [empty_pb2, field_mask_pb2, timestamp_pb2] - -_local_modules = [ - crawled_url_pb2, - finding_addon_pb2, - finding_pb2, - finding_type_stats_pb2, - scan_config_error_pb2, - scan_config_pb2, - scan_run_error_trace_pb2, - scan_run_pb2, - scan_run_warning_trace_pb2, - web_security_scanner_pb2, -] - -names = [] - -for module in _shared_modules: # pragma: NO COVER - for name, message in get_messages(module).items(): - setattr(sys.modules[__name__], name, message) - names.append(name) -for module in _local_modules: - for name, message in get_messages(module).items(): - message.__module__ = "google.cloud.websecurityscanner_v1beta.types" - setattr(sys.modules[__name__], name, message) - names.append(name) - - -__all__ = tuple(sorted(names)) diff --git a/google/cloud/websecurityscanner_v1beta/types/__init__.py b/google/cloud/websecurityscanner_v1beta/types/__init__.py new file mode 100644 index 0000000..adb9a0a --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/types/__init__.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 .crawled_url import CrawledUrl +from .finding_addon import ( + Form, + OutdatedLibrary, + ViolatingResource, + VulnerableParameters, + VulnerableHeaders, + Xss, +) +from .finding import Finding +from .finding_type_stats import FindingTypeStats +from .scan_config_error import ScanConfigError +from .scan_run_error_trace import ScanRunErrorTrace +from .scan_run_warning_trace import ScanRunWarningTrace +from .scan_run import ScanRun +from .scan_config import ScanConfig +from .web_security_scanner import ( + CreateScanConfigRequest, + DeleteScanConfigRequest, + GetScanConfigRequest, + ListScanConfigsRequest, + UpdateScanConfigRequest, + ListScanConfigsResponse, + StartScanRunRequest, + GetScanRunRequest, + ListScanRunsRequest, + ListScanRunsResponse, + StopScanRunRequest, + ListCrawledUrlsRequest, + ListCrawledUrlsResponse, + GetFindingRequest, + ListFindingsRequest, + ListFindingsResponse, + ListFindingTypeStatsRequest, + ListFindingTypeStatsResponse, +) + + +__all__ = ( + "CrawledUrl", + "Form", + "OutdatedLibrary", + "ViolatingResource", + "VulnerableParameters", + "VulnerableHeaders", + "Xss", + "Finding", + "FindingTypeStats", + "ScanConfigError", + "ScanRunErrorTrace", + "ScanRunWarningTrace", + "ScanRun", + "ScanConfig", + "CreateScanConfigRequest", + "DeleteScanConfigRequest", + "GetScanConfigRequest", + "ListScanConfigsRequest", + "UpdateScanConfigRequest", + "ListScanConfigsResponse", + "StartScanRunRequest", + "GetScanRunRequest", + "ListScanRunsRequest", + "ListScanRunsResponse", + "StopScanRunRequest", + "ListCrawledUrlsRequest", + "ListCrawledUrlsResponse", + "GetFindingRequest", + "ListFindingsRequest", + "ListFindingsResponse", + "ListFindingTypeStatsRequest", + "ListFindingTypeStatsResponse", +) diff --git a/google/cloud/websecurityscanner_v1beta/types/crawled_url.py b/google/cloud/websecurityscanner_v1beta/types/crawled_url.py new file mode 100644 index 0000000..0218c40 --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/types/crawled_url.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1beta", manifest={"CrawledUrl",}, +) + + +class CrawledUrl(proto.Message): + r"""A CrawledUrl resource represents a URL that was crawled + during a ScanRun. Web Security Scanner Service crawls the web + applications, following all links within the scope of sites, to + find the URLs to test against. + + Attributes: + http_method (str): + The http method of the request that was used + to visit the URL, in uppercase. + url (str): + The URL that was crawled. + body (str): + The body of the request that was used to + visit the URL. + """ + + http_method = proto.Field(proto.STRING, number=1) + + url = proto.Field(proto.STRING, number=2) + + body = proto.Field(proto.STRING, number=3) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1beta/types/finding.py b/google/cloud/websecurityscanner_v1beta/types/finding.py new file mode 100644 index 0000000..5a01b73 --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/types/finding.py @@ -0,0 +1,134 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +from google.cloud.websecurityscanner_v1beta.types import finding_addon + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1beta", manifest={"Finding",}, +) + + +class Finding(proto.Message): + r"""A Finding resource represents a vulnerability instance + identified during a ScanRun. + + Attributes: + name (str): + The resource name of the Finding. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanruns/{scanRunId}/findings/{findingId}'. + The finding IDs are generated by the system. + finding_type (str): + The type of the Finding. + Detailed and up-to-date information on findings + can be found here: + https://cloud.google.com/security- + scanner/docs/scan-result-details + http_method (str): + The http method of the request that triggered + the vulnerability, in uppercase. + fuzzed_url (str): + The URL produced by the server-side fuzzer + and used in the request that triggered the + vulnerability. + body (str): + The body of the request that triggered the + vulnerability. + description (str): + The description of the vulnerability. + reproduction_url (str): + The URL containing human-readable payload + that user can leverage to reproduce the + vulnerability. + frame_url (str): + If the vulnerability was originated from + nested IFrame, the immediate parent IFrame is + reported. + final_url (str): + The URL where the browser lands when the + vulnerability is detected. + tracking_id (str): + The tracking ID uniquely identifies a + vulnerability instance across multiple ScanRuns. + form (~.finding_addon.Form): + An addon containing information reported for + a vulnerability with an HTML form, if any. + outdated_library (~.finding_addon.OutdatedLibrary): + An addon containing information about + outdated libraries. + violating_resource (~.finding_addon.ViolatingResource): + An addon containing detailed information + regarding any resource causing the vulnerability + such as JavaScript sources, image, audio files, + etc. + vulnerable_headers (~.finding_addon.VulnerableHeaders): + An addon containing information about + vulnerable or missing HTTP headers. + vulnerable_parameters (~.finding_addon.VulnerableParameters): + An addon containing information about request + parameters which were found to be vulnerable. + xss (~.finding_addon.Xss): + An addon containing information reported for + an XSS, if any. + """ + + name = proto.Field(proto.STRING, number=1) + + finding_type = proto.Field(proto.STRING, number=2) + + http_method = proto.Field(proto.STRING, number=3) + + fuzzed_url = proto.Field(proto.STRING, number=4) + + body = proto.Field(proto.STRING, number=5) + + description = proto.Field(proto.STRING, number=6) + + reproduction_url = proto.Field(proto.STRING, number=7) + + frame_url = proto.Field(proto.STRING, number=8) + + final_url = proto.Field(proto.STRING, number=9) + + tracking_id = proto.Field(proto.STRING, number=10) + + form = proto.Field(proto.MESSAGE, number=16, message=finding_addon.Form,) + + outdated_library = proto.Field( + proto.MESSAGE, number=11, message=finding_addon.OutdatedLibrary, + ) + + violating_resource = proto.Field( + proto.MESSAGE, number=12, message=finding_addon.ViolatingResource, + ) + + vulnerable_headers = proto.Field( + proto.MESSAGE, number=15, message=finding_addon.VulnerableHeaders, + ) + + vulnerable_parameters = proto.Field( + proto.MESSAGE, number=13, message=finding_addon.VulnerableParameters, + ) + + xss = proto.Field(proto.MESSAGE, number=14, message=finding_addon.Xss,) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1beta/types/finding_addon.py b/google/cloud/websecurityscanner_v1beta/types/finding_addon.py new file mode 100644 index 0000000..6482c6e --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/types/finding_addon.py @@ -0,0 +1,144 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1beta", + manifest={ + "Form", + "OutdatedLibrary", + "ViolatingResource", + "VulnerableParameters", + "VulnerableHeaders", + "Xss", + }, +) + + +class Form(proto.Message): + r"""! Information about a vulnerability with an HTML. + + Attributes: + action_uri (str): + ! The URI where to send the form when it's + submitted. + fields (Sequence[str]): + ! The names of form fields related to the + vulnerability. + """ + + action_uri = proto.Field(proto.STRING, number=1) + + fields = proto.RepeatedField(proto.STRING, number=2) + + +class OutdatedLibrary(proto.Message): + r"""Information reported for an outdated library. + + Attributes: + library_name (str): + The name of the outdated library. + version (str): + The version number. + learn_more_urls (Sequence[str]): + URLs to learn more information about the + vulnerabilities in the library. + """ + + library_name = proto.Field(proto.STRING, number=1) + + version = proto.Field(proto.STRING, number=2) + + learn_more_urls = proto.RepeatedField(proto.STRING, number=3) + + +class ViolatingResource(proto.Message): + r"""Information regarding any resource causing the vulnerability + such as JavaScript sources, image, audio files, etc. + + Attributes: + content_type (str): + The MIME type of this resource. + resource_url (str): + URL of this violating resource. + """ + + content_type = proto.Field(proto.STRING, number=1) + + resource_url = proto.Field(proto.STRING, number=2) + + +class VulnerableParameters(proto.Message): + r"""Information about vulnerable request parameters. + + Attributes: + parameter_names (Sequence[str]): + The vulnerable parameter names. + """ + + parameter_names = proto.RepeatedField(proto.STRING, number=1) + + +class VulnerableHeaders(proto.Message): + r"""Information about vulnerable or missing HTTP Headers. + + Attributes: + headers (Sequence[~.finding_addon.VulnerableHeaders.Header]): + List of vulnerable headers. + missing_headers (Sequence[~.finding_addon.VulnerableHeaders.Header]): + List of missing headers. + """ + + class Header(proto.Message): + r"""Describes a HTTP Header. + + Attributes: + name (str): + Header name. + value (str): + Header value. + """ + + name = proto.Field(proto.STRING, number=1) + + value = proto.Field(proto.STRING, number=2) + + headers = proto.RepeatedField(proto.MESSAGE, number=1, message=Header,) + + missing_headers = proto.RepeatedField(proto.MESSAGE, number=2, message=Header,) + + +class Xss(proto.Message): + r"""Information reported for an XSS. + + Attributes: + stack_traces (Sequence[str]): + Stack traces leading to the point where the + XSS occurred. + error_message (str): + An error message generated by a javascript + breakage. + """ + + stack_traces = proto.RepeatedField(proto.STRING, number=1) + + error_message = proto.Field(proto.STRING, number=2) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1beta/types/finding_type_stats.py b/google/cloud/websecurityscanner_v1beta/types/finding_type_stats.py new file mode 100644 index 0000000..13ba498 --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/types/finding_type_stats.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1beta", manifest={"FindingTypeStats",}, +) + + +class FindingTypeStats(proto.Message): + r"""A FindingTypeStats resource represents stats regarding a + specific FindingType of Findings under a given ScanRun. + + Attributes: + finding_type (str): + The finding type associated with the stats. + finding_count (int): + The count of findings belonging to this + finding type. + """ + + finding_type = proto.Field(proto.STRING, number=1) + + finding_count = proto.Field(proto.INT32, number=2) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1beta/types/scan_config.py b/google/cloud/websecurityscanner_v1beta/types/scan_config.py new file mode 100644 index 0000000..a03317e --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/types/scan_config.py @@ -0,0 +1,220 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +from google.cloud.websecurityscanner_v1beta.types import scan_run +from google.protobuf import timestamp_pb2 as timestamp # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1beta", manifest={"ScanConfig",}, +) + + +class ScanConfig(proto.Message): + r"""A ScanConfig resource contains the configurations to launch a + scan. + + Attributes: + name (str): + The resource name of the ScanConfig. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + The ScanConfig IDs are generated by the system. + display_name (str): + Required. The user provided display name of + the ScanConfig. + max_qps (int): + The maximum QPS during scanning. A valid value ranges from 5 + to 20 inclusively. If the field is unspecified or its value + is set 0, server will default to 15. Other values outside of + [5, 20] range will be rejected with INVALID_ARGUMENT error. + starting_urls (Sequence[str]): + Required. The starting URLs from which the + scanner finds site pages. + authentication (~.scan_config.ScanConfig.Authentication): + The authentication configuration. If + specified, service will use the authentication + configuration during scanning. + user_agent (~.scan_config.ScanConfig.UserAgent): + The user agent used during scanning. + blacklist_patterns (Sequence[str]): + The blacklist URL patterns as described in + https://cloud.google.com/security- + scanner/docs/excluded-urls + schedule (~.scan_config.ScanConfig.Schedule): + The schedule of the ScanConfig. + target_platforms (Sequence[~.scan_config.ScanConfig.TargetPlatform]): + Set of Cloud Platforms targeted by the scan. If empty, + APP_ENGINE will be used as a default. + export_to_security_command_center (~.scan_config.ScanConfig.ExportToSecurityCommandCenter): + Controls export of scan configurations and + results to Cloud Security Command Center. + latest_run (~.scan_run.ScanRun): + Latest ScanRun if available. + risk_level (~.scan_config.ScanConfig.RiskLevel): + The risk level selected for the scan + """ + + class UserAgent(proto.Enum): + r"""Type of user agents used for scanning.""" + USER_AGENT_UNSPECIFIED = 0 + CHROME_LINUX = 1 + CHROME_ANDROID = 2 + SAFARI_IPHONE = 3 + + class TargetPlatform(proto.Enum): + r"""Cloud platforms supported by Cloud Web Security Scanner.""" + TARGET_PLATFORM_UNSPECIFIED = 0 + APP_ENGINE = 1 + COMPUTE = 2 + + class RiskLevel(proto.Enum): + r"""Scan risk levels supported by Cloud Web Security Scanner. LOW + impact scanning will minimize requests with the potential to + modify data. To achieve the maximum scan coverage, NORMAL risk + level is recommended. + """ + RISK_LEVEL_UNSPECIFIED = 0 + NORMAL = 1 + LOW = 2 + + class ExportToSecurityCommandCenter(proto.Enum): + r"""Controls export of scan configurations and results to Cloud + Security Command Center. + """ + EXPORT_TO_SECURITY_COMMAND_CENTER_UNSPECIFIED = 0 + ENABLED = 1 + DISABLED = 2 + + class Authentication(proto.Message): + r"""Scan authentication configuration. + + Attributes: + google_account (~.scan_config.ScanConfig.Authentication.GoogleAccount): + Authentication using a Google account. + custom_account (~.scan_config.ScanConfig.Authentication.CustomAccount): + Authentication using a custom account. + """ + + class GoogleAccount(proto.Message): + r"""Describes authentication configuration that uses a Google + account. + + Attributes: + username (str): + Required. The user name of the Google + account. + password (str): + Required. Input only. The password of the + Google account. The credential is stored + encrypted and not returned in any response nor + included in audit logs. + """ + + username = proto.Field(proto.STRING, number=1) + + password = proto.Field(proto.STRING, number=2) + + class CustomAccount(proto.Message): + r"""Describes authentication configuration that uses a custom + account. + + Attributes: + username (str): + Required. The user name of the custom + account. + password (str): + Required. Input only. The password of the + custom account. The credential is stored + encrypted and not returned in any response nor + included in audit logs. + login_url (str): + Required. The login form URL of the website. + """ + + username = proto.Field(proto.STRING, number=1) + + password = proto.Field(proto.STRING, number=2) + + login_url = proto.Field(proto.STRING, number=3) + + google_account = proto.Field( + proto.MESSAGE, + number=1, + oneof="authentication", + message="ScanConfig.Authentication.GoogleAccount", + ) + + custom_account = proto.Field( + proto.MESSAGE, + number=2, + oneof="authentication", + message="ScanConfig.Authentication.CustomAccount", + ) + + class Schedule(proto.Message): + r"""Scan schedule configuration. + + Attributes: + schedule_time (~.timestamp.Timestamp): + A timestamp indicates when the next run will + be scheduled. The value is refreshed by the + server after each run. If unspecified, it will + default to current server time, which means the + scan will be scheduled to start immediately. + interval_duration_days (int): + Required. The duration of time between + executions in days. + """ + + schedule_time = proto.Field( + proto.MESSAGE, number=1, message=timestamp.Timestamp, + ) + + interval_duration_days = proto.Field(proto.INT32, number=2) + + name = proto.Field(proto.STRING, number=1) + + display_name = proto.Field(proto.STRING, number=2) + + max_qps = proto.Field(proto.INT32, number=3) + + starting_urls = proto.RepeatedField(proto.STRING, number=4) + + authentication = proto.Field(proto.MESSAGE, number=5, message=Authentication,) + + user_agent = proto.Field(proto.ENUM, number=6, enum=UserAgent,) + + blacklist_patterns = proto.RepeatedField(proto.STRING, number=7) + + schedule = proto.Field(proto.MESSAGE, number=8, message=Schedule,) + + target_platforms = proto.RepeatedField(proto.ENUM, number=9, enum=TargetPlatform,) + + export_to_security_command_center = proto.Field( + proto.ENUM, number=10, enum=ExportToSecurityCommandCenter, + ) + + latest_run = proto.Field(proto.MESSAGE, number=11, message=scan_run.ScanRun,) + + risk_level = proto.Field(proto.ENUM, number=12, enum=RiskLevel,) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1beta/types/scan_config_error.py b/google/cloud/websecurityscanner_v1beta/types/scan_config_error.py new file mode 100644 index 0000000..1f2642a --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/types/scan_config_error.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1beta", manifest={"ScanConfigError",}, +) + + +class ScanConfigError(proto.Message): + r"""Defines a custom error message used by CreateScanConfig and + UpdateScanConfig APIs when scan configuration validation fails. + It is also reported as part of a ScanRunErrorTrace message if + scan validation fails due to a scan configuration error. + + Attributes: + code (~.scan_config_error.ScanConfigError.Code): + Indicates the reason code for a configuration + failure. + field_name (str): + Indicates the full name of the ScanConfig field that + triggers this error, for example "scan_config.max_qps". This + field is provided for troubleshooting purposes only and its + actual value can change in the future. + """ + + class Code(proto.Enum): + r"""Output only. + Defines an error reason code. + Next id: 44 + """ + CODE_UNSPECIFIED = 0 + OK = 0 + INTERNAL_ERROR = 1 + APPENGINE_API_BACKEND_ERROR = 2 + APPENGINE_API_NOT_ACCESSIBLE = 3 + APPENGINE_DEFAULT_HOST_MISSING = 4 + CANNOT_USE_GOOGLE_COM_ACCOUNT = 6 + CANNOT_USE_OWNER_ACCOUNT = 7 + COMPUTE_API_BACKEND_ERROR = 8 + COMPUTE_API_NOT_ACCESSIBLE = 9 + CUSTOM_LOGIN_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT = 10 + CUSTOM_LOGIN_URL_MALFORMED = 11 + CUSTOM_LOGIN_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS = 12 + CUSTOM_LOGIN_URL_MAPPED_TO_UNRESERVED_ADDRESS = 13 + CUSTOM_LOGIN_URL_HAS_NON_ROUTABLE_IP_ADDRESS = 14 + CUSTOM_LOGIN_URL_HAS_UNRESERVED_IP_ADDRESS = 15 + DUPLICATE_SCAN_NAME = 16 + INVALID_FIELD_VALUE = 18 + FAILED_TO_AUTHENTICATE_TO_TARGET = 19 + FINDING_TYPE_UNSPECIFIED = 20 + FORBIDDEN_TO_SCAN_COMPUTE = 21 + FORBIDDEN_UPDATE_TO_MANAGED_SCAN = 43 + MALFORMED_FILTER = 22 + MALFORMED_RESOURCE_NAME = 23 + PROJECT_INACTIVE = 24 + REQUIRED_FIELD = 25 + RESOURCE_NAME_INCONSISTENT = 26 + SCAN_ALREADY_RUNNING = 27 + SCAN_NOT_RUNNING = 28 + SEED_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT = 29 + SEED_URL_MALFORMED = 30 + SEED_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS = 31 + SEED_URL_MAPPED_TO_UNRESERVED_ADDRESS = 32 + SEED_URL_HAS_NON_ROUTABLE_IP_ADDRESS = 33 + SEED_URL_HAS_UNRESERVED_IP_ADDRESS = 35 + SERVICE_ACCOUNT_NOT_CONFIGURED = 36 + TOO_MANY_SCANS = 37 + UNABLE_TO_RESOLVE_PROJECT_INFO = 38 + UNSUPPORTED_BLACKLIST_PATTERN_FORMAT = 39 + UNSUPPORTED_FILTER = 40 + UNSUPPORTED_FINDING_TYPE = 41 + UNSUPPORTED_URL_SCHEME = 42 + + code = proto.Field(proto.ENUM, number=1, enum=Code,) + + field_name = proto.Field(proto.STRING, number=2) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1beta/types/scan_run.py b/google/cloud/websecurityscanner_v1beta/types/scan_run.py new file mode 100644 index 0000000..7097998 --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/types/scan_run.py @@ -0,0 +1,124 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +from google.cloud.websecurityscanner_v1beta.types import scan_run_error_trace +from google.cloud.websecurityscanner_v1beta.types import scan_run_warning_trace +from google.protobuf import timestamp_pb2 as timestamp # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1beta", manifest={"ScanRun",}, +) + + +class ScanRun(proto.Message): + r"""A ScanRun is a output-only resource representing an actual + run of the scan. Next id: 12 + + Attributes: + name (str): + The resource name of the ScanRun. The name + follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + The ScanRun IDs are generated by the system. + execution_state (~.scan_run.ScanRun.ExecutionState): + The execution state of the ScanRun. + result_state (~.scan_run.ScanRun.ResultState): + The result state of the ScanRun. This field + is only available after the execution state + reaches "FINISHED". + start_time (~.timestamp.Timestamp): + The time at which the ScanRun started. + end_time (~.timestamp.Timestamp): + The time at which the ScanRun reached + termination state - that the ScanRun is either + finished or stopped by user. + urls_crawled_count (int): + The number of URLs crawled during this + ScanRun. If the scan is in progress, the value + represents the number of URLs crawled up to now. + urls_tested_count (int): + The number of URLs tested during this + ScanRun. If the scan is in progress, the value + represents the number of URLs tested up to now. + The number of URLs tested is usually larger than + the number URLS crawled because typically a + crawled URL is tested with multiple test + payloads. + has_vulnerabilities (bool): + Whether the scan run has found any + vulnerabilities. + progress_percent (int): + The percentage of total completion ranging + from 0 to 100. If the scan is in queue, the + value is 0. If the scan is running, the value + ranges from 0 to 100. If the scan is finished, + the value is 100. + error_trace (~.scan_run_error_trace.ScanRunErrorTrace): + If result_state is an ERROR, this field provides the primary + reason for scan's termination and more details, if such are + available. + warning_traces (Sequence[~.scan_run_warning_trace.ScanRunWarningTrace]): + A list of warnings, if such are encountered + during this scan run. + """ + + class ExecutionState(proto.Enum): + r"""Types of ScanRun execution state.""" + EXECUTION_STATE_UNSPECIFIED = 0 + QUEUED = 1 + SCANNING = 2 + FINISHED = 3 + + class ResultState(proto.Enum): + r"""Types of ScanRun result state.""" + RESULT_STATE_UNSPECIFIED = 0 + SUCCESS = 1 + ERROR = 2 + KILLED = 3 + + name = proto.Field(proto.STRING, number=1) + + execution_state = proto.Field(proto.ENUM, number=2, enum=ExecutionState,) + + result_state = proto.Field(proto.ENUM, number=3, enum=ResultState,) + + start_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) + + end_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) + + urls_crawled_count = proto.Field(proto.INT64, number=6) + + urls_tested_count = proto.Field(proto.INT64, number=7) + + has_vulnerabilities = proto.Field(proto.BOOL, number=8) + + progress_percent = proto.Field(proto.INT32, number=9) + + error_trace = proto.Field( + proto.MESSAGE, number=10, message=scan_run_error_trace.ScanRunErrorTrace, + ) + + warning_traces = proto.RepeatedField( + proto.MESSAGE, number=11, message=scan_run_warning_trace.ScanRunWarningTrace, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1beta/types/scan_run_error_trace.py b/google/cloud/websecurityscanner_v1beta/types/scan_run_error_trace.py new file mode 100644 index 0000000..a69f5ea --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/types/scan_run_error_trace.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +from google.cloud.websecurityscanner_v1beta.types import ( + scan_config_error as gcw_scan_config_error, +) + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1beta", manifest={"ScanRunErrorTrace",}, +) + + +class ScanRunErrorTrace(proto.Message): + r"""Output only. + Defines an error trace message for a ScanRun. + + Attributes: + code (~.scan_run_error_trace.ScanRunErrorTrace.Code): + Indicates the error reason code. + scan_config_error (~.gcw_scan_config_error.ScanConfigError): + If the scan encounters SCAN_CONFIG_ISSUE error, this field + has the error message encountered during scan configuration + validation that is performed before each scan run. + most_common_http_error_code (int): + If the scan encounters TOO_MANY_HTTP_ERRORS, this field + indicates the most common HTTP error code, if such is + available. For example, if this code is 404, the scan has + encountered too many NOT_FOUND responses. + """ + + class Code(proto.Enum): + r"""Output only. + Defines an error reason code. + Next id: 7 + """ + CODE_UNSPECIFIED = 0 + INTERNAL_ERROR = 1 + SCAN_CONFIG_ISSUE = 2 + AUTHENTICATION_CONFIG_ISSUE = 3 + TIMED_OUT_WHILE_SCANNING = 4 + TOO_MANY_REDIRECTS = 5 + TOO_MANY_HTTP_ERRORS = 6 + + code = proto.Field(proto.ENUM, number=1, enum=Code,) + + scan_config_error = proto.Field( + proto.MESSAGE, number=2, message=gcw_scan_config_error.ScanConfigError, + ) + + most_common_http_error_code = proto.Field(proto.INT32, number=3) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1beta/types/scan_run_warning_trace.py b/google/cloud/websecurityscanner_v1beta/types/scan_run_warning_trace.py new file mode 100644 index 0000000..933e88d --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/types/scan_run_warning_trace.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1beta", manifest={"ScanRunWarningTrace",}, +) + + +class ScanRunWarningTrace(proto.Message): + r"""Output only. + Defines a warning trace message for ScanRun. Warning traces + provide customers with useful information that helps make the + scanning process more effective. + + Attributes: + code (~.scan_run_warning_trace.ScanRunWarningTrace.Code): + Indicates the warning code. + """ + + class Code(proto.Enum): + r"""Output only. + Defines a warning message code. + Next id: 6 + """ + CODE_UNSPECIFIED = 0 + INSUFFICIENT_CRAWL_RESULTS = 1 + TOO_MANY_CRAWL_RESULTS = 2 + TOO_MANY_FUZZ_TASKS = 3 + BLOCKED_BY_IAP = 4 + + code = proto.Field(proto.ENUM, number=1, enum=Code,) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/websecurityscanner_v1beta/types/web_security_scanner.py b/google/cloud/websecurityscanner_v1beta/types/web_security_scanner.py new file mode 100644 index 0000000..6cb03bc --- /dev/null +++ b/google/cloud/websecurityscanner_v1beta/types/web_security_scanner.py @@ -0,0 +1,404 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 proto # type: ignore + + +from google.cloud.websecurityscanner_v1beta.types import crawled_url +from google.cloud.websecurityscanner_v1beta.types import finding +from google.cloud.websecurityscanner_v1beta.types import ( + finding_type_stats as gcw_finding_type_stats, +) +from google.cloud.websecurityscanner_v1beta.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_run +from google.protobuf import field_mask_pb2 as field_mask # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.websecurityscanner.v1beta", + manifest={ + "CreateScanConfigRequest", + "DeleteScanConfigRequest", + "GetScanConfigRequest", + "ListScanConfigsRequest", + "UpdateScanConfigRequest", + "ListScanConfigsResponse", + "StartScanRunRequest", + "GetScanRunRequest", + "ListScanRunsRequest", + "ListScanRunsResponse", + "StopScanRunRequest", + "ListCrawledUrlsRequest", + "ListCrawledUrlsResponse", + "GetFindingRequest", + "ListFindingsRequest", + "ListFindingsResponse", + "ListFindingTypeStatsRequest", + "ListFindingTypeStatsResponse", + }, +) + + +class CreateScanConfigRequest(proto.Message): + r"""Request for the ``CreateScanConfig`` method. + + Attributes: + parent (str): + Required. The parent resource name where the + scan is created, which should be a project + resource name in the format + 'projects/{projectId}'. + scan_config (~.gcw_scan_config.ScanConfig): + Required. The ScanConfig to be created. + """ + + parent = proto.Field(proto.STRING, number=1) + + scan_config = proto.Field( + proto.MESSAGE, number=2, message=gcw_scan_config.ScanConfig, + ) + + +class DeleteScanConfigRequest(proto.Message): + r"""Request for the ``DeleteScanConfig`` method. + + Attributes: + name (str): + Required. The resource name of the ScanConfig + to be deleted. The name follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + """ + + name = proto.Field(proto.STRING, number=1) + + +class GetScanConfigRequest(proto.Message): + r"""Request for the ``GetScanConfig`` method. + + Attributes: + name (str): + Required. The resource name of the ScanConfig + to be returned. The name follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListScanConfigsRequest(proto.Message): + r"""Request for the ``ListScanConfigs`` method. + + Attributes: + parent (str): + Required. The parent resource name, which + should be a project resource name in the format + 'projects/{projectId}'. + page_token (str): + A token identifying a page of results to be returned. This + should be a ``next_page_token`` value returned from a + previous List request. If unspecified, the first page of + results is returned. + page_size (int): + The maximum number of ScanConfigs to return, + can be limited by server. If not specified or + not positive, the implementation will select a + reasonable value. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_token = proto.Field(proto.STRING, number=2) + + page_size = proto.Field(proto.INT32, number=3) + + +class UpdateScanConfigRequest(proto.Message): + r"""Request for the ``UpdateScanConfigRequest`` method. + + Attributes: + scan_config (~.gcw_scan_config.ScanConfig): + Required. The ScanConfig to be updated. The + name field must be set to identify the resource + to be updated. The values of fields not covered + by the mask will be ignored. + update_mask (~.field_mask.FieldMask): + Required. The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + """ + + scan_config = proto.Field( + proto.MESSAGE, number=2, message=gcw_scan_config.ScanConfig, + ) + + update_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask.FieldMask,) + + +class ListScanConfigsResponse(proto.Message): + r"""Response for the ``ListScanConfigs`` method. + + Attributes: + scan_configs (Sequence[~.gcw_scan_config.ScanConfig]): + The list of ScanConfigs returned. + next_page_token (str): + Token to retrieve the next page of results, + or empty if there are no more results in the + list. + """ + + @property + def raw_page(self): + return self + + scan_configs = proto.RepeatedField( + proto.MESSAGE, number=1, message=gcw_scan_config.ScanConfig, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class StartScanRunRequest(proto.Message): + r"""Request for the ``StartScanRun`` method. + + Attributes: + name (str): + Required. The resource name of the ScanConfig + to be used. The name follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + """ + + name = proto.Field(proto.STRING, number=1) + + +class GetScanRunRequest(proto.Message): + r"""Request for the ``GetScanRun`` method. + + Attributes: + name (str): + Required. The resource name of the ScanRun to + be returned. The name follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListScanRunsRequest(proto.Message): + r"""Request for the ``ListScanRuns`` method. + + Attributes: + parent (str): + Required. The parent resource name, which + should be a scan resource name in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}'. + page_token (str): + A token identifying a page of results to be returned. This + should be a ``next_page_token`` value returned from a + previous List request. If unspecified, the first page of + results is returned. + page_size (int): + The maximum number of ScanRuns to return, can + be limited by server. If not specified or not + positive, the implementation will select a + reasonable value. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_token = proto.Field(proto.STRING, number=2) + + page_size = proto.Field(proto.INT32, number=3) + + +class ListScanRunsResponse(proto.Message): + r"""Response for the ``ListScanRuns`` method. + + Attributes: + scan_runs (Sequence[~.scan_run.ScanRun]): + The list of ScanRuns returned. + next_page_token (str): + Token to retrieve the next page of results, + or empty if there are no more results in the + list. + """ + + @property + def raw_page(self): + return self + + scan_runs = proto.RepeatedField(proto.MESSAGE, number=1, message=scan_run.ScanRun,) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class StopScanRunRequest(proto.Message): + r"""Request for the ``StopScanRun`` method. + + Attributes: + name (str): + Required. The resource name of the ScanRun to + be stopped. The name follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListCrawledUrlsRequest(proto.Message): + r"""Request for the ``ListCrawledUrls`` method. + + Attributes: + parent (str): + Required. The parent resource name, which + should be a scan run resource name in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + page_token (str): + A token identifying a page of results to be returned. This + should be a ``next_page_token`` value returned from a + previous List request. If unspecified, the first page of + results is returned. + page_size (int): + The maximum number of CrawledUrls to return, + can be limited by server. If not specified or + not positive, the implementation will select a + reasonable value. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_token = proto.Field(proto.STRING, number=2) + + page_size = proto.Field(proto.INT32, number=3) + + +class ListCrawledUrlsResponse(proto.Message): + r"""Response for the ``ListCrawledUrls`` method. + + Attributes: + crawled_urls (Sequence[~.crawled_url.CrawledUrl]): + The list of CrawledUrls returned. + next_page_token (str): + Token to retrieve the next page of results, + or empty if there are no more results in the + list. + """ + + @property + def raw_page(self): + return self + + crawled_urls = proto.RepeatedField( + proto.MESSAGE, number=1, message=crawled_url.CrawledUrl, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class GetFindingRequest(proto.Message): + r"""Request for the ``GetFinding`` method. + + Attributes: + name (str): + Required. The resource name of the Finding to + be returned. The name follows the format of + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListFindingsRequest(proto.Message): + r"""Request for the ``ListFindings`` method. + + Attributes: + parent (str): + Required. The parent resource name, which + should be a scan run resource name in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + filter (str): + Required. The filter expression. The expression must be in + the format: . Supported field: 'finding_type'. Supported + operator: '='. + page_token (str): + A token identifying a page of results to be returned. This + should be a ``next_page_token`` value returned from a + previous List request. If unspecified, the first page of + results is returned. + page_size (int): + The maximum number of Findings to return, can + be limited by server. If not specified or not + positive, the implementation will select a + reasonable value. + """ + + parent = proto.Field(proto.STRING, number=1) + + filter = proto.Field(proto.STRING, number=2) + + page_token = proto.Field(proto.STRING, number=3) + + page_size = proto.Field(proto.INT32, number=4) + + +class ListFindingsResponse(proto.Message): + r"""Response for the ``ListFindings`` method. + + Attributes: + findings (Sequence[~.finding.Finding]): + The list of Findings returned. + next_page_token (str): + Token to retrieve the next page of results, + or empty if there are no more results in the + list. + """ + + @property + def raw_page(self): + return self + + findings = proto.RepeatedField(proto.MESSAGE, number=1, message=finding.Finding,) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class ListFindingTypeStatsRequest(proto.Message): + r"""Request for the ``ListFindingTypeStats`` method. + + Attributes: + parent (str): + Required. The parent resource name, which + should be a scan run resource name in the format + 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + """ + + parent = proto.Field(proto.STRING, number=1) + + +class ListFindingTypeStatsResponse(proto.Message): + r"""Response for the ``ListFindingTypeStats`` method. + + Attributes: + finding_type_stats (Sequence[~.gcw_finding_type_stats.FindingTypeStats]): + The list of FindingTypeStats returned. + """ + + finding_type_stats = proto.RepeatedField( + proto.MESSAGE, number=1, message=gcw_finding_type_stats.FindingTypeStats, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 984ae5a..25c0a06 100644 --- a/noxfile.py +++ b/noxfile.py @@ -23,14 +23,15 @@ import nox -BLACK_VERSION = "black==19.3b0" +BLACK_VERSION = "black==19.10b0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] -if os.path.exists("samples"): - BLACK_PATHS.append("samples") +DEFAULT_PYTHON_VERSION = "3.8" +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] +UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8"] -@nox.session(python="3.7") +@nox.session(python=DEFAULT_PYTHON_VERSION) def lint(session): """Run linters. @@ -38,7 +39,9 @@ def lint(session): serious code quality issues. """ session.install("flake8", BLACK_VERSION) - session.run("black", "--check", *BLACK_PATHS) + session.run( + "black", "--check", *BLACK_PATHS, + ) session.run("flake8", "google", "tests") @@ -53,10 +56,12 @@ def blacken(session): check the state of the `gcp_ubuntu_config` we use for that Kokoro run. """ session.install(BLACK_VERSION) - session.run("black", *BLACK_PATHS) + session.run( + "black", *BLACK_PATHS, + ) -@nox.session(python="3.7") +@nox.session(python=DEFAULT_PYTHON_VERSION) def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" session.install("docutils", "pygments") @@ -65,6 +70,8 @@ def lint_setup_py(session): def default(session): # Install all test dependencies, then install this package in-place. + session.install("asyncmock", "pytest-asyncio") + session.install("mock", "pytest", "pytest-cov") session.install("-e", ".") @@ -72,6 +79,7 @@ def default(session): session.run( "py.test", "--quiet", + "--cov=google.cloud.websecurityscanner", "--cov=google.cloud", "--cov=tests.unit", "--cov-append", @@ -83,13 +91,13 @@ def default(session): ) -@nox.session(python=["2.7", "3.5", "3.6", "3.7", "3.8"]) +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) def unit(session): """Run the unit test suite.""" default(session) -@nox.session(python=["2.7", "3.7"]) +@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" system_test_path = os.path.join("tests", "system.py") @@ -109,8 +117,9 @@ def system(session): # Install all test dependencies, then install this package into the # virtualenv's dist-packages. - session.install("mock", "pytest") - session.install("-e", "../test_utils/") + session.install( + "mock", "pytest", "google-cloud-testutils", + ) session.install("-e", ".") # Run py.test against the system tests. @@ -120,7 +129,7 @@ def system(session): session.run("py.test", "--quiet", system_test_folder_path, *session.posargs) -@nox.session(python="3.7") +@nox.session(python=DEFAULT_PYTHON_VERSION) def cover(session): """Run the final coverage report. @@ -128,17 +137,17 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=89") + session.run("coverage", "report", "--show-missing", "--fail-under=100") session.run("coverage", "erase") -@nox.session(python="3.7") +@nox.session(python=DEFAULT_PYTHON_VERSION) def docs(session): """Build the docs for this library.""" session.install("-e", ".") - session.install("sphinx", "alabaster", "recommonmark") + session.install("sphinx<3.0.0", "alabaster", "recommonmark") shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) session.run( diff --git a/samples/AUTHORING_GUIDE.md b/samples/AUTHORING_GUIDE.md new file mode 100644 index 0000000..55c97b3 --- /dev/null +++ b/samples/AUTHORING_GUIDE.md @@ -0,0 +1 @@ +See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md \ No newline at end of file diff --git a/samples/CONTRIBUTING.md b/samples/CONTRIBUTING.md new file mode 100644 index 0000000..34c882b --- /dev/null +++ b/samples/CONTRIBUTING.md @@ -0,0 +1 @@ +See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/CONTRIBUTING.md \ No newline at end of file diff --git a/scripts/decrypt-secrets.sh b/scripts/decrypt-secrets.sh new file mode 100755 index 0000000..ff599eb --- /dev/null +++ b/scripts/decrypt-secrets.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Copyright 2015 Google Inc. All rights reserved. +# +# 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. + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ROOT=$( dirname "$DIR" ) + +# Work from the project root. +cd $ROOT + +# Use SECRET_MANAGER_PROJECT if set, fallback to cloud-devrel-kokoro-resources. +PROJECT_ID="${SECRET_MANAGER_PROJECT:-cloud-devrel-kokoro-resources}" + +gcloud secrets versions access latest --secret="python-docs-samples-test-env" \ + > testing/test-env.sh +gcloud secrets versions access latest \ + --secret="python-docs-samples-service-account" \ + > testing/service-account.json +gcloud secrets versions access latest \ + --secret="python-docs-samples-client-secrets" \ + > testing/client-secrets.json \ No newline at end of file diff --git a/scripts/fixup_websecurityscanner_v1alpha_keywords.py b/scripts/fixup_websecurityscanner_v1alpha_keywords.py new file mode 100644 index 0000000..871b0ca --- /dev/null +++ b/scripts/fixup_websecurityscanner_v1alpha_keywords.py @@ -0,0 +1,190 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class websecurityscannerCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_scan_config': ('parent', 'scan_config', ), + 'delete_scan_config': ('name', ), + 'get_finding': ('name', ), + 'get_scan_config': ('name', ), + 'get_scan_run': ('name', ), + 'list_crawled_urls': ('parent', 'page_token', 'page_size', ), + 'list_findings': ('parent', 'filter', 'page_token', 'page_size', ), + 'list_finding_type_stats': ('parent', ), + 'list_scan_configs': ('parent', 'page_token', 'page_size', ), + 'list_scan_runs': ('parent', 'page_token', 'page_size', ), + 'start_scan_run': ('name', ), + 'stop_scan_run': ('name', ), + 'update_scan_config': ('scan_config', 'update_mask', ), + + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), + cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=websecurityscannerCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the websecurityscanner client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/scripts/fixup_websecurityscanner_v1beta_keywords.py b/scripts/fixup_websecurityscanner_v1beta_keywords.py new file mode 100644 index 0000000..871b0ca --- /dev/null +++ b/scripts/fixup_websecurityscanner_v1beta_keywords.py @@ -0,0 +1,190 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class websecurityscannerCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_scan_config': ('parent', 'scan_config', ), + 'delete_scan_config': ('name', ), + 'get_finding': ('name', ), + 'get_scan_config': ('name', ), + 'get_scan_run': ('name', ), + 'list_crawled_urls': ('parent', 'page_token', 'page_size', ), + 'list_findings': ('parent', 'filter', 'page_token', 'page_size', ), + 'list_finding_type_stats': ('parent', ), + 'list_scan_configs': ('parent', 'page_token', 'page_size', ), + 'list_scan_runs': ('parent', 'page_token', 'page_size', ), + 'start_scan_run': ('name', ), + 'stop_scan_run': ('name', ), + 'update_scan_config': ('scan_config', 'update_mask', ), + + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), + cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=websecurityscannerCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the websecurityscanner client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py new file mode 100644 index 0000000..d309d6e --- /dev/null +++ b/scripts/readme-gen/readme_gen.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +# Copyright 2016 Google Inc +# +# 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. + +"""Generates READMEs using configuration defined in yaml.""" + +import argparse +import io +import os +import subprocess + +import jinja2 +import yaml + + +jinja_env = jinja2.Environment( + trim_blocks=True, + loader=jinja2.FileSystemLoader( + os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) + +README_TMPL = jinja_env.get_template('README.tmpl.rst') + + +def get_help(file): + return subprocess.check_output(['python', file, '--help']).decode() + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('source') + parser.add_argument('--destination', default='README.rst') + + args = parser.parse_args() + + source = os.path.abspath(args.source) + root = os.path.dirname(source) + destination = os.path.join(root, args.destination) + + jinja_env.globals['get_help'] = get_help + + with io.open(source, 'r') as f: + config = yaml.load(f) + + # This allows get_help to execute in the right directory. + os.chdir(root) + + output = README_TMPL.render(config) + + with io.open(destination, 'w') as f: + f.write(output) + + +if __name__ == '__main__': + main() diff --git a/scripts/readme-gen/templates/README.tmpl.rst b/scripts/readme-gen/templates/README.tmpl.rst new file mode 100644 index 0000000..4fd2397 --- /dev/null +++ b/scripts/readme-gen/templates/README.tmpl.rst @@ -0,0 +1,87 @@ +{# The following line is a lie. BUT! Once jinja2 is done with it, it will + become truth! #} +.. This file is automatically generated. Do not edit this file directly. + +{{product.name}} Python Samples +=============================================================================== + +.. image:: https://gstatic.com/cloudssh/images/open-btn.png + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor={{folder}}/README.rst + + +This directory contains samples for {{product.name}}. {{product.description}} + +{{description}} + +.. _{{product.name}}: {{product.url}} + +{% if required_api_url %} +To run the sample, you need to enable the API at: {{required_api_url}} +{% endif %} + +{% if required_role %} +To run the sample, you need to have `{{required_role}}` role. +{% endif %} + +{{other_required_steps}} + +{% if setup %} +Setup +------------------------------------------------------------------------------- + +{% for section in setup %} + +{% include section + '.tmpl.rst' %} + +{% endfor %} +{% endif %} + +{% if samples %} +Samples +------------------------------------------------------------------------------- + +{% for sample in samples %} +{{sample.name}} ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +{% if not sample.hide_cloudshell_button %} +.. image:: https://gstatic.com/cloudssh/images/open-btn.png + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor={{folder}}/{{sample.file}},{{folder}}/README.rst +{% endif %} + + +{{sample.description}} + +To run this sample: + +.. code-block:: bash + + $ python {{sample.file}} +{% if sample.show_help %} + + {{get_help(sample.file)|indent}} +{% endif %} + + +{% endfor %} +{% endif %} + +{% if cloud_client_library %} + +The client library +------------------------------------------------------------------------------- + +This sample uses the `Google Cloud Client Library for Python`_. +You can read the documentation for more details on API usage and use GitHub +to `browse the source`_ and `report issues`_. + +.. _Google Cloud Client Library for Python: + https://googlecloudplatform.github.io/google-cloud-python/ +.. _browse the source: + https://github.com/GoogleCloudPlatform/google-cloud-python +.. _report issues: + https://github.com/GoogleCloudPlatform/google-cloud-python/issues + +{% endif %} + +.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/scripts/readme-gen/templates/auth.tmpl.rst b/scripts/readme-gen/templates/auth.tmpl.rst new file mode 100644 index 0000000..1446b94 --- /dev/null +++ b/scripts/readme-gen/templates/auth.tmpl.rst @@ -0,0 +1,9 @@ +Authentication +++++++++++++++ + +This sample requires you to have authentication setup. Refer to the +`Authentication Getting Started Guide`_ for instructions on setting up +credentials for applications. + +.. _Authentication Getting Started Guide: + https://cloud.google.com/docs/authentication/getting-started diff --git a/scripts/readme-gen/templates/auth_api_key.tmpl.rst b/scripts/readme-gen/templates/auth_api_key.tmpl.rst new file mode 100644 index 0000000..11957ce --- /dev/null +++ b/scripts/readme-gen/templates/auth_api_key.tmpl.rst @@ -0,0 +1,14 @@ +Authentication +++++++++++++++ + +Authentication for this service is done via an `API Key`_. To obtain an API +Key: + +1. Open the `Cloud Platform Console`_ +2. Make sure that billing is enabled for your project. +3. From the **Credentials** page, create a new **API Key** or use an existing + one for your project. + +.. _API Key: + https://developers.google.com/api-client-library/python/guide/aaa_apikeys +.. _Cloud Console: https://console.cloud.google.com/project?_ diff --git a/scripts/readme-gen/templates/install_deps.tmpl.rst b/scripts/readme-gen/templates/install_deps.tmpl.rst new file mode 100644 index 0000000..a0406db --- /dev/null +++ b/scripts/readme-gen/templates/install_deps.tmpl.rst @@ -0,0 +1,29 @@ +Install Dependencies +++++++++++++++++++++ + +#. Clone python-docs-samples and change directory to the sample directory you want to use. + + .. code-block:: bash + + $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git + +#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. + + .. _Python Development Environment Setup Guide: + https://cloud.google.com/python/setup + +#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. + + .. code-block:: bash + + $ virtualenv env + $ source env/bin/activate + +#. Install the dependencies needed to run the samples. + + .. code-block:: bash + + $ pip install -r requirements.txt + +.. _pip: https://pip.pypa.io/ +.. _virtualenv: https://virtualenv.pypa.io/ diff --git a/scripts/readme-gen/templates/install_portaudio.tmpl.rst b/scripts/readme-gen/templates/install_portaudio.tmpl.rst new file mode 100644 index 0000000..5ea33d1 --- /dev/null +++ b/scripts/readme-gen/templates/install_portaudio.tmpl.rst @@ -0,0 +1,35 @@ +Install PortAudio ++++++++++++++++++ + +Install `PortAudio`_. This is required by the `PyAudio`_ library to stream +audio from your computer's microphone. PyAudio depends on PortAudio for cross-platform compatibility, and is installed differently depending on the +platform. + +* For Mac OS X, you can use `Homebrew`_:: + + brew install portaudio + + **Note**: if you encounter an error when running `pip install` that indicates + it can't find `portaudio.h`, try running `pip install` with the following + flags:: + + pip install --global-option='build_ext' \ + --global-option='-I/usr/local/include' \ + --global-option='-L/usr/local/lib' \ + pyaudio + +* For Debian / Ubuntu Linux:: + + apt-get install portaudio19-dev python-all-dev + +* Windows may work without having to install PortAudio explicitly (it will get + installed with PyAudio). + +For more details, see the `PyAudio installation`_ page. + + +.. _PyAudio: https://people.csail.mit.edu/hubert/pyaudio/ +.. _PortAudio: http://www.portaudio.com/ +.. _PyAudio installation: + https://people.csail.mit.edu/hubert/pyaudio/#downloads +.. _Homebrew: http://brew.sh diff --git a/setup.cfg b/setup.cfg index 3bd5555..c3a2b39 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,19 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2020 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 +# +# https://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. + # Generated by synthtool. DO NOT EDIT! [bdist_wheel] universal = 1 diff --git a/setup.py b/setup.py index 40eaf70..49b5cd0 100644 --- a/setup.py +++ b/setup.py @@ -22,14 +22,17 @@ name = "google-cloud-websecurityscanner" description = ("Google Cloud Web Security Scanner API client library",) -version = "0.4.0" +version = "1.0.0" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta' # 'Development Status :: 5 - Production/Stable' release_status = "Development Status :: 3 - Alpha" -dependencies = ["google-api-core[grpc] >= 1.14.0, < 2.0.0dev"] - +dependencies = [ + "google-api-core[grpc] >= 1.22.0, < 2.0.0dev", + "proto-plus >= 0.4.0", + "libcst >= 0.2.5", +] extras = {} @@ -44,7 +47,9 @@ # Only include packages under the 'google' namespace. Do not include tests, # benchmarks, etc. packages = [ - package for package in setuptools.find_packages() if package.startswith("google") + package + for package in setuptools.PEP420PackageFinder.find() + if package.startswith("google") ] # Determine which namespaces are needed. @@ -69,19 +74,21 @@ "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", ], platforms="Posix; MacOS X; Windows", packages=packages, namespace_packages=namespaces, install_requires=dependencies, extras_require=extras, - python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", + python_requires=">=3.6", + scripts=[ + "scripts/fixup_websecurityscanner_v1alpha_keywords.py", + "scripts/fixup_websecurityscanner_v1beta_keywords.py", + ], include_package_data=True, zip_safe=False, ) diff --git a/synth.metadata b/synth.metadata index 4c54cee..c18f2bc 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,26 +1,17 @@ { - "updateTime": "2020-01-30T20:59:06.689419Z", "sources": [ - { - "generator": { - "name": "artman", - "version": "0.44.4", - "dockerImage": "googleapis/artman@sha256:19e945954fc960a4bdfee6cb34695898ab21a8cf0bac063ee39b91f00a1faec8" - } - }, { "git": { - "name": "googleapis", - "remote": "git@github.com:googleapis/googleapis.git", - "sha": "7a15e7fe78ff4b6d5c9606a3264559e5bde341d1", - "internalRef": "292391607" + "name": ".", + "remote": "https://github.com/googleapis/python-websecurityscanner.git", + "sha": "bd5365c10f681b2300a834c13a9a970e71c74b03" } }, { - "template": { - "name": "python_split_library", - "origin": "synthtool.gcp", - "version": "2019.10.17" + "git": { + "name": "synthtool", + "remote": "https://github.com/googleapis/synthtool.git", + "sha": "d07b7b7afa718686db7b095317f608a2f1b6b1cb" } } ], @@ -31,8 +22,7 @@ "apiName": "websecurityscanner", "apiVersion": "v1alpha", "language": "python", - "generator": "gapic", - "config": "google/cloud/websecurityscanner/artman_websecurityscanner_v1alpha.yaml" + "generator": "bazel" } }, { @@ -41,8 +31,7 @@ "apiName": "websecurityscanner", "apiVersion": "v1beta", "language": "python", - "generator": "gapic", - "config": "google/cloud/websecurityscanner/artman_websecurityscanner_v1beta.yaml" + "generator": "bazel" } } ] diff --git a/synth.py b/synth.py index 3acc511..f01c751 100644 --- a/synth.py +++ b/synth.py @@ -16,7 +16,7 @@ import synthtool as s from synthtool import gcp -gapic = gcp.GAPICGenerator() +gapic = gcp.GAPICBazel() common = gcp.CommonTemplates() @@ -26,27 +26,28 @@ versions = ["v1alpha", "v1beta"] for version in versions: - library = gapic.py_library( - "websecurityscanner", - version, - config_path=f"/google/cloud/websecurityscanner" - f"/artman_websecurityscanner_{version}.yaml", - artman_output_name=f"websecurityscanner-{version}", - include_protos=True, - ) - - s.move(library / f"google/cloud/websecurityscanner_{version}/proto") - s.move(library / f"google/cloud/websecurityscanner_{version}/gapic") - s.move(library / f"google/cloud/websecurityscanner_{version}/*.py") - s.move(library / f"docs/gapic/{version}") - s.move(library / f"tests/unit/gapic/{version}") - -s.move(library / "google/cloud/websecurityscanner.py") + library = gapic.py_library( + service="websecurityscanner", + version=version, + bazel_target=f"//google/cloud/websecurityscanner/{version}:websecurityscanner-{version}-py", + include_protos=True, + ) + s.move(library / f"google/cloud/websecurityscanner_{version}") + s.move(library / "tests") + s.move(library / "scripts") + s.move(library / "docs", excludes=[library / "docs/index.rst"]) + # ---------------------------------------------------------------------------- # Add templated files # ---------------------------------------------------------------------------- -templated_files = common.py_library(cov_level=89) -s.move(templated_files) +templated_files = common.py_library( + samples=False, # set to True only if there are samples + microgenerator=True, +) +s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file + +# TODO(busunkim): Use latest sphinx after microgenerator transition +s.replace("noxfile.py", """['"]sphinx['"]""", '"sphinx<3.0.0"') s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/testing/.gitignore b/testing/.gitignore new file mode 100644 index 0000000..b05fbd6 --- /dev/null +++ b/testing/.gitignore @@ -0,0 +1,3 @@ +test-env.sh +service-account.json +client-secrets.json \ No newline at end of file diff --git a/tests/unit/gapic/v1alpha/test_web_security_scanner_client_v1alpha.py b/tests/unit/gapic/v1alpha/test_web_security_scanner_client_v1alpha.py deleted file mode 100644 index e123b29..0000000 --- a/tests/unit/gapic/v1alpha/test_web_security_scanner_client_v1alpha.py +++ /dev/null @@ -1,677 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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. - -"""Unit tests.""" - -import mock -import pytest - -from google.cloud import websecurityscanner_v1alpha -from google.cloud.websecurityscanner_v1alpha.proto import crawled_url_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import finding_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import scan_config_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import scan_run_pb2 -from google.cloud.websecurityscanner_v1alpha.proto import web_security_scanner_pb2 -from google.protobuf import empty_pb2 -from google.protobuf import field_mask_pb2 - - -class MultiCallableStub(object): - """Stub for the grpc.UnaryUnaryMultiCallable interface.""" - - def __init__(self, method, channel_stub): - self.method = method - self.channel_stub = channel_stub - - def __call__(self, request, timeout=None, metadata=None, credentials=None): - self.channel_stub.requests.append((self.method, request)) - - response = None - if self.channel_stub.responses: - response = self.channel_stub.responses.pop() - - if isinstance(response, Exception): - raise response - - if response: - return response - - -class ChannelStub(object): - """Stub for the grpc.Channel interface.""" - - def __init__(self, responses=[]): - self.responses = responses - self.requests = [] - - def unary_unary(self, method, request_serializer=None, response_deserializer=None): - return MultiCallableStub(method, self) - - -class CustomException(Exception): - pass - - -class TestWebSecurityScannerClient(object): - def test_create_scan_config(self): - # Setup Expected Response - name = "name3373707" - display_name = "displayName1615086568" - max_qps = 844445913 - expected_response = { - "name": name, - "display_name": display_name, - "max_qps": max_qps, - } - expected_response = scan_config_pb2.ScanConfig(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - parent = client.project_path("[PROJECT]") - scan_config = {} - - response = client.create_scan_config(parent, scan_config) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.CreateScanConfigRequest( - parent=parent, scan_config=scan_config - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_create_scan_config_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - parent = client.project_path("[PROJECT]") - scan_config = {} - - with pytest.raises(CustomException): - client.create_scan_config(parent, scan_config) - - def test_delete_scan_config(self): - channel = ChannelStub() - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - client.delete_scan_config(name) - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.DeleteScanConfigRequest(name=name) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_delete_scan_config_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - with pytest.raises(CustomException): - client.delete_scan_config(name) - - def test_get_scan_config(self): - # Setup Expected Response - name_2 = "name2-1052831874" - display_name = "displayName1615086568" - max_qps = 844445913 - expected_response = { - "name": name_2, - "display_name": display_name, - "max_qps": max_qps, - } - expected_response = scan_config_pb2.ScanConfig(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - response = client.get_scan_config(name) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.GetScanConfigRequest(name=name) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_get_scan_config_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - with pytest.raises(CustomException): - client.get_scan_config(name) - - def test_list_scan_configs(self): - # Setup Expected Response - next_page_token = "" - scan_configs_element = {} - scan_configs = [scan_configs_element] - expected_response = { - "next_page_token": next_page_token, - "scan_configs": scan_configs, - } - expected_response = web_security_scanner_pb2.ListScanConfigsResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - parent = client.project_path("[PROJECT]") - - paged_list_response = client.list_scan_configs(parent) - resources = list(paged_list_response) - assert len(resources) == 1 - - assert expected_response.scan_configs[0] == resources[0] - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.ListScanConfigsRequest( - parent=parent - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_list_scan_configs_exception(self): - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - parent = client.project_path("[PROJECT]") - - paged_list_response = client.list_scan_configs(parent) - with pytest.raises(CustomException): - list(paged_list_response) - - def test_update_scan_config(self): - # Setup Expected Response - name = "name3373707" - display_name = "displayName1615086568" - max_qps = 844445913 - expected_response = { - "name": name, - "display_name": display_name, - "max_qps": max_qps, - } - expected_response = scan_config_pb2.ScanConfig(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - scan_config = {} - update_mask = {} - - response = client.update_scan_config(scan_config, update_mask) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.UpdateScanConfigRequest( - scan_config=scan_config, update_mask=update_mask - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_update_scan_config_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - scan_config = {} - update_mask = {} - - with pytest.raises(CustomException): - client.update_scan_config(scan_config, update_mask) - - def test_start_scan_run(self): - # Setup Expected Response - name_2 = "name2-1052831874" - urls_crawled_count = 1749797253 - urls_tested_count = 1498664068 - has_vulnerabilities = False - progress_percent = 2137894861 - expected_response = { - "name": name_2, - "urls_crawled_count": urls_crawled_count, - "urls_tested_count": urls_tested_count, - "has_vulnerabilities": has_vulnerabilities, - "progress_percent": progress_percent, - } - expected_response = scan_run_pb2.ScanRun(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - response = client.start_scan_run(name) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.StartScanRunRequest(name=name) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_start_scan_run_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - with pytest.raises(CustomException): - client.start_scan_run(name) - - def test_get_scan_run(self): - # Setup Expected Response - name_2 = "name2-1052831874" - urls_crawled_count = 1749797253 - urls_tested_count = 1498664068 - has_vulnerabilities = False - progress_percent = 2137894861 - expected_response = { - "name": name_2, - "urls_crawled_count": urls_crawled_count, - "urls_tested_count": urls_tested_count, - "has_vulnerabilities": has_vulnerabilities, - "progress_percent": progress_percent, - } - expected_response = scan_run_pb2.ScanRun(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - name = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - response = client.get_scan_run(name) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.GetScanRunRequest(name=name) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_get_scan_run_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - name = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - with pytest.raises(CustomException): - client.get_scan_run(name) - - def test_list_scan_runs(self): - # Setup Expected Response - next_page_token = "" - scan_runs_element = {} - scan_runs = [scan_runs_element] - expected_response = {"next_page_token": next_page_token, "scan_runs": scan_runs} - expected_response = web_security_scanner_pb2.ListScanRunsResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - parent = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - paged_list_response = client.list_scan_runs(parent) - resources = list(paged_list_response) - assert len(resources) == 1 - - assert expected_response.scan_runs[0] == resources[0] - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.ListScanRunsRequest(parent=parent) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_list_scan_runs_exception(self): - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - parent = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - paged_list_response = client.list_scan_runs(parent) - with pytest.raises(CustomException): - list(paged_list_response) - - def test_stop_scan_run(self): - # Setup Expected Response - name_2 = "name2-1052831874" - urls_crawled_count = 1749797253 - urls_tested_count = 1498664068 - has_vulnerabilities = False - progress_percent = 2137894861 - expected_response = { - "name": name_2, - "urls_crawled_count": urls_crawled_count, - "urls_tested_count": urls_tested_count, - "has_vulnerabilities": has_vulnerabilities, - "progress_percent": progress_percent, - } - expected_response = scan_run_pb2.ScanRun(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - name = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - response = client.stop_scan_run(name) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.StopScanRunRequest(name=name) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_stop_scan_run_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - name = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - with pytest.raises(CustomException): - client.stop_scan_run(name) - - def test_list_crawled_urls(self): - # Setup Expected Response - next_page_token = "" - crawled_urls_element = {} - crawled_urls = [crawled_urls_element] - expected_response = { - "next_page_token": next_page_token, - "crawled_urls": crawled_urls, - } - expected_response = web_security_scanner_pb2.ListCrawledUrlsResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - parent = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - paged_list_response = client.list_crawled_urls(parent) - resources = list(paged_list_response) - assert len(resources) == 1 - - assert expected_response.crawled_urls[0] == resources[0] - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.ListCrawledUrlsRequest( - parent=parent - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_list_crawled_urls_exception(self): - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - parent = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - paged_list_response = client.list_crawled_urls(parent) - with pytest.raises(CustomException): - list(paged_list_response) - - def test_get_finding(self): - # Setup Expected Response - name_2 = "name2-1052831874" - http_method = "httpMethod820747384" - fuzzed_url = "fuzzedUrl-2120677666" - body = "body3029410" - description = "description-1724546052" - reproduction_url = "reproductionUrl-244934180" - frame_url = "frameUrl545464221" - final_url = "finalUrl355601190" - tracking_id = "trackingId1878901667" - expected_response = { - "name": name_2, - "http_method": http_method, - "fuzzed_url": fuzzed_url, - "body": body, - "description": description, - "reproduction_url": reproduction_url, - "frame_url": frame_url, - "final_url": final_url, - "tracking_id": tracking_id, - } - expected_response = finding_pb2.Finding(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - name = client.finding_path( - "[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]" - ) - - response = client.get_finding(name) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.GetFindingRequest(name=name) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_get_finding_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - name = client.finding_path( - "[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]" - ) - - with pytest.raises(CustomException): - client.get_finding(name) - - def test_list_findings(self): - # Setup Expected Response - next_page_token = "" - findings_element = {} - findings = [findings_element] - expected_response = {"next_page_token": next_page_token, "findings": findings} - expected_response = web_security_scanner_pb2.ListFindingsResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - parent = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - filter_ = "filter-1274492040" - - paged_list_response = client.list_findings(parent, filter_) - resources = list(paged_list_response) - assert len(resources) == 1 - - assert expected_response.findings[0] == resources[0] - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.ListFindingsRequest( - parent=parent, filter=filter_ - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_list_findings_exception(self): - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - parent = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - filter_ = "filter-1274492040" - - paged_list_response = client.list_findings(parent, filter_) - with pytest.raises(CustomException): - list(paged_list_response) - - def test_list_finding_type_stats(self): - # Setup Expected Response - expected_response = {} - expected_response = web_security_scanner_pb2.ListFindingTypeStatsResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup Request - parent = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - response = client.list_finding_type_stats(parent) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.ListFindingTypeStatsRequest( - parent=parent - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_list_finding_type_stats_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1alpha.WebSecurityScannerClient() - - # Setup request - parent = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - with pytest.raises(CustomException): - client.list_finding_type_stats(parent) diff --git a/tests/unit/gapic/v1beta/test_web_security_scanner_client_v1beta.py b/tests/unit/gapic/v1beta/test_web_security_scanner_client_v1beta.py deleted file mode 100644 index 1d0e23a..0000000 --- a/tests/unit/gapic/v1beta/test_web_security_scanner_client_v1beta.py +++ /dev/null @@ -1,679 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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. - -"""Unit tests.""" - -import mock -import pytest - -from google.cloud import websecurityscanner_v1beta -from google.cloud.websecurityscanner_v1beta.proto import crawled_url_pb2 -from google.cloud.websecurityscanner_v1beta.proto import finding_pb2 -from google.cloud.websecurityscanner_v1beta.proto import scan_config_pb2 -from google.cloud.websecurityscanner_v1beta.proto import scan_run_pb2 -from google.cloud.websecurityscanner_v1beta.proto import web_security_scanner_pb2 -from google.protobuf import empty_pb2 -from google.protobuf import field_mask_pb2 - - -class MultiCallableStub(object): - """Stub for the grpc.UnaryUnaryMultiCallable interface.""" - - def __init__(self, method, channel_stub): - self.method = method - self.channel_stub = channel_stub - - def __call__(self, request, timeout=None, metadata=None, credentials=None): - self.channel_stub.requests.append((self.method, request)) - - response = None - if self.channel_stub.responses: - response = self.channel_stub.responses.pop() - - if isinstance(response, Exception): - raise response - - if response: - return response - - -class ChannelStub(object): - """Stub for the grpc.Channel interface.""" - - def __init__(self, responses=[]): - self.responses = responses - self.requests = [] - - def unary_unary(self, method, request_serializer=None, response_deserializer=None): - return MultiCallableStub(method, self) - - -class CustomException(Exception): - pass - - -class TestWebSecurityScannerClient(object): - def test_create_scan_config(self): - # Setup Expected Response - name = "name3373707" - display_name = "displayName1615086568" - max_qps = 844445913 - expected_response = { - "name": name, - "display_name": display_name, - "max_qps": max_qps, - } - expected_response = scan_config_pb2.ScanConfig(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - parent = client.project_path("[PROJECT]") - scan_config = {} - - response = client.create_scan_config(parent, scan_config) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.CreateScanConfigRequest( - parent=parent, scan_config=scan_config - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_create_scan_config_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - parent = client.project_path("[PROJECT]") - scan_config = {} - - with pytest.raises(CustomException): - client.create_scan_config(parent, scan_config) - - def test_delete_scan_config(self): - channel = ChannelStub() - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - client.delete_scan_config(name) - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.DeleteScanConfigRequest(name=name) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_delete_scan_config_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - with pytest.raises(CustomException): - client.delete_scan_config(name) - - def test_get_scan_config(self): - # Setup Expected Response - name_2 = "name2-1052831874" - display_name = "displayName1615086568" - max_qps = 844445913 - expected_response = { - "name": name_2, - "display_name": display_name, - "max_qps": max_qps, - } - expected_response = scan_config_pb2.ScanConfig(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - response = client.get_scan_config(name) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.GetScanConfigRequest(name=name) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_get_scan_config_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - with pytest.raises(CustomException): - client.get_scan_config(name) - - def test_list_scan_configs(self): - # Setup Expected Response - next_page_token = "" - scan_configs_element = {} - scan_configs = [scan_configs_element] - expected_response = { - "next_page_token": next_page_token, - "scan_configs": scan_configs, - } - expected_response = web_security_scanner_pb2.ListScanConfigsResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - parent = client.project_path("[PROJECT]") - - paged_list_response = client.list_scan_configs(parent) - resources = list(paged_list_response) - assert len(resources) == 1 - - assert expected_response.scan_configs[0] == resources[0] - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.ListScanConfigsRequest( - parent=parent - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_list_scan_configs_exception(self): - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - parent = client.project_path("[PROJECT]") - - paged_list_response = client.list_scan_configs(parent) - with pytest.raises(CustomException): - list(paged_list_response) - - def test_update_scan_config(self): - # Setup Expected Response - name = "name3373707" - display_name = "displayName1615086568" - max_qps = 844445913 - expected_response = { - "name": name, - "display_name": display_name, - "max_qps": max_qps, - } - expected_response = scan_config_pb2.ScanConfig(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - scan_config = {} - update_mask = {} - - response = client.update_scan_config(scan_config, update_mask) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.UpdateScanConfigRequest( - scan_config=scan_config, update_mask=update_mask - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_update_scan_config_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - scan_config = {} - update_mask = {} - - with pytest.raises(CustomException): - client.update_scan_config(scan_config, update_mask) - - def test_start_scan_run(self): - # Setup Expected Response - name_2 = "name2-1052831874" - urls_crawled_count = 1749797253 - urls_tested_count = 1498664068 - has_vulnerabilities = False - progress_percent = 2137894861 - expected_response = { - "name": name_2, - "urls_crawled_count": urls_crawled_count, - "urls_tested_count": urls_tested_count, - "has_vulnerabilities": has_vulnerabilities, - "progress_percent": progress_percent, - } - expected_response = scan_run_pb2.ScanRun(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - response = client.start_scan_run(name) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.StartScanRunRequest(name=name) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_start_scan_run_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - with pytest.raises(CustomException): - client.start_scan_run(name) - - def test_get_scan_run(self): - # Setup Expected Response - name_2 = "name2-1052831874" - urls_crawled_count = 1749797253 - urls_tested_count = 1498664068 - has_vulnerabilities = False - progress_percent = 2137894861 - expected_response = { - "name": name_2, - "urls_crawled_count": urls_crawled_count, - "urls_tested_count": urls_tested_count, - "has_vulnerabilities": has_vulnerabilities, - "progress_percent": progress_percent, - } - expected_response = scan_run_pb2.ScanRun(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - name = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - response = client.get_scan_run(name) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.GetScanRunRequest(name=name) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_get_scan_run_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - name = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - with pytest.raises(CustomException): - client.get_scan_run(name) - - def test_list_scan_runs(self): - # Setup Expected Response - next_page_token = "" - scan_runs_element = {} - scan_runs = [scan_runs_element] - expected_response = {"next_page_token": next_page_token, "scan_runs": scan_runs} - expected_response = web_security_scanner_pb2.ListScanRunsResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - parent = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - paged_list_response = client.list_scan_runs(parent) - resources = list(paged_list_response) - assert len(resources) == 1 - - assert expected_response.scan_runs[0] == resources[0] - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.ListScanRunsRequest(parent=parent) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_list_scan_runs_exception(self): - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - parent = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") - - paged_list_response = client.list_scan_runs(parent) - with pytest.raises(CustomException): - list(paged_list_response) - - def test_stop_scan_run(self): - # Setup Expected Response - name_2 = "name2-1052831874" - urls_crawled_count = 1749797253 - urls_tested_count = 1498664068 - has_vulnerabilities = False - progress_percent = 2137894861 - expected_response = { - "name": name_2, - "urls_crawled_count": urls_crawled_count, - "urls_tested_count": urls_tested_count, - "has_vulnerabilities": has_vulnerabilities, - "progress_percent": progress_percent, - } - expected_response = scan_run_pb2.ScanRun(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - name = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - response = client.stop_scan_run(name) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.StopScanRunRequest(name=name) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_stop_scan_run_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - name = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - with pytest.raises(CustomException): - client.stop_scan_run(name) - - def test_list_crawled_urls(self): - # Setup Expected Response - next_page_token = "" - crawled_urls_element = {} - crawled_urls = [crawled_urls_element] - expected_response = { - "next_page_token": next_page_token, - "crawled_urls": crawled_urls, - } - expected_response = web_security_scanner_pb2.ListCrawledUrlsResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - parent = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - paged_list_response = client.list_crawled_urls(parent) - resources = list(paged_list_response) - assert len(resources) == 1 - - assert expected_response.crawled_urls[0] == resources[0] - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.ListCrawledUrlsRequest( - parent=parent - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_list_crawled_urls_exception(self): - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - parent = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - paged_list_response = client.list_crawled_urls(parent) - with pytest.raises(CustomException): - list(paged_list_response) - - def test_get_finding(self): - # Setup Expected Response - name_2 = "name2-1052831874" - finding_type = "findingType274496048" - http_method = "httpMethod820747384" - fuzzed_url = "fuzzedUrl-2120677666" - body = "body3029410" - description = "description-1724546052" - reproduction_url = "reproductionUrl-244934180" - frame_url = "frameUrl545464221" - final_url = "finalUrl355601190" - tracking_id = "trackingId1878901667" - expected_response = { - "name": name_2, - "finding_type": finding_type, - "http_method": http_method, - "fuzzed_url": fuzzed_url, - "body": body, - "description": description, - "reproduction_url": reproduction_url, - "frame_url": frame_url, - "final_url": final_url, - "tracking_id": tracking_id, - } - expected_response = finding_pb2.Finding(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - name = client.finding_path( - "[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]" - ) - - response = client.get_finding(name) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.GetFindingRequest(name=name) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_get_finding_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - name = client.finding_path( - "[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]" - ) - - with pytest.raises(CustomException): - client.get_finding(name) - - def test_list_findings(self): - # Setup Expected Response - next_page_token = "" - findings_element = {} - findings = [findings_element] - expected_response = {"next_page_token": next_page_token, "findings": findings} - expected_response = web_security_scanner_pb2.ListFindingsResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - parent = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - filter_ = "filter-1274492040" - - paged_list_response = client.list_findings(parent, filter_) - resources = list(paged_list_response) - assert len(resources) == 1 - - assert expected_response.findings[0] == resources[0] - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.ListFindingsRequest( - parent=parent, filter=filter_ - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_list_findings_exception(self): - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - parent = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - filter_ = "filter-1274492040" - - paged_list_response = client.list_findings(parent, filter_) - with pytest.raises(CustomException): - list(paged_list_response) - - def test_list_finding_type_stats(self): - # Setup Expected Response - expected_response = {} - expected_response = web_security_scanner_pb2.ListFindingTypeStatsResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup Request - parent = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - response = client.list_finding_type_stats(parent) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = web_security_scanner_pb2.ListFindingTypeStatsRequest( - parent=parent - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_list_finding_type_stats_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = websecurityscanner_v1beta.WebSecurityScannerClient() - - # Setup request - parent = client.scan_run_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]") - - with pytest.raises(CustomException): - client.list_finding_type_stats(parent) diff --git a/google/cloud/websecurityscanner_v1alpha/gapic/__init__.py b/tests/unit/gapic/websecurityscanner_v1alpha/__init__.py similarity index 100% rename from google/cloud/websecurityscanner_v1alpha/gapic/__init__.py rename to tests/unit/gapic/websecurityscanner_v1alpha/__init__.py diff --git a/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py b/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py new file mode 100644 index 0000000..1642c75 --- /dev/null +++ b/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py @@ -0,0 +1,4154 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 mock + +import grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + +from google import auth +from google.api_core import client_options +from google.api_core import exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.auth import credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.websecurityscanner_v1alpha.services.web_security_scanner import ( + WebSecurityScannerAsyncClient, +) +from google.cloud.websecurityscanner_v1alpha.services.web_security_scanner import ( + WebSecurityScannerClient, +) +from google.cloud.websecurityscanner_v1alpha.services.web_security_scanner import pagers +from google.cloud.websecurityscanner_v1alpha.services.web_security_scanner import ( + transports, +) +from google.cloud.websecurityscanner_v1alpha.types import crawled_url +from google.cloud.websecurityscanner_v1alpha.types import finding +from google.cloud.websecurityscanner_v1alpha.types import finding_addon +from google.cloud.websecurityscanner_v1alpha.types import finding_type_stats +from google.cloud.websecurityscanner_v1alpha.types import scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1alpha.types import scan_run +from google.cloud.websecurityscanner_v1alpha.types import web_security_scanner +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import timestamp_pb2 as timestamp # type: ignore + + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert WebSecurityScannerClient._get_default_mtls_endpoint(None) is None + assert ( + WebSecurityScannerClient._get_default_mtls_endpoint(api_endpoint) + == api_mtls_endpoint + ) + assert ( + WebSecurityScannerClient._get_default_mtls_endpoint(api_mtls_endpoint) + == api_mtls_endpoint + ) + assert ( + WebSecurityScannerClient._get_default_mtls_endpoint(sandbox_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + WebSecurityScannerClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + WebSecurityScannerClient._get_default_mtls_endpoint(non_googleapi) + == non_googleapi + ) + + +@pytest.mark.parametrize( + "client_class", [WebSecurityScannerClient, WebSecurityScannerAsyncClient] +) +def test_web_security_scanner_client_from_service_account_file(client_class): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_file" + ) as factory: + factory.return_value = creds + client = client_class.from_service_account_file("dummy/file/path.json") + assert client._transport._credentials == creds + + client = client_class.from_service_account_json("dummy/file/path.json") + assert client._transport._credentials == creds + + assert client._transport._host == "websecurityscanner.googleapis.com:443" + + +def test_web_security_scanner_client_get_transport_class(): + transport = WebSecurityScannerClient.get_transport_class() + assert transport == transports.WebSecurityScannerGrpcTransport + + transport = WebSecurityScannerClient.get_transport_class("grpc") + assert transport == transports.WebSecurityScannerGrpcTransport + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (WebSecurityScannerClient, transports.WebSecurityScannerGrpcTransport, "grpc"), + ( + WebSecurityScannerAsyncClient, + transports.WebSecurityScannerGrpcAsyncIOTransport, + "grpc_asyncio", + ), + ], +) +def test_web_security_scanner_client_client_options( + client_class, transport_class, transport_name +): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(WebSecurityScannerClient, "get_transport_class") as gtc: + transport = transport_class(credentials=credentials.AnonymousCredentials()) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(WebSecurityScannerClient, "get_transport_class") as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + api_mtls_endpoint="squid.clam.whelk", + client_cert_source=None, + quota_project_id=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "never"}): + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_ENDPOINT, + client_cert_source=None, + quota_project_id=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "always"}): + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_MTLS_ENDPOINT, + client_cert_source=None, + quota_project_id=None, + ) + + # Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is + # "auto", and client_cert_source is provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "auto"}): + options = client_options.ClientOptions( + client_cert_source=client_cert_source_callback + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_MTLS_ENDPOINT, + client_cert_source=client_cert_source_callback, + quota_project_id=None, + ) + + # Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is + # "auto", and default_client_cert_source is provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "auto"}): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_MTLS_ENDPOINT, + client_cert_source=None, + quota_project_id=None, + ) + + # Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is + # "auto", but client_cert_source and default_client_cert_source are None. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "auto"}): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_ENDPOINT, + client_cert_source=None, + quota_project_id=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_ENDPOINT, + client_cert_source=None, + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (WebSecurityScannerClient, transports.WebSecurityScannerGrpcTransport, "grpc"), + ( + WebSecurityScannerAsyncClient, + transports.WebSecurityScannerGrpcAsyncIOTransport, + "grpc_asyncio", + ), + ], +) +def test_web_security_scanner_client_client_options_scopes( + client_class, transport_class, transport_name +): + # Check the case scopes are provided. + options = client_options.ClientOptions(scopes=["1", "2"],) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + api_mtls_endpoint=client.DEFAULT_ENDPOINT, + client_cert_source=None, + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (WebSecurityScannerClient, transports.WebSecurityScannerGrpcTransport, "grpc"), + ( + WebSecurityScannerAsyncClient, + transports.WebSecurityScannerGrpcAsyncIOTransport, + "grpc_asyncio", + ), + ], +) +def test_web_security_scanner_client_client_options_credentials_file( + client_class, transport_class, transport_name +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_ENDPOINT, + client_cert_source=None, + quota_project_id=None, + ) + + +def test_web_security_scanner_client_client_options_from_dict(): + with mock.patch( + "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.transports.WebSecurityScannerGrpcTransport.__init__" + ) as grpc_transport: + grpc_transport.return_value = None + client = WebSecurityScannerClient( + client_options={"api_endpoint": "squid.clam.whelk"} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + api_mtls_endpoint="squid.clam.whelk", + client_cert_source=None, + quota_project_id=None, + ) + + +def test_create_scan_config(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.CreateScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.create_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gcw_scan_config.ScanConfig( + name="name_value", + display_name="display_name_value", + max_qps=761, + starting_urls=["starting_urls_value"], + user_agent=gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX, + blacklist_patterns=["blacklist_patterns_value"], + target_platforms=[gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE], + ) + + response = client.create_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, gcw_scan_config.ScanConfig) + + assert response.name == "name_value" + + assert response.display_name == "display_name_value" + + assert response.max_qps == 761 + + assert response.starting_urls == ["starting_urls_value"] + + assert response.user_agent == gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX + + assert response.blacklist_patterns == ["blacklist_patterns_value"] + + assert response.target_platforms == [ + gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE + ] + + +@pytest.mark.asyncio +async def test_create_scan_config_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.CreateScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.create_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gcw_scan_config.ScanConfig( + name="name_value", + display_name="display_name_value", + max_qps=761, + starting_urls=["starting_urls_value"], + user_agent=gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX, + blacklist_patterns=["blacklist_patterns_value"], + target_platforms=[gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE], + ) + ) + + response = await client.create_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, gcw_scan_config.ScanConfig) + + assert response.name == "name_value" + + assert response.display_name == "display_name_value" + + assert response.max_qps == 761 + + assert response.starting_urls == ["starting_urls_value"] + + assert response.user_agent == gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX + + assert response.blacklist_patterns == ["blacklist_patterns_value"] + + assert response.target_platforms == [ + gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE + ] + + +def test_create_scan_config_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.CreateScanConfigRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.create_scan_config), "__call__" + ) as call: + call.return_value = gcw_scan_config.ScanConfig() + + client.create_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_scan_config_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.CreateScanConfigRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.create_scan_config), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gcw_scan_config.ScanConfig() + ) + + await client.create_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_create_scan_config_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.create_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gcw_scan_config.ScanConfig() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_scan_config( + parent="parent_value", + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + assert args[0].scan_config == gcw_scan_config.ScanConfig(name="name_value") + + +def test_create_scan_config_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_scan_config( + web_security_scanner.CreateScanConfigRequest(), + parent="parent_value", + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_scan_config_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.create_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gcw_scan_config.ScanConfig() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gcw_scan_config.ScanConfig() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_scan_config( + parent="parent_value", + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + assert args[0].scan_config == gcw_scan_config.ScanConfig(name="name_value") + + +@pytest.mark.asyncio +async def test_create_scan_config_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_scan_config( + web_security_scanner.CreateScanConfigRequest(), + parent="parent_value", + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + ) + + +def test_delete_scan_config(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.DeleteScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.delete_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_scan_config_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.DeleteScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.delete_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + response = await client.delete_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_scan_config_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.DeleteScanConfigRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.delete_scan_config), "__call__" + ) as call: + call.return_value = None + + client.delete_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_scan_config_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.DeleteScanConfigRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.delete_scan_config), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + await client.delete_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_delete_scan_config_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.delete_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_scan_config(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +def test_delete_scan_config_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_scan_config( + web_security_scanner.DeleteScanConfigRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_scan_config_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.delete_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_scan_config(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_delete_scan_config_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_scan_config( + web_security_scanner.DeleteScanConfigRequest(), name="name_value", + ) + + +def test_get_scan_config(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.GetScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_scan_config), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_config.ScanConfig( + name="name_value", + display_name="display_name_value", + max_qps=761, + starting_urls=["starting_urls_value"], + user_agent=scan_config.ScanConfig.UserAgent.CHROME_LINUX, + blacklist_patterns=["blacklist_patterns_value"], + target_platforms=[scan_config.ScanConfig.TargetPlatform.APP_ENGINE], + ) + + response = client.get_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_config.ScanConfig) + + assert response.name == "name_value" + + assert response.display_name == "display_name_value" + + assert response.max_qps == 761 + + assert response.starting_urls == ["starting_urls_value"] + + assert response.user_agent == scan_config.ScanConfig.UserAgent.CHROME_LINUX + + assert response.blacklist_patterns == ["blacklist_patterns_value"] + + assert response.target_platforms == [ + scan_config.ScanConfig.TargetPlatform.APP_ENGINE + ] + + +@pytest.mark.asyncio +async def test_get_scan_config_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.GetScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + scan_config.ScanConfig( + name="name_value", + display_name="display_name_value", + max_qps=761, + starting_urls=["starting_urls_value"], + user_agent=scan_config.ScanConfig.UserAgent.CHROME_LINUX, + blacklist_patterns=["blacklist_patterns_value"], + target_platforms=[scan_config.ScanConfig.TargetPlatform.APP_ENGINE], + ) + ) + + response = await client.get_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_config.ScanConfig) + + assert response.name == "name_value" + + assert response.display_name == "display_name_value" + + assert response.max_qps == 761 + + assert response.starting_urls == ["starting_urls_value"] + + assert response.user_agent == scan_config.ScanConfig.UserAgent.CHROME_LINUX + + assert response.blacklist_patterns == ["blacklist_patterns_value"] + + assert response.target_platforms == [ + scan_config.ScanConfig.TargetPlatform.APP_ENGINE + ] + + +def test_get_scan_config_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.GetScanConfigRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_scan_config), "__call__") as call: + call.return_value = scan_config.ScanConfig() + + client.get_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_scan_config_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.GetScanConfigRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_scan_config), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + scan_config.ScanConfig() + ) + + await client.get_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_scan_config_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_scan_config), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_config.ScanConfig() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_scan_config(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +def test_get_scan_config_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_scan_config( + web_security_scanner.GetScanConfigRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_scan_config_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = scan_config.ScanConfig() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + scan_config.ScanConfig() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_scan_config(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_scan_config_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_scan_config( + web_security_scanner.GetScanConfigRequest(), name="name_value", + ) + + +def test_list_scan_configs(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListScanConfigsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_scan_configs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListScanConfigsResponse( + next_page_token="next_page_token_value", + ) + + response = client.list_scan_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListScanConfigsPager) + + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_scan_configs_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListScanConfigsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_configs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListScanConfigsResponse( + next_page_token="next_page_token_value", + ) + ) + + response = await client.list_scan_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListScanConfigsAsyncPager) + + assert response.next_page_token == "next_page_token_value" + + +def test_list_scan_configs_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListScanConfigsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_scan_configs), "__call__" + ) as call: + call.return_value = web_security_scanner.ListScanConfigsResponse() + + client.list_scan_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_scan_configs_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListScanConfigsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_configs), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListScanConfigsResponse() + ) + + await client.list_scan_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_scan_configs_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_scan_configs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListScanConfigsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_scan_configs(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +def test_list_scan_configs_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_scan_configs( + web_security_scanner.ListScanConfigsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_scan_configs_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_configs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListScanConfigsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListScanConfigsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_scan_configs(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_scan_configs_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_scan_configs( + web_security_scanner.ListScanConfigsRequest(), parent="parent_value", + ) + + +def test_list_scan_configs_pager(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_scan_configs), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanConfigsResponse( + scan_configs=[ + scan_config.ScanConfig(), + scan_config.ScanConfig(), + scan_config.ScanConfig(), + ], + next_page_token="abc", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[], next_page_token="def", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(),], next_page_token="ghi", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(), scan_config.ScanConfig(),], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_scan_configs(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, scan_config.ScanConfig) for i in results) + + +def test_list_scan_configs_pages(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_scan_configs), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanConfigsResponse( + scan_configs=[ + scan_config.ScanConfig(), + scan_config.ScanConfig(), + scan_config.ScanConfig(), + ], + next_page_token="abc", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[], next_page_token="def", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(),], next_page_token="ghi", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(), scan_config.ScanConfig(),], + ), + RuntimeError, + ) + pages = list(client.list_scan_configs(request={}).pages) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_scan_configs_async_pager(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_configs), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanConfigsResponse( + scan_configs=[ + scan_config.ScanConfig(), + scan_config.ScanConfig(), + scan_config.ScanConfig(), + ], + next_page_token="abc", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[], next_page_token="def", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(),], next_page_token="ghi", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(), scan_config.ScanConfig(),], + ), + RuntimeError, + ) + async_pager = await client.list_scan_configs(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, scan_config.ScanConfig) for i in responses) + + +@pytest.mark.asyncio +async def test_list_scan_configs_async_pages(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_configs), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanConfigsResponse( + scan_configs=[ + scan_config.ScanConfig(), + scan_config.ScanConfig(), + scan_config.ScanConfig(), + ], + next_page_token="abc", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[], next_page_token="def", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(),], next_page_token="ghi", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(), scan_config.ScanConfig(),], + ), + RuntimeError, + ) + pages = [] + async for page in (await client.list_scan_configs(request={})).pages: + pages.append(page) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +def test_update_scan_config(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.UpdateScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.update_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gcw_scan_config.ScanConfig( + name="name_value", + display_name="display_name_value", + max_qps=761, + starting_urls=["starting_urls_value"], + user_agent=gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX, + blacklist_patterns=["blacklist_patterns_value"], + target_platforms=[gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE], + ) + + response = client.update_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, gcw_scan_config.ScanConfig) + + assert response.name == "name_value" + + assert response.display_name == "display_name_value" + + assert response.max_qps == 761 + + assert response.starting_urls == ["starting_urls_value"] + + assert response.user_agent == gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX + + assert response.blacklist_patterns == ["blacklist_patterns_value"] + + assert response.target_platforms == [ + gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE + ] + + +@pytest.mark.asyncio +async def test_update_scan_config_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.UpdateScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.update_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gcw_scan_config.ScanConfig( + name="name_value", + display_name="display_name_value", + max_qps=761, + starting_urls=["starting_urls_value"], + user_agent=gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX, + blacklist_patterns=["blacklist_patterns_value"], + target_platforms=[gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE], + ) + ) + + response = await client.update_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, gcw_scan_config.ScanConfig) + + assert response.name == "name_value" + + assert response.display_name == "display_name_value" + + assert response.max_qps == 761 + + assert response.starting_urls == ["starting_urls_value"] + + assert response.user_agent == gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX + + assert response.blacklist_patterns == ["blacklist_patterns_value"] + + assert response.target_platforms == [ + gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE + ] + + +def test_update_scan_config_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.UpdateScanConfigRequest() + request.scan_config.name = "scan_config.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.update_scan_config), "__call__" + ) as call: + call.return_value = gcw_scan_config.ScanConfig() + + client.update_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "scan_config.name=scan_config.name/value",) in kw[ + "metadata" + ] + + +@pytest.mark.asyncio +async def test_update_scan_config_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.UpdateScanConfigRequest() + request.scan_config.name = "scan_config.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.update_scan_config), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gcw_scan_config.ScanConfig() + ) + + await client.update_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "scan_config.name=scan_config.name/value",) in kw[ + "metadata" + ] + + +def test_update_scan_config_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.update_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gcw_scan_config.ScanConfig() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_scan_config( + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + update_mask=field_mask.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].scan_config == gcw_scan_config.ScanConfig(name="name_value") + + assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + + +def test_update_scan_config_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_scan_config( + web_security_scanner.UpdateScanConfigRequest(), + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + update_mask=field_mask.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_scan_config_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.update_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gcw_scan_config.ScanConfig() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gcw_scan_config.ScanConfig() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_scan_config( + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + update_mask=field_mask.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].scan_config == gcw_scan_config.ScanConfig(name="name_value") + + assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + + +@pytest.mark.asyncio +async def test_update_scan_config_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_scan_config( + web_security_scanner.UpdateScanConfigRequest(), + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + update_mask=field_mask.FieldMask(paths=["paths_value"]), + ) + + +def test_start_scan_run(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.StartScanRunRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.start_scan_run), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun( + name="name_value", + execution_state=scan_run.ScanRun.ExecutionState.QUEUED, + result_state=scan_run.ScanRun.ResultState.SUCCESS, + urls_crawled_count=1935, + urls_tested_count=1846, + has_vulnerabilities=True, + progress_percent=1733, + ) + + response = client.start_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_run.ScanRun) + + assert response.name == "name_value" + + assert response.execution_state == scan_run.ScanRun.ExecutionState.QUEUED + + assert response.result_state == scan_run.ScanRun.ResultState.SUCCESS + + assert response.urls_crawled_count == 1935 + + assert response.urls_tested_count == 1846 + + assert response.has_vulnerabilities is True + + assert response.progress_percent == 1733 + + +@pytest.mark.asyncio +async def test_start_scan_run_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.StartScanRunRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.start_scan_run), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + scan_run.ScanRun( + name="name_value", + execution_state=scan_run.ScanRun.ExecutionState.QUEUED, + result_state=scan_run.ScanRun.ResultState.SUCCESS, + urls_crawled_count=1935, + urls_tested_count=1846, + has_vulnerabilities=True, + progress_percent=1733, + ) + ) + + response = await client.start_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_run.ScanRun) + + assert response.name == "name_value" + + assert response.execution_state == scan_run.ScanRun.ExecutionState.QUEUED + + assert response.result_state == scan_run.ScanRun.ResultState.SUCCESS + + assert response.urls_crawled_count == 1935 + + assert response.urls_tested_count == 1846 + + assert response.has_vulnerabilities is True + + assert response.progress_percent == 1733 + + +def test_start_scan_run_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.StartScanRunRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.start_scan_run), "__call__") as call: + call.return_value = scan_run.ScanRun() + + client.start_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_start_scan_run_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.StartScanRunRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.start_scan_run), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(scan_run.ScanRun()) + + await client.start_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_start_scan_run_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.start_scan_run), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.start_scan_run(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +def test_start_scan_run_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.start_scan_run( + web_security_scanner.StartScanRunRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_start_scan_run_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.start_scan_run), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(scan_run.ScanRun()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.start_scan_run(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_start_scan_run_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.start_scan_run( + web_security_scanner.StartScanRunRequest(), name="name_value", + ) + + +def test_get_scan_run(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.GetScanRunRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_scan_run), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun( + name="name_value", + execution_state=scan_run.ScanRun.ExecutionState.QUEUED, + result_state=scan_run.ScanRun.ResultState.SUCCESS, + urls_crawled_count=1935, + urls_tested_count=1846, + has_vulnerabilities=True, + progress_percent=1733, + ) + + response = client.get_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_run.ScanRun) + + assert response.name == "name_value" + + assert response.execution_state == scan_run.ScanRun.ExecutionState.QUEUED + + assert response.result_state == scan_run.ScanRun.ResultState.SUCCESS + + assert response.urls_crawled_count == 1935 + + assert response.urls_tested_count == 1846 + + assert response.has_vulnerabilities is True + + assert response.progress_percent == 1733 + + +@pytest.mark.asyncio +async def test_get_scan_run_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.GetScanRunRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_scan_run), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + scan_run.ScanRun( + name="name_value", + execution_state=scan_run.ScanRun.ExecutionState.QUEUED, + result_state=scan_run.ScanRun.ResultState.SUCCESS, + urls_crawled_count=1935, + urls_tested_count=1846, + has_vulnerabilities=True, + progress_percent=1733, + ) + ) + + response = await client.get_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_run.ScanRun) + + assert response.name == "name_value" + + assert response.execution_state == scan_run.ScanRun.ExecutionState.QUEUED + + assert response.result_state == scan_run.ScanRun.ResultState.SUCCESS + + assert response.urls_crawled_count == 1935 + + assert response.urls_tested_count == 1846 + + assert response.has_vulnerabilities is True + + assert response.progress_percent == 1733 + + +def test_get_scan_run_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.GetScanRunRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_scan_run), "__call__") as call: + call.return_value = scan_run.ScanRun() + + client.get_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_scan_run_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.GetScanRunRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_scan_run), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(scan_run.ScanRun()) + + await client.get_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_scan_run_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_scan_run), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_scan_run(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +def test_get_scan_run_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_scan_run( + web_security_scanner.GetScanRunRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_scan_run_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_scan_run), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(scan_run.ScanRun()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_scan_run(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_scan_run_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_scan_run( + web_security_scanner.GetScanRunRequest(), name="name_value", + ) + + +def test_list_scan_runs(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListScanRunsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_scan_runs), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListScanRunsResponse( + next_page_token="next_page_token_value", + ) + + response = client.list_scan_runs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListScanRunsPager) + + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_scan_runs_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListScanRunsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_runs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListScanRunsResponse( + next_page_token="next_page_token_value", + ) + ) + + response = await client.list_scan_runs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListScanRunsAsyncPager) + + assert response.next_page_token == "next_page_token_value" + + +def test_list_scan_runs_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListScanRunsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_scan_runs), "__call__") as call: + call.return_value = web_security_scanner.ListScanRunsResponse() + + client.list_scan_runs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_scan_runs_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListScanRunsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_runs), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListScanRunsResponse() + ) + + await client.list_scan_runs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_scan_runs_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_scan_runs), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListScanRunsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_scan_runs(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +def test_list_scan_runs_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_scan_runs( + web_security_scanner.ListScanRunsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_scan_runs_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_runs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListScanRunsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListScanRunsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_scan_runs(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_scan_runs_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_scan_runs( + web_security_scanner.ListScanRunsRequest(), parent="parent_value", + ) + + +def test_list_scan_runs_pager(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_scan_runs), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(), scan_run.ScanRun(),], + next_page_token="abc", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[], next_page_token="def", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(),], next_page_token="ghi", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(),], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_scan_runs(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, scan_run.ScanRun) for i in results) + + +def test_list_scan_runs_pages(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_scan_runs), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(), scan_run.ScanRun(),], + next_page_token="abc", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[], next_page_token="def", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(),], next_page_token="ghi", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(),], + ), + RuntimeError, + ) + pages = list(client.list_scan_runs(request={}).pages) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_scan_runs_async_pager(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_runs), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(), scan_run.ScanRun(),], + next_page_token="abc", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[], next_page_token="def", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(),], next_page_token="ghi", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(),], + ), + RuntimeError, + ) + async_pager = await client.list_scan_runs(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, scan_run.ScanRun) for i in responses) + + +@pytest.mark.asyncio +async def test_list_scan_runs_async_pages(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_runs), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(), scan_run.ScanRun(),], + next_page_token="abc", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[], next_page_token="def", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(),], next_page_token="ghi", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(),], + ), + RuntimeError, + ) + pages = [] + async for page in (await client.list_scan_runs(request={})).pages: + pages.append(page) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +def test_stop_scan_run(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.StopScanRunRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.stop_scan_run), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun( + name="name_value", + execution_state=scan_run.ScanRun.ExecutionState.QUEUED, + result_state=scan_run.ScanRun.ResultState.SUCCESS, + urls_crawled_count=1935, + urls_tested_count=1846, + has_vulnerabilities=True, + progress_percent=1733, + ) + + response = client.stop_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_run.ScanRun) + + assert response.name == "name_value" + + assert response.execution_state == scan_run.ScanRun.ExecutionState.QUEUED + + assert response.result_state == scan_run.ScanRun.ResultState.SUCCESS + + assert response.urls_crawled_count == 1935 + + assert response.urls_tested_count == 1846 + + assert response.has_vulnerabilities is True + + assert response.progress_percent == 1733 + + +@pytest.mark.asyncio +async def test_stop_scan_run_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.StopScanRunRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.stop_scan_run), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + scan_run.ScanRun( + name="name_value", + execution_state=scan_run.ScanRun.ExecutionState.QUEUED, + result_state=scan_run.ScanRun.ResultState.SUCCESS, + urls_crawled_count=1935, + urls_tested_count=1846, + has_vulnerabilities=True, + progress_percent=1733, + ) + ) + + response = await client.stop_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_run.ScanRun) + + assert response.name == "name_value" + + assert response.execution_state == scan_run.ScanRun.ExecutionState.QUEUED + + assert response.result_state == scan_run.ScanRun.ResultState.SUCCESS + + assert response.urls_crawled_count == 1935 + + assert response.urls_tested_count == 1846 + + assert response.has_vulnerabilities is True + + assert response.progress_percent == 1733 + + +def test_stop_scan_run_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.StopScanRunRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.stop_scan_run), "__call__") as call: + call.return_value = scan_run.ScanRun() + + client.stop_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_stop_scan_run_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.StopScanRunRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.stop_scan_run), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(scan_run.ScanRun()) + + await client.stop_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_stop_scan_run_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.stop_scan_run), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.stop_scan_run(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +def test_stop_scan_run_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.stop_scan_run( + web_security_scanner.StopScanRunRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_stop_scan_run_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.stop_scan_run), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(scan_run.ScanRun()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.stop_scan_run(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_stop_scan_run_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.stop_scan_run( + web_security_scanner.StopScanRunRequest(), name="name_value", + ) + + +def test_list_crawled_urls(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListCrawledUrlsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_crawled_urls), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListCrawledUrlsResponse( + next_page_token="next_page_token_value", + ) + + response = client.list_crawled_urls(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCrawledUrlsPager) + + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_crawled_urls_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListCrawledUrlsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_crawled_urls), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListCrawledUrlsResponse( + next_page_token="next_page_token_value", + ) + ) + + response = await client.list_crawled_urls(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCrawledUrlsAsyncPager) + + assert response.next_page_token == "next_page_token_value" + + +def test_list_crawled_urls_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListCrawledUrlsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_crawled_urls), "__call__" + ) as call: + call.return_value = web_security_scanner.ListCrawledUrlsResponse() + + client.list_crawled_urls(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_crawled_urls_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListCrawledUrlsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_crawled_urls), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListCrawledUrlsResponse() + ) + + await client.list_crawled_urls(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_crawled_urls_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_crawled_urls), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListCrawledUrlsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_crawled_urls(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +def test_list_crawled_urls_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_crawled_urls( + web_security_scanner.ListCrawledUrlsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_crawled_urls_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_crawled_urls), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListCrawledUrlsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListCrawledUrlsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_crawled_urls(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_crawled_urls_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_crawled_urls( + web_security_scanner.ListCrawledUrlsRequest(), parent="parent_value", + ) + + +def test_list_crawled_urls_pager(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_crawled_urls), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[ + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + ], + next_page_token="abc", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[], next_page_token="def", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(),], next_page_token="ghi", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(), crawled_url.CrawledUrl(),], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_crawled_urls(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, crawled_url.CrawledUrl) for i in results) + + +def test_list_crawled_urls_pages(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_crawled_urls), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[ + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + ], + next_page_token="abc", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[], next_page_token="def", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(),], next_page_token="ghi", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(), crawled_url.CrawledUrl(),], + ), + RuntimeError, + ) + pages = list(client.list_crawled_urls(request={}).pages) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_crawled_urls_async_pager(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_crawled_urls), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[ + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + ], + next_page_token="abc", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[], next_page_token="def", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(),], next_page_token="ghi", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(), crawled_url.CrawledUrl(),], + ), + RuntimeError, + ) + async_pager = await client.list_crawled_urls(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, crawled_url.CrawledUrl) for i in responses) + + +@pytest.mark.asyncio +async def test_list_crawled_urls_async_pages(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_crawled_urls), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[ + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + ], + next_page_token="abc", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[], next_page_token="def", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(),], next_page_token="ghi", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(), crawled_url.CrawledUrl(),], + ), + RuntimeError, + ) + pages = [] + async for page in (await client.list_crawled_urls(request={})).pages: + pages.append(page) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +def test_get_finding(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.GetFindingRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_finding), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = finding.Finding( + name="name_value", + finding_type=finding.Finding.FindingType.MIXED_CONTENT, + http_method="http_method_value", + fuzzed_url="fuzzed_url_value", + body="body_value", + description="description_value", + reproduction_url="reproduction_url_value", + frame_url="frame_url_value", + final_url="final_url_value", + tracking_id="tracking_id_value", + ) + + response = client.get_finding(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, finding.Finding) + + assert response.name == "name_value" + + assert response.finding_type == finding.Finding.FindingType.MIXED_CONTENT + + assert response.http_method == "http_method_value" + + assert response.fuzzed_url == "fuzzed_url_value" + + assert response.body == "body_value" + + assert response.description == "description_value" + + assert response.reproduction_url == "reproduction_url_value" + + assert response.frame_url == "frame_url_value" + + assert response.final_url == "final_url_value" + + assert response.tracking_id == "tracking_id_value" + + +@pytest.mark.asyncio +async def test_get_finding_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.GetFindingRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_finding), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + finding.Finding( + name="name_value", + finding_type=finding.Finding.FindingType.MIXED_CONTENT, + http_method="http_method_value", + fuzzed_url="fuzzed_url_value", + body="body_value", + description="description_value", + reproduction_url="reproduction_url_value", + frame_url="frame_url_value", + final_url="final_url_value", + tracking_id="tracking_id_value", + ) + ) + + response = await client.get_finding(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, finding.Finding) + + assert response.name == "name_value" + + assert response.finding_type == finding.Finding.FindingType.MIXED_CONTENT + + assert response.http_method == "http_method_value" + + assert response.fuzzed_url == "fuzzed_url_value" + + assert response.body == "body_value" + + assert response.description == "description_value" + + assert response.reproduction_url == "reproduction_url_value" + + assert response.frame_url == "frame_url_value" + + assert response.final_url == "final_url_value" + + assert response.tracking_id == "tracking_id_value" + + +def test_get_finding_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.GetFindingRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_finding), "__call__") as call: + call.return_value = finding.Finding() + + client.get_finding(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_finding_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.GetFindingRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_finding), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(finding.Finding()) + + await client.get_finding(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_finding_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_finding), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = finding.Finding() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_finding(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +def test_get_finding_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_finding( + web_security_scanner.GetFindingRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_finding_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_finding), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = finding.Finding() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(finding.Finding()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_finding(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_finding_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_finding( + web_security_scanner.GetFindingRequest(), name="name_value", + ) + + +def test_list_findings(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListFindingsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_findings), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListFindingsResponse( + next_page_token="next_page_token_value", + ) + + response = client.list_findings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFindingsPager) + + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_findings_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListFindingsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_findings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListFindingsResponse( + next_page_token="next_page_token_value", + ) + ) + + response = await client.list_findings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFindingsAsyncPager) + + assert response.next_page_token == "next_page_token_value" + + +def test_list_findings_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListFindingsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_findings), "__call__") as call: + call.return_value = web_security_scanner.ListFindingsResponse() + + client.list_findings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_findings_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListFindingsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_findings), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListFindingsResponse() + ) + + await client.list_findings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_findings_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_findings), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListFindingsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_findings( + parent="parent_value", filter="filter_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + assert args[0].filter == "filter_value" + + +def test_list_findings_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_findings( + web_security_scanner.ListFindingsRequest(), + parent="parent_value", + filter="filter_value", + ) + + +@pytest.mark.asyncio +async def test_list_findings_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_findings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListFindingsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListFindingsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_findings( + parent="parent_value", filter="filter_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + assert args[0].filter == "filter_value" + + +@pytest.mark.asyncio +async def test_list_findings_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_findings( + web_security_scanner.ListFindingsRequest(), + parent="parent_value", + filter="filter_value", + ) + + +def test_list_findings_pager(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_findings), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(), finding.Finding(),], + next_page_token="abc", + ), + web_security_scanner.ListFindingsResponse( + findings=[], next_page_token="def", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(),], next_page_token="ghi", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(),], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_findings(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, finding.Finding) for i in results) + + +def test_list_findings_pages(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_findings), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(), finding.Finding(),], + next_page_token="abc", + ), + web_security_scanner.ListFindingsResponse( + findings=[], next_page_token="def", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(),], next_page_token="ghi", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(),], + ), + RuntimeError, + ) + pages = list(client.list_findings(request={}).pages) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_findings_async_pager(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_findings), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(), finding.Finding(),], + next_page_token="abc", + ), + web_security_scanner.ListFindingsResponse( + findings=[], next_page_token="def", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(),], next_page_token="ghi", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(),], + ), + RuntimeError, + ) + async_pager = await client.list_findings(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, finding.Finding) for i in responses) + + +@pytest.mark.asyncio +async def test_list_findings_async_pages(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_findings), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(), finding.Finding(),], + next_page_token="abc", + ), + web_security_scanner.ListFindingsResponse( + findings=[], next_page_token="def", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(),], next_page_token="ghi", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(),], + ), + RuntimeError, + ) + pages = [] + async for page in (await client.list_findings(request={})).pages: + pages.append(page) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +def test_list_finding_type_stats(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListFindingTypeStatsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_finding_type_stats), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListFindingTypeStatsResponse() + + response = client.list_finding_type_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, web_security_scanner.ListFindingTypeStatsResponse) + + +@pytest.mark.asyncio +async def test_list_finding_type_stats_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListFindingTypeStatsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_finding_type_stats), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListFindingTypeStatsResponse() + ) + + response = await client.list_finding_type_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, web_security_scanner.ListFindingTypeStatsResponse) + + +def test_list_finding_type_stats_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListFindingTypeStatsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_finding_type_stats), "__call__" + ) as call: + call.return_value = web_security_scanner.ListFindingTypeStatsResponse() + + client.list_finding_type_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_finding_type_stats_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListFindingTypeStatsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_finding_type_stats), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListFindingTypeStatsResponse() + ) + + await client.list_finding_type_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_finding_type_stats_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_finding_type_stats), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListFindingTypeStatsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_finding_type_stats(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +def test_list_finding_type_stats_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_finding_type_stats( + web_security_scanner.ListFindingTypeStatsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_finding_type_stats_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_finding_type_stats), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListFindingTypeStatsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListFindingTypeStatsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_finding_type_stats(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_finding_type_stats_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_finding_type_stats( + web_security_scanner.ListFindingTypeStatsRequest(), parent="parent_value", + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.WebSecurityScannerGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.WebSecurityScannerGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = WebSecurityScannerClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.WebSecurityScannerGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = WebSecurityScannerClient( + client_options={"scopes": ["1", "2"]}, transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.WebSecurityScannerGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + client = WebSecurityScannerClient(transport=transport) + assert client._transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.WebSecurityScannerGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.WebSecurityScannerGrpcAsyncIOTransport( + credentials=credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + assert isinstance(client._transport, transports.WebSecurityScannerGrpcTransport,) + + +def test_web_security_scanner_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(exceptions.DuplicateCredentialArgs): + transport = transports.WebSecurityScannerTransport( + credentials=credentials.AnonymousCredentials(), + credentials_file="credentials.json", + ) + + +def test_web_security_scanner_base_transport(): + # Instantiate the base transport. + transport = transports.WebSecurityScannerTransport( + credentials=credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + "create_scan_config", + "delete_scan_config", + "get_scan_config", + "list_scan_configs", + "update_scan_config", + "start_scan_run", + "get_scan_run", + "list_scan_runs", + "stop_scan_run", + "list_crawled_urls", + "get_finding", + "list_findings", + "list_finding_type_stats", + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + +def test_web_security_scanner_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object(auth, "load_credentials_from_file") as load_creds: + load_creds.return_value = (credentials.AnonymousCredentials(), None) + transport = transports.WebSecurityScannerTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +def test_web_security_scanner_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(auth, "default") as adc: + adc.return_value = (credentials.AnonymousCredentials(), None) + WebSecurityScannerClient() + adc.assert_called_once_with( + scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +def test_web_security_scanner_transport_auth_adc(): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(auth, "default") as adc: + adc.return_value = (credentials.AnonymousCredentials(), None) + transports.WebSecurityScannerGrpcTransport( + host="squid.clam.whelk", quota_project_id="octopus" + ) + adc.assert_called_once_with( + scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +def test_web_security_scanner_host_no_port(): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions( + api_endpoint="websecurityscanner.googleapis.com" + ), + ) + assert client._transport._host == "websecurityscanner.googleapis.com:443" + + +def test_web_security_scanner_host_with_port(): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions( + api_endpoint="websecurityscanner.googleapis.com:8000" + ), + ) + assert client._transport._host == "websecurityscanner.googleapis.com:8000" + + +def test_web_security_scanner_grpc_transport_channel(): + channel = grpc.insecure_channel("http://localhost/") + + # Check that if channel is provided, mtls endpoint and client_cert_source + # won't be used. + callback = mock.MagicMock() + transport = transports.WebSecurityScannerGrpcTransport( + host="squid.clam.whelk", + channel=channel, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=callback, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert not callback.called + + +def test_web_security_scanner_grpc_asyncio_transport_channel(): + channel = aio.insecure_channel("http://localhost/") + + # Check that if channel is provided, mtls endpoint and client_cert_source + # won't be used. + callback = mock.MagicMock() + transport = transports.WebSecurityScannerGrpcAsyncIOTransport( + host="squid.clam.whelk", + channel=channel, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=callback, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert not callback.called + + +@mock.patch("grpc.ssl_channel_credentials", autospec=True) +@mock.patch("google.api_core.grpc_helpers.create_channel", autospec=True) +def test_web_security_scanner_grpc_transport_channel_mtls_with_client_cert_source( + grpc_create_channel, grpc_ssl_channel_cred +): + # Check that if channel is None, but api_mtls_endpoint and client_cert_source + # are provided, then a mTLS channel will be created. + mock_cred = mock.Mock() + + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + transport = transports.WebSecurityScannerGrpcTransport( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + ) + assert transport.grpc_channel == mock_grpc_channel + + +@mock.patch("grpc.ssl_channel_credentials", autospec=True) +@mock.patch("google.api_core.grpc_helpers_async.create_channel", autospec=True) +def test_web_security_scanner_grpc_asyncio_transport_channel_mtls_with_client_cert_source( + grpc_create_channel, grpc_ssl_channel_cred +): + # Check that if channel is None, but api_mtls_endpoint and client_cert_source + # are provided, then a mTLS channel will be created. + mock_cred = mock.Mock() + + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + transport = transports.WebSecurityScannerGrpcAsyncIOTransport( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + ) + assert transport.grpc_channel == mock_grpc_channel + + +@pytest.mark.parametrize( + "api_mtls_endpoint", ["mtls.squid.clam.whelk", "mtls.squid.clam.whelk:443"] +) +@mock.patch("google.api_core.grpc_helpers.create_channel", autospec=True) +def test_web_security_scanner_grpc_transport_channel_mtls_with_adc( + grpc_create_channel, api_mtls_endpoint +): + # Check that if channel and client_cert_source are None, but api_mtls_endpoint + # is provided, then a mTLS channel will be created with SSL ADC. + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + # Mock google.auth.transport.grpc.SslCredentials class. + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + mock_cred = mock.Mock() + transport = transports.WebSecurityScannerGrpcTransport( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint=api_mtls_endpoint, + client_cert_source=None, + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + ) + assert transport.grpc_channel == mock_grpc_channel + + +@pytest.mark.parametrize( + "api_mtls_endpoint", ["mtls.squid.clam.whelk", "mtls.squid.clam.whelk:443"] +) +@mock.patch("google.api_core.grpc_helpers_async.create_channel", autospec=True) +def test_web_security_scanner_grpc_asyncio_transport_channel_mtls_with_adc( + grpc_create_channel, api_mtls_endpoint +): + # Check that if channel and client_cert_source are None, but api_mtls_endpoint + # is provided, then a mTLS channel will be created with SSL ADC. + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + # Mock google.auth.transport.grpc.SslCredentials class. + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + mock_cred = mock.Mock() + transport = transports.WebSecurityScannerGrpcAsyncIOTransport( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint=api_mtls_endpoint, + client_cert_source=None, + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_scan_run_path(): + project = "squid" + scan_config = "clam" + scan_run = "whelk" + + expected = "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}".format( + project=project, scan_config=scan_config, scan_run=scan_run, + ) + actual = WebSecurityScannerClient.scan_run_path(project, scan_config, scan_run) + assert expected == actual + + +def test_parse_scan_run_path(): + expected = { + "project": "octopus", + "scan_config": "oyster", + "scan_run": "nudibranch", + } + path = WebSecurityScannerClient.scan_run_path(**expected) + + # Check that the path construction is reversible. + actual = WebSecurityScannerClient.parse_scan_run_path(path) + assert expected == actual + + +def test_scan_config_path(): + project = "squid" + scan_config = "clam" + + expected = "projects/{project}/scanConfigs/{scan_config}".format( + project=project, scan_config=scan_config, + ) + actual = WebSecurityScannerClient.scan_config_path(project, scan_config) + assert expected == actual + + +def test_parse_scan_config_path(): + expected = { + "project": "whelk", + "scan_config": "octopus", + } + path = WebSecurityScannerClient.scan_config_path(**expected) + + # Check that the path construction is reversible. + actual = WebSecurityScannerClient.parse_scan_config_path(path) + assert expected == actual diff --git a/google/cloud/websecurityscanner_v1alpha/gapic/transports/__init__.py b/tests/unit/gapic/websecurityscanner_v1beta/__init__.py similarity index 100% rename from google/cloud/websecurityscanner_v1alpha/gapic/transports/__init__.py rename to tests/unit/gapic/websecurityscanner_v1beta/__init__.py diff --git a/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py b/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py new file mode 100644 index 0000000..aa9695e --- /dev/null +++ b/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py @@ -0,0 +1,4214 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 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 mock + +import grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + +from google import auth +from google.api_core import client_options +from google.api_core import exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.auth import credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.websecurityscanner_v1beta.services.web_security_scanner import ( + WebSecurityScannerAsyncClient, +) +from google.cloud.websecurityscanner_v1beta.services.web_security_scanner import ( + WebSecurityScannerClient, +) +from google.cloud.websecurityscanner_v1beta.services.web_security_scanner import pagers +from google.cloud.websecurityscanner_v1beta.services.web_security_scanner import ( + transports, +) +from google.cloud.websecurityscanner_v1beta.types import crawled_url +from google.cloud.websecurityscanner_v1beta.types import finding +from google.cloud.websecurityscanner_v1beta.types import finding_addon +from google.cloud.websecurityscanner_v1beta.types import finding_type_stats +from google.cloud.websecurityscanner_v1beta.types import scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_config as gcw_scan_config +from google.cloud.websecurityscanner_v1beta.types import scan_config_error +from google.cloud.websecurityscanner_v1beta.types import ( + scan_config_error as gcw_scan_config_error, +) +from google.cloud.websecurityscanner_v1beta.types import scan_run +from google.cloud.websecurityscanner_v1beta.types import scan_run_error_trace +from google.cloud.websecurityscanner_v1beta.types import scan_run_warning_trace +from google.cloud.websecurityscanner_v1beta.types import web_security_scanner +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import timestamp_pb2 as timestamp # type: ignore + + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert WebSecurityScannerClient._get_default_mtls_endpoint(None) is None + assert ( + WebSecurityScannerClient._get_default_mtls_endpoint(api_endpoint) + == api_mtls_endpoint + ) + assert ( + WebSecurityScannerClient._get_default_mtls_endpoint(api_mtls_endpoint) + == api_mtls_endpoint + ) + assert ( + WebSecurityScannerClient._get_default_mtls_endpoint(sandbox_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + WebSecurityScannerClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + WebSecurityScannerClient._get_default_mtls_endpoint(non_googleapi) + == non_googleapi + ) + + +@pytest.mark.parametrize( + "client_class", [WebSecurityScannerClient, WebSecurityScannerAsyncClient] +) +def test_web_security_scanner_client_from_service_account_file(client_class): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_file" + ) as factory: + factory.return_value = creds + client = client_class.from_service_account_file("dummy/file/path.json") + assert client._transport._credentials == creds + + client = client_class.from_service_account_json("dummy/file/path.json") + assert client._transport._credentials == creds + + assert client._transport._host == "websecurityscanner.googleapis.com:443" + + +def test_web_security_scanner_client_get_transport_class(): + transport = WebSecurityScannerClient.get_transport_class() + assert transport == transports.WebSecurityScannerGrpcTransport + + transport = WebSecurityScannerClient.get_transport_class("grpc") + assert transport == transports.WebSecurityScannerGrpcTransport + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (WebSecurityScannerClient, transports.WebSecurityScannerGrpcTransport, "grpc"), + ( + WebSecurityScannerAsyncClient, + transports.WebSecurityScannerGrpcAsyncIOTransport, + "grpc_asyncio", + ), + ], +) +def test_web_security_scanner_client_client_options( + client_class, transport_class, transport_name +): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(WebSecurityScannerClient, "get_transport_class") as gtc: + transport = transport_class(credentials=credentials.AnonymousCredentials()) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(WebSecurityScannerClient, "get_transport_class") as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + api_mtls_endpoint="squid.clam.whelk", + client_cert_source=None, + quota_project_id=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "never"}): + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_ENDPOINT, + client_cert_source=None, + quota_project_id=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "always"}): + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_MTLS_ENDPOINT, + client_cert_source=None, + quota_project_id=None, + ) + + # Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is + # "auto", and client_cert_source is provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "auto"}): + options = client_options.ClientOptions( + client_cert_source=client_cert_source_callback + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_MTLS_ENDPOINT, + client_cert_source=client_cert_source_callback, + quota_project_id=None, + ) + + # Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is + # "auto", and default_client_cert_source is provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "auto"}): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_MTLS_ENDPOINT, + client_cert_source=None, + quota_project_id=None, + ) + + # Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is + # "auto", but client_cert_source and default_client_cert_source are None. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "auto"}): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_ENDPOINT, + client_cert_source=None, + quota_project_id=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_ENDPOINT, + client_cert_source=None, + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (WebSecurityScannerClient, transports.WebSecurityScannerGrpcTransport, "grpc"), + ( + WebSecurityScannerAsyncClient, + transports.WebSecurityScannerGrpcAsyncIOTransport, + "grpc_asyncio", + ), + ], +) +def test_web_security_scanner_client_client_options_scopes( + client_class, transport_class, transport_name +): + # Check the case scopes are provided. + options = client_options.ClientOptions(scopes=["1", "2"],) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + api_mtls_endpoint=client.DEFAULT_ENDPOINT, + client_cert_source=None, + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (WebSecurityScannerClient, transports.WebSecurityScannerGrpcTransport, "grpc"), + ( + WebSecurityScannerAsyncClient, + transports.WebSecurityScannerGrpcAsyncIOTransport, + "grpc_asyncio", + ), + ], +) +def test_web_security_scanner_client_client_options_credentials_file( + client_class, transport_class, transport_name +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + api_mtls_endpoint=client.DEFAULT_ENDPOINT, + client_cert_source=None, + quota_project_id=None, + ) + + +def test_web_security_scanner_client_client_options_from_dict(): + with mock.patch( + "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.transports.WebSecurityScannerGrpcTransport.__init__" + ) as grpc_transport: + grpc_transport.return_value = None + client = WebSecurityScannerClient( + client_options={"api_endpoint": "squid.clam.whelk"} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + api_mtls_endpoint="squid.clam.whelk", + client_cert_source=None, + quota_project_id=None, + ) + + +def test_create_scan_config(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.CreateScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.create_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gcw_scan_config.ScanConfig( + name="name_value", + display_name="display_name_value", + max_qps=761, + starting_urls=["starting_urls_value"], + user_agent=gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX, + blacklist_patterns=["blacklist_patterns_value"], + target_platforms=[gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE], + export_to_security_command_center=gcw_scan_config.ScanConfig.ExportToSecurityCommandCenter.ENABLED, + risk_level=gcw_scan_config.ScanConfig.RiskLevel.NORMAL, + ) + + response = client.create_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, gcw_scan_config.ScanConfig) + + assert response.name == "name_value" + + assert response.display_name == "display_name_value" + + assert response.max_qps == 761 + + assert response.starting_urls == ["starting_urls_value"] + + assert response.user_agent == gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX + + assert response.blacklist_patterns == ["blacklist_patterns_value"] + + assert response.target_platforms == [ + gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE + ] + + assert ( + response.export_to_security_command_center + == gcw_scan_config.ScanConfig.ExportToSecurityCommandCenter.ENABLED + ) + + assert response.risk_level == gcw_scan_config.ScanConfig.RiskLevel.NORMAL + + +@pytest.mark.asyncio +async def test_create_scan_config_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.CreateScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.create_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gcw_scan_config.ScanConfig( + name="name_value", + display_name="display_name_value", + max_qps=761, + starting_urls=["starting_urls_value"], + user_agent=gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX, + blacklist_patterns=["blacklist_patterns_value"], + target_platforms=[gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE], + export_to_security_command_center=gcw_scan_config.ScanConfig.ExportToSecurityCommandCenter.ENABLED, + risk_level=gcw_scan_config.ScanConfig.RiskLevel.NORMAL, + ) + ) + + response = await client.create_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, gcw_scan_config.ScanConfig) + + assert response.name == "name_value" + + assert response.display_name == "display_name_value" + + assert response.max_qps == 761 + + assert response.starting_urls == ["starting_urls_value"] + + assert response.user_agent == gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX + + assert response.blacklist_patterns == ["blacklist_patterns_value"] + + assert response.target_platforms == [ + gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE + ] + + assert ( + response.export_to_security_command_center + == gcw_scan_config.ScanConfig.ExportToSecurityCommandCenter.ENABLED + ) + + assert response.risk_level == gcw_scan_config.ScanConfig.RiskLevel.NORMAL + + +def test_create_scan_config_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.CreateScanConfigRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.create_scan_config), "__call__" + ) as call: + call.return_value = gcw_scan_config.ScanConfig() + + client.create_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_scan_config_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.CreateScanConfigRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.create_scan_config), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gcw_scan_config.ScanConfig() + ) + + await client.create_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_create_scan_config_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.create_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gcw_scan_config.ScanConfig() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_scan_config( + parent="parent_value", + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + assert args[0].scan_config == gcw_scan_config.ScanConfig(name="name_value") + + +def test_create_scan_config_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_scan_config( + web_security_scanner.CreateScanConfigRequest(), + parent="parent_value", + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_scan_config_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.create_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gcw_scan_config.ScanConfig() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gcw_scan_config.ScanConfig() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_scan_config( + parent="parent_value", + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + assert args[0].scan_config == gcw_scan_config.ScanConfig(name="name_value") + + +@pytest.mark.asyncio +async def test_create_scan_config_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_scan_config( + web_security_scanner.CreateScanConfigRequest(), + parent="parent_value", + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + ) + + +def test_delete_scan_config(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.DeleteScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.delete_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_scan_config_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.DeleteScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.delete_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + response = await client.delete_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_scan_config_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.DeleteScanConfigRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.delete_scan_config), "__call__" + ) as call: + call.return_value = None + + client.delete_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_scan_config_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.DeleteScanConfigRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.delete_scan_config), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + await client.delete_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_delete_scan_config_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.delete_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_scan_config(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +def test_delete_scan_config_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_scan_config( + web_security_scanner.DeleteScanConfigRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_scan_config_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.delete_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_scan_config(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_delete_scan_config_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_scan_config( + web_security_scanner.DeleteScanConfigRequest(), name="name_value", + ) + + +def test_get_scan_config(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.GetScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_scan_config), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_config.ScanConfig( + name="name_value", + display_name="display_name_value", + max_qps=761, + starting_urls=["starting_urls_value"], + user_agent=scan_config.ScanConfig.UserAgent.CHROME_LINUX, + blacklist_patterns=["blacklist_patterns_value"], + target_platforms=[scan_config.ScanConfig.TargetPlatform.APP_ENGINE], + export_to_security_command_center=scan_config.ScanConfig.ExportToSecurityCommandCenter.ENABLED, + risk_level=scan_config.ScanConfig.RiskLevel.NORMAL, + ) + + response = client.get_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_config.ScanConfig) + + assert response.name == "name_value" + + assert response.display_name == "display_name_value" + + assert response.max_qps == 761 + + assert response.starting_urls == ["starting_urls_value"] + + assert response.user_agent == scan_config.ScanConfig.UserAgent.CHROME_LINUX + + assert response.blacklist_patterns == ["blacklist_patterns_value"] + + assert response.target_platforms == [ + scan_config.ScanConfig.TargetPlatform.APP_ENGINE + ] + + assert ( + response.export_to_security_command_center + == scan_config.ScanConfig.ExportToSecurityCommandCenter.ENABLED + ) + + assert response.risk_level == scan_config.ScanConfig.RiskLevel.NORMAL + + +@pytest.mark.asyncio +async def test_get_scan_config_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.GetScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + scan_config.ScanConfig( + name="name_value", + display_name="display_name_value", + max_qps=761, + starting_urls=["starting_urls_value"], + user_agent=scan_config.ScanConfig.UserAgent.CHROME_LINUX, + blacklist_patterns=["blacklist_patterns_value"], + target_platforms=[scan_config.ScanConfig.TargetPlatform.APP_ENGINE], + export_to_security_command_center=scan_config.ScanConfig.ExportToSecurityCommandCenter.ENABLED, + risk_level=scan_config.ScanConfig.RiskLevel.NORMAL, + ) + ) + + response = await client.get_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_config.ScanConfig) + + assert response.name == "name_value" + + assert response.display_name == "display_name_value" + + assert response.max_qps == 761 + + assert response.starting_urls == ["starting_urls_value"] + + assert response.user_agent == scan_config.ScanConfig.UserAgent.CHROME_LINUX + + assert response.blacklist_patterns == ["blacklist_patterns_value"] + + assert response.target_platforms == [ + scan_config.ScanConfig.TargetPlatform.APP_ENGINE + ] + + assert ( + response.export_to_security_command_center + == scan_config.ScanConfig.ExportToSecurityCommandCenter.ENABLED + ) + + assert response.risk_level == scan_config.ScanConfig.RiskLevel.NORMAL + + +def test_get_scan_config_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.GetScanConfigRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_scan_config), "__call__") as call: + call.return_value = scan_config.ScanConfig() + + client.get_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_scan_config_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.GetScanConfigRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_scan_config), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + scan_config.ScanConfig() + ) + + await client.get_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_scan_config_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_scan_config), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_config.ScanConfig() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_scan_config(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +def test_get_scan_config_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_scan_config( + web_security_scanner.GetScanConfigRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_scan_config_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = scan_config.ScanConfig() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + scan_config.ScanConfig() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_scan_config(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_scan_config_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_scan_config( + web_security_scanner.GetScanConfigRequest(), name="name_value", + ) + + +def test_list_scan_configs(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListScanConfigsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_scan_configs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListScanConfigsResponse( + next_page_token="next_page_token_value", + ) + + response = client.list_scan_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListScanConfigsPager) + + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_scan_configs_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListScanConfigsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_configs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListScanConfigsResponse( + next_page_token="next_page_token_value", + ) + ) + + response = await client.list_scan_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListScanConfigsAsyncPager) + + assert response.next_page_token == "next_page_token_value" + + +def test_list_scan_configs_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListScanConfigsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_scan_configs), "__call__" + ) as call: + call.return_value = web_security_scanner.ListScanConfigsResponse() + + client.list_scan_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_scan_configs_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListScanConfigsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_configs), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListScanConfigsResponse() + ) + + await client.list_scan_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_scan_configs_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_scan_configs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListScanConfigsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_scan_configs(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +def test_list_scan_configs_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_scan_configs( + web_security_scanner.ListScanConfigsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_scan_configs_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_configs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListScanConfigsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListScanConfigsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_scan_configs(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_scan_configs_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_scan_configs( + web_security_scanner.ListScanConfigsRequest(), parent="parent_value", + ) + + +def test_list_scan_configs_pager(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_scan_configs), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanConfigsResponse( + scan_configs=[ + scan_config.ScanConfig(), + scan_config.ScanConfig(), + scan_config.ScanConfig(), + ], + next_page_token="abc", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[], next_page_token="def", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(),], next_page_token="ghi", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(), scan_config.ScanConfig(),], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_scan_configs(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, scan_config.ScanConfig) for i in results) + + +def test_list_scan_configs_pages(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_scan_configs), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanConfigsResponse( + scan_configs=[ + scan_config.ScanConfig(), + scan_config.ScanConfig(), + scan_config.ScanConfig(), + ], + next_page_token="abc", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[], next_page_token="def", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(),], next_page_token="ghi", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(), scan_config.ScanConfig(),], + ), + RuntimeError, + ) + pages = list(client.list_scan_configs(request={}).pages) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_scan_configs_async_pager(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_configs), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanConfigsResponse( + scan_configs=[ + scan_config.ScanConfig(), + scan_config.ScanConfig(), + scan_config.ScanConfig(), + ], + next_page_token="abc", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[], next_page_token="def", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(),], next_page_token="ghi", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(), scan_config.ScanConfig(),], + ), + RuntimeError, + ) + async_pager = await client.list_scan_configs(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, scan_config.ScanConfig) for i in responses) + + +@pytest.mark.asyncio +async def test_list_scan_configs_async_pages(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_configs), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanConfigsResponse( + scan_configs=[ + scan_config.ScanConfig(), + scan_config.ScanConfig(), + scan_config.ScanConfig(), + ], + next_page_token="abc", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[], next_page_token="def", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(),], next_page_token="ghi", + ), + web_security_scanner.ListScanConfigsResponse( + scan_configs=[scan_config.ScanConfig(), scan_config.ScanConfig(),], + ), + RuntimeError, + ) + pages = [] + async for page in (await client.list_scan_configs(request={})).pages: + pages.append(page) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +def test_update_scan_config(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.UpdateScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.update_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gcw_scan_config.ScanConfig( + name="name_value", + display_name="display_name_value", + max_qps=761, + starting_urls=["starting_urls_value"], + user_agent=gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX, + blacklist_patterns=["blacklist_patterns_value"], + target_platforms=[gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE], + export_to_security_command_center=gcw_scan_config.ScanConfig.ExportToSecurityCommandCenter.ENABLED, + risk_level=gcw_scan_config.ScanConfig.RiskLevel.NORMAL, + ) + + response = client.update_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, gcw_scan_config.ScanConfig) + + assert response.name == "name_value" + + assert response.display_name == "display_name_value" + + assert response.max_qps == 761 + + assert response.starting_urls == ["starting_urls_value"] + + assert response.user_agent == gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX + + assert response.blacklist_patterns == ["blacklist_patterns_value"] + + assert response.target_platforms == [ + gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE + ] + + assert ( + response.export_to_security_command_center + == gcw_scan_config.ScanConfig.ExportToSecurityCommandCenter.ENABLED + ) + + assert response.risk_level == gcw_scan_config.ScanConfig.RiskLevel.NORMAL + + +@pytest.mark.asyncio +async def test_update_scan_config_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.UpdateScanConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.update_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gcw_scan_config.ScanConfig( + name="name_value", + display_name="display_name_value", + max_qps=761, + starting_urls=["starting_urls_value"], + user_agent=gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX, + blacklist_patterns=["blacklist_patterns_value"], + target_platforms=[gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE], + export_to_security_command_center=gcw_scan_config.ScanConfig.ExportToSecurityCommandCenter.ENABLED, + risk_level=gcw_scan_config.ScanConfig.RiskLevel.NORMAL, + ) + ) + + response = await client.update_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, gcw_scan_config.ScanConfig) + + assert response.name == "name_value" + + assert response.display_name == "display_name_value" + + assert response.max_qps == 761 + + assert response.starting_urls == ["starting_urls_value"] + + assert response.user_agent == gcw_scan_config.ScanConfig.UserAgent.CHROME_LINUX + + assert response.blacklist_patterns == ["blacklist_patterns_value"] + + assert response.target_platforms == [ + gcw_scan_config.ScanConfig.TargetPlatform.APP_ENGINE + ] + + assert ( + response.export_to_security_command_center + == gcw_scan_config.ScanConfig.ExportToSecurityCommandCenter.ENABLED + ) + + assert response.risk_level == gcw_scan_config.ScanConfig.RiskLevel.NORMAL + + +def test_update_scan_config_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.UpdateScanConfigRequest() + request.scan_config.name = "scan_config.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.update_scan_config), "__call__" + ) as call: + call.return_value = gcw_scan_config.ScanConfig() + + client.update_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "scan_config.name=scan_config.name/value",) in kw[ + "metadata" + ] + + +@pytest.mark.asyncio +async def test_update_scan_config_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.UpdateScanConfigRequest() + request.scan_config.name = "scan_config.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.update_scan_config), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gcw_scan_config.ScanConfig() + ) + + await client.update_scan_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "scan_config.name=scan_config.name/value",) in kw[ + "metadata" + ] + + +def test_update_scan_config_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.update_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gcw_scan_config.ScanConfig() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_scan_config( + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + update_mask=field_mask.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].scan_config == gcw_scan_config.ScanConfig(name="name_value") + + assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + + +def test_update_scan_config_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_scan_config( + web_security_scanner.UpdateScanConfigRequest(), + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + update_mask=field_mask.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_scan_config_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.update_scan_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gcw_scan_config.ScanConfig() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gcw_scan_config.ScanConfig() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_scan_config( + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + update_mask=field_mask.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].scan_config == gcw_scan_config.ScanConfig(name="name_value") + + assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + + +@pytest.mark.asyncio +async def test_update_scan_config_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_scan_config( + web_security_scanner.UpdateScanConfigRequest(), + scan_config=gcw_scan_config.ScanConfig(name="name_value"), + update_mask=field_mask.FieldMask(paths=["paths_value"]), + ) + + +def test_start_scan_run(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.StartScanRunRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.start_scan_run), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun( + name="name_value", + execution_state=scan_run.ScanRun.ExecutionState.QUEUED, + result_state=scan_run.ScanRun.ResultState.SUCCESS, + urls_crawled_count=1935, + urls_tested_count=1846, + has_vulnerabilities=True, + progress_percent=1733, + ) + + response = client.start_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_run.ScanRun) + + assert response.name == "name_value" + + assert response.execution_state == scan_run.ScanRun.ExecutionState.QUEUED + + assert response.result_state == scan_run.ScanRun.ResultState.SUCCESS + + assert response.urls_crawled_count == 1935 + + assert response.urls_tested_count == 1846 + + assert response.has_vulnerabilities is True + + assert response.progress_percent == 1733 + + +@pytest.mark.asyncio +async def test_start_scan_run_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.StartScanRunRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.start_scan_run), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + scan_run.ScanRun( + name="name_value", + execution_state=scan_run.ScanRun.ExecutionState.QUEUED, + result_state=scan_run.ScanRun.ResultState.SUCCESS, + urls_crawled_count=1935, + urls_tested_count=1846, + has_vulnerabilities=True, + progress_percent=1733, + ) + ) + + response = await client.start_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_run.ScanRun) + + assert response.name == "name_value" + + assert response.execution_state == scan_run.ScanRun.ExecutionState.QUEUED + + assert response.result_state == scan_run.ScanRun.ResultState.SUCCESS + + assert response.urls_crawled_count == 1935 + + assert response.urls_tested_count == 1846 + + assert response.has_vulnerabilities is True + + assert response.progress_percent == 1733 + + +def test_start_scan_run_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.StartScanRunRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.start_scan_run), "__call__") as call: + call.return_value = scan_run.ScanRun() + + client.start_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_start_scan_run_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.StartScanRunRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.start_scan_run), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(scan_run.ScanRun()) + + await client.start_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_start_scan_run_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.start_scan_run), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.start_scan_run(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +def test_start_scan_run_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.start_scan_run( + web_security_scanner.StartScanRunRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_start_scan_run_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.start_scan_run), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(scan_run.ScanRun()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.start_scan_run(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_start_scan_run_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.start_scan_run( + web_security_scanner.StartScanRunRequest(), name="name_value", + ) + + +def test_get_scan_run(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.GetScanRunRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_scan_run), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun( + name="name_value", + execution_state=scan_run.ScanRun.ExecutionState.QUEUED, + result_state=scan_run.ScanRun.ResultState.SUCCESS, + urls_crawled_count=1935, + urls_tested_count=1846, + has_vulnerabilities=True, + progress_percent=1733, + ) + + response = client.get_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_run.ScanRun) + + assert response.name == "name_value" + + assert response.execution_state == scan_run.ScanRun.ExecutionState.QUEUED + + assert response.result_state == scan_run.ScanRun.ResultState.SUCCESS + + assert response.urls_crawled_count == 1935 + + assert response.urls_tested_count == 1846 + + assert response.has_vulnerabilities is True + + assert response.progress_percent == 1733 + + +@pytest.mark.asyncio +async def test_get_scan_run_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.GetScanRunRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_scan_run), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + scan_run.ScanRun( + name="name_value", + execution_state=scan_run.ScanRun.ExecutionState.QUEUED, + result_state=scan_run.ScanRun.ResultState.SUCCESS, + urls_crawled_count=1935, + urls_tested_count=1846, + has_vulnerabilities=True, + progress_percent=1733, + ) + ) + + response = await client.get_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_run.ScanRun) + + assert response.name == "name_value" + + assert response.execution_state == scan_run.ScanRun.ExecutionState.QUEUED + + assert response.result_state == scan_run.ScanRun.ResultState.SUCCESS + + assert response.urls_crawled_count == 1935 + + assert response.urls_tested_count == 1846 + + assert response.has_vulnerabilities is True + + assert response.progress_percent == 1733 + + +def test_get_scan_run_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.GetScanRunRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_scan_run), "__call__") as call: + call.return_value = scan_run.ScanRun() + + client.get_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_scan_run_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.GetScanRunRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_scan_run), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(scan_run.ScanRun()) + + await client.get_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_scan_run_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_scan_run), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_scan_run(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +def test_get_scan_run_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_scan_run( + web_security_scanner.GetScanRunRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_scan_run_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_scan_run), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(scan_run.ScanRun()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_scan_run(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_scan_run_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_scan_run( + web_security_scanner.GetScanRunRequest(), name="name_value", + ) + + +def test_list_scan_runs(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListScanRunsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_scan_runs), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListScanRunsResponse( + next_page_token="next_page_token_value", + ) + + response = client.list_scan_runs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListScanRunsPager) + + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_scan_runs_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListScanRunsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_runs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListScanRunsResponse( + next_page_token="next_page_token_value", + ) + ) + + response = await client.list_scan_runs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListScanRunsAsyncPager) + + assert response.next_page_token == "next_page_token_value" + + +def test_list_scan_runs_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListScanRunsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_scan_runs), "__call__") as call: + call.return_value = web_security_scanner.ListScanRunsResponse() + + client.list_scan_runs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_scan_runs_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListScanRunsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_runs), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListScanRunsResponse() + ) + + await client.list_scan_runs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_scan_runs_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_scan_runs), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListScanRunsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_scan_runs(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +def test_list_scan_runs_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_scan_runs( + web_security_scanner.ListScanRunsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_scan_runs_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_runs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListScanRunsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListScanRunsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_scan_runs(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_scan_runs_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_scan_runs( + web_security_scanner.ListScanRunsRequest(), parent="parent_value", + ) + + +def test_list_scan_runs_pager(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_scan_runs), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(), scan_run.ScanRun(),], + next_page_token="abc", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[], next_page_token="def", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(),], next_page_token="ghi", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(),], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_scan_runs(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, scan_run.ScanRun) for i in results) + + +def test_list_scan_runs_pages(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_scan_runs), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(), scan_run.ScanRun(),], + next_page_token="abc", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[], next_page_token="def", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(),], next_page_token="ghi", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(),], + ), + RuntimeError, + ) + pages = list(client.list_scan_runs(request={}).pages) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_scan_runs_async_pager(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_runs), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(), scan_run.ScanRun(),], + next_page_token="abc", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[], next_page_token="def", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(),], next_page_token="ghi", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(),], + ), + RuntimeError, + ) + async_pager = await client.list_scan_runs(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, scan_run.ScanRun) for i in responses) + + +@pytest.mark.asyncio +async def test_list_scan_runs_async_pages(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_scan_runs), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(), scan_run.ScanRun(),], + next_page_token="abc", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[], next_page_token="def", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(),], next_page_token="ghi", + ), + web_security_scanner.ListScanRunsResponse( + scan_runs=[scan_run.ScanRun(), scan_run.ScanRun(),], + ), + RuntimeError, + ) + pages = [] + async for page in (await client.list_scan_runs(request={})).pages: + pages.append(page) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +def test_stop_scan_run(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.StopScanRunRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.stop_scan_run), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun( + name="name_value", + execution_state=scan_run.ScanRun.ExecutionState.QUEUED, + result_state=scan_run.ScanRun.ResultState.SUCCESS, + urls_crawled_count=1935, + urls_tested_count=1846, + has_vulnerabilities=True, + progress_percent=1733, + ) + + response = client.stop_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_run.ScanRun) + + assert response.name == "name_value" + + assert response.execution_state == scan_run.ScanRun.ExecutionState.QUEUED + + assert response.result_state == scan_run.ScanRun.ResultState.SUCCESS + + assert response.urls_crawled_count == 1935 + + assert response.urls_tested_count == 1846 + + assert response.has_vulnerabilities is True + + assert response.progress_percent == 1733 + + +@pytest.mark.asyncio +async def test_stop_scan_run_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.StopScanRunRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.stop_scan_run), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + scan_run.ScanRun( + name="name_value", + execution_state=scan_run.ScanRun.ExecutionState.QUEUED, + result_state=scan_run.ScanRun.ResultState.SUCCESS, + urls_crawled_count=1935, + urls_tested_count=1846, + has_vulnerabilities=True, + progress_percent=1733, + ) + ) + + response = await client.stop_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, scan_run.ScanRun) + + assert response.name == "name_value" + + assert response.execution_state == scan_run.ScanRun.ExecutionState.QUEUED + + assert response.result_state == scan_run.ScanRun.ResultState.SUCCESS + + assert response.urls_crawled_count == 1935 + + assert response.urls_tested_count == 1846 + + assert response.has_vulnerabilities is True + + assert response.progress_percent == 1733 + + +def test_stop_scan_run_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.StopScanRunRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.stop_scan_run), "__call__") as call: + call.return_value = scan_run.ScanRun() + + client.stop_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_stop_scan_run_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.StopScanRunRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.stop_scan_run), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(scan_run.ScanRun()) + + await client.stop_scan_run(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_stop_scan_run_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.stop_scan_run), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.stop_scan_run(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +def test_stop_scan_run_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.stop_scan_run( + web_security_scanner.StopScanRunRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_stop_scan_run_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.stop_scan_run), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = scan_run.ScanRun() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(scan_run.ScanRun()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.stop_scan_run(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_stop_scan_run_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.stop_scan_run( + web_security_scanner.StopScanRunRequest(), name="name_value", + ) + + +def test_list_crawled_urls(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListCrawledUrlsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_crawled_urls), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListCrawledUrlsResponse( + next_page_token="next_page_token_value", + ) + + response = client.list_crawled_urls(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCrawledUrlsPager) + + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_crawled_urls_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListCrawledUrlsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_crawled_urls), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListCrawledUrlsResponse( + next_page_token="next_page_token_value", + ) + ) + + response = await client.list_crawled_urls(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCrawledUrlsAsyncPager) + + assert response.next_page_token == "next_page_token_value" + + +def test_list_crawled_urls_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListCrawledUrlsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_crawled_urls), "__call__" + ) as call: + call.return_value = web_security_scanner.ListCrawledUrlsResponse() + + client.list_crawled_urls(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_crawled_urls_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListCrawledUrlsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_crawled_urls), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListCrawledUrlsResponse() + ) + + await client.list_crawled_urls(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_crawled_urls_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_crawled_urls), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListCrawledUrlsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_crawled_urls(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +def test_list_crawled_urls_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_crawled_urls( + web_security_scanner.ListCrawledUrlsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_crawled_urls_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_crawled_urls), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListCrawledUrlsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListCrawledUrlsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_crawled_urls(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_crawled_urls_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_crawled_urls( + web_security_scanner.ListCrawledUrlsRequest(), parent="parent_value", + ) + + +def test_list_crawled_urls_pager(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_crawled_urls), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[ + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + ], + next_page_token="abc", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[], next_page_token="def", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(),], next_page_token="ghi", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(), crawled_url.CrawledUrl(),], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_crawled_urls(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, crawled_url.CrawledUrl) for i in results) + + +def test_list_crawled_urls_pages(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_crawled_urls), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[ + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + ], + next_page_token="abc", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[], next_page_token="def", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(),], next_page_token="ghi", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(), crawled_url.CrawledUrl(),], + ), + RuntimeError, + ) + pages = list(client.list_crawled_urls(request={}).pages) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_crawled_urls_async_pager(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_crawled_urls), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[ + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + ], + next_page_token="abc", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[], next_page_token="def", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(),], next_page_token="ghi", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(), crawled_url.CrawledUrl(),], + ), + RuntimeError, + ) + async_pager = await client.list_crawled_urls(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, crawled_url.CrawledUrl) for i in responses) + + +@pytest.mark.asyncio +async def test_list_crawled_urls_async_pages(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_crawled_urls), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[ + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + crawled_url.CrawledUrl(), + ], + next_page_token="abc", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[], next_page_token="def", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(),], next_page_token="ghi", + ), + web_security_scanner.ListCrawledUrlsResponse( + crawled_urls=[crawled_url.CrawledUrl(), crawled_url.CrawledUrl(),], + ), + RuntimeError, + ) + pages = [] + async for page in (await client.list_crawled_urls(request={})).pages: + pages.append(page) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +def test_get_finding(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.GetFindingRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_finding), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = finding.Finding( + name="name_value", + finding_type="finding_type_value", + http_method="http_method_value", + fuzzed_url="fuzzed_url_value", + body="body_value", + description="description_value", + reproduction_url="reproduction_url_value", + frame_url="frame_url_value", + final_url="final_url_value", + tracking_id="tracking_id_value", + ) + + response = client.get_finding(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, finding.Finding) + + assert response.name == "name_value" + + assert response.finding_type == "finding_type_value" + + assert response.http_method == "http_method_value" + + assert response.fuzzed_url == "fuzzed_url_value" + + assert response.body == "body_value" + + assert response.description == "description_value" + + assert response.reproduction_url == "reproduction_url_value" + + assert response.frame_url == "frame_url_value" + + assert response.final_url == "final_url_value" + + assert response.tracking_id == "tracking_id_value" + + +@pytest.mark.asyncio +async def test_get_finding_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.GetFindingRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_finding), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + finding.Finding( + name="name_value", + finding_type="finding_type_value", + http_method="http_method_value", + fuzzed_url="fuzzed_url_value", + body="body_value", + description="description_value", + reproduction_url="reproduction_url_value", + frame_url="frame_url_value", + final_url="final_url_value", + tracking_id="tracking_id_value", + ) + ) + + response = await client.get_finding(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, finding.Finding) + + assert response.name == "name_value" + + assert response.finding_type == "finding_type_value" + + assert response.http_method == "http_method_value" + + assert response.fuzzed_url == "fuzzed_url_value" + + assert response.body == "body_value" + + assert response.description == "description_value" + + assert response.reproduction_url == "reproduction_url_value" + + assert response.frame_url == "frame_url_value" + + assert response.final_url == "final_url_value" + + assert response.tracking_id == "tracking_id_value" + + +def test_get_finding_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.GetFindingRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_finding), "__call__") as call: + call.return_value = finding.Finding() + + client.get_finding(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_finding_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.GetFindingRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_finding), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(finding.Finding()) + + await client.get_finding(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_finding_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.get_finding), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = finding.Finding() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_finding(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +def test_get_finding_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_finding( + web_security_scanner.GetFindingRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_finding_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.get_finding), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = finding.Finding() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(finding.Finding()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_finding(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_finding_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_finding( + web_security_scanner.GetFindingRequest(), name="name_value", + ) + + +def test_list_findings(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListFindingsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_findings), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListFindingsResponse( + next_page_token="next_page_token_value", + ) + + response = client.list_findings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFindingsPager) + + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_findings_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListFindingsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_findings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListFindingsResponse( + next_page_token="next_page_token_value", + ) + ) + + response = await client.list_findings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFindingsAsyncPager) + + assert response.next_page_token == "next_page_token_value" + + +def test_list_findings_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListFindingsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_findings), "__call__") as call: + call.return_value = web_security_scanner.ListFindingsResponse() + + client.list_findings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_findings_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListFindingsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_findings), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListFindingsResponse() + ) + + await client.list_findings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_findings_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_findings), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListFindingsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_findings( + parent="parent_value", filter="filter_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + assert args[0].filter == "filter_value" + + +def test_list_findings_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_findings( + web_security_scanner.ListFindingsRequest(), + parent="parent_value", + filter="filter_value", + ) + + +@pytest.mark.asyncio +async def test_list_findings_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_findings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListFindingsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListFindingsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_findings( + parent="parent_value", filter="filter_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + assert args[0].filter == "filter_value" + + +@pytest.mark.asyncio +async def test_list_findings_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_findings( + web_security_scanner.ListFindingsRequest(), + parent="parent_value", + filter="filter_value", + ) + + +def test_list_findings_pager(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_findings), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(), finding.Finding(),], + next_page_token="abc", + ), + web_security_scanner.ListFindingsResponse( + findings=[], next_page_token="def", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(),], next_page_token="ghi", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(),], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_findings(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, finding.Finding) for i in results) + + +def test_list_findings_pages(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client._transport.list_findings), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(), finding.Finding(),], + next_page_token="abc", + ), + web_security_scanner.ListFindingsResponse( + findings=[], next_page_token="def", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(),], next_page_token="ghi", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(),], + ), + RuntimeError, + ) + pages = list(client.list_findings(request={}).pages) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_findings_async_pager(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_findings), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(), finding.Finding(),], + next_page_token="abc", + ), + web_security_scanner.ListFindingsResponse( + findings=[], next_page_token="def", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(),], next_page_token="ghi", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(),], + ), + RuntimeError, + ) + async_pager = await client.list_findings(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, finding.Finding) for i in responses) + + +@pytest.mark.asyncio +async def test_list_findings_async_pages(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_findings), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(), finding.Finding(),], + next_page_token="abc", + ), + web_security_scanner.ListFindingsResponse( + findings=[], next_page_token="def", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(),], next_page_token="ghi", + ), + web_security_scanner.ListFindingsResponse( + findings=[finding.Finding(), finding.Finding(),], + ), + RuntimeError, + ) + pages = [] + async for page in (await client.list_findings(request={})).pages: + pages.append(page) + for page, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page.raw_page.next_page_token == token + + +def test_list_finding_type_stats(transport: str = "grpc"): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListFindingTypeStatsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_finding_type_stats), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListFindingTypeStatsResponse() + + response = client.list_finding_type_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, web_security_scanner.ListFindingTypeStatsResponse) + + +@pytest.mark.asyncio +async def test_list_finding_type_stats_async(transport: str = "grpc_asyncio"): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = web_security_scanner.ListFindingTypeStatsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_finding_type_stats), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListFindingTypeStatsResponse() + ) + + response = await client.list_finding_type_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, web_security_scanner.ListFindingTypeStatsResponse) + + +def test_list_finding_type_stats_field_headers(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListFindingTypeStatsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_finding_type_stats), "__call__" + ) as call: + call.return_value = web_security_scanner.ListFindingTypeStatsResponse() + + client.list_finding_type_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_finding_type_stats_field_headers_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = web_security_scanner.ListFindingTypeStatsRequest() + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_finding_type_stats), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListFindingTypeStatsResponse() + ) + + await client.list_finding_type_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_finding_type_stats_flattened(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._transport.list_finding_type_stats), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListFindingTypeStatsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_finding_type_stats(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +def test_list_finding_type_stats_flattened_error(): + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_finding_type_stats( + web_security_scanner.ListFindingTypeStatsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_finding_type_stats_flattened_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client._client._transport.list_finding_type_stats), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = web_security_scanner.ListFindingTypeStatsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + web_security_scanner.ListFindingTypeStatsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_finding_type_stats(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_finding_type_stats_flattened_error_async(): + client = WebSecurityScannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_finding_type_stats( + web_security_scanner.ListFindingTypeStatsRequest(), parent="parent_value", + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.WebSecurityScannerGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.WebSecurityScannerGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = WebSecurityScannerClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.WebSecurityScannerGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = WebSecurityScannerClient( + client_options={"scopes": ["1", "2"]}, transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.WebSecurityScannerGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + client = WebSecurityScannerClient(transport=transport) + assert client._transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.WebSecurityScannerGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.WebSecurityScannerGrpcAsyncIOTransport( + credentials=credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = WebSecurityScannerClient(credentials=credentials.AnonymousCredentials(),) + assert isinstance(client._transport, transports.WebSecurityScannerGrpcTransport,) + + +def test_web_security_scanner_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(exceptions.DuplicateCredentialArgs): + transport = transports.WebSecurityScannerTransport( + credentials=credentials.AnonymousCredentials(), + credentials_file="credentials.json", + ) + + +def test_web_security_scanner_base_transport(): + # Instantiate the base transport. + transport = transports.WebSecurityScannerTransport( + credentials=credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + "create_scan_config", + "delete_scan_config", + "get_scan_config", + "list_scan_configs", + "update_scan_config", + "start_scan_run", + "get_scan_run", + "list_scan_runs", + "stop_scan_run", + "list_crawled_urls", + "get_finding", + "list_findings", + "list_finding_type_stats", + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + +def test_web_security_scanner_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object(auth, "load_credentials_from_file") as load_creds: + load_creds.return_value = (credentials.AnonymousCredentials(), None) + transport = transports.WebSecurityScannerTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +def test_web_security_scanner_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(auth, "default") as adc: + adc.return_value = (credentials.AnonymousCredentials(), None) + WebSecurityScannerClient() + adc.assert_called_once_with( + scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +def test_web_security_scanner_transport_auth_adc(): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(auth, "default") as adc: + adc.return_value = (credentials.AnonymousCredentials(), None) + transports.WebSecurityScannerGrpcTransport( + host="squid.clam.whelk", quota_project_id="octopus" + ) + adc.assert_called_once_with( + scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +def test_web_security_scanner_host_no_port(): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions( + api_endpoint="websecurityscanner.googleapis.com" + ), + ) + assert client._transport._host == "websecurityscanner.googleapis.com:443" + + +def test_web_security_scanner_host_with_port(): + client = WebSecurityScannerClient( + credentials=credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions( + api_endpoint="websecurityscanner.googleapis.com:8000" + ), + ) + assert client._transport._host == "websecurityscanner.googleapis.com:8000" + + +def test_web_security_scanner_grpc_transport_channel(): + channel = grpc.insecure_channel("http://localhost/") + + # Check that if channel is provided, mtls endpoint and client_cert_source + # won't be used. + callback = mock.MagicMock() + transport = transports.WebSecurityScannerGrpcTransport( + host="squid.clam.whelk", + channel=channel, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=callback, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert not callback.called + + +def test_web_security_scanner_grpc_asyncio_transport_channel(): + channel = aio.insecure_channel("http://localhost/") + + # Check that if channel is provided, mtls endpoint and client_cert_source + # won't be used. + callback = mock.MagicMock() + transport = transports.WebSecurityScannerGrpcAsyncIOTransport( + host="squid.clam.whelk", + channel=channel, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=callback, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert not callback.called + + +@mock.patch("grpc.ssl_channel_credentials", autospec=True) +@mock.patch("google.api_core.grpc_helpers.create_channel", autospec=True) +def test_web_security_scanner_grpc_transport_channel_mtls_with_client_cert_source( + grpc_create_channel, grpc_ssl_channel_cred +): + # Check that if channel is None, but api_mtls_endpoint and client_cert_source + # are provided, then a mTLS channel will be created. + mock_cred = mock.Mock() + + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + transport = transports.WebSecurityScannerGrpcTransport( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + ) + assert transport.grpc_channel == mock_grpc_channel + + +@mock.patch("grpc.ssl_channel_credentials", autospec=True) +@mock.patch("google.api_core.grpc_helpers_async.create_channel", autospec=True) +def test_web_security_scanner_grpc_asyncio_transport_channel_mtls_with_client_cert_source( + grpc_create_channel, grpc_ssl_channel_cred +): + # Check that if channel is None, but api_mtls_endpoint and client_cert_source + # are provided, then a mTLS channel will be created. + mock_cred = mock.Mock() + + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + transport = transports.WebSecurityScannerGrpcAsyncIOTransport( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + ) + assert transport.grpc_channel == mock_grpc_channel + + +@pytest.mark.parametrize( + "api_mtls_endpoint", ["mtls.squid.clam.whelk", "mtls.squid.clam.whelk:443"] +) +@mock.patch("google.api_core.grpc_helpers.create_channel", autospec=True) +def test_web_security_scanner_grpc_transport_channel_mtls_with_adc( + grpc_create_channel, api_mtls_endpoint +): + # Check that if channel and client_cert_source are None, but api_mtls_endpoint + # is provided, then a mTLS channel will be created with SSL ADC. + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + # Mock google.auth.transport.grpc.SslCredentials class. + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + mock_cred = mock.Mock() + transport = transports.WebSecurityScannerGrpcTransport( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint=api_mtls_endpoint, + client_cert_source=None, + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + ) + assert transport.grpc_channel == mock_grpc_channel + + +@pytest.mark.parametrize( + "api_mtls_endpoint", ["mtls.squid.clam.whelk", "mtls.squid.clam.whelk:443"] +) +@mock.patch("google.api_core.grpc_helpers_async.create_channel", autospec=True) +def test_web_security_scanner_grpc_asyncio_transport_channel_mtls_with_adc( + grpc_create_channel, api_mtls_endpoint +): + # Check that if channel and client_cert_source are None, but api_mtls_endpoint + # is provided, then a mTLS channel will be created with SSL ADC. + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + # Mock google.auth.transport.grpc.SslCredentials class. + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + mock_cred = mock.Mock() + transport = transports.WebSecurityScannerGrpcAsyncIOTransport( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint=api_mtls_endpoint, + client_cert_source=None, + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_scan_config_path(): + project = "squid" + scan_config = "clam" + + expected = "projects/{project}/scanConfigs/{scan_config}".format( + project=project, scan_config=scan_config, + ) + actual = WebSecurityScannerClient.scan_config_path(project, scan_config) + assert expected == actual + + +def test_parse_scan_config_path(): + expected = { + "project": "whelk", + "scan_config": "octopus", + } + path = WebSecurityScannerClient.scan_config_path(**expected) + + # Check that the path construction is reversible. + actual = WebSecurityScannerClient.parse_scan_config_path(path) + assert expected == actual + + +def test_scan_run_path(): + project = "squid" + scan_config = "clam" + scan_run = "whelk" + + expected = "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}".format( + project=project, scan_config=scan_config, scan_run=scan_run, + ) + actual = WebSecurityScannerClient.scan_run_path(project, scan_config, scan_run) + assert expected == actual + + +def test_parse_scan_run_path(): + expected = { + "project": "octopus", + "scan_config": "oyster", + "scan_run": "nudibranch", + } + path = WebSecurityScannerClient.scan_run_path(**expected) + + # Check that the path construction is reversible. + actual = WebSecurityScannerClient.parse_scan_run_path(path) + assert expected == actual