VULN_CHECK_I913V6 % g3UdZddlmZddlmZmZddlmZddlm Z m Z ddl m Z ddl Z ddlZddlZddlmZdd lmZdd lmZed d gZd ed<eZd ed<ej6ZdZGddeZGddeZ GddeZ!edGddeZ"Gdde"eZ#GddeZ$Gdd eZ%Gd!d"eZ&Gd#d$Z'eefd%Z(e(Z) e)fd&Z*y)'z2 Validation errors, and some surrounding helpers. ) annotations) defaultdictdeque)pformat)dedentindent)ClassVarN)define) Unresolvable)_utilsanyOfoneOfzfrozenset[str] WEAK_MATCHESSTRONG_MATCHESc|dk(r0tjtjtdtSt dt d|)NRefResolutionError) stacklevelzmodule z has no attribute )warningswarn_RefResolutionError_DEPRECATION_MESSAGEDeprecationWarningAttributeError__name__)names :/usr/lib/python3.12/site-packages/jsonschema/exceptions.py __getattr__rsG ##  4 4  #" 78*,>tfE FFc eZdZUded<ded<edddeeeddef dfd ZdZdZed Z e d Z e d Z e d Z dd ZdZdZxZS)_Errorz ClassVar[str]!_word_for_schema_in_error_message#_word_for_instance_in_error_messageNc Lt |||||||||| | ||_t|x|_|_t| x|_|_t||_ |x|_ |_ ||_ ||_ ||_||_| |_| |_|D] } || _ yN)super__init__messagerpath relative_path schema_pathrelative_schema_pathlistcontextcause __cause__ validatorvalidator_valueinstanceschemaparent _type_checker)selfr)r2r*r0r/r3r4r5r,r6 type_checkererror __class__s rr(z_Error.__init__)s             ).t4 D&7<[7II44G} &++ T^".    )EELrcPd|jjd|jdS)N<: >)r;rr)r8s r__repr__z_Error.__repr__Rs'4>>**+2dll-=Q??rc|j|j|j|jf}t d|Dr |j St j|jt|jdd}t j|j|j}d}td|j d|jd|dtt|jd |j!d |dtt|jd |j!d j#S) Nc3,K|] }|tuywr&)_unset).0ms r z!_Error.__str__..Ys:$9qqF{$9s) containerindices z z Failed validating z in z: Hwidthz On )r2r3r4r5anyr)r format_as_indexr"r.r-r#r+rrrlstriprstrip)r8essential_for_verboser, instance_pathprefixs r__str__z_Error.__str__Us5 NND00$--!  :$9: :<< ,,<<223CR8 ..>>&&  \\N#~~0[MB 26?FFHIJ R8&AHHJKL    rc.|di|jS)Nr$ _contents)clsothers r create_fromz_Error.create_fromrs'U__&''rc|j}| |jSt|j}|jt |j |Sr&)r6r+r extendleftreversed absolute_pathr8r6r*s rraz_Error.absolute_pathvsH >%% %T''( !5!567 rc|j}| |jSt|j}|jt |j |Sr&)r6r-rr_r`absolute_schema_pathrbs rrdz_Error.absolute_schema_pathsH >,, ,T../ ! rcd}|jD]/}t|tr|dt|zdzz }(|d|zz }1|S)N$[].)ra isinstanceintstr)r8r*elems r json_pathz_Error.json_pathsM&&D$$c$i#--d " '  rc ||jtur||_|jD]%\}}t||tust |||'yr&)r7rDitemsgetattrsetattr)r8r9kwargskvs r_setz _Error._setsL  #(:(:f(D!-D LLNDAqtQ6)a##rc0d}tfd|DS)N) r)r0r/r2r3r*r,r4r5r6c3:K|]}|t|fywr&)rq)rEattrr8s rrGz#_Error._contents..sBEDT74./Es)dict)r8attrss` rrZz_Error._contentss BEBBBrc jd}t|tr&j j j|Stfd|DS#ttf$rYywxYw)NtypeFc3jK|]*}jjj|,ywr&)r7is_typer4)rE expected_typer8s rrGz'_Error._matches_type..s0 !)     & &t}}m D!)s03) r5KeyError TypeErrorrjrlr7rr4rP)r8expecteds` r _matches_typez_Error._matches_typesr {{6*H h $%%--dmmXF F !)   )$  sAA.-A.)r)rlr&)r __module__ __qualname____annotations__rDr(rArW classmethodr]propertyrardrnrvrZr __classcell__r;s@rr!r!$s'44)66  ' ' R@ :(($C  rr!ceZdZdZdZdZy)ValidationErrorz: An instance was invalid under a provided schema. r5r4Nrrr__doc__r"r#r$rrrrs)1%*4'rrceZdZdZdZdZy) SchemaErrorzB A schema was invalid under its corresponding metaschema. metaschemar5Nrr$rrrrs)5%*2'rrF)slotsc,eZdZUdZdZded<dZdZy)rz& A ref could not be resolved. zjsonschema.exceptions.RefResolutionError is deprecated as of version 4.18.0. If you wish to catch potential reference resolution errors, directly catch referencing.exceptions.Unresolvable. Exception_causecp|j|jurtS|j|jk(Sr&)r;NotImplementedrr8r\s r__eq__z_RefResolutionError.__eq__s+ >> 0! !{{ell**rc,t|jSr&)rlrr@s rrWz_RefResolutionError.__str__s4;;rN)rrrrrrrrWr$rrrrs#  > +  rrc2eZdZddZdZdZdZdZdZy) _WrappedReferencingErrorc2tj|d|y)N_wrapped)object __setattr__)r8r0s rr(z!_WrappedReferencingError.__init__s4U3rc|j|jur|j|jk(S|j|jjur|j|k(StSr&)r;rrrs rrz_WrappedReferencingError.__eq__sP ??dnn ,==ENN2 2 __ 7 7 7==E) )rc.t|j|Sr&)rqr)r8rys rrz$_WrappedReferencingError.__getattr__st}}d++rc,t|jSr&)hashrr@s r__hash__z!_WrappedReferencingError.__hash__sDMM""rc"d|jdS)Nz)rr;rr@s rrWz _WrappedReferencingError.__str__s(--))2232dmm_EErN)r0 _Unresolvable) rrrr(rrrrArWr$rrrrs!4,#>FrrceZdZdZdZdZy)UndefinedTypeCheckzN A type checker was asked to check a type it did not have registered. c||_yr&r})r8r}s rr(zUndefinedTypeCheck.__init__s  rc"d|jdS)NzType z is unknown to this type checkerrr@s rrWzUndefinedTypeCheck.__str__styym#CDDrNrrrrr(rWr$rrrrsErrceZdZdZdZdZy) UnknownTypezP A validator was asked to validate an instance against an unknown type. c.||_||_||_yr&)r}r4r5)r8r}r4r5s rr(zUnknownType.__init__s    rc d}td|jdtt|jd|j dtt|j d|j djS)NrKz Unknown type z, for validator with schema: rLrMz7 While checking instance: rO)rr}rrr5rRr4rS)r8rVs rrWzUnknownType.__str__ s))' 26?FFHIJ R8&AHHJKL     rNrr$rrrrs  rrc*eZdZdZdfd ZdZxZS) FormatErrorz% Validating a format failed. cPt|||||_|x|_|_yr&)r'r(r)r0r1)r8r)r0r;s rr(zFormatError.__init__s' %( &++ T^rc|jSr&)r)r@s rrWzFormatError.__str__!s ||rr&)rrrrr(rWrrs@rrrs, rrcPeZdZdZeZd dZdZdZdZ dZ dZ dZ e d Zy ) ErrorTreezF ErrorTrees make it easier to check which validations failed. ci|_t|j|_|D]D}|}|jD]}||} ||j|j <|j |_Fyr&)errorsrr;rZr*r2r4 _instance)r8rr:rIelements rr(zErrorTree.__init__,s` $T^^4EI ::%g. &05I  U__ -"'..I  rc||jvS)zC Check whether ``instance[index]`` has any errors. rYr8indexs r __contains__zErrorTree.__contains__8s&&rcj|jtur||vr|j||j|S)aQ Retrieve the child tree one level down at the given ``index``. If the index is not in the instance that this tree corresponds to and is not known by this tree, whatever error would be raised by ``instance.__getitem__`` will be propagated (usually this is some subclass of `LookupError`. )rrDrZrs r __getitem__zErrorTree.__getitem__>s2 >> 'E,= NN5 !~~e$$rc"||j|<y)zB Add an error to the tree at the given ``index``. NrY)r8rvalues r __setitem__zErrorTree.__setitem__Ks!&urc,t|jS)zY Iterate (non-recursively) over the indices in the instance with errors. )iterrZr@s r__iter__zErrorTree.__iter__QsDNN##rc|jS)z, Return the `total_errors`. ) total_errorsr@s r__len__zErrorTree.__len__Ws   rcjt|}|dk(rdnd}d|jjd|d|dS)Nr:rr=z (z total z)>)lenr;r)r8totalrs rrAzErrorTree.__repr__]s>D !QJH4>>**+2eWGF82FFrctd|jjD}t|j|zS)zT The total number of errors in the entire tree, including children. c38K|]\}}t|ywr&)r)rE_trees rrGz)ErrorTree.total_errors..gsK4JD3t94Js)sumrZrprr)r8 child_errorss rrzErrorTree.total_errorsbs5 KDNN4H4H4JKK 4;;,..rN)r$)rrrrrDrr(rrrrrrArrr$rrrr%sFI 1' %& $ ! G //rrcfd}|S)az Create a key function that can be used to sort errors by relevance. Arguments: weak (set): a collection of validation keywords to consider to be "weak". If there are two errors at the same level of the instance and one is in the set of weak validation keywords, the other error will take priority. By default, :kw:`anyOf` and :kw:`oneOf` are considered weak keywords and will be superseded by other same-level validation errors. strong (set): a collection of validation keywords to consider to be "strong" cv|j}t|j |v|v|j fSr&)r2rr*r)r:r2strongweaks r relevancezby_relevance..relevance}sCOO _  T !  ##% %   rr$)rrrs`` r by_relevancerks$  rcLt|}t|d}|yttj|g||}|j r[t jd|j |}t|dk(r||d||dk(r|S|d}|j r[|S)a Try to find an error that appears to be the best match among given errors. In general, errors that are higher up in the instance (i.e. for which `ValidationError.path` is shorter) are considered better matches, since they indicate "more" is wrong with the instance. If the resulting match is either :kw:`oneOf` or :kw:`anyOf`, the *opposite* assumption is made -- i.e. the deepest error is picked, since these keywords only need to match once, and any other errors may not be relevant. Arguments: errors (collections.abc.Iterable): the errors to select from. Do not provide a mixture of errors from different validation attempts (i.e. from different instances or schemas), since it won't produce sensical output. key (collections.abc.Callable): the key to use when sorting errors. See `relevance` and transitively `by_relevance` for more details (the default is to sort with the defaults of that function). Changing the default is only useful if you want to change the function that rates errors but still want the error context descent done by this function. Returns: the best matching error, or ``None`` if the iterable was empty .. note:: This function is a heuristic. Its return value may change for a given set of inputs from version to version if better heuristics are added. N)keyrrr) rnextmax itertoolschainr/heapq nsmallestr)rrbestsmallests r best_matchrsL&\F  D | yvv.C 8D ,,??1dll< x=A #hqk"2c(1+6F"FK{ ,, Kr)+r __future__r collectionsrrpprintrtextwraprrtypingr rrrr{r referencing.exceptionsr r jsonschemar frozensetrrrUnsetrDrrr!rrrrrrrrrrrr$rrrs#*# @('7);< n< N %3r