Ë
    tPêjG  ã                  ó„  — d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZmZ ddlmZ dd	lmZ  ed
e«      Zdd„Z e	d¬«       G d„ d«      «       Z e	d¬«       G d„ de«      «       Z e	d¬«       G d„ de«      «       Z e	d¬«       G d„ d«      «       Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)z‡
Interfaces for interacting with vulnerability services, i.e. sources
of vulnerability information for fully resolved Python packages.
é    )Úannotations)ÚABCÚabstractmethod)ÚIterator)Ú	dataclassÚreplace)Údatetime)ÚAnyÚNewType)Úcanonicalize_name)ÚVersionÚVulnerabilityIDc                óL   — | j                  d«      ry| j                  d«      ryy)NÚPYSECé   ÚCVEé   é   )Ú
startswith)Úids    úa/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/pip_audit/_service/interface.pyÚ_id_comparison_keyr      s#   € Ø	‡}�}�WÔØØ	�‰�uÔ	ØØó    T)Úfrozenc                  ó@   — e Zd ZU dZded<   	 dd„Zed	d„«       Zd
d„Zy)Ú
Dependencyz`
    Represents an abstract Python package.

    This class cannot be constructed directly.
    ÚstrÚnamec                ó   — t         ‚)z7
        A stub constructor that always fails.
        ©ÚNotImplementedError)ÚselfÚ_argsÚ_kwargss      r   Ú__init__zDependency.__init__+   s
   € ô "Ð!r   c                ó,   — t        | j                  «      S )z@
        The `Dependency`'s PEP-503 canonicalized name.
        )r   r   ©r"   s    r   Úcanonical_namezDependency.canonical_name2   s   € ô
 ! §¡Ó+Ð+r   c                ó&   — | j                   t        u S )zJ
        Check whether the `Dependency` was skipped by the audit.
        )Ú	__class__ÚSkippedDependencyr'   s    r   Ú
is_skippedzDependency.is_skipped9   s   € ð �~‰~Ô!2Ð2Ð2r   N)r#   r
   r$   r
   ÚreturnÚNone)r-   r   )r-   Úbool)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r%   Úpropertyr(   r,   © r   r   r   r      s1   … ñð ƒIðó"ð ò,ó ð,ô3r   r   c                  ó   — e Zd ZU dZded<   y)ÚResolvedDependencyz5
    Represents a fully resolved Python package.
    r   ÚversionN©r0   r1   r2   r3   r4   r6   r   r   r8   r8   @   s   … ñð Ôr   r8   c                  ó   — e Zd ZU dZded<   y)r+   z[
    Represents a Python package that was unable to be audited and therefore, skipped.
    r   Úskip_reasonNr:   r6   r   r   r+   r+   I   s   … ñð Ôr   r+   c                  ó�   — e Zd ZU dZded<   	 ded<   	 ded<   	 ded	<   	 d
Zded<   	 e	 	 	 	 	 	 	 	 	 	 dd„«       Zdd„Zdd„Z	dd„Z
y
)ÚVulnerabilityResultzt
    Represents a "result" from a vulnerability service, indicating a vulnerability
    in some Python package.
    r   r   r   Údescriptionúlist[Version]Úfix_versionszset[VulnerabilityID]ÚaliasesNúdatetime | NoneÚ	publishedc           
     ód   — |j                  t        ¬«        | |d   ||t        |dd «      |«      S )zœ
        Instantiates a `VulnerabilityResult` with the given data, prioritizing
        PYSEC and CVE vulnerability IDs for the primary identifier.
        )Úkeyr   r   N)Úsortr   Úset)ÚclsÚidsr?   rA   rD   s        r   ÚcreatezVulnerabilityResult.creater   s4   € ð 	�‰Ô'ˆÔ(Ù�3�q‘6˜;¨´c¸#¸a¸b¸'³lÀIÓNÐNr   c                ó–   — t        | j                  | j                  hz  j                  |j                  |j                  hz  «      «      S )zæ
        Returns whether this result is an "alias" of another result.

        Two results are said to be aliases if their respective sets of
        `{id, *aliases}` intersect at all. A result is therefore its own alias.
        )r/   rB   r   Úintersection)r"   Úothers     r   Úalias_ofzVulnerabilityResult.alias_of‚   s8   € ô �T—\‘\ T§W¡W IÑ-×;Ñ;¸E¿M¹MÈUÏXÉXÈJÑ<VÓWÓXÐXr   c                ój   — | j                   |j                   | j                  hz
  z  }t        | |¬«      S )zS
        Merge `other`'s aliases into this result, returning a new result.
        )rB   )rB   r   r   )r"   rN   rB   s      r   Úmerge_aliasesz!VulnerabilityResult.merge_aliases‹   s.   € ð —,‘, §¡°$·'±'°Ñ!:Ñ:ˆÜ�t WÔ-Ð-r   c                óN   — t        || j                  | j                  hz  z  «      S )zE
        Returns whether ids intersects with {id} | aliases.
        )r/   rB   r   )r"   rJ   s     r   Ú
has_any_idzVulnerabilityResult.has_any_id”   s#   € ô �C˜4Ÿ<™<¨4¯7©7¨)Ñ3Ñ4Ó5Ð5r   )
rJ   zlist[VulnerabilityID]r?   r   rA   r@   rD   rC   r-   r>   )rN   r>   r-   r/   )rN   r>   r-   r>   )rJ   zset[str]r-   r/   )r0   r1   r2   r3   r4   rD   ÚclassmethodrK   rO   rQ   rS   r6   r   r   r>   r>   R   s§   … ñð
 	Óðð Óðð  Óðð "Ó!ðð "&€IˆÓ%ðð ðOà"ðOð ðOð $ð	Oð
 #ðOð 
òOó ðOóYó.ô6r   r>   c                  óL   — e Zd ZdZe	 	 	 	 dd„«       Z	 	 	 	 dd„Zedd„«       Zy)	ÚVulnerabilityServicezV
    Represents an abstract provider of Python package vulnerability information.
    c                ó   — t         ‚)z“
        Query the `VulnerabilityService` for information about the given `Dependency`,
        returning a list of `VulnerabilityResult`.
        r    )r"   Úspecs     r   ÚqueryzVulnerabilityService.query    s
   € ô "Ð!r   c              #  ó@   K  — |D ]  }| j                  |«      –— Œ y­w)zù
        Query the vulnerability service for information on multiple dependencies.

        `VulnerabilityService` implementations can override this implementation with
        a more optimized one, if they support batched or bulk requests.
        N)rY   )r"   ÚspecsrX   s      r   Ú	query_allzVulnerabilityService.query_allª   s&   è ø€ ð ò 	#ˆDØ—*‘*˜TÓ"Ó"ñ	#ùs   ‚c                ó€   — | €y 	 t        j                  | d«      S # t        $ r t        j                  | d«      cY S w xY w)Nz%Y-%m-%dT%H:%M:%S.%fZz%Y-%m-%dT%H:%M:%SZ)r	   ÚstrptimeÚ
ValueError)Údts    r   Ú_parse_rfc3339z#VulnerabilityService._parse_rfc3339¶   sF   € àˆ:Øð	?Ü×$Ñ$ RÐ)@ÓAÐAøÜò 	?Ü×$Ñ$ RÐ)=Ó>Ò>ð	?ús   … ›=¼=N)rX   r   r-   z,tuple[Dependency, list[VulnerabilityResult]])r[   zIterator[Dependency]r-   z6Iterator[tuple[Dependency, list[VulnerabilityResult]]])r`   z
str | Noner-   rC   )	r0   r1   r2   r3   r   rY   r\   Ústaticmethodra   r6   r   r   rV   rV   ›   sT   „ ñð ð"Øð"à	5ò"ó ð"ð
#Ø)ð
#à	?ó
#ð ò?ó ñ?r   rV   c                  ó   — e Zd ZdZy)ÚServiceErrorzÂ
    Raised when a `VulnerabilityService` fails, for any reason.

    Concrete implementations of `VulnerabilityService` are expected to subclass
    this exception to provide more context.
    N©r0   r1   r2   r3   r6   r   r   rd   rd   Å   s   „ ñð 	r   rd   c                  ó   — e Zd ZdZy)ÚConnectionErrorz‚
    A specialization of `ServiceError` specifically for cases where the
    vulnerability service is unreachable or offline.
    Nre   r6   r   r   rg   rg   Ð   s   „ ñð
 	r   rg   N)r   r   r-   Úint)r3   Ú
__future__r   Úabcr   r   Úcollections.abcr   Údataclassesr   r   r	   Útypingr
   r   Úpackaging.utilsr   Úpackaging.versionr   r   r   r   r   r8   r+   r>   rV   Ú	Exceptionrd   rg   r6   r   r   ú<module>rq      sÜ   ðñõ
 #ç #Ý $ß *Ý ß å -Ý %áÐ+¨SÓ1€óñ �$Ô÷ 3ð  3ó ð 3ñF �$Ôô˜ó ó ðñ �$Ôô˜
ó ó ðñ �$Ô÷E6ð E6ó ðE6ôP'?˜3ô '?ôT	�9ô 	ô	�lõ 	r   