
    "                        S r SSKJr  SSKJr  SSKJr  SSK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QrSrS rS r\R4                  " \R6                  R8                  5       " S S\R:                  5      5       r\R4                  " \R6                  R>                  \R6                  R@                  5       " S S\5      5       r!g)z>Command to show Container Analysis Data for a specified image.    )absolute_import)division)unicode_literalsN)docker_name)container_data_util)util)filter_util)base)requests)flags)log)BUILDVULNERABILITYIMAGE
DEPLOYMENT	DISCOVERYz_^(?P<project>([^\/]+\.[^\/]+\/)?([^\/\.]+))\/(?P<repo>(us\.|eu\.|asia\.)?gcr.io)\/(?P<image>.*)c                    SU R                   ;  a  U $ [        R                  " [        U R                  5      nU(       d  U $ [
        R                  " 5       n[
        R                  " UR                  S5      5      nUR                  UR                  R                  R                  :X  a  [        R                  " S5        U $ [        R                  " SR                  UR                  S5      UR                  S5      5      5        [         R"                  " SR                  UR                  S5      SR                  UR                  S5      UR                  S5      5      U R$                  S	95      $ )
zConverts gcr.io repos on AR from pkg.dev->gcr.io.

Args:
  image_name: Image to convert to GCR.

Returns:
  The same image_name, but maybe in GCR format.
zpkg.devprojectzgcr.io repositories in Artifact Registry are only scanned if redirected. Redirect this project before checking scanning resultsz{Container Analysis API uses the gcr.io hostname for scanning results of gcr.io repositories. Using https://{}/{} instead...repoz {registry}/{repository}@{sha256}z{}/{}image)registry
repositorysha256)r   rematchGCR_REPO_REGEXr   ar_requestsGetMessagesGetProjectSettingsgrouplegacyRedirectionStateProjectSettings%LegacyRedirectionStateValueValuesEnum REDIRECTION_FROM_GCR_IO_DISABLEDr   warningformatr   Digestdigest)
image_namematchesmessagessettingss       (lib/surface/container/images/describe.pyMaybeConvertToGCRr.   .   s4    j))) HH^Z%:%:;'	$$&(++GMM),DE(%%		!	!	G	G	h	hi KK	N ++==CV
--
y!9> 
		(//==(^^mmI&g(> "" 0 
     c                 0    [         R                  " U SSS9  g )NdescribeF)verbrepeated)r   AddTagOrDigestPositionalparsers    r-   _CommonArgsr7   ]   s      j5Ir/   c                   .    \ rS rSrSr\S 5       rS rSrg)Describeb   a  Lists information about the specified image.

## EXAMPLES

Describe the specified image:

  $ {command} gcr.io/myproject/myimage@digest

        Or:

  $ {command} gcr.io/myproject/myimage:tag

Find the digest for a tag:

  $ {command} gcr.io/myproject/myimage:tag \
    --format="value(image_summary.digest)"

        Or:

  $ {command} gcr.io/myproject/myimage:tag \
    --format="value(image_summary.fully_qualified_digest)"

c                     [        U 5        g )N)r7   r5   s    r-   ArgsDescribe.Args|   s
    r/   c                 2   [         R                  " UR                  5         [        [         R                  " UR                  5      5      n[
        R                  " UR                  UR                  UR                  S9sSSS5        $ ! , (       d  f       g= f).  This is what gets called when the user runs this command.

Args:
  args: an argparse namespace. All the arguments that were provided to this
    command invocation.

Raises:
  InvalidImageNameError: If the user specified an invalid image name.
Returns:
  Some value that we want to have printed later.
r   r   r(   N)
r   WrapExpectedDockerlessErrorsr)   r.   GetDigestFromNamer   ContainerDatar   r   r(   )selfargsimg_names      r-   RunDescribe.Run   sb     
	*	*4??	;"4#9#9$//#JKh ..$$((" 
<	;	;s   AB
B N	__name__
__module____qualname____firstlineno____doc__staticmethodr<   rG   __static_attributes__rI   r/   r-   r9   r9   b   s     0  "r/   r9   c                   .    \ rS rSrSr\S 5       rS rSrg)DescribeAlphaAndBeta   a  Lists container analysis data for a given image.

Lists container analysis data for a valid image.

## EXAMPLES

Describe the specified image:

  $ {command} gcr.io/myproject/myimage@digest

        Or:

  $ {command} gcr.io/myproject/myimage:tag

Find the digest for a tag:

  $ {command} gcr.io/myproject/myimage:tag \
    --format="value(image_summary.digest)"

        Or:

  $ {command} gcr.io/myproject/myimage:tag \
    --format="value(image_summary.fully_qualified_digest)"

See package vulnerabilities found by the Container Analysis API for the
specified image:

  $ {command} gcr.io/myproject/myimage@digest --show-package-vulnerability
c                     [        U 5        U R                  SSSS9  U R                  SSSS9  U R                  S	SS
S9  U R                  SSSS9  U R                  SSSS9  U R                  SSSS9  g )Nz--metadata-filter zPAdditional filter to fetch metadata for a given fully qualified image reference.)defaulthelpz--show-build-details
store_truez%Include build metadata in the output.)actionrX   z--show-package-vulnerabilityz-Include vulnerability metadata in the output.z--show-image-basisz*Include base image metadata in the output.z--show-deploymentz*Include deployment metadata in the output.z--show-all-metadataz#Include all metadata in the output.)r7   add_argumentr5   s    r-   r<   DescribeAlphaAndBeta.Args   s     9  ;
 4  6 &<  > 9  ; 9  ; 2  4r/   c                    / nUR                   (       a  UR                  S5        UR                  (       a"  UR                  S5        UR                  S5        UR                  (       a  UR                  S5        UR                  (       a  UR                  S5        UR
                  (       a  [        nU(       d  UR                  (       Ga  [        R                  " 5       nUR                  U5        UR                  UR                  5        [        R                  " UR                  5         [        [        R                   " UR                  5      5      nUR#                  SR%                  U5      /5        [        R&                  " XC5      nUR(                  R*                  (       d$  UR                   (       d  UR
                  (       d  U?UR,                  R.                  (       d$  UR                  (       d  UR
                  (       d  U?UR0                  R2                  (       d$  UR                  (       d  UR
                  (       d  U?UR4                  R6                  (       d$  UR                  (       d  UR
                  (       d  U?UR8                  R:                  (       d$  UR                  (       d  UR
                  (       d  U?UsSSS5        $ [        R                  " UR                  5         [        [        R                   " UR                  5      5      n[<        R>                  " UR@                  URB                  URD                  S9sSSS5        $ ! , (       d  f       g= f! , (       d  f       g= f)	r?   r   r   r   r   r   z
https://{}Nr@   )#show_build_detailsappendshow_package_vulnerabilityshow_image_basisshow_deploymentshow_all_metadata_DEFAULT_KINDSmetadata_filterr	   ContainerAnalysisFilter	WithKindsWithCustomFilterr   rA   r)   r.   rB   WithResourcesr&   TransformContainerAnalysisDatabuild_details_summarybuild_detailspackage_vulnerability_summaryvulnerabilitiesdiscovery_summary	discoveryimage_basis_summarybase_imagesdeployment_summarydeploymentsr   rC   r   r   r(   )rD   rE   filter_kindsfrF   datas         r-   rG   DescribeAlphaAndBeta.Run   sK    L'"&&/*+&'",'#lt+++

-
-
/akk,--.,,T__=$T%;%;DOO%LM 	
,,X678228?**88''0F0F(22BB//8N8N0&&00//8N8N$((44%%d.D.D&''33$$T-C-C%- >=0 ,,T__=$T%;%;DOO%LM"00&&**??$ >=1 >=0 >=s   -FM4AM,
M),
M:rI   NrJ   rI   r/   r-   rS   rS      s     < 4 4<=$r/   rS   )"rO   
__future__r   r   r   r   containerregistry.clientr   'googlecloudsdk.api_lib.container.imagesr   r   (googlecloudsdk.api_lib.containeranalysisr	   googlecloudsdk.callioper
   $googlecloudsdk.command_lib.artifactsr   r   $googlecloudsdk.command_lib.containerr   googlecloudsdk.corer   rd   r   r.   r7   ReleaseTracksReleaseTrackGADescribeCommandr9   ALPHABETArS   rI   r/   r-   <module>r      s    E &  ' 	 0 G 8 @ ( H 6 # t,^J
 D%%(()/"t## /" */"d D%%++T->->-C-CD{$8 {$ E{$r/   