
    ܖid                        d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZmZmZ  ej                  e      Z ed	       G d
 d             Z G d d      Zy)z
Core auditing APIs.
    )annotationsN)Iterator)	dataclass)DependencySource)
DependencyVulnerabilityResultVulnerabilityServiceT)frozenc                       e Zd ZU dZdZded<   y)AuditOptionszE
    Settings the control the behavior of an `Auditor` instance.
    Fbooldry_runN)__name__
__module____qualname____doc__r   __annotations__     T/var/www/html/content-pipeline/venv/lib/python3.12/site-packages/pip_audit/_audit.pyr   r      s     GTr   r   c                  <    e Zd ZdZ e       f	 	 	 ddZ	 	 	 	 ddZy)Auditorz
    The core class of the `pip-audit` API.

    For a given dependency source and vulnerability service, supply a mapping of dependencies to
    known vulnerabilities.
    c                     || _         || _        y)z
        Create a new auditor. Auditors start with no dependencies to audit;
        each `audit` step is fed a `DependencySource`.

        The behavior of the auditor can be optionally tweaked with the `options`
        parameter.
        N)_service_options)selfserviceoptionss      r   __init__zAuditor.__init__"   s      r   c              #  2  	K   |j                         }| j                  j                  r6t        j	                  dt        t        |             d       dE d{    y| j                  j                  |      D ]  \  }}g }t               }|D ]X  		j                  j                  d      s|j                  	j                  	j                  hz         |j                  	       Z |D ]  	|j                  	j                  	j                  hz        r5t!        	fdt#        |      D              \  }}|j%                  	      ||<   a|j                  	j                  	j                  hz         |j                  	        ||f  y7 :w)a  
        Perform the auditing step, collecting dependencies from `source`.

        Individual vulnerability results are uniqued based on their `aliases` sets:
        any two results for the same dependency that share an alias are collapsed
        into a single result with a union of all aliases.

        `PYSEC`-identified results are given priority over other results.
        zDry run: would have audited z	 packagesr   NPYSECc              3  P   K   | ]  \  }}|j                        s||f  y w)N)alias_of).0ipvs      r   	<genexpr>z Auditor.audit.<locals>.<genexpr>W   s)      -'-1AJJWXMQF-s   &	&)collectr   r   loggerinfolenlistr   	query_allsetid
startswithupdatealiasesappendintersectionnext	enumeratemerge_aliases)
r   sourcespecsdepvulnsunique_vulnsseen_aliasesidxpreviousr'   s
            @r   auditzAuditor.audit1   sm      ==  KK6s4;7G6H	RSMM"mm55e< *
U:<),  +A44??73  ''		QTTF(:; ''*+  +A $00addV1CD(, -1:<1H- )X -5,B,B1,ES)  ''		QTTF(:; ''*+ L))9* s   AFFD:FN)r   r	   r   r   )r9   r   returnz6Iterator[tuple[Dependency, list[VulnerabilityResult]]])r   r   r   r   r   r   rA   r   r   r   r   r      s:     !- %   /*&/*	?/*r   r   )r   
__future__r   loggingcollections.abcr   dataclassesr   pip_audit._dependency_sourcer   pip_audit._servicer   r   r	   	getLoggerr   r*   r   r   r   r   r   <module>rJ      s]    #  $ ! 9 T T			8	$ $  F* F*r   