Ë
    tPêjÀ  ã                  ó¶   — d Z ddlmZ ddlZddlmZ ddlmZ ddlZddl	m
Z
mZ ddlmZ ddlmZmZmZmZmZmZmZ  ej,                  e«      Z G d	„ d
e«      Zy)zx
Functionality for using the [PyPI](https://warehouse.pypa.io/api-reference/json.html)
API as a `VulnerabilityService`.
é    )ÚannotationsN)ÚPath)Úcast)ÚInvalidVersionÚVersion)Úcaching_session)ÚConnectionErrorÚ
DependencyÚResolvedDependencyÚServiceErrorÚSkippedDependencyÚVulnerabilityResultÚVulnerabilityServicec                  ó2   — e Zd ZdZ	 d	 	 	 	 	 	 	 dd„Zdd„Zy)ÚPyPIServicez}
    An implementation of `VulnerabilityService` that uses PyPI to provide Python
    package vulnerability information.
    Nc                ó2   — t        |«      | _        || _        y)a«  
        Create a new `PyPIService`.

        `cache_dir` is an optional cache directory to use, for caching and reusing PyPI API
        requests. If `None`, `pip-audit` will attempt to use `pip`'s cache directory before falling
        back on its own default cache directory.

        `timeout` is an optional argument to control how many seconds the component should wait for
        responses to network requests.
        N)r   ÚsessionÚtimeout)ÚselfÚ	cache_dirr   Úkwargss       ú\/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/pip_audit/_service/pypi.pyÚ__init__zPyPIService.__init__#   s   € ô ' yÓ1ˆŒØˆ�ó    c                ó   — |j                  «       r|g fS t        t        |«      }d|j                  › dt	        |j
                  «      › d�}	 | j                  j                  || j                  ¬«      }|j                  «        |j+                  «       }g }|j                  d«      }|€||fS |D ]è  }	|	d   }
|	j                  d«      }|�t         j#                  d|
› d|› �«       Œ7	 |	d   D �cg c]  }t-        |«      ‘Œ }}|j1                  «        |	j                  d«      }|€|	j                  d«      }|€d}|j3                  dd«      }|j5                  t7        j8                  |
g|	d   ¢||| j;                  |	j                  d«      «      ¬«      «       Œê ||fS # t        j                  $ r t        d«      ‚t        j                  $ r t        d«      ‚t        j                  $ rk}j                  dk(  rPd|j                  › d	|j
                  › d
�}t         j#                  |«       t%        |j&                  |¬«      g fcY d}~S t(        |‚d}~ww xY wc c}w # t.        $ r}t)        d|	d   › �«      |‚d}~ww xY w)zs
        Queries PyPI for the given `Dependency` specification.

        See `VulnerabilityService.query`.
        zhttps://pypi.org/pypi/ú/z/json)Úurlr   z PyPI is not redirecting properlyz.Could not connect to PyPI's vulnerability feedi”  z7Dependency not found on PyPI and could not be audited: z (ú))ÚnameÚskip_reasonNÚvulnerabilitiesÚidÚ	withdrawnzPyPI vuln entry 'z' marked as withdrawn at Úfixed_inz&Received malformed version from PyPI: ÚsummaryÚdetailszN/Aú
ú ÚaliasesÚ	published)ÚidsÚdescriptionÚfix_versionsr*   )Ú
is_skippedr   r   Úcanonical_nameÚstrÚversionr   Úgetr   Úraise_for_statusÚrequestsÚTooManyRedirectsr	   ÚConnectTimeoutÚ	HTTPErrorÚstatus_codeÚloggerÚdebugr   r   r   Újsonr   r   ÚsortÚreplaceÚappendr   ÚcreateÚ_parse_rfc3339)r   Úspecr   ÚresponseÚ
http_errorr    Úresponse_jsonÚresultsÚvulnsÚvr"   Úwithdrawn_atr$   r-   Úivr,   s                   r   ÚqueryzPyPIService.query3   sŸ  € ð �?‰?ÔØ˜�8ˆOÜÔ&¨Ó-ˆà& t×':Ñ':Ð&;¸1¼SÀÇÁÓ=NÐ<OÈuÐUˆð	/Ø*.¯,©,×*:Ñ*:¸sÈDÏLÉLÐ*:Ó*YˆHØ×%Ñ%Ô'ð. !Ÿ™›ˆØ-/ˆØ×!Ñ!Ð"3Ó4ˆð ˆ=Ø˜�=Ð àò &	ˆAØ�4‘ˆBð Ÿ5™5 Ó-ˆLØÐ'Ü—‘Ð0°°Ð4MÈlÈ^Ð\Ô]ØðeØBCÀJÁ-ÖP°h¤¨Õ 1ÐP�ÐPð
 ×ÑÔàŸ%™% 	Ó*ˆKØÐ"ØŸe™e IÓ.�àÐ"Ø#�ð &×-Ñ-¨d°CÓ8ˆKà�N‰NÜ#×*Ñ*ØÐ+˜a 	™lÐ+Ø +Ø!-Ø"×1Ñ1°!·%±%¸Ó2DÓEô	õð?&	ðP �Wˆ}ÐøôM ×(Ñ(ò 	Fô "Ð"DÓEÐEÜ×&Ñ&ò 	Tô "Ð"RÓSÐSÜ×!Ñ!ò 	/Ø×#Ñ# sÒ*àMØ×*Ñ*Ð+¨2¨d¯l©l¨^¸1ð>ð ô —‘˜[Ô)Ü(¨d¯i©iÀ[ÔQÐSUÐUÕUÜ JÐ.ûð	/üò:  QøÜ!ò eÜ"Ð%KÈAÈjÉMÈ?Ð#[Ó\ÐbdÐdûðeúsP   Á7F Ã&IÃ-IÃ?IÆAIÇ*AIÉIÉ	IÉIÉIÉ	I=É&I8É8I=)NN)r   zPath | Noner   z
int | Noner   ÚdictÚreturnÚNone)rA   r
   rL   z,tuple[Dependency, list[VulnerabilityResult]])Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   rJ   © r   r   r   r      s9   „ ñð DHðØ$ðØ6@ðØSWðà	óô Ur   r   )rQ   Ú
__future__r   ÚloggingÚpathlibr   Útypingr   r4   Úpackaging.versionr   r   Úpip_audit._cacher   Úpip_audit._service.interfacer	   r
   r   r   r   r   r   Ú	getLoggerrN   r9   r   rR   r   r   ú<module>r[      sS   ðñõ
 #ã Ý Ý ã ß 5å ,÷÷ ñ ð 
ˆ×	Ñ	˜8Ó	$€ôkÐ&õ kr   