
    ܖip                         d Z ddlZddlZddlmZmZ ddlm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 dd	lmZ dd
lmZ ddlmZ ddlmZ ej8                  dk\  rddlmZ nddlmZ ddlZ ddl!m"Z" ddl#m$Z% ddl&m'Z'm(Z( ddl)m*Z*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6 dZ7e jp                   G d de9e             Z:e jv                   G d d             Z<e jp                   G d de9e             Z=e jv                   G d d             Z>e jp                   G d  d!e9e             Z? G d" d#e j                  j                        ZBe jv                   G d$ d%             ZCe jp                   G d& d'e9e             ZD G d( d)e j                  j                        ZE e jv                  d*+       G d, d-e j                  j                               ZF e jv                  d*+       G d. d/             ZG e jv                  d*+       G d0 d1             ZH e jv                  d*+       G d2 d3             ZI e jv                  d*+       G d4 d5             ZJ e jv                  d*+       G d6 d7             ZK e jv                  d*+       G d8 d9             ZLy):a  
Uniform set of models to represent objects within a CycloneDX software bill-of-materials.

You can either create a `cyclonedx.model.bom.Bom` yourself programmatically, or generate a `cyclonedx.model.bom.Bom`
from a `cyclonedx.parser.BaseParser` implementation.
    N)	GeneratorIterable)datetime)Enum)reduce)loads)AnyOptionalUnion)quote)UUID)warn)Element)      )
deprecated)	SortedSet   )ComparableTuple)InvalidLocaleTypeExceptionInvalidUriException)!CycloneDxDeserializationException'SerializationOfUnexpectedValueException)SchemaVersion1Dot0SchemaVersion1Dot1SchemaVersion1Dot2SchemaVersion1Dot3SchemaVersion1Dot4SchemaVersion1Dot5SchemaVersion1Dot6SchemaVersion1Dot7   )BomRefzurn:cdx:c                        e Zd ZdZdZdZdZdZy)DataFlowz
    This is our internal representation of the dataFlowType simple type within the CycloneDX standard.

    .. note::
        See the CycloneDX Schema: https://cyclonedx.org/docs/1.7/xml/#type_dataFlowType
    inboundoutboundzbi-directionalunknownN)__name__
__module____qualname____doc__INBOUNDOUTBOUNDBI_DIRECTIONALUNKNOWN     \/var/www/html/content-pipeline/venv/lib/python3.12/site-packages/cyclonedx/model/__init__.pyr%   r%   @   s     GH%NGr2   r%   c                      e Zd ZdZdededdfdZe ej                         defd              Z
e
j                  deddfd       Z
e ej                  d	       ej                  ej                  j                        defd
                     Zej                  deddfd       ZdefdZdedefdZdedefdZdefdZdefdZy)DataClassificationa  
    This is our internal representation of the `dataClassificationType` complex type within the CycloneDX standard.

    DataClassification might be deprecated since CycloneDX 1.5, but it is not deprecated in this library.
    In fact, this library will try to provide a compatibility layer if needed.

    .. note::
        See the CycloneDX Schema for dataClassificationType:
        https://cyclonedx.org/docs/1.7/xml/#type_dataClassificationType
    flowclassificationreturnNc                     || _         || _        y N)r6   r7   )selfr6   r7   s      r3   __init__zDataClassification.__init__[   s    
 	,r2   c                     | j                   S )a  
        Specifies the flow direction of the data.

        Valid values are: inbound, outbound, bi-directional, and unknown.

        Direction is relative to the service.

        - Inbound flow states that data enters the service
        - Outbound flow states that data leaves the service
        - Bi-directional states that data flows both ways
        - Unknown states that the direction is not known

        Returns:
            `DataFlow`
        _flowr;   s    r3   r6   zDataClassification.flowc   s    $ zzr2   c                     || _         y r:   r>   )r;   r6   s     r3   r6   zDataClassification.floww   	    
r2   .c                     | j                   S )z
        Data classification tags data according to its type, sensitivity, and value if altered, stolen, or destroyed.

        Returns:
            `str`
        _classificationr@   s    r3   r7   z!DataClassification.classification{   s     ###r2   c                     || _         y r:   rE   )r;   r7   s     r3   r7   z!DataClassification.classification   s
    -r2   c                 D    t        | j                  | j                  f      S r:   )_ComparableTupler6   r7   r@   s    r3   __comparable_tuplez%DataClassification.__comparable_tuple   s#    IIt**!
  	r2   otherc                 f    t        |t              r!| j                         |j                         k(  S yNF)
isinstancer5   %_DataClassification__comparable_tupler;   rK   s     r3   __eq__zDataClassification.__eq__   -    e/0**,0H0H0JJJr2   c                 p    t        |t              r!| j                         |j                         k  S t        S r:   )rN   r5   rO   NotImplementedrP   s     r3   __lt__zDataClassification.__lt__   0    e/0**,u/G/G/IIIr2   c                 4    t        | j                               S r:   )hashrO   r@   s    r3   __hash__zDataClassification.__hash__       D++-..r2   c                 "    d| j                    dS )Nz<DataClassification flow=>)r6   r@   s    r3   __repr__zDataClassification.__repr__   s    *499+Q77r2   )r)   r*   r+   r,   r%   strr<   propertyserializablexml_attributer6   setterxml_name
xml_stringXmlStringSerializationTypeNORMALIZED_STRINGr7   rI   rO   objectboolrQ   rU   intrY   r]   r1   r2   r3   r5   r5   N   sA   	-- - 
	- \!h  " $ 
[[ d   \3\\DDVVW$ $ X   $ .S .T . .$4 
F t 
F t 
/# /8# 8r2   r5   c                       e Zd ZdZdZy)Encodingz
    This is our internal representation of the encoding simple type within the CycloneDX standard.

    .. note::
        See the CycloneDX Schema: https://cyclonedx.org/docs/1.7/xml/#type_encoding
    base64N)r)   r*   r+   r,   BASE_64r1   r2   r3   rk   rk      s     Gr2   rk   c            	       L   e Zd ZdZdZedddededee   ddfd	Ze	 e
j                          e
j                  d
       e
j                  e
j                  j                        defd                            Zej"                  deddfd       Ze	 e
j                         dee   fd              Zej"                  dee   ddfd       Ze	 e
j                  d      defd              Zej"                  deddfd       ZdefdZdedefdZdedefdZdefdZdefdZy)AttachedTextz
    This is our internal representation of the `attachedTextType` complex type within the CycloneDX standard.

    .. note::
        See the CycloneDX Schema for hashType: https://cyclonedx.org/docs/1.7/xml/#type_attachedTextType
    
text/plainNcontent_typeencodingcontentrr   rs   r8   c                .    || _         || _        || _        y r:   )rr   rs   rt   r;   rt   rr   rs   s       r3   r<   zAttachedText.__init__   s     ) r2   content-typec                     | j                   S )z
        Specifies the content type of the text. Defaults to text/plain if not specified.

        Returns:
            `str`
        _content_typer@   s    r3   rr   zAttachedText.content_type   s     !!!r2   c                     || _         y r:   ry   r;   rr   s     r3   rr   zAttachedText.content_type   
    )r2   c                     | j                   S )z
        Specifies the optional encoding the text is represented in.

        Returns:
            `Encoding` if set else `None`
        	_encodingr@   s    r3   rs   zAttachedText.encoding        ~~r2   c                     || _         y r:   r   r;   rs   s     r3   rs   zAttachedText.encoding   	    !r2   rC   c                     | j                   S )z
        The attachment data.

        Proactive controls such as input validation and sanitization should be employed to prevent misuse of attachment
        text.

        Returns:
            `str`
        _contentr@   s    r3   rt   zAttachedText.content   s     }}r2   c                     || _         y r:   r   r;   rt   s     r3   rt   zAttachedText.content   	    r2   c                 Z    t        | j                  | j                  | j                  f      S r:   )rI   rr   rs   rt   r@   s    r3   rJ   zAttachedText.__comparable_tuple   s)    t}}dll!
  	r2   rK   c                 f    t        |t              r!| j                         |j                         k(  S yrM   )rN   ro   _AttachedText__comparable_tuplerP   s     r3   rQ   zAttachedText.__eq__   s,    e\***,0H0H0JJJr2   c                 p    t        |t              r!| j                         |j                         k  S t        S r:   )rN   ro   r   rT   rP   s     r3   rU   zAttachedText.__lt__   s/    e\***,u/G/G/IIIr2   c                 4    t        | j                               S r:   )rX   r   r@   s    r3   rY   zAttachedText.__hash__  rZ   r2   c                 <    d| j                    d| j                   dS )Nz<AttachedText content-type=, encoding=r\   rq   r@   s    r3   r]   zAttachedText.__repr__  s#    ,T->->,?{4==/YZ[[r2   )r)   r*   r+   r,   DEFAULT_CONTENT_TYPEr^   r
   rk   r<   r_   r`   ra   rc   rd   re   rf   rr   rb   rs   rt   rI   r   rg   rh   rQ   r	   rU   ri   rY   r]   r1   r2   r3   ro   ro      s    (
 1'+	  8$	
 
 \!\>*\\DDVVW"c " X + " " * * * * \!(8,  "  __"(!3 " " " \3
 
   
 ^^ s  t    $4 
F t 
C D 
/# /\# \r2   ro   c                   H    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZy)HashAlgorithmz
    This is our internal representation of the hashAlg simple type within the CycloneDX standard.

    .. note::
        See the CycloneDX Schema: https://cyclonedx.org/docs/1.7/xml/#type_hashAlg
    zBLAKE2b-256zBLAKE2b-384zBLAKE2b-512BLAKE3MD5zSHA-1zSHA-256zSHA-384zSHA-512zSHA3-256zSHA3-384zSHA3-512zStreebog-256zStreebog-512N)r)   r*   r+   r,   BLAKE2B_256BLAKE2B_384BLAKE2B_512r   r   SHA_1SHA_256SHA_384SHA_512SHA3_256SHA3_384SHA3_512STREEBOG_256STREEBOG_512r1   r2   r3   r   r   	  sO      KKKF
CEGGGHHH!L!Lr2   r   c                   T   e Zd ZU dZ e       Zeeej                     e	e
   f   ed<    e	e
j                  e
j                  e
j                  e
j                  e
j                   e
j"                  e
j$                  h      ee<   ee   ee<   ee   e
j*                  e
j,                  e
j.                  e
j0                  e
j2                  hz  ee<   ee   ee<   ee   ee<   ee   ee<   ee   ee<   ee   e
j>                  e
j@                  hz  ee!<   e"de#d   deej                     de$d   fd       Z%e"d	e#d   de&eej                        d
e'de(e'   fd       Z)e"d	e#d   de*de&eej                        de&e*   d
e'de+fd       Z,e"d	e'd
e'de(d   fd       Z-e"d	dde&e*   d
e'de(d   fd       Z.y)&_HashTypeRepositorySerializationHelper   THIS CLASS IS NON-PUBLIC API  -_HashTypeRepositorySerializationHelper__CASEShtsHashTypeviewr8   )r   NNc              #      K   | j                   j                  |d      }|D ]*  }|j                  |v r| t        d|t        d       , y w)Nr1   z8serialization omitted due to unsupported HashAlgorithm: r   )category
stacklevel)r   getalgr   UserWarning)clsr   r   caseshts        r3   __prepz-_HashTypeRepositorySerializationHelper.__prep@  sQ     b) 	9BvvOPRvV)a9		9s   AAo__c                    |J | j                  ||      D cg c]  }t        |j                  |             c}S c c}w )N)view_),_HashTypeRepositorySerializationHelper__prep
json_loadsas_json)r   r   r   r   r   s        r3   json_normalizez5_HashTypeRepositorySerializationHelper.json_normalizeJ  sX     
 

1d+	
  

   
 	
 
s   ">element_namexmlnsc                ~    J t        |      }|j                  fd| j                  |      D               |S )Nc              3   H   K   | ]  }|j                  d d        yw)FrX   )r   	as_stringr   r   N)as_xml).0r   r   r   s     r3   	<genexpr>zG_HashTypeRepositorySerializationHelper.xml_normalize.<locals>.<genexpr>^  s2      
  IIe&  
s   ")
XmlElementextendr   )r   r   r   r   r   r   elems      ``  r3   xml_normalizez4_HashTypeRepositorySerializationHelper.xml_normalizeV  sH     ,' 
 

1d+
 	

 r2   c                 R    |D cg c]  }t         j                  |       c}S c c}w r:   )r   	from_json)r   r   r   r   s       r3   json_denormalizez7_HashTypeRepositorySerializationHelper.json_denormalizee  s2    
  
 
 	
 
s   $r   
default_nsc                T    |D cg c]  }t         j                  ||       c}S c c}w r:   )r   from_xml)r   r   r   r   r   s        r3   xml_denormalizez6_HashTypeRepositorySerializationHelper.xml_denormalizem  s4     +,
$& J 
 	
 
s   %N)/r)   r*   r+   r,   dictr   typer`   ViewType	frozensetr   __annotations__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r   r!   classmethodr   r   r   r
   r	   listr   r^   r   r   r   r   r1   r2   r3   r   r   "  s   *KO6GT$|,,-y/GGHQ"+- #G #**<"=G")*<"=!!!!!!A #G #**<"=G")*<"=G")*<"=G")*<"=G")*<"=""""A #G
 9*- 9T,:O:O5P 9U^_uUv 9 9 	
x
3 	
%d<+@+@&AB	
 	
%)#Y	
 	
 hz2 $'$T,*?*?%@A &c]  	 %/	  
 
"
'+J'7
 
 
 
$,SM
!
&*:&6
 
r2   r   c                      e Zd ZdZe ed      dededd fd              Ze ed      dedd fd	              Zd
e	deddfdZ
e ej                         de	fd              Zej                  d
e	ddfd       Ze ej                   d       ej"                  ej$                  j&                        defd                     Zej                  deddfd       ZdefdZdedefdZdedefdZdefdZdefdZy)r   z
    This is our internal representation of the hashType complex type within the CycloneDX standard.

    .. note::
        See the CycloneDX Schema for hashType: https://cyclonedx.org/docs/1.7/xml/#type_hashType
    z^Deprecated - use cyclonedx.contrib.hash.factories.HashTypeFactory().from_hashlib_alg() insteadhashlib_algrt   r8   c                 <    ddl m}  |       j                  | |      S )u<  Deprecated — Alias of :func:`cyclonedx.contrib.hash.factories.HashTypeFactory.from_hashlib_alg`.

        Attempts to convert a hashlib-algorithm to our internal model classes.

        .. deprecated:: next
            Use ``cyclonedx.contrib.hash.factories.HashTypeFactory().from_hashlib_alg()`` instead.
        r   HashTypeFactory)contrib.hash.factoriesr   from_hashlib_alg)r   rt   r   s      r3   r   zHashType.from_hashlib_alg  s     	= 11+wGGr2   z`Deprecated - use cyclonedx.contrib.hash.factories.HashTypeFactory().from_composite_str() insteadcomposite_hashc                 :    ddl m}  |       j                  |       S )u  Deprecated — Alias of :func:`cyclonedx.contrib.hash.factories.HashTypeFactory.from_composite_str`.

        Attempts to convert a string which includes both the Hash Algorithm and Hash Value and represent using our
        internal model classes.

        .. deprecated:: next
            Use ``cyclonedx.contrib.hash.factories.HashTypeFactory().from_composite_str()`` instead.
        r   r   )r   r   from_composite_str)r   r   s     r3   r   zHashType.from_composite_str  s     	= 33NCCr2   r   Nc                     || _         || _        y r:   )r   rt   )r;   r   rt   s      r3   r<   zHashType.__init__  s    
 r2   c                     | j                   S )zp
        Specifies the algorithm used to create the hash.

        Returns:
            `HashAlgorithm`
        _algr@   s    r3   r   zHashType.alg       yyr2   c                     || _         y r:   r   )r;   r   s     r3   r   zHashType.alg  	    	r2   rC   c                     | j                   S )zI
        Hash value content.

        Returns:
            `str`
        r   r@   s    r3   rt   zHashType.content  s     }}r2   c                     || _         y r:   r   r   s     r3   rt   zHashType.content  r   r2   c                 D    t        | j                  | j                  f      S r:   )rI   r   rt   r@   s    r3   rJ   zHashType.__comparable_tuple  s!    HHdll!
  	r2   rK   c                 f    t        |t              r!| j                         |j                         k(  S yrM   )rN   r   _HashType__comparable_tuplerP   s     r3   rQ   zHashType.__eq__  ,    eX&**,0H0H0JJJr2   c                 p    t        |t              r!| j                         |j                         k  S t        S r:   )rN   r   r   rT   rP   s     r3   rU   zHashType.__lt__  /    eX&**,u/G/G/IIIr2   c                 4    t        | j                               S r:   )rX   r   r@   s    r3   rY   zHashType.__hash__  rZ   r2   c                 P    d| j                   j                   d| j                   dS )Nz
<HashType :r\   )r   namert   r@   s    r3   r]   zHashType.__repr__  s#    DHHMM?!DLL>;;r2   )r)   r*   r+   r,   staticmethodr   r^   r   r   r   r<   r_   r`   ra   r   rb   rc   rd   re   TOKENrt   rI   r   rg   rh   rQ   r	   rU   ri   rY   r]   r1   r2   r3   r   r   w  s    pq
Hc 
HC 
HJ 
H r 
H rsD3 D: D t D  
	 \!]  "  	ZZ}    \3\\DDJJK  L    ^^ s  t    $4 
F t 
C D 
/# /<# <r2   r   c                       e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)Z+d*Z,d+Z-d,Z.d-Z/d+Z0d.Z1d/Z2d0Z3y1)2ExternalReferenceTypez
    Enum object that defines the permissible 'types' for an External Reference according to the CycloneDX schema.

    .. note::
        See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_externalReferenceType
    zadversary-model
advisoriesattestationbomz
build-metazbuild-systemzcertification-reportchatcitationzcodified-infrastructurezcomponent-analysis-reportconfigurationzdigital-signaturedistributionzdistribution-intakedocumentationzdynamic-analysis-reportzelectronic-signatureevidencezexploitability-statementformulationzissue-trackerlicenselogzmailing-listzmaturity-reportz
model-cardpatentzpatent-assertionzpatent-familyzpentest-reportpoamzquality-metricszrelease-noteszrfc-9116zrisk-assessmentzruntime-analysis-reportzsecurity-contactzstatic-analysis-reportsocialzsource-distributionvcssupportzthreat-modelzvulnerability-assertionwebsiterK   N)4r)   r*   r+   r,   ADVERSARY_MODEL
ADVISORIESATTESTATIONBOM
BUILD_METABUILD_SYSTEMCERTIFICATION_REPORTCHATCITATIONCODIFIED_INFRASTRUCTURECOMPONENT_ANALYSIS_REPORTCONFIGURATIONDIGITAL_SIGNATUREDISTRIBUTIONDISTRIBUTION_INTAKEDOCUMENTATIONDYNAMIC_ANALYSIS_REPORTELECTRONIC_SIGNATUREEVIDENCEEXPLOITABILITY_STATEMENTFORMULATIONISSUE_TRACKERLICENSELOGMAILING_LISTMATURITY_REPORT
MODEL_CARDPATENTPATENT_ASSERTIONPATENT_FAMILYPENTEST_REPORTPOAMQUALITY_METRICSRELEASE_NOTESRFC_9166RISK_ASSESSMENTRUNTIME_ANALYSIS_REPORTSECURITY_CONTACTSTATIC_ANALYSIS_REPORTSOCIALSOURCE_DISTRIBUTIONSCMSUPPORTTHREAT_MODELVCSVULNERABILITY_ASSERTIONWEBSITEOTHERr1   r2   r3   r   r     s    (OJK
CJ!L1DH7 ;#M+!L/#M71H9K#MG
C!L'OJF)#M%ND'O#MH'O7)5F/
CG!L
C7GEr2   r   c                      e Zd ZU dZ e       Zeeej                     e	e
   f   ed<    e	e
j                  e
j                  e
j                  e
j                  e
j                   e
j"                  e
j$                  e
j&                  e
j(                  e
j*                  e
j,                  e
j.                  e
j0                  e
j2                  e
j4                  h      ee<   ee   ee<   ee   ee<   ee   e
j<                  hz  ee<   ee   e
j@                  e
jB                  e
jD                  e
jF                  e
jH                  e
jJ                  e
jL                  e
jN                  e
jP                  e
jR                  e
jT                  e
jV                  e
jX                  e
jZ                  e
j\                  e
j^                  e
j`                  e
jb                  e
jd                  e
jf                  e
jh                  e
jj                  e
jl                  hz  ee7<   ee7   e
jp                  e
jr                  e
jt                  e
jv                  hz  ee<<   ee<   e
jz                  e
j|                  e
j~                  e
j                  hz  eeA<   eBde
deej                     deCfd       ZDeBdeEdeFeej                        deEdeCfd	       ZGeBdeEdeFeej                        deEdeCfd
       ZHeBdeEde
fd       ZIy)%_ExternalReferenceSerializationHelperr   ,_ExternalReferenceSerializationHelper__CASESextrefr   r8   c                     || j                   j                  |d      v r|j                  S t        j                  j                  S )Nr1   )r;  r   r   r8  value)r   r<  r   s      r3   __normalizez1_ExternalReferenceSerializationHelper.__normalizeV  sA     r22  %		 ',,
%		r2   r   r   c                .    |J | j                  ||      S r:   0_ExternalReferenceSerializationHelper__normalizer   r   r   r   s       r3   r   z4_ExternalReferenceSerializationHelper.json_normalize^  !     q$''r2   c                .    |J | j                  ||      S r:   rA  rC  s       r3   r   z3_ExternalReferenceSerializationHelper.xml_normalizee  rD  r2   c                     t        |      S r:   )r   r   r   s     r3   deserializez1_ExternalReferenceSerializationHelper.deserializel  s    $Q''r2   N)Jr)   r*   r+   r,   r   r;  r   r`   r   r   r   r   r5  r  r7  r
  r  r!  r0  r  r  r3  r  r  r  r  r8  r   r   r   r*  r   r  r.  r#  r   r  r  r  r  r4  r	  r,  r6  r  r'  r/  r  r-  r  r"  r  r)  r  r(  r   r1  r  r  r+  r    r  r$  r%  r&  r!   r   r^   rB  r	   r
   r   r   rH  r1   r2   r3   r:  r:    sb   *SWSYGT$|,,-y9N/OOPY"+!!++%%((!!**$$""++%%**%%((**##- #G" #**<"=G")*<"=G")*<"=++A #G #**<"=11..((!!++&&))))**----5566,,44555577--22--55""/A #G2 #**<"=1122//&&	A #G #**<"=&&$$..++	A #G !6 d<CXCX>Y ^a   (s (%d<+@+@&AB( (%(( ( (c ($T,*?*?%@A(($'( ( (C ($9 ( (r2   r:  T)%ignore_unknown_during_deserializationc                      e Zd ZdZ ej
                  dej                  ej                  z         ZdZ	e
dedeeef   defd       Zededefd	       Zd
eddfdZdedefdZdedefdZdefdZdefdZdefdZe ej6                  d       ej8                  d      defd                     Zededefd       Zededd fd       Ze	 	 dde e!ef   dede"e ee#f      dd fd       Z$defdZ%y)XsUria  
    Helper class that allows us to perform validation on data strings that are defined as xs:anyURI
    in CycloneDX schema.

    Developers can just use this via `str(XsUri('https://www.google.com'))`.

    .. note::
        See XSD definition for xsd:anyURI: http://www.datypic.com/sc/xsd/t-xsd_anyURI.html
        See JSON Schema definition for iri-reference: https://tools.ietf.org/html/rfc3987
    z%(?![0-9A-F]{2})|#.*#)	) z%20)"z%22)'z%27)[z%5B)]z%5D)<z%3C)r\   z%3E){z%7B)}z%7Dvrr8   c                       | j                   | S r:   )replace)rT  rU  s     r3   __spec_replacezXsUri.__spec_replace  s    qyy!}r2   r   c                 D    t        | j                  | j                  |      S )a~  
         Make a string valid to
         - XML::anyURI spec.
         - JSON::iri-reference spec.

         BEST EFFORT IMPLEMENTATION

         @see http://www.w3.org/TR/xmlschema-2/#anyURI
         @see http://www.datypic.com/sc/xsd/t-xsd_anyURI.html
         @see https://datatracker.ietf.org/doc/html/rfc2396
         @see https://datatracker.ietf.org/doc/html/rfc3987
        )r   _XsUri__spec_replace_XsUri__SPEC_REPLACEMENTSrG  s     r3   _spec_migratezXsUri._spec_migrate  s     c((#*A*A1EEr2   uriNc                     t        j                  t        j                  |      rt	        d| d      | j                  |      | _        y )NzSupplied value 'z$' does not appear to be a valid URI.)researchrK  _INVALID_URI_REGEXr   r\  _uri)r;   r]  s     r3   r<   zXsUri.__init__  sD    99U--s3%"3%'KL  &&s+	r2   rK   c                 V    t        |t              r| j                  |j                  k(  S yrM   )rN   rK  rb  rP   s     r3   rQ   zXsUri.__eq__  s"    eU#99

**r2   c                 `    t        |t              r| j                  |j                  k  S t        S r:   )rN   rK  rb  rT   rP   s     r3   rU   zXsUri.__lt__  s%    eU#99uzz))r2   c                 ,    t        | j                        S r:   )rX   rb  r@   s    r3   rY   zXsUri.__hash__  s    DIIr2   c                 "    d| j                    dS )Nz<XsUri r\   rb  r@   s    r3   r]   zXsUri.__repr__  s    1%%r2   c                     | j                   S r:   rg  r@   s    r3   __str__zXsUri.__str__  s    yyr2   rC   c                     | j                   S r:   rg  r@   s    r3   r]  z	XsUri.uri  s     yyr2   c                 T    t        |t              rt        |      S t        d|      )Nz"Attempt to serialize a non-XsUri: )rN   rK  r^   r   rG  s     r3   	serializezXsUri.serialize  s,    aq6M5068 	8r2   c                 n    	 t        t        |            S # t        $ r}t        d|      |d }~ww xY w)N)r]  z&XsUri string supplied does not parse: )rK  r^   
ValueErrorr   )r   r   errs      r3   rH  zXsUri.deserialize  s@    	SV$$ 	38>	s    	4/4serial_numberversionbom_refc                 b    |rdt        t        |             nd} | t         | d| |       S )a  
        Generate a BOM-Link URI.

        Args:
            serial_number: The unique serial number of the BOM.
            version: The version of the BOM. The default version is 1.
            bom_ref: The unique identifier of the component, service, or vulnerability within the BOM.

        Returns:
            XsUri: Instance of XsUri with the generated BOM-Link URI.
        # /)	url_quoter^   _BOM_LINK_PREFIX)r   rp  rq  rr  bom_ref_parts        r3   make_bom_linkzXsUri.make_bom_link  s?    $ 9@9S\234R&'ayOPPr2   c                 @    | j                   j                  t              S )zV
        Check if the URI is a BOM-Link.

        Returns:
            `bool`
        )rb  
startswithrx  r@   s    r3   is_bom_linkzXsUri.is_bom_link  s     yy##$455r2   )r"   N)&r)   r*   r+   r,   r_  compile
IGNORECASE	MULTILINEra  r[  r   r^   tuplerZ  r   r\  r<   r	   rh   rQ   rU   ri   rY   r]   ri  r_   r`   	json_namerc   r]  rl  rH  r   r   r
   r#   rz  r}  r1   r2   r3   rK  rK  q  s   	 $$<bmmbll>Z[
 # %S/ c   Fc Fc F F,C ,D ,C D 
C D 
# &# &  \C \3S    !  8# 8# 8 8 C G    04	QT3Y'Q Q %V,-	Q
 
Q Q(6T 6r2   rK  c                      e Zd ZdZdddddededee   deee	      deed	      d
dfdZ
e ej                  d      d
efd              Zej                  ded
dfd       Zed
ee   fd       Zej                  dee   d
dfd       Ze ej"                  e       ej&                         d
efd                     Zej                  ded
dfd       Ze ej*                  e       ej*                  e       ej*                  e       ej*                  e       ej*                  e       ej"                  e      dd                                                 Zej                  dee	   d
dfd       Ze ej*                  e       ej:                  ej<                  j>                  d      dd                     Z e j                  ded	   d
dfd       Z d
e!fdZ"de#d
e$fdZ%de&d
e$fdZ'd
e(fdZ)d
efdZ*y) ExternalReferencea  
    This is our internal representation of an ExternalReference complex type that can be used in multiple places within
    a CycloneDX BOM document.

    .. note::
        See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_externalReference
    N)commenthashes
propertiesr   urlr  r  r  Propertyr8   c                Z    || _         || _        || _        |xs g | _        |xs g | _        y r:   )r  r  r   r  r  )r;   r   r  r  r  r  s         r3   r<   zExternalReference.__init__  s0     	l$*r2   r"   c                     | j                   S )zZ
        The URL to the external reference.

        Returns:
            `XsUri`
        _urlr@   s    r3   r  zExternalReference.url  r   r2   c                     || _         y r:   r  )r;   r  s     r3   r  zExternalReference.url  r   r2   c                     | j                   S )z
        An optional comment describing the external reference.

        Returns:
            `str` if set else `None`
        _commentr@   s    r3   r  zExternalReference.comment  s     }}r2   c                     || _         y r:   r  )r;   r  s     r3   r  zExternalReference.comment   r   r2   c                     | j                   S )a  
        Specifies the type of external reference.

        There are built-in types to describe common references. If a type does not exist for the reference being
        referred to, use the "other" type.

        Returns:
            `ExternalReferenceType`
        _typer@   s    r3   r   zExternalReference.type$  s     zzr2   c                     || _         y r:   r  )r;   r   s     r3   r   zExternalReference.type3  rB   r2   c                     | j                   S )zw
        The hashes of the external reference (if applicable).

        Returns:
            Set of `HashType`
        )_hashesr@   s    r3   r  zExternalReference.hashes7  s     ||r2   c                 $    t        |      | _        y r:   )r   r  )r;   r  s     r3   r  zExternalReference.hashesG  s     (r2   r_   c                     | j                   S )a  
        Provides the ability to document properties in a key/value store. This provides flexibility to include data not
        officially supported in the standard without having to use additional namespaces or create extensions.

        Return:
            Set of `Property`
        )_propertiesr@   s    r3   r  zExternalReference.propertiesK  s     r2   c                 $    t        |      | _        y r:   )r   r  )r;   r  s     r3   r  zExternalReference.propertiesX  s    $Z0r2   c           	          t        | j                  | j                  | j                  t        | j                        t        | j
                        f      S r:   )rI   r  r  r  r  r  r@   s    r3   rJ   z$ExternalReference.__comparable_tuple\  s?    JJ		4==T\\*,<T__,M!
  	r2   rK   c                 f    t        |t              r!| j                         |j                         k(  S yrM   )rN   r  $_ExternalReference__comparable_tuplerP   s     r3   rQ   zExternalReference.__eq__b  s-    e./**,0H0H0JJJr2   c                 p    t        |t              r!| j                         |j                         k  S t        S r:   )rN   r  r  rT   rP   s     r3   rU   zExternalReference.__lt__g  s0    e./**,u/G/G/IIIr2   c                 4    t        | j                               S r:   )rX   r  r@   s    r3   rY   zExternalReference.__hash__l  rZ   r2   c                 P    d| j                   j                   d| j                   dS )Nz<ExternalReference z, r\   )r   r   r  r@   s    r3   r]   zExternalReference.__repr__o  s$    $TYY^^$4BtxxjBBr2   )r8   zSortedSet[HashType])r8   zSortedSet[Property])+r)   r*   r+   r,   r   rK  r
   r^   r   r   r<   r_   r`   xml_sequencer  rb   r  type_mappingr:  ra   r   r   r   r   r   r    r!   r   r  	xml_arrayXmlArraySerializationTypeNESTEDr  rI   r  rg   rh   rQ   r	   rU   ri   rY   r]   r1   r2   r3   r  r    s    "&/359+#+ + #	+
 (+,+ Xj12+ 
+ \q!U  "  	ZZu    #   ^^ x}       \DE\!
+ 
 " F 
 
[[. 4   \)*\)*\)*\)*\)*\EF G + + + + +  ]])Xh/ )D ) ) \)*\LBBII:V  W +   1Xj%9 1d 1 1$4 F t 
C D 
/# /C# Cr2   r  c                      e Zd ZdZdddedee   ddfdZe ej                         defd              Z
e
j                  deddfd	       Z
e ej                  d
       ej                  ej                  j                        dee   fd                     Zej                  dee   ddfd       ZdefdZdedefdZdedefdZdefdZdefdZy)r  aD  
    This is our internal representation of `propertyType` complex type that can be used in multiple places within
    a CycloneDX BOM document.

    .. note::
        See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_propertyType

    Specifies an individual property with a name and value.
    N)r>  r   r>  r8   c                     || _         || _        y r:   )r   r>  )r;   r   r>  s      r3   r<   zProperty.__init__  s    
 	
r2   c                     | j                   S )z
        The name of the property.

        Duplicate names are allowed, each potentially having a different value.

        Returns:
            `str`
        _namer@   s    r3   r   zProperty.name  s     zzr2   c                     || _         y r:   r  r;   r   s     r3   r   zProperty.name  rB   r2   rC   c                     | j                   S )zN
        Value of this Property.

        Returns:
             `str`
        _valuer@   s    r3   r>  zProperty.value  s     {{r2   c                     || _         y r:   r  )r;   r>  s     r3   r>  zProperty.value  	    r2   c                 D    t        | j                  | j                  f      S r:   )rI   r   r>  r@   s    r3   rJ   zProperty.__comparable_tuple  s!    IItzz!
  	r2   rK   c                 f    t        |t              r!| j                         |j                         k(  S yrM   )rN   r  _Property__comparable_tuplerP   s     r3   rQ   zProperty.__eq__  r   r2   c                 p    t        |t              r!| j                         |j                         k  S t        S r:   )rN   r  r  rT   rP   s     r3   rU   zProperty.__lt__  r   r2   c                 4    t        | j                               S r:   )rX   r  r@   s    r3   rY   zProperty.__hash__  rZ   r2   c                 "    d| j                    dS )Nz<Property name=r\   )r   r@   s    r3   r]   zProperty.__repr__  s     1--r2   )r)   r*   r+   r,   r^   r
   r<   r_   r`   ra   r   rb   rc   rd   re   rf   r>  rI   r  rg   rh   rQ   r	   rU   ri   rY   r]   r1   r2   r3   r  r  s  sP     $ } 
	 \!	c 	 " 	 
[[    \3\\DDVVWx}  X    \\8C= T  $4 
F t 
C D 
/# /.# .r2   r  c            	          e Zd ZU dZdZeed<   ddddedee   dee   d	dfd
Z	e
 ej                  d      d	efd              Zej                  ded	dfd       Ze
 ej                          ej                  d      d	ee   fd                     Zej                  ded	dfd       Ze
 ej                         d	ee   fd              Zej                  dee   d	dfd       Zd	efdZded	efdZded	efdZd	efdZd	efdZy)NoteTexta
  
    This is our internal representation of the Note.text complex type that can be used in multiple places within
    a CycloneDX BOM document.

    .. note::
        See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_releaseNotesType
    rp   r   Nrq   rt   rr   rs   r8   c                R    || _         |xs t        j                  | _        || _        y r:   )rt   r  r   rr   rs   rv   s       r3   r<   zNoteText.__init__  s%     (IH,I,I r2   rC   c                     | j                   S )ze
        Get the text content of this Note.

        Returns:
            `str` note content
        r   r@   s    r3   rt   zNoteText.content  s     }}r2   c                     || _         y r:   r   r   s     r3   rt   zNoteText.content  r   r2   rw   c                     | j                   S )z
        Get the content-type of this Note.

        Defaults to 'text/plain' if one was not explicitly specified.

        Returns:
            `str` content-type
        ry   r@   s    r3   rr   zNoteText.content_type  s     !!!r2   c                     || _         y r:   ry   r|   s     r3   rr   zNoteText.content_type  r}   r2   c                     | j                   S )z
        Get the encoding method used for the note's content.

        Returns:
            `Encoding` if set else `None`
        r   r@   s    r3   rs   zNoteText.encoding  r   r2   c                     || _         y r:   r   r   s     r3   rs   zNoteText.encoding   r   r2   c                 Z    t        | j                  | j                  | j                  f      S r:   )rI   rt   rr   rs   r@   s    r3   rJ   zNoteText.__comparable_tuple  s)    LL$++T]]!
  	r2   rK   c                 f    t        |t              r!| j                         |j                         k(  S yrM   )rN   r  _NoteText__comparable_tuplerP   s     r3   rQ   zNoteText.__eq__	  r   r2   c                 p    t        |t              r!| j                         |j                         k  S t        S r:   )rN   r  r  rT   rP   s     r3   rU   zNoteText.__lt__  r   r2   c                 4    t        | j                               S r:   )rX   r  r@   s    r3   rY   zNoteText.__hash__  rZ   r2   c                 <    d| j                    d| j                   dS )Nz<NoteText content_type=r   r\   rq   r@   s    r3   r]   zNoteText.__repr__  s#    ():):(;;t}}oUVWWr2   )r)   r*   r+   r,   r   r^   r   r
   rk   r<   r_   r`   rc   rt   rb   ra   rr   rs   rI   r  rg   rh   rQ   r	   rU   ri   rY   r]   r1   r2   r3   r  r    s    !-#,
 '+'+	!! sm! 8$	!
 
! \3     ^^ s  t     \!\>*	"hsm 	" + " 	" * * * * \!(8,  "  __"(!3 " " "$4 
F t 
C D 
/# /X# Xr2   r  c                   V   e Zd ZdZ ej
                  d      Zdddedee	   ddfdZ
edefd	       Zej                  deddfd
       Ze ej                  d      dee	   fd              Zej                  dee	   ddfd       ZdefdZdedefdZdedefdZdefdZde	fdZy)Notea=  
    This is our internal representation of the Note complex type that can be used in multiple places within
    a CycloneDX BOM document.

    .. note::
        See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_releaseNotesType

    @todo: Replace ``NoteText`` with ``AttachedText``?
    z^[a-z]{2}(?:\-[A-Z]{2})?$N)localetextr  r8   c                     || _         || _        y r:   )r  r  )r;   r  r  s      r3   r<   zNote.__init__(  s    
 	r2   c                     | j                   S )zj
        Specifies the full content of the release note.

        Returns:
            `NoteText`
        _textr@   s    r3   r  z	Note.text0  s     zzr2   c                     || _         y r:   r  r;   r  s     r3   r  z	Note.text:  rB   r2   r"   c                     | j                   S )a  
        Get the ISO locale of this Note.

        The ISO-639 (or higher) language code and optional ISO-3166 (or higher) country code.

        Examples include: "en", "en-US", "fr" and "fr-CA".

        Returns:
            `str` locale if set else `None`
        )_localer@   s    r3   r  zNote.locale>  s     ||r2   c                     || _         t        |t              r;t        j                  t
        j                  |      sd | _         t        d|d      y y )NzSupplied locale z is not a valid locale. Locale string should be formatted as the ISO-639 (or higher) language code and optional ISO-3166 (or higher) country code. according to ISO-639 format. Examples include: 'en', 'en-US'.)r  rN   r^   r_  r`  r  _LOCALE_TYPE_REGEXr   )r;   r  s     r3   r  zNote.localeM  sX    fc"99T44f=#0&vj 1x x  > #r2   c                 D    t        | j                  | j                  f      S r:   )rI   r  r  r@   s    r3   rJ   zNote.__comparable_tupleY  s!    KK!
  	r2   rK   c                 f    t        |t              r!| j                         |j                         k(  S yrM   )rN   r  _Note__comparable_tuplerP   s     r3   rQ   zNote.__eq__^  s,    eT"**,0H0H0JJJr2   c                 p    t        |t              r!| j                         |j                         k  S t        S r:   )rN   r  r  rT   rP   s     r3   rU   zNote.__lt__c  s/    eT"**,u/G/G/IIIr2   c                 4    t        | j                               S r:   )rX   r  r@   s    r3   rY   zNote.__hash__h  rZ   r2   c                 :    dt        |        d| j                   dS )Nz	<Note id=z	, locale=r\   )idr  r@   s    r3   r]   zNote.__repr__k  s    2d8*Idkk]!<<r2   )r)   r*   r+   r,   r_  r~  r  r  r
   r^   r<   r_   r  rb   r`   r  r  rI   r  rg   rh   rQ   r	   rU   ri   rY   r]   r1   r2   r3   r  r    s/    $$@A
 !%  
	 h   
[[ d   \q!  "  ]]	Xc] 	t 	 	$4 
F t 
C D 
/# /=# =r2   r  c            	       n   e Zd ZdZdddddee   dee   dee   ddfdZe e	j                  e	j                  j                        dee   fd	              Zej                  dee   ddfd
       Ze e	j                  e	j                   j"                        dee   fd              Zej                  dee   ddfd       Ze e	j                  e	j                   j"                        dee   fd              Zej                  dee   ddfd       ZdefdZdedefdZdedefdZdefdZdefdZy)IdentifiableActionz
    This is our internal representation of the `identifiableActionType` complex type.

    .. note::
        See the CycloneDX specification: https://cyclonedx.org/docs/1.7/xml/#type_identifiableActionType
    N	timestampr   emailr  r   r  r8   c                .    || _         || _        || _        y r:   r  )r;   r  r   r  s       r3   r<   zIdentifiableAction.__init__x  s     #	
r2   c                     | j                   S )zy
        The timestamp in which the action occurred.

        Returns:
            `datetime` if set else `None`
        
_timestampr@   s    r3   r  zIdentifiableAction.timestamp  s     r2   c                     || _         y r:   r  )r;   r  s     r3   r  zIdentifiableAction.timestamp  s	    #r2   c                     | j                   S )z}
        The name of the individual who performed the action.

        Returns:
            `str` if set else `None`
        r  r@   s    r3   r   zIdentifiableAction.name       zzr2   c                     || _         y r:   r  r  s     r3   r   zIdentifiableAction.name  rB   r2   c                     | j                   S )z
        The email address of the individual who performed the action.

        Returns:
            `str` if set else `None`
        _emailr@   s    r3   r  zIdentifiableAction.email  s     {{r2   c                     || _         y r:   r  )r;   r  s     r3   r  zIdentifiableAction.email  r  r2   c                 Z    t        | j                  | j                  | j                  f      S r:   )rI   r  r   r  r@   s    r3   rJ   z%IdentifiableAction.__comparable_tuple  s'    NNDIItzz!
  	r2   rK   c                 f    t        |t              r!| j                         |j                         k(  S yrM   )rN   r  %_IdentifiableAction__comparable_tuplerP   s     r3   rQ   zIdentifiableAction.__eq__  rR   r2   c                 p    t        |t              r!| j                         |j                         k  S t        S r:   )rN   r  r  rT   rP   s     r3   rU   zIdentifiableAction.__lt__  rV   r2   c                 4    t        | j                               S r:   )rX   r  r@   s    r3   rY   zIdentifiableAction.__hash__  rZ   r2   c                 <    d| j                    d| j                   dS )Nz<IdentifiableAction name=z, email=r\   )r   r  r@   s    r3   r]   zIdentifiableAction.__repr__  s    *499+Xdjj\KKr2   )r)   r*   r+   r,   r
   r   r^   r<   r_   r`   r  helpersXsdDateTimer  rb   rd   re   rf   r   r  rI   r  rg   rh   rQ   r	   rU   ri   rY   r]   r1   r2   r3   r  r  o  s    )-"#	H% sm }	
 
 \|33??@8H-  A  $8H#5 $$ $ $ \\DDVVWhsm  X  
[[# 4   \\DDVVWx}  X  \\8C= T  $4 
F t 
C D 
/# /L# Lr2   r  c                       e Zd ZdZdeddfdZe ej                  d      defd              Z	e	j                  deddfd       Z	d	edefd
Zd	edefdZdefdZdefdZy)	Copyrightz
    This is our internal representation of the `copyrightsType` complex type.

    .. note::
        See the CycloneDX specification: https://cyclonedx.org/docs/1.7/xml/#type_copyrightsType
    r  r8   Nc                    || _         y r:   r  r  s     r3   r<   zCopyright.__init__  s     	r2   rC   c                     | j                   S )z]
        Copyright statement.

        Returns:
            `str` if set else `None`
        r  r@   s    r3   r  zCopyright.text  r  r2   c                     || _         y r:   r  r  s     r3   r  zCopyright.text  rB   r2   rK   c                 V    t        |t              r| j                  |j                  k(  S yrM   )rN   r  r  rP   s     r3   rQ   zCopyright.__eq__  s"    eY'::,,r2   c                 `    t        |t              r| j                  |j                  k  S t        S r:   )rN   r  r  rT   rP   s     r3   rU   zCopyright.__lt__  s%    eY'::++r2   c                 ,    t        | j                        S r:   )rX   r  r@   s    r3   rY   zCopyright.__hash__  s    DJJr2   c                 "    d| j                    dS )Nz<Copyright text=r\   r  r@   s    r3   r]   zCopyright.__repr__  s    !$))A..r2   )r)   r*   r+   r,   r^   r<   r_   r`   rc   r  rb   rg   rh   rQ   r	   rU   ri   rY   r]   r1   r2   r3   r  r    s     
 \3c     
[[   F t 
C D 
 #  /# /r2   r  )Mr,   r_  syscollections.abcr   r   r   enumr   	functoolsr   jsonr   r   typingr	   r
   r   urllib.parser   rw  uuidr   warningsr   xml.etree.ElementTreer   r   version_infor   typing_extensionspy_serializabler`   sortedcontainersr   _internal.comparer   rI   exception.modelr   r   exception.serializationr   r   schema.schemar   r   r   r   r   r   r    r!   rr  r#   rx  serializable_enumr^   r%   serializable_classr5   rk   ro   r   r  
BaseHelperr   r   r   r:  rK  r  r  r  r  r  r  r1   r2   r3   <module>r     s  $ 
 
 /    $ ' ' +   7w#, & & C M p	 	 	   
sD 
  
   O8 O8 !O8d sD      Y\ Y\ !Y\x "C "  "0R
\-A-A-L-L R
j   _< _< !_<D 8C 8  8vX(L,@,@,K,K X(v !  tLz6L  ++ z6 Mz6z !  tL@C @C M@CF !  tLG. G. MG.T !  tLXX XX MXXv !  tLQ= Q= MQ=h !  tLRL RL MRLj !  tL+/ +/ M+/r2   