Client for Web Security Scanner API#

class google.cloud.websecurityscanner_v1beta.WebSecurityScannerClient(transport=None, channel=None, credentials=None, client_config=None, client_info=None, client_options=None)[source]#

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.

Constructor.

Parameters
  • (Union[WebSecurityScannerGrpcTransport, (transport) – 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.

create_scan_config(parent, scan_config, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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)
Parameters
  • 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, ScanConfig]) –

    Required. The ScanConfig to be created.

    If a dict is provided, it must be of the same form as the protobuf message ScanConfig

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • 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 ScanConfig instance.

Raises
delete_scan_config(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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)
Parameters
  • 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 not be retried.

  • 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
enums = <module 'google.cloud.websecurityscanner_v1beta.gapic.enums' from '/usr/local/lib/python3.7/site-packages/google/cloud/websecurityscanner_v1beta/gapic/enums.py'>#
classmethod finding_path(project, scan_config, scan_run, finding)[source]#

Return a fully-qualified finding string.

classmethod from_service_account_file(filename, *args, **kwargs)[source]#

Creates an instance of this client using the provided credentials file.

Parameters
  • 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

The constructed client.

Return type

WebSecurityScannerClient

classmethod from_service_account_json(filename, *args, **kwargs)#

Creates an instance of this client using the provided credentials file.

Parameters
  • 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

The constructed client.

Return type

WebSecurityScannerClient

get_finding(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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)
Parameters
  • 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 not be retried.

  • 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 Finding instance.

Raises
get_scan_config(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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)
Parameters
  • 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 not be retried.

  • 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 ScanConfig instance.

Raises
get_scan_run(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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)
Parameters
  • 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 not be retried.

  • 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 ScanRun instance.

Raises
list_crawled_urls(parent, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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
Parameters
  • 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 not be retried.

  • 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 PageIterator instance. An iterable of CrawledUrl instances. You can also iterate over the pages of the response using its pages property.

Raises
list_finding_type_stats(parent, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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)
Parameters
  • 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 not be retried.

  • 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 ListFindingTypeStatsResponse instance.

Raises
list_findings(parent, filter_, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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
Parameters
  • 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) – 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 not be retried.

  • 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 PageIterator instance. An iterable of Finding instances. You can also iterate over the pages of the response using its pages property.

Raises
list_scan_configs(parent, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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
Parameters
  • 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 not be retried.

  • 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 PageIterator instance. An iterable of ScanConfig instances. You can also iterate over the pages of the response using its pages property.

Raises
list_scan_runs(parent, page_size=None, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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
Parameters
  • 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 not be retried.

  • 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 PageIterator instance. An iterable of ScanRun instances. You can also iterate over the pages of the response using its pages property.

Raises
classmethod project_path(project)[source]#

Return a fully-qualified project string.

classmethod scan_config_path(project, scan_config)[source]#

Return a fully-qualified scan_config string.

classmethod scan_run_path(project, scan_config, scan_run)[source]#

Return a fully-qualified scan_run string.

start_scan_run(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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)
Parameters
  • 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 not be retried.

  • 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 ScanRun instance.

Raises
stop_scan_run(name, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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)
Parameters
  • 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 not be retried.

  • 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 ScanRun instance.

Raises
update_scan_config(scan_config, update_mask, retry=<object object>, timeout=<object object>, metadata=None)[source]#

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)
Parameters
  • scan_config (Union[dict, 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 ScanConfig

  • update_mask (Union[dict, 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 FieldMask

  • retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • 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 ScanConfig instance.

Raises