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