feat: Add new gcloud commands, API clients, and third-party libraries across various services.

This commit is contained in:
2026-01-01 20:26:35 +01:00
parent 5e23cbece0
commit a19e592eb7
25221 changed files with 8324611 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 Google LLC. 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.
"""The command group for the Cloud Web Security Scanner CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class WebSecurityScanner(base.Group):
"""Manage Cloud Web Security Scanner resources.
Commands for managing Google Cloud Web Security Scanner resources.
"""
category = base.SECURITY_CATEGORY
def Filter(self, context, args):
# TODO(b/190541292): Determine if command group works with project number
base.RequireProjectID(args)
del context, args

View File

@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 Google LLC. 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.
"""The command group for the Cloud Web Security Scanner scan configs CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ScanConfigs(base.Group):
"""Manage Cloud Web Security Scanner scan configs resources.
Commands for managing Google Cloud Web Security Scanner scan configs
resources.
"""

View File

@@ -0,0 +1,48 @@
# Copyright 2019 Google LLC. 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.
- release_tracks: [ALPHA]
help_text:
brief: Create a Web Security Scanner ScanConfig.
description: |
Creates a Web Security Scanner ScanConfig.
examples: |
The following command creates a scan config named "my-scan-config":
$ {command} --display-name=my-scan-config
request:
collection: websecurityscanner.projects.scanConfigs
modify_request_hooks:
- googlecloudsdk.command_lib.web_security_scanner.auth:SetScanConfigAuth
arguments:
resource:
help_text: Something about a project
spec: !REF googlecloudsdk.command_lib.web_security_scanner.resources:project
is_parent_resource: true
params:
- _REF_: googlecloudsdk.command_lib.web_security_scanner.flags:display_name
required: true
- _REF_: googlecloudsdk.command_lib.web_security_scanner.flags:starting_urls
required: true
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:max_qps
- group:
params:
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:schedule_interval_days
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:schedule_next_start
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:target_platforms
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:user_agent
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:blacklist_patterns
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:export_to_security_center
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:risk_level
additional_arguments_hook: googlecloudsdk.command_lib.web_security_scanner.auth:AuthFlags

View File

@@ -0,0 +1,33 @@
# Copyright 2019 Google LLC. 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.
- release_tracks: [ALPHA]
help_text:
brief: Delete a scan config.
description: Delete a scan config.
examples: |
The following command deletes the specified scan config:
$ {command} SCAN_CONFIG
request:
collection: websecurityscanner.projects.scanConfigs
api_version: v1beta
arguments:
resource:
help_text: Scan config to delete.
spec: !REF googlecloudsdk.command_lib.web_security_scanner.resources:scan_config
is_positional: true

View File

@@ -0,0 +1,33 @@
# Copyright 2019 Google LLC. 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.
- release_tracks: [ALPHA]
help_text:
brief: Describe a scan config.
description: Describe a scan config.
examples: |
The following command describes the given scan config:
$ {command} SCAN_CONFIG
request:
collection: websecurityscanner.projects.scanConfigs
api_version: v1beta
arguments:
resource:
help_text: Scan config to get.
spec: !REF googlecloudsdk.command_lib.web_security_scanner.resources:scan_config
is_positional: true

View File

@@ -0,0 +1,37 @@
# Copyright 2019 Google LLC. 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.
- release_tracks: [ALPHA]
help_text:
brief: List all scan configs.
description: List all scan configs.
examples: |
The following commands list all the scan configs in the given project:
$ {command} --project=testProject
$ {command} --project=testProject --limit=5
request:
collection: websecurityscanner.projects.scanConfigs
api_version: v1beta
response:
id_field: name
arguments:
resource:
help_text: Project to list scan configs for.
spec: !REF googlecloudsdk.command_lib.web_security_scanner.resources:project

View File

@@ -0,0 +1,50 @@
# Copyright 2019 Google LLC. 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.
- release_tracks: [ALPHA]
help_text:
brief: Update a Web Security Scanner ScanConfig.
description: |
Updates a Web Security Scanner ScanConfig.
examples: |
The following commands update the attributes of the specified scan config:
$ {command} SCAN_CONFIG --user-agent=CHROME_ANDROID
$ {command} SCAN_CONFIG --auth-type=google --auth-user=username@gmail.com --auth-password=password
$ {command} SCAN_CONFIG --auth-type=custom --auth-user=username --auth-password=password --auth-url=http://example.com/login
request:
collection: websecurityscanner.projects.scanConfigs
modify_request_hooks:
- googlecloudsdk.command_lib.web_security_scanner.auth:SetScanConfigAuth
- googlecloudsdk.command_lib.web_security_scanner.auth:AddAuthFieldMask
arguments:
resource:
help_text: Scan config to update.
spec: !REF googlecloudsdk.command_lib.web_security_scanner.resources:scan_config
is_positional: true
params:
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:display_name
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:starting_urls
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:max_qps
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:schedule_interval_days
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:schedule_next_start
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:target_platforms
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:user_agent
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:blacklist_patterns
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:export_to_security_center
- !REF googlecloudsdk.command_lib.web_security_scanner.flags:risk_level
additional_arguments_hook: googlecloudsdk.command_lib.web_security_scanner.auth:AuthFlags

View File

@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 Google LLC. 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.
"""The command group for the Cloud Web Security Scanner scan runs CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ScanRuns(base.Group):
"""Manage Cloud Web Security Scanner scan runs resources.
Commands for managing Google Cloud Web Security Scanner scan runs resources.
"""

View File

@@ -0,0 +1,35 @@
# Copyright 2019 Google LLC. 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.
- release_tracks: [ALPHA]
help_text:
brief: Describe a scan run.
description: Describe a scan run.
examples: |
The following commands describe the given scan run:
$ {command} SCAN_RUN --scan-config=SCAN_CONFIG
$ {command} SCAN_RUN
request:
collection: websecurityscanner.projects.scanConfigs.scanRuns
api_version: v1beta
arguments:
resource:
help_text: Scan run to describe.
spec: !REF googlecloudsdk.command_lib.web_security_scanner.resources:scan_run
is_positional: true

View File

@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 Google LLC. 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.
"""The command group for the Cloud Web Security Scanner findings CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Findings(base.Group):
"""Manage Cloud Web Security Scanner findings resources.
Commands for managing Google Cloud Web Security Scanner findings resources.
"""

View File

@@ -0,0 +1,108 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 Google LLC. 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.
"""findings list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import itertools
from apitools.base.py import exceptions as apitools_exceptions
from apitools.base.py import list_pager
from googlecloudsdk.api_lib.web_security_scanner import wss_base
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.web_security_scanner import resource_args
HTTP_ERROR_FORMAT = (
'ResponseError: code={status_code}, message={status_message}')
@wss_base.UseWebSecurityScannerApi(wss_base.WebSecurityScannerApiVersion.V1BETA)
class List(base.ListCommand, wss_base.WebSecurityScannerCommand):
"""List all the findings for a given scan run."""
detailed_help = {
'EXAMPLES':
"""\
To list all the findings for a given scan run, run:
$ {command} SCAN_RUN
""",
}
@staticmethod
def Args(parser):
"""Args is called by calliope to gather arguments for this command.
Args:
parser: An argparse parser that you can use to add arguments that go on
the command line after this command. Positional arguments are allowed.
"""
resource_args.AddScanRunResourceArg(parser)
def Run(self, args):
"""Run 'list findings'.
Args:
args: argparse.Namespace, The arguments that this command was invoked
with.
Returns:
All the scan findings for a given scan run
Raises:
HttpException: An http error response was received while executing api
request.
"""
scan_run_ref = args.CONCEPTS.scan_run.Parse()
try:
# get all existing finding types via ListFindingTypeStats.
list_finding_type_stats_response = \
self.client.projects_scanConfigs_scanRuns_findingTypeStats.List(
request=self.messages.
WebsecurityscannerProjectsScanConfigsScanRunsFindingTypeStatsListRequest(
parent=scan_run_ref.RelativeName()))
finding_types = []
for finding_type_stats in \
list_finding_type_stats_response.findingTypeStats:
finding_types.append(finding_type_stats.findingType)
# get paged findings for each type
all_findings = []
for finding_type in finding_types:
request = (
self.messages
.WebsecurityscannerProjectsScanConfigsScanRunsFindingsListRequest(
parent=scan_run_ref.RelativeName(),
filter='finding_type=' + finding_type))
all_findings.append(
list_pager.YieldFromList(
self.client.projects_scanConfigs_scanRuns_findings,
request,
field='findings',
batch_size_attribute=None))
return [
finding for finding in itertools.chain.from_iterable(all_findings)
]
except apitools_exceptions.HttpError as error:
raise exceptions.HttpException(error, HTTP_ERROR_FORMAT)

View File

@@ -0,0 +1,36 @@
# Copyright 2019 Google LLC. 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.
- release_tracks: [ALPHA]
help_text:
brief: List scan runs for a scan config.
description: List scan runs for a scan config.
examples: |
The following command lists scan runs for the given scan config:
$ {command} --scan-config SCAN_CONFIG
request:
collection: websecurityscanner.projects.scanConfigs.scanRuns
api_version: v1beta
response:
id_field: name
arguments:
resource:
help_text: Scan config to get scan runs for.
spec: !REF googlecloudsdk.command_lib.web_security_scanner.resources:scan_config
is_positional: false

View File

@@ -0,0 +1,39 @@
# Copyright 2019 Google LLC. 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.
- release_tracks: [ALPHA]
help_text:
brief: List crawled URLs for a scan run.
description: List crawled URLs for a scan run.
examples: |
The following commands delete the specified scan config:
$ {command} --scan-run=SCAN_RUN
$ {command} --scan-run=SCAN_RUN_ID --scan-config=SCAN_CONFIG_ID --project=testProject --limit=5
command_type: LIST
request:
method: list
collection: websecurityscanner.projects.scanConfigs.scanRuns.crawledUrls
api_version: v1beta
arguments:
resource:
help_text: Scan run to list crawled URLs for.
spec: !REF googlecloudsdk.command_lib.web_security_scanner.resources:scan_run
is_positional: false
is_parent_resource: true

View File

@@ -0,0 +1,34 @@
# Copyright 2019 Google LLC. 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.
- release_tracks: [ALPHA]
help_text:
brief: Start a scan run for a scan config.
description: Start a scan run for a scan config.
examples: |
The following command starts a scan run for the given scan config:
$ {command} SCAN_CONFIG
request:
method: start
collection: websecurityscanner.projects.scanConfigs
api_version: v1beta
arguments:
resource:
help_text: Scan config to start a scan run for.
spec: !REF googlecloudsdk.command_lib.web_security_scanner.resources:scan_config
is_positional: true

View File

@@ -0,0 +1,34 @@
# Copyright 2019 Google LLC. 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.
- release_tracks: [ALPHA]
help_text:
brief: Stop a scan run.
description: Stop a scan run.
examples: |
The following command stops the given scan run:
$ {command} SCAN_RUN
request:
method: stop
collection: websecurityscanner.projects.scanConfigs.scanRuns
api_version: v1beta
arguments:
resource:
help_text: Scan run to stop.
spec: !REF googlecloudsdk.command_lib.web_security_scanner.resources:scan_run
is_positional: true