
    <io                     <   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r	SSKJr  SSKJrJrJr  SSKJrJr  SSKJr  SSKJrJrJrJrJrJrJrJr  SS	KJ r   \RB                  " S
5      r"\RB                  " S5      r#Sr$S r%S r&S r' " S S\(5      r) " S S\)5      r* " S S\)5      r+ " S S\)5      r, " S S\)5      r- " S S\)5      r. " S S\)5      r/ " S S\)5      r0 " S  S!\)5      r1 " S" S#\)5      r2 " S$ S%\25      r3 " S& S'\)5      r4 " S( S)\)5      r5 " S* S+\)5      r6\RB                  " S,5      r7 " S- S.\)5      r8 " S/ S0\+5      r9 " S1 S2\)5      r: " S3 S4\+5      r; " S5 S6\+5      r< " S7 S8\+5      r= " S9 S:\)5      r> " S; S<\25      r? " S= S>\)5      r@g)?zJClasses for representing properties of STIX Objects and Cyber Observables.    N   )	_STIXBase)CustomContentErrorDictionaryKeyError	STIXError)parseparse_observable)class_for_type)STIXTypeClass	_get_dictget_class_hierarchy_namesget_type_from_id	is_objectis_stix_typeparse_into_datetimeto_enum)DEFAULT_VERSIONz^-?[a-z0-9]+(-[a-z0-9]+)*-?$z"^([a-z][a-z0-9]*)+([a-z0-9-]+)*-?$zAnot a valid STIX identifier, must match <object-type>--<UUID>: {}c                     [         R                  " U 5      nUR                  [         R                  :H  nU(       a  US:X  a  UR                  S:H  nU$ )aL  
Check whether the given UUID string is valid with respect to the given STIX
spec version.  STIX 2.0 requires UUIDv4; 2.1 only requires the RFC 4122
variant.

:param uuid_str: A UUID as a string
:param spec_version: The STIX spec version
:return: True if the UUID is valid, False if not
:raises ValueError: If uuid_str is malformed
2.0   )uuidUUIDvariantRFC_4122version)uuid_strspec_versionuuid_objoks       J/home/james-whalen/.local/lib/python3.13/site-packages/stix2/properties.py_check_uuidr!      sE     yy"H			T]]	*B	le#"I    c                    U(       a0  U R                  U5      (       d  [        SR                  U5      5      e U(       a  U [        U5      S nOU R	                  S5      nXS-   S n[        X15      nU(       d  [        [        R                  U 5      5      eg! [         a    [        [        R                  U 5      5      ef = f)a  
Check the STIX identifier for correctness, raise an exception if there are
errors.

:param id_: The STIX identifier
:param spec_version: The STIX specification version to use
:param required_prefix: The required prefix on the identifier, if any.
    This function doesn't add a "--" suffix to the prefix, so callers must
    add it if it is important.  Pass None to skip the prefix check.
:raises ValueError: If there are any errors with the identifier
zmust start with '{}'.N--   )
startswith
ValueErrorformatlenindexr!   ERROR_INVALID_ID)id_r   required_prefix	uuid_partidxresults         r    _validate_idr1   3   s     ~~o..4;;OLMM
7C012I))D/CEFIY5
 )00566 	  7)005667s   9B )Cc                 "   US:X  a/  [         R                  " [        U 5      (       d  [        SU -  5      eO.[         R                  " [        U 5      (       d  [        SU -  5      e[        U 5      S:  d  [        U 5      S:  a  [        SU -  5      eg)z
Check the STIX type name for correctness, raise an exception if there are
errors.

:param type_: The STIX type name
:param spec_version: The STIX specification version to use
:raises ValueError: If there are any errors with the identifier
r   zdInvalid type name '%s': must only contain the characters a-z (lowercase ASCII), 0-9, and hyphen (-).zInvalid type name '%s': must only contain the characters a-z (lowercase ASCII), 0-9, and hyphen (-) and must begin with an a-z character      z=Invalid type name '%s': must be between 3 and 250 characters.N)rematch
TYPE_REGEXr'   TYPE_21_REGEXr)   )type_r   s     r    _validate_typer:   S   s     uxx
E**I  + xxu--79>?  5zA~Uc)KeS
 	
 *r"   c                   6    \ rS rSrSrSS jrS	S jrSS jrSrg)
Propertyq   a  Represent a property of STIX data type.

Subclasses can define the following attributes as keyword arguments to
``__init__()``.

Args:
    required (bool): If ``True``, the property must be provided when
        creating an object with that property. No default value exists for
        these properties. (Default: ``False``)
    fixed: This provides a constant default value. Users are free to
        provide this value explicitly when constructing an object (which
        allows you to copy **all** values from an existing object to a new
        object), but if the user provides a value other than the ``fixed``
        value, it will raise an error. This is semantically equivalent to
        defining both:

        - a ``clean()`` function that checks if the value matches the fixed
          value, and
        - a ``default()`` function that returns the fixed value.

Subclasses can also define the following functions:

- ``def clean(self, value, allow_custom) -> (any, has_custom):``
    - Return a value that is valid for this property, and enforce and
      detect value customization.  If ``value`` is not valid for this
      property, you may attempt to transform it first.  If ``value`` is not
      valid and no such transformation is possible, it must raise an
      exception.  The method is also responsible for enforcing and
      detecting customizations.  If allow_custom is False, no customizations
      must be allowed.  If any are encountered, an exception must be raised
      (e.g. CustomContentError).  If none are encountered, False must be
      returned for has_custom.  If allow_custom is True, then the clean()
      method is responsible for detecting any customizations in the value
      (just because the user has elected to allow customizations doesn't
      mean there actually are any).  The method must return an appropriate
      value for has_custom.  Customization may not be applicable/possible
      for a property.  In that case, allow_custom can be ignored, and
      has_custom must be returned as False.

- ``def default(self):``
    - provide a default value for this property.
    - ``default()`` can return the special value ``NOW`` to use the current
        time. This is useful when several timestamps in the same object
        need to use the same default value, so calling now() for each
        property-- likely several microseconds apart-- does not work.

Subclasses can instead provide a lambda function for ``default`` as a
keyword argument. ``clean`` should not be provided as a lambda since
lambdas cannot raise their own exceptions.

When instantiating Properties, ``required`` and ``default`` should not be
used together. ``default`` implies that the property is required in the
specification so this function will be used to supply a value if none is
provided. ``required`` means that the user must provide this; it is
required in the specification and we can't or don't want to create a
default value.

c                 p    XR                   :w  a$  [        SR                  U R                   5      5      eUS4$ )Nzmust equal '{}'.F)_fixed_valuer'   r(   selfvalueallow_customs      r    _default_cleanProperty._default_clean   s5    %%%/66t7H7HIJJe|r"   Nc                    ^ Xl         U(       a  U(       a  [        S5      eT(       a#  TU l        U R                  U l        U4S jU l        U(       a  X0l        g g )NzaCan't use 'required' and 'default' together. 'required'really means 'the user must provide this.'c                     > T $ N fixeds   r    <lambda>#Property.__init__.<locals>.<lambda>   s    5r"   )requiredr   r?   rD   cleandefault)rA   rN   rK   rP   s     ` r    __init__Property.__init__   sM     = 
  %D,,DJ(DL"L r"   c                 
    US4$ NFrI   r@   s      r    rO   Property.clean   s    e|r"   )r?   rO   rP   rN   F)FNN)	__name__
__module____qualname____firstlineno____doc__rD   rQ   rO   __static_attributes__rI   r"   r    r<   r<   q   s    9v
# r"   r<   c                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )ListProperty   c                   > SU l         [        R                  " U5      (       a>  [        U[        5      (       a  U" 5       U l         O7[        U[
        5      (       a  Xl         O[        U[        5      (       a  Xl         U R                   (       d#  [        SR                  [        U5      5      5      e[        [        U ]2  " S0 UD6  g)zP
``contained`` should be a Property class or instance, or a _STIXBase
subclass.
NzInvalid list element type: {}rI   )	containedinspectisclass
issubclassr<   r   
isinstance	TypeErrorr(   strsuperr^   rQ   )rA   ra   kwargs	__class__s      r    rQ   ListProperty.__init__   s    
 ??9%% )X..!*Iy11!*	8,,&N~~/66	N  	lD*4V4r"   c           	      D    [        U5        [        U[        [
        45      (       a  U/n/ nSn[        U R                  [        5      (       aC  U H<  nU R                  R                  XR5      u  pgUR                  U5        U=(       d    UnM>     OU H  n[        XPR                  5      (       a  UnOv[        U[        R                  R                  5      (       a  U R                  " SSU0UD6nO8[        SR                  U R                  R                  [        U5      5      5      eUR                  U5        U=(       d    UR                  nM     U(       d  U(       a  [!        S5      e[#        U5      S:  a  [        S5      eX44$ ! [         a    [        S5      ef = f)	Nzmust be an iterable.FrC   zCan't create a {} out of {}custom content encounteredr   must not be empty.rI   )iterrf   r'   re   r   rg   ra   r<   rO   appendcollectionsabcMappingr(   _type
has_customr   r)   )rA   rB   rC   r0   ru   itemvalidtemp_customs           r    rO   ListProperty.clean   si   	5K ei-..GE
dnnh//%)^^%9%9$%M"e$'6;
  dNN33 Ekoo&=&=>> NNMMME %5<< NN00#d)  e$';5+;+;
! $ 
$%ABB v;?122!!Q  	5344	5s   F	 	F)ra   rW   rX   rY   rZ   rQ   rO   r\   __classcell__rj   s   @r    r^   r^      s    56+" +"r"   r^   c                   2   ^  \ rS rSrU 4S jrSS jrSrU =r$ )StringPropertyi  c                 .   > [         [        U ]
  " S0 UD6  g NrI   )rh   r~   rQ   )rA   ri   rj   s     r    rQ   StringProperty.__init__  s    nd,6v6r"   c                 J    [        U[        5      (       d  [        U5      nUS4$ rT   )re   rg   r@   s      r    rO   StringProperty.clean  s"    %%%JEe|r"   rI   rV   rz   r|   s   @r    r~   r~     s    7 r"   r~   c                   .   ^  \ rS rSr\4U 4S jjrSrU =r$ )TypePropertyi  c                 J   > [        X5        X l        [        [        U ]  US9  g )NrJ   )r:   r   rh   r   rQ   rA   typer   rj   s      r    rQ   TypeProperty.__init__  s#    t*(lD**6r"   r   )rW   rX   rY   rZ   r   rQ   r\   r{   r|   s   @r    r   r     s    *9 7 7r"   r   c                   >   ^  \ rS rSr\4U 4S jjrSS jrS rSrU =r	$ )
IDPropertyi$  c                 J   > US-   U l         X l        [        [        U ]  5         g )Nr$   )r-   r   rh   r   rQ   r   s      r    rQ   IDProperty.__init__&  s"    #d{(j$(*r"   c                 J    [        XR                  U R                  5        US4$ rT   )r1   r   r-   r@   s      r    rO   IDProperty.clean+  s"    U--t/C/CDe|r"   c                 X    U R                   [        [        R                  " 5       5      -   $ rH   )r-   rg   r   uuid4)rA   s    r    rP   IDProperty.default/  s    ##c$**,&777r"   )r-   r   rV   )
rW   rX   rY   rZ   r   rQ   rO   rP   r\   r{   r|   s   @r    r   r   $  s    *9 +
8 8r"   r   c                   6   ^  \ rS rSrSU 4S jjrSS jrSrU =r$ )IntegerPropertyi3  c                 F   > Xl         X l        [        [        U ]  " S0 UD6  g r   )minmaxrh   r   rQ   rA   r   r   ri   rj   s       r    rQ   IntegerProperty.__init__5  s    ot-77r"   c                 `    [        U5      nU R                  b6  XR                  :  a'  SR	                  U R                  U5      n[        U5      eU R
                  b6  XR
                  :  a'  SR	                  U R
                  U5      n[        U5      eUS4$ ! [         a    [        S5      ef = f)Nzmust be an integer. minimum value is {}. received {} maximum value is {}. received {}F)int	Exceptionr'   r   r(   r   rA   rB   rC   msgs       r    rO   IntegerProperty.clean:  s    	4JE 88EHH$44;;DHHeLCS/!88EHH$44;;DHHeLCS/!e|  	4233	4   B B-r   r   NNrV   rz   r|   s   @r    r   r   3  s    8
 r"   r   c                   6   ^  \ rS rSrSU 4S jjrSS jrSrU =r$ )FloatPropertyiK  c                 F   > Xl         X l        [        [        U ]  " S0 UD6  g r   )r   r   rh   r   rQ   r   s       r    rQ   FloatProperty.__init__M  s    mT+5f5r"   c                 `    [        U5      nU R                  b6  XR                  :  a'  SR	                  U R                  U5      n[        U5      eU R
                  b6  XR
                  :  a'  SR	                  U R
                  U5      n[        U5      eUS4$ ! [         a    [        S5      ef = f)Nzmust be a float.r   r   F)floatr   r'   r   r(   r   r   s       r    rO   FloatProperty.cleanR  s    	1%LE 88EHH$44;;DHHeLCS/!88EHH$44;;DHHeLCS/!e|  	1/00	1r   r   r   rV   rz   r|   s   @r    r   r   K  s    6
 r"   r   c                   .    \ rS rSr/ SQr/ SQrSS jrSrg)BooleanPropertyic  )truet1r   T)falsef0r   Fc                     [        U[        5      (       a  UR                  5       nXR                  ;   a  SnUS4$ XR                  ;   a  SnUS4$ [        S5      e)NTFzmust be a boolean value.)re   rg   lower_trues_falsesr'   )rA   rB   rC   r0   s       r    rO   BooleanProperty.cleang  s`    eS!!KKMEKKF u} ll"F u} 788r"   rI   NrV   )rW   rX   rY   rZ   r   r   rO   r\   rI   r"   r    r   r   c  s    (F+Gr"   r   c                   6   ^  \ rS rSrSU 4S jjrSS jrSrU =r$ )TimestampPropertyiv  c                 F   > Xl         X l        [        [        U ]  " S0 UD6  g r   )	precisionprecision_constraintrh   r   rQ   )rA   r   r   ri   rj   s       r    rQ   TimestampProperty.__init__x  s!    "$8!/9&9r"   c                 F    [        XR                  U R                  5      S4$ rT   )r   r   r   r@   s      r    rO   TimestampProperty.clean~  s&    ">>4#<#<
 	r"   )r   r   )anyexactrV   rz   r|   s   @r    r   r   v  s    : r"   r   c                   8   ^  \ rS rSr\4U 4S jjrSS jrSrU =r$ )DictionaryPropertyi  c                 :   > Xl         [        [        U ]  " S0 UD6  g r   )r   rh   r   rQ   )rA   r   ri   rj   s      r    rQ   DictionaryProperty.__init__  s    ( $0:6:r"   c                     [        U5      nUR                  5        H  nU R                  S:X  a7  [	        U5      S:  a  [        US5      e[	        U5      S:  a  [        US5      eO+U R                  S:X  a  [	        U5      S:  a  [        US	5      e[        R                  " S
U5      (       a  M  Sn[        XE5      e   [	        U5      S:  a  [        S5      eUS4$ ! [         a    [        S5      ef = f)Nz1The dictionary property must contain a dictionaryr   r3   zshorter than 3 characters   zlonger than 256 charactersz2.1r4   zlonger than 250 charactersz^[a-zA-Z0-9_-]+$zhcontains characters other than lowercase a-z, uppercase A-Z, numerals 0-9, hyphen (-), or underscore (_)r   rn   F)r   r'   keysr   r)   r   r5   r6   )rA   rB   rC   	dictifiedkr   s         r    rO   DictionaryProperty.clean  s    	R!%(I !A  E)q6A:,Q0KLLVc\,Q0LMM """e+q6C<,Q0LMM88/33% 
 )00 "" y>A122%-  	RPQQ	Rs   C C3r   rV   	rW   rX   rY   rZ   r   rQ   rO   r\   r{   r|   s   @r    r   r     s    $3 ;   r"   r   c                   :   ^  \ rS rSr\4U 4S jjrU 4S jrSrU =r$ )HashesPropertyi  c                    > [         TU ]  " SSU0UD6  Xl        0 U l        U H9  n[        R
                  R                  U5      nU(       d  M+  X@R                  U'   M;     g )Nr   rI   )rh   rQ    _HashesProperty__spec_hash_names!_HashesProperty__alg_to_spec_namestix2hashesinfer_hash_algorithm)rA   spec_hash_namesr   ri   spec_hash_namealgrj   s         r    rQ   HashesProperty.__init__  sY    =l=f=!0 #%-N,,33NCCs/='', .r"   c                   > [         TU ]  X5      u  p40 nSnUR                  5        H  u  px[        R                  R                  U5      n	U	(       ao  [        R                  R                  X5      (       d$  [        SR                  XR                  5      5      eU R                  R                  U	5      n
U
(       d  SnUn
OUn
XR                  ;  a  SnU(       d  U(       a  [        SU-   5      eXU
'   M     XV4$ )NFz'{0}' is not a valid {1} hashTzcustom hash algorithm: )rh   rO   itemsr   r   r   
check_hashr'   r(   namer   getr   r   )rA   rB   rC   
clean_dict_	spec_dictru   hash_khash_vhash_alg	spec_namerj   s              r    rO   HashesProperty.clean  s     e:
	
(..0NF||88@H||..x@@$7>>"MM  !3377A	  "&J &I #	$:$::!%JJ(-6  $*i C 1F $$r"   )__alg_to_spec_name__spec_hash_namesr   r|   s   @r    r   r     s    5D >+% +%r"   r   c                       \ rS rSrSS jrSrg)BinaryPropertyi  c                      [         R                  " U5        US4$ ! [        R                  [        4 a    [        S5      ef = f)Nz$must contain a base64 encoded stringF)base64	b64decodebinasciiErrorrf   r'   r@   s      r    rO   BinaryProperty.clean  sJ    	EU# e| 	* 	ECDD	Es	    &ArI   NrV   rW   rX   rY   rZ   rO   r\   rI   r"   r    r   r     s    r"   r   c                       \ rS rSrSS jrSrg)HexPropertyi  c                 X    [         R                  " SU5      (       d  [        S5      eUS4$ )Nz^([a-fA-F0-9]{2})+$z5must contain an even number of hexadecimal charactersF)r5   r6   r'   r@   s      r    rO   HexProperty.clean  s*    xx.66TUUe|r"   rI   NrV   r   rI   r"   r    r   r         r"   r   c                   N   ^  \ rS rSr\" S5      u  rrSS\4U 4S jjrS r	Sr
U =r$ )ReferencePropertyi  r%   Nc                 |  > X0l         Ub  Uc  Uc  Uc  [        S5      eU(       a  [        U[        5      (       d  U/nOU(       a  [        U[        5      (       d  U/nUb  [	        U5      S:X  a  [        S5      eU(       a  U R
                  OU R                  U l        [        5       U l	        [        5       U l
        U=(       d    UnU H/  n [        U[        5      nU R                  R                  U5        M1     [        [         U ]F  " S0 UD6  g! [         a    U R                  R                  U5         Mp  f = f)z8
references sometimes must be to a specific object type
Nz>Exactly one of 'valid_types' and 'invalid_types' must be givenr   z+Impossible type constraint: empty whitelistrI   )r   r'   re   listr)   
_WHITELIST
_BLACKLIST	auth_typesetgenerics	specificsr   r   addKeyErrorrh   r   rQ   )	rA   valid_typesinvalid_typesr   ri   typesr9   
enum_valuerj   s	           r    rQ   ReferenceProperty.__init__  s    )#(A$)> 
 z+t<<&-K:mT#B#B*OM"s;'71'<JKK,7T__
 ,}E.$UM:
 !!*-  	/9&9  *""5)*s   D%D;:D;c                    [        U[        5      (       a  UR                  n[        U5      n[	        XR
                  S 5        [        U5      n[        5       nU R                  nU R                  nU R                  nU(       a6  XpR                  :X  a'  U(       a   U R                  n[        [        5      U-
  nXdpdXpR                  :X  a"  [        X0R
                  /UQ76 =(       d    X6;   nO1[        X0R
                  /UQ76 (       + =(       a    X6;  =(       d    X4;   n[        X0R
                  5      (       + =(       d    UR!                  S5      n	U(       d  U R                  R#                  U R                  5      n
SR%                  S U
 5       5      n
U R                  U R                  :X  a  SU
-  nOSU
-  nU(       d  U	(       a  US-  n['        SU< SU< 35      eU(       d  U	(       a  [)        S	U-   5      eX4$ )
Nzx-z, c              3   h   #    U  H(  n[        U[        5      (       a  UR                  OUv   M*     g 7frH   )re   r   r   ).0xs     r    	<genexpr>*ReferenceProperty.clean.<locals>.<genexpr>U  s(     [UZPQ
1m(D(Daff!KUZs   02z1not one of the valid types for this property: %s.z/one of the invalid types for this property: %s.z< A custom object type may be allowed with allow_custom=True.zThe type-specifying prefix 'z' for this property is z!reference to custom object type: )re   r   idrg   r1   r   r   r   r   r  r   r   r   r   r   r   r&   unionjoinr'   r   )rA   rB   rC   obj_typeblacklist_exceptionsr   r  r   type_okru   r  r   s               r    rO   ReferenceProperty.clean   s   eY''HHEE
U--t4#E*  #u==NN	NN	I8X I=)H4H.7)'"++.6 '&  !//2:  0/2 1	  #8->->?? )""4( 	 NN((7EII[UZ[[E~~0IEQG%OJUUS" 
 
$3h>    r"   )r   r   r   r  )rW   rX   rY   rZ   ranger   r   r   rQ   rO   r\   r{   r|   s   @r    r   r     s*    "1XJ
#'t/ %:NF! F!r"   r   z8^([a-z0-9_-]{3,250}(\.(\[\d+\]|[a-z0-9_-]{1,250}))*|id)$c                       \ rS rSrSS jrSrg)SelectorPropertyil  c                 T    [         R                  U5      (       d  [        S5      eUS4$ )Nzmust adhere to selector syntax.F)SELECTOR_REGEXr6   r'   r@   s      r    rO   SelectorProperty.cleann  s)    ##E**>??e|r"   rI   NrV   r   rI   r"   r    r  r  l  r   r"   r  c                   ,   ^  \ rS rSrSU 4S jjrSrU =r$ )ObjectReferencePropertyit  c                 r   > U(       a  [        U5      [        La  U/nXl        [        [        U ]  " S0 UD6  g r   )r   r   r  rh   r  rQ   )rA   r  ri   rj   s      r    rQ    ObjectReferenceProperty.__init__v  s2    4,D8&-K&%t5??r"   )r  rH   )rW   rX   rY   rZ   rQ   r\   r{   r|   s   @r    r  r  t  s    @ @r"   r  c                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )EmbeddedObjectPropertyi}  c                 :   > Xl         [        [        U ]  " S0 UD6  g r   )r   rh   r!  rQ   )rA   r   ri   rj   s      r    rQ   EmbeddedObjectProperty.__init__  s    	$d4>v>r"   c                 d   [        U[        5      (       a  U R                  " SSU0UD6nOH[        XR                  5      (       d.  [        SR	                  U R                  R
                  5      5      eSn[        U[        5      (       a  UR                  nU(       d  U(       a  [        S5      eX4$ )NrC   zmust be of type {}.Frm   rI   )	re   dictr   r'   r(   rW   r   ru   r   )rA   rB   rC   ru   s       r    rO   EmbeddedObjectProperty.clean  s    eT""IIA<A5AEE99--299$)):L:LMNN
eY''))J
$%ABB  r"   )r   rz   r|   s   @r    r!  r!  }  s    ?! !r"   r!  c                   8   ^  \ rS rSrSrU 4S jrU 4S jrSrU =r$ )EnumPropertyi  z\
Used for enumeration type properties.  Properties of this type do not allow
customization.
c                 j   > [        U[        5      (       a  U/nXl        [        [        U ]  " S0 UD6  g r   )re   rg   allowedrh   r(  rQ   rA   r*  ri   rj   s      r    rQ   EnumProperty.__init__  s.    gs##iGlD*4V4r"   c                    > [         [        U ]  X5      u  p4X0R                  ;  a  [	        SR                  U5      5      eUS4$ )Nz-value '{}' is not valid for this enumeration.F)rh   r(  rO   r*  r'   r(   )rA   rB   rC   cleaned_valuer   rj   s        r    rO   EnumProperty.clean  sD     t:5O,LSSTabcce##r"   r*  	rW   rX   rY   rZ   r[   rQ   rO   r\   r{   r|   s   @r    r(  r(    s    
5$ $r"   r(  c                   8   ^  \ rS rSrSrU 4S jrU 4S jrSrU =r$ )OpenVocabPropertyi  z&
Used for open vocab type properties.
c                 j   > [         [        U ]
  " S0 UD6  [        U[        5      (       a  U/nXl        g r   )rh   r3  rQ   re   rg   r*  r+  s      r    rQ   OpenVocabProperty.__init__  s/    /9&9gs##iGr"   c                 8   > [         [        U ]  X5      u  p4SnX54$ rT   )rh   r3  rO   )rA   rB   rC   r.  r   ru   rj   s         r    rO   OpenVocabProperty.clean  s+     !2D?
 
((r"   r0  r1  r|   s   @r    r3  r3    s    ) )r"   r3  c                       \ rS rSrSrg)PatternPropertyi  rI   N)rW   rX   rY   rZ   r\   rI   r"   r    r9  r9    s    r"   r9  c                   8   ^  \ rS rSrSr\4U 4S jjrS rSrU =r	$ )ObservablePropertyi  z3Property for holding Cyber Observable Objects.
    c                 :   > Xl         [        [        U ]  " U0 UD6  g rH   )r   rh   r;  rQ   rA   r   argsri   rj   s       r    rQ   ObservableProperty.__init__      ( $0$A&Ar"   c                     [        U5      n[        R                  " U5      nU0 :X  a  [        S5      eUR	                  5        VVs0 s H
  u  pEXES   _M     nnnSnUR	                  5        Hw  u  p[        U	UUU R                  S9n
[        U
[        5      (       a  U=(       d    U
R                  nOSnU(       d$  U(       a  [        SR                  U
S   5      5      eXU'   My     X74$ ! [         a    [        S5      ef = fs  snnf )Nz1The observable property must contain a dictionaryz;The observable property must contain a non-empty dictionaryr   F)rC   r   Tzcustomized {} observable found)r   copydeepcopyr'   r   r	   r   re   r   ru   r   r(   )rA   rB   rC   r   r   v
valid_refsru   keyobj
parsed_objs              r    rO   ObservableProperty.clean  s   	R!%(I i0I ?Z[[1:1BC1Bva6l1B
C
!)HC))))	J *i00'@:+@+@
 "
J(4;;"6*  (cN+ *. $$?  	RPQQ	R
 Ds   !C+ D+Dr   
rW   rX   rY   rZ   r[   r   rQ   rO   r\   r{   r|   s   @r    r;  r;    s     %4 B&% &%r"   r;  c                   :   ^  \ rS rSrSr\S4U 4S jjrS rSrU =r	$ )ExtensionsPropertyi  z@Property for representing extensions on Observable objects.
    Fc                 (   > [         [        U ]  XS9  g )N)r   rN   )rh   rL  rQ   )rA   r   rN   rj   s      r    rQ   ExtensionsProperty.__init__  s     $0l0^r"   c           	          [        U5      n[        R                  " U5      nSnUR	                  5        GH  u  pV[        XPR                  S5      nU(       a  [        U[        5      (       a  U" S
SU0UD6nO7[        Xg5      (       a  UnO$[        SR                  U[        U5      5      5      eU=(       d    UR                  nU(       d!  U(       a  [        SR                  U5      5      eXU'   M  UR                  S5      (       a  [        XPR                  S5        O$U(       a  SnO[        S	R                  U5      5      eXcU'   GM     X44$ ! [         a    [        S5      ef = f)Nz1The extensions property must contain a dictionaryF
extensionsrC   z$Can't create extension '{}' from {}.z$custom content found in {} extensionzextension-definition--Tz&Can't parse unknown extension type: {}rI   )r   rB  rC  r'   r   r
   r   re   r%  rf   r(   r   ru   r   r&   r1   )	rA   rB   rC   r   ru   rF  subvalueclsexts	            r    rO   ExtensionsProperty.clean  s^   	R!%(I i0I 
&__.MC &7&7FCh--D<D8DC.. #C#>EEh  (93>>
#
,>EE  "%# >>":;; ..0H "!%J,-U-\-\]`-abb!)#Y /\ $$e  	RPQQ	Rs   !E E%rI   rJ  r|   s   @r    rL  rL    s     %4e _9% 9%r"   rL  c                   4   ^  \ rS rSr\4U 4S jjrS rSrU =r$ )STIXObjectPropertyiA  c                 :   > Xl         [        [        U ]  " U0 UD6  g rH   )r   rh   rV  rQ   r=  s       r    rQ   STIXObjectProperty.__init__C  r@  r"   c                   ^ 1 Skm[        U4S j[        U5       5       5      (       aQ  SU;   a  U R                  S:X  a  [        S5      eU(       d  UR                  (       a  [        S5      eXR                  4$  [        U5      nU0 :X  a  [        S5      eS	U;   a  US	   S
:X  a  [        S5      eSU;   a  U R                  S:X  a  [        S5      e[        X2S9n[        U[        5      (       a  UR                  nOSnU(       d$  U(       a  [        SR                  US	   5      5      eXE4$ ! [         a    [        S5      ef = f)N>   _DomainObjectMarkingDefinition_RelationshipObjectc              3   .   >#    U  H
  nUT;   v   M     g 7frH   rI   )r  r  stix2_classess     r    r  +STIXObjectProperty.clean.<locals>.<genexpr>K  s      
5 5s   r   r   zZSpec version 2.0 bundles don't yet support containing objects of a different spec version.rm   z5This property may only contain a dictionary or objectz?This property may only contain a non-empty dictionary or objectr   bundlez-This property may not contain a Bundle object)rC   Tzcustomized {} object found)r   r   r   r'   ru   r   r   r   re   r   r(   )rA   rB   rC   r   rH  ru   r^  s         @r    rO   STIXObjectProperty.cleanG  sg    V 
.u5
 
 
 &4+<+<+E    E$4$4()EFF****	V!%(I ?^__Y9V#4#@LMMY&4+<+<+EB 
 9@
j),,#..J J
 %,33v&  %%?  	VTUU	Vs   ;D- -Er   r   r|   s   @r    rV  rV  A  s    $3 B:& :&r"   rV  )Ar[   r   r   collections.abcrq   rB  rb   r5   r   r   stix2.hashesbaser   
exceptionsr   r   r   parsingr   r	   registryr
   utilsr   r   r   r   r   r   r   r   r   r   compiler7   r8   r+   r!   r1   r:   objectr<   r^   r~   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r!  r(  r3  r9  r;  rL  rV  rI   r"   r    <module>rk     s   P      	     I I , $   %ZZ78


@AG 
(7@
<Rv RjH"8 H"VX 78 78 8h 0H 0h &    D:%' :%zX ( q! q!h WXx @n @!X !,$> $*) )B	n 	.% .%b@%+ @%F@& @&r"   