
    3                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SS	KJr  SS
KJr  SS	KJr  SS
KJr  SSKJr  SSKJr  \R,                  " \R.                  R0                  \R.                  R2                  \R.                  R4                  5      \R6                   " S S\R8                  5      5       5       rSS jrg)z9Command for listing an organization or source's findings.    )absolute_import)division)print_function)unicode_literals)
list_pager)securitycenter_client)base)flags)util)
properties)timesc                       \ rS rSrSrSS\R                  R                  R                  R                  5        S3SS.r
\S 5       rS	 rS
rg)List#   z*List an organization or source's findings.zz
          List an organization or source's findings. To list across all
          sources provide a '-' as the source id.a  
          List all ACTIVE findings under organization `123456` across all
          sources:

            $ {command} 123456 --filter="state=\"ACTIVE\""

          List all ACTIVE findings under project `abc` across all sources:

            $ {command} projects/abc --filter="state=\"ACTIVE\""

          List all ACTIVE findings under folder `456` across all sources:

            $ {command} folders/456 --filter="state=\"ACTIVE\""

          List all ACTIVE findings under organization `123456` and source
          `5678`:

            $ {command} 123456 --source=5678 --filter="state=\"ACTIVE\""

          Only list category and resource_name of all ACTIVE findings under
          organization `123456` and source `5678`:

            $ {command} 123456 --source=5678  --filter="state=\"ACTIVE\""
              --field-mask="finding.category,finding.resource_name"

          List all ACTIVE findings of XSS category/type, under organization
          `123456` and source `5678`:

            $ {command} 123456 --source=5678
              --filter="state=\"ACTIVE\" AND category=\"XSS\""

          List all findings attached to a particular resource under organization
          `123456`:

            $ {command} 123456
              --filter="resource_name=\"//container.a  /projects/pid/zones/zone-id/clusters/cluster-id\""

          List all ACTIVE findings that took place on `2019-01-01T01:00:00 GMT`
          time, under organization `123456`:

            $ {command} 123456
              --filter="state=\"ACTIVE\" AND event_time > 1546304400000""

          List all findings under organization `123456` across all sources and
          `location=eu`:

            $ {command} 123456 --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                 p   [         R                  R                  U 5        [        R                  " 5       S   R                  U 5        [        R                  " U 5        [        R                  R                  U 5        [        R                  R                  U 5        [        R                  R                  U 5        [        R                  R                  U 5        [        R                  R                  U 5        [        R                  R                  U 5        U R                  SSS9  U R                  SSS9  g )Nr   z--field-maska  
        Field mask to specify the finding fields listed in the response. An
        empty field mask will list all fields. For example:
        --field-mask="finding.category,finding.resource_name" will only output
        category and resource_name for the findings in addition to default
        attributes. Notice the difference between hyphens (-) used with flags
        v/s camel case used in field masks. An empty or missing field mask will
        list all fields.)helpz
--order-bya$  
        Expression that defines what fields and order to use for sorting.
        String value should follow SQL syntax: comma separated list of fields.
        For example: "name,resource_properties.a_property". The default sorting
        order is ascending. To specify descending order for a field, a suffix "
        desc" should be appended to the field name. For example:
        --order-by="name desc,source_properties.a_property" will order by name
        in descending order while source_properties.a_property in ascending
        order.)r	   URI_FLAGRemoveFromParser	scc_flagsAppendParentArgAddToParserr
   AddParentGroupPAGE_TOKEN_FLAGREAD_TIME_FLAGCOMPARE_DURATION_FLAGSOURCE_FLAGAPI_VERSION_FLAGLOCATION_FLAGadd_argument)parsers     lib/surface/scc/findings/list.pyArgs	List.Argsd   s     	MM""6* "..v6	 ))&1((0	++F3	!!&)**62''/
  
       c                    SS/n[         R                  " X5      n[        R                  " U5      nUR	                  5       nUS:X  a  UR                  S5      (       aL  UR                  Ul        [        R                  " UR                  5      n[        R                  " U5      Ul        UR                  S5      (       aL  UR                  Ul        [        R                  " UR                  5      n[        R                  " U5      Ul        UR                  Ul        UR                   b%  ["        R$                  " UR                   5      Ul        UR&                  Ul        SUl        UR(                  Ul        UR,                  Ul        UR0                  Ul        UR4                  Ul        [7        XU5      n[        R8                  " U5      n[:        R<                  " UR>                  USUR,                  SS9$ )Ncompare_duration	read_timev1 pageSizelistFindingsResults)batch_size_attribute
batch_sizefield) r    GetApiVersionUsingDeprecatedArgsr   GetMessages5SecuritycenterOrganizationsSourcesFindingsListRequestIsKnownAndSpecifiedr(   compareDurationr   ParseDurationFormatDurationForJsonr)   readTimeParseDateTimeFormatDateTime
field_mask	fieldMaskscc_utilCleanUpUserMaskInputfilterorder_byorderBy	page_sizer,   
page_token	pageTokenparent_GenerateParent	GetClientr   YieldFromListorganizations_sources_findings)	selfargsdeprecated_argsversionmessagesrequestcompare_duration_isoread_time_dtclients	            r#   RunList.Run   s   );7O33DJG$009HLLNG $		!	!"4	5	5"&"7"7$2273J3JK"'"="= #
 
	!	!+	.	.>>**7+;+;< //=G$"778I8IJg[[GNDKmmGO~~GG[[GNdW5G",,W5F ##--'>># r&    N)__name__
__module____qualname____firstlineno____doc__r   VALUEScoreuniverse_domainGetdetailed_helpstaticmethodr$   rS   __static_attributes__rU   r&   r#   r   r   #   sl    
 35#6F 7A6G6G6L6L6\6\6`6`6b5c d/G.2`rk8-t ' 'R,r&   r   c                     [         R                  " U 5        U R                  (       a!  SU R                  ;   a  U R                  U l        [         R                  " X5      Ul        U$ )zGenerates a finding's parent using org and source and hook up filter.

Args:
  args: (argparse namespace)
  req: request
  version: API version for the request

Returns:
  req: Modified request
z	/sources/)r   ValidateMutexOnSourceAndParentrE   sourceGetFullSourceName)rK   reqrM   s      r#   rF   rF      sF     %%d+	[[[DKK/++DK%%d4#*	*r&   N)r*   )rZ   
__future__r   r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.sccr   googlecloudsdk.callioper	   googlecloudsdk.command_lib.sccr
   r   r   r=   'googlecloudsdk.command_lib.scc.findingsgooglecloudsdk.corer   googlecloudsdk.core.utilr   ReleaseTracksReleaseTrackGABETAALPHADefaultUniverseOnlyListCommandr   rF   rU   r&   r#   <module>rv      s    @ &  % ' ' < ( = ; 9 8 * *
 $++00$2C2C2I2I S4 S Slr&   