| Server IP : 35.236.43.222 / Your IP : 216.73.216.143 Web Server : Apache System : Linux order-form-vm-001 5.10.0-37-cloud-amd64 #1 SMP Debian 5.10.247-1 (2025-12-11) x86_64 User : deploy ( 1002) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/lib/google-cloud-sdk/lib/surface/scc/findings/__pycache__/ |
Upload File : |
�
��� � �D � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlZddlZddlm Z ddl
mZ dd l
mZ dd
l
mZ ddl
mZ dd
lmZ ddlmZ ddlmZ ej ej j ej j ej j � � G d
� dej � � � � Zdd�ZdS )zdCommand to Filter an organization or source's findings and group them by their specified properties.� )�absolute_import)�division)�print_function)�unicode_literalsN)�securitycenter_client)�arg_parsers)�base)�flags)�util)�timesc �: � e Zd ZdZdddd�Zed� � � Zd� ZdS ) �GroupzZFilter an organization or source's findings and groups them by their specified properties.zF
To group across all sources provide a '-' as the source id.a'
Group findings under organization `123456` across all sources by their
category:
$ {command} 123456 --group-by="category"
Group findings under project `example-project` across all sources by
their category:
$ {command} projects/example-project --group-by="category"
Group findings under folders `456` across all sources by their
category:
$ {command} folders/456 --group-by="category"
Group findings under organization `123456` and source `5678`, by their
category:
$ {command} 123456 --source=5678 --group-by="category"
Group ACTIVE findings under organization `123456` and source `5678`,
by their category:
$ {command} 123456 --source=5678 --group-by="category"
--filter="state=\"ACTIVE\""
Group findings under organization `123456` and `location=eu` across
all sources by their category:
$ {command} 123456 --group-by="category" --location=euz�
This command uses the Security Command Center API. For more information,
see [Security Command Center API.](https://cloud.google.com/security-command-center/docs/reference/rest))�DESCRIPTION�EXAMPLESz
API REFERENCEc � � t j � � d � | � � t j � | � � t j � | � � t
j � | � � t
j � | � � t j � | � � t j � | � � | �
dd�� � | �
dd�� � | �
dt j dt j d �
� � d�� � d S )
Nr z--filtera�
Expression that defines the filter to apply across findings. The
expression is a list of one or more restrictions combined via logical
operators 'AND' and 'OR'. Parentheses are supported, and 'OR' has higher
precedence than 'AND'. Restrictions have the form
'<field> <operator> <value>' and may have a '-' character in front of
them to indicate negation. Examples include: name,
source_properties.a_property, security_marks.marks.marka.
The supported operators are:
* '=' for all value types.
* '>', '<', '>=', '<=' for integer values.
* ':', meaning substring matching, for strings.
The supported value types are:string literals in quotes, integer
literals without quotes, boolean literals 'true' and 'false' without
quotes. Some example filters: 'source_properties.size = 100',
'category=\"XSS\" AND event_time > 10' etc.)�helpz
--group-byaS
Expression that defines what findings fields to use for grouping
(including 'state'). String value should follow SQL syntax: comma
separated list of fields. For example: "parent,resource_name".
The following fields are supported:
* resource_name
* category
* state
* parentz--page-size� T)� unlimitedzx
Maximum number of results to return in a single response. Default is 10,
minimum is 1, maximum is 1000.)�typer )� scc_flags�AppendParentArg�AddToParser�PAGE_TOKEN_FLAG�READ_TIME_FLAGr
�COMPARE_DURATION_FLAG�SOURCE_FLAG�API_VERSION_FLAG�
LOCATION_FLAG�add_argumentr �
BoundedInt�sys�maxsize)�parsers �!lib/surface/scc/findings/group.py�Argsz
Group.ArgsP sD � � �����"�.�.�v�6�6�6�
��)�)�&�1�1�1�
��(�(��0�0�0� ��+�+�F�3�3�3� ��!�!�&�)�)�)�
��*�*�6�2�2�2�
��'�'��/�/�/�
����9� � � � �* ����� � � � � ����
�
#�A�s�{�d�
C�
C�
C�*� � � � � � � c �T � ddg}t j ||� � }t j |� � }|� � � }|� � � |_ |dk r�|� d� � rM|j |j _ t j |j j � � }t j |� � |j _ |� d� � rM|j
|j _ t j |j j � � }t j |� � |j _ |j |j _ |j |j _ |j |j _ |j |j _ t1 |||� � }t j |� � }|j � |� � } | S )N�compare_duration� read_time�v1)r � GetApiVersionUsingDeprecatedArgsr �GetMessages�6SecuritycenterOrganizationsSourcesFindingsGroupRequest�GroupFindingsRequest�groupFindingsRequest�IsKnownAndSpecifiedr( �compareDurationr �
ParseDuration�FormatDurationForJsonr) �readTime�
ParseDateTime�FormatDateTime�filter�group_by�groupBy� page_size�pageSize�
page_token� pageToken�_GenerateParentForGroupCommand� GetClient�organizations_sources_findingsr )
�self�args�deprecated_args�version�messages�request�compare_duration_iso�read_time_dt�client�results
r$ �Runz Group.Run� s� � �)�;�7�O��3�D�/�J�J�G�$�0��9�9�H��M�M�O�O�G�#+�#@�#@�#B�#B�G� � �$���
� !� !�"4� 5� 5�
�7;�7L��$�4�$�2��(�8�
�
��
�'�(<�=�=� �$�4�
� !� !�+� .� .�
�04���$�-��*��(�1�
�
�� 16�0D��1
� 1
��$�-� +/�+�G� �'�+/�=�G� �(�,0�N�G� �)�-1�_�G� �*�,�T�7�G�D�D�G�
"�
,�W�
5�
5�F�
�
2�
8�
8��
A�
A�F��Mr&