ɺhjdZdZddlZddlZddlmZddlmZddlmZddlm Z e j Z dZ d Z e d eZe d eZe d eZe d eZdZdZdZdZdZdZ d.dZeejeZeejeZeejeZeejeZeejeejZ eejeejZ!eej"dZ#eej$dZ%eej"dZ&eej$dZ'eZ(eZ)eejee*Z+ d.dZ, d.dZ-dZ.dZ/ej0dej1Z2dZ3d Z4d!Z5d"Z6d#Z7d$Z8d%Z9d&Z:d/d'Z;d(Zd+Z?d,Z@d-ZAeAZBdS)0a Code for decoding protocol buffer primitives. This code is very similar to encoder.py -- read the docs for that module first. A "decoder" is a function with the signature: Decode(buffer, pos, end, message, field_dict) The arguments are: buffer: The string containing the encoded message. pos: The current position in the string. end: The position in the string where the current message ends. May be less than len(buffer) if we're reading a sub-message. message: The message object into which we're parsing. field_dict: message._fields (avoids a hashtable lookup). The decoder reads the field and stores it into field_dict, returning the new buffer position. A decoder for a repeated field may proactively decode all of the elements of that field, if they appear consecutively. Note that decoders may throw any of the following: IndexError: Indicates a truncated message. struct.error: Unpacking of a fixed-width field failed. message.DecodeError: Other errors. Decoders are expected to raise an exception if they are called with pos > end. This allows callers to be lax about bounds checking: it's fineto read past "end" as long as you are sure that someone else will notice and throw an exception later on. Something up the call stack is expected to catch IndexError and struct.error and convert them to message.DecodeError. Decoders are constructed using decoder constructors with the signature: MakeDecoder(field_number, is_repeated, is_packed, key, new_default) The arguments are: field_number: The field number of the field we want to decode. is_repeated: Is the field a repeated field? (bool) is_packed: Is the field a packed field? (bool) key: The key to use when looking up the field within field_dict. (This is actually the FieldDescriptor but nothing in this file should depend on that.) new_default: A function which takes a message object as a parameter and returns a new instance of the default value for this field. (This is called for repeated fields and sub-messages, when an instance does not already exist.) As with encoders, we define a decoder constructor for every type of field. Then, for every field of every message class we construct an actual decoder. That decoder goes into a dict indexed by tag, so when we decode a message we repeatedly read a tag, look up the corresponding decoder, and invoke it. z kenton@google.com (Kenton Varda)N) containers)encoder) wire_format)messagecfd}|S)aReturn an encoder for a basic varint value (does not include tag). Decoded values will be bitwise-anded with the given mask before being returned, e.g. to limit them to 32 bits. The returned decoder does not take the usual "end" parameter -- the caller is expected to do bounds checking after the fact (often the caller can defer such checking until later). The decoder returns a (value, new_pos) pair. cd}d} ||}||dz|zz}|dz }|dzs|z}|}||fS|dz }|dkrtdLNr@z$Too many bytes when decoding varint. _DecodeError)bufferposresultshiftbmask result_types /builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib64/python3.11/site-packages/google/protobuf/internal/decoder.py DecodeVarintz$_VarintDecoder..DecodeVarintks F E C +a !d(u$%f Qhc$h$V$$} qje "ABBB C)rrrs`` r_VarintDecoderras0 C C C C C C rc:d|dz zd|zdz fd}|S)z0Like _VarintDecoder() but decodes signed values.r cd}d} ||}||dz|zz}|dz }|dzs|z}|z z }|}||fS|dz }|dkrtdTr r)rrrrrrrsignbits rrz*_SignedVarintDecoder..DecodeVarints F E C +a !d(u$%f Qhc$h$7"g-V$$} qje "ABBB Crr)bitsrrrrs ` @@r_SignedVarintDecoderr!|sS $(O' t)q$CCCCCCC rlrl c|}||dzr|dz }||dz|dz }|||}||fS)aRead a tag from the memoryview, and return a (tag_bytes, new_pos) tuple. We return the raw bytes of the tag rather than decoding them. The raw bytes can then be used to look up the proper decoder. This effectively allows us to trade some work that would be done in pure-python (decoding a varint) for work that is done in C (searching for a byte string in a hash table). In a low-level language it would be much cheaper to decode the varint and use that, but not in Python. Args: buffer: memoryview object of the encoded bytes pos: int of the current position to start from Returns: Tuple[bytes, int] of the tag data and new position. r r )tobytes)rrstart tag_bytess rReadTagr'sc" %s d 1HC s d (#U3Y''))) Crc dfd }|S)zReturn a constructor for a decoder for fields of a particular type. Args: wire_type: The field's wire type. decode_value: A function which decodes an individual value, e.g. _DecodeVarint() Fc |rt  fd}|S|r/tj|  t   fd}|S fd}|S)NcV| }||  |} ||\}}||z }||krtd||kr*||\}}||||k*||kr|d=td|S)NTruncated message.Packed element was truncated.get setdefaultrappend) rrendr field_dictvalueendpointelement decode_valuekeylocal_DecodeVarint new_defaults rDecodePackedFieldzB_SimpleDecoder..SpecificDecoder..DecodePackedFieldss## =''[[-A-ABB%,,VS993C c>>122 2Hnn'<44.7C ,,w   Hnn >>Bi<== = rc| }||  |} ||\}}||| z}||| ks||kr||krtd|SU)Nr r+)r/r0r1r) rrr2rr3r4r6new_posr7r8r:r&tag_lens rDecodeRepeatedFieldzD_SimpleDecoder..SpecificDecoder..DecodeRepeatedFieldss## =''[[-A-ABB% +|FC88 7G ,,w   '!# GCK I - -C}} !5666N rc||\}}||krtdr|s|dn||<|S)Nr+rpop) rrr2rr3 new_valueclear_if_defaultr7r8s r DecodeFieldz<_SimpleDecoder..SpecificDecoder..DecodeFieldse'<44C 99122 2  &I & ..d # # # #%*S/ r) _DecodeVarintrTagByteslen) field_number is_repeated is_packedr8r:rDr;r?rEr9r&r>r7 wire_types ``` @@@rSpecificDecoderz'_SimpleDecoder..SpecificDecoders/( "<;;iIg! rFr)rLr7rMs`` r_SimpleDecoderrOs5(-1111111f rc2fd}t||S)zLike SimpleDecoder but additionally invokes modify_value on every value before storing it. Usually modify_value is ZigZagDecode. c<||\}}||fSNr)rrrr=r7 modify_values r InnerDecodez%_ModifiedDecoder..InnerDecodes.$ VS11VW L ' **r)rO)rLr7rSrTs `` r_ModifiedDecoderrUs4++++++  ; / //rcvtjtjfd}t||S)zReturn a constructor for a decoder for a fixed-width field. Args: wire_type: The field's wire type. format: The format string to pass to struct.unpack(). cJ|z}|||d}||fS)Nrr)rrr=rformat local_unpack value_sizes rrTz'_StructPackDecoder..InnerDecodes7JG \&&W"5 6 6q 9F G r)structcalcsizeunpackrO)rLrXrTrYrZs ` @@r_StructPackDecoderr^sRv&&*,  ; / //rcZtjfd}ttj|S)zReturns a decoder for a float field. This code works around a bug in struct.unpack for non-finite 32-bit floating-point values. c4|dz}|||}|dddvrU|dddkrG|dddkrtj|fS|dddkrtj |fStj|fSd |d}||fS) a#Decode serialized float to a float and new position. Args: buffer: memoryview of the serialized bytes pos: int, position in the memory view to start at. Returns: Tuple[float, int] of the deserialized float value and new position in the serialized data. rsz.InnerDecode(sAgGW%--//K AaCK''K!,<,G,G QqS _ , ,'"" QqS W $ $ 7##h  \$ , ,Q /F G r)r[r]rOrWIRETYPE_FIXED32rTrYs @r _FloatDecoderrms;,     B  4k B BBrcZtjfd}ttj|S)zkReturns a decoder for a double field. This code works around a bug in struct.unpack for not-a-number. c|dz}|||}|dddvr*|dddkr|dddkrtj|fSd|d}||fS) a"Decode serialized double to a double and new position. Args: buffer: memoryview of the serialized bytes. pos: int, position in the memory view to start at. Returns: Tuple[float, int] of the decoded double value and new position in the serialized data. r rcrsz.InnerDecodeTsAgG#g+&..00L ac k ) ) !A# ' ) ) !A# "A A Ah  \$ - -a 0F G r)r[r]rOrWIRETYPE_FIXED64rls @r_DoubleDecoderruLs: ,:  4k B BBrFc j |rt  fd}|S|r:tjtj t   fd}|S fd}|S)z!Returns a decoder for enum field.c| }|| |} ||\}}||z }||krtd||kr|}t||\}}| jvr||n|jsg|_tj tj } |j| ||| f|j tj|_ |j  tj |||k||kr1| jvr|d=n|jd=|j jd=td|S)aDecode serialized packed enum to its value and a new position. Args: buffer: memoryview of the serialized bytes. pos: int, position in the memory view to start at. end: int, end position of serialized data message: Message object to store unknown fields in field_dict: Map[Descriptor, Any] to store decoded values in. Returns: int, new position in serialized data. Nr+r,r-)r/r0r_DecodeSignedVarint32values_by_numberr1_unknown_fieldsrrGrWIRETYPE_VARINTr$_unknown_field_setrUnknownFieldSet_add_values)rrr2rr3r4r5value_start_posr6r& enum_typerIr8r9r:s rr;z&EnumDecoder..DecodePackedFieldzsnnS!!e %%c;;w+?+?@@**6377ox#oh C/000 (NN.vs;;# i0 0 0 ,,w    ( )&(G #&|'2'BDD)  ! ( (&!45==??@ B B B  ' /)3)C)E)EG &  $ ) )K7 B B B! (NN& x i0 0 0Bii%b)(04:;;; jrcJ| }||  |} t||\}}|jvr||n|jsg|_|j |||f|jtj |_|j tj || z}||| ks||kr||krtd|S)Decode serialized repeated enum to its value and a new position. Args: buffer: memoryview of the serialized bytes. pos: int, position in the memory view to start at. end: int, end position of serialized data message: Message object to store unknown fields in field_dict: Map[Descriptor, Any] to store decoded values in. Returns: int, new position in serialized data. Nr r+)r/r0rxryr1rzr$r|rr}r~rr{r)rrr2rr3r4r6r=rrIr8r:r&r>s rr?z(EnumDecoder..DecodeRepeatedFieldsMnnS!!e %%c;;w+?+?@@263??' i0 0 0 ,,w    ( )&(G #  ! ( (&W-55778 : : :  ' /)3)C)E)EG &  $ ) )K7 B B B  '#+ ) + +w#~~ s]]344 4.-rc|}t||\}}||krtdr|s| d|S| jvr|| <n|jsg|_t j tj}|j |||| f|j tj |_ |j  tj||S)rr+N)rxrrBryrzrrGrr{r1r$r|rr}r~) rrr2rr3r enum_valuer&rDrrIr8s rrEz EnumDecoder..DecodeFields+o/<<z3 s/000 *sD!!! y1 1 1$ 3& '$&' !$\%0%@BB && s23;;== > @ @ @  % -'1'A'C'C' $"'' +5z C C Cjr)rrFrrGrr{rH) rIrJrKr8r:rDr;r?rErr9r&r>s ` ``` @@@@r EnumDecoderrtsm)D&000000000b P {/JKKI)nnG&&&&&&&&&&N ########H r._ConvertToUnicode%se  H (G$$ee    &'aa7ah  Ls( A AA cH| }||  |}  ||\}}||z}||krtd||||| z}||| ks||kr|SkNr Truncated string.r.)rrr2rr3r4sizer=rr8r9r:r&r>s rr?z*StringDecoder..DecodeRepeatedField6snnS!!e %%c;;w+?+?@@ ((55 s* S==011 1 &&vc'k':;;<<< '#+ ) + +w#~~. rc ||\}}||z}||krtdr|s| dn|||| <|SNrrA) rrr2rr3rr=rrDr8r9s rrEz"StringDecoder..DecodeFieldGs&&vs33ktSd g 3./// A$AsD!!!!++F3w;,?@@ 3 nrrFrrGrWIRETYPE_LENGTH_DELIMITEDrH) rIrJrKr8r:rDr?rErr9r&r>s ``` @@@@r StringDecoderrs%      !,!FHHI)nnG          rc t|rJ|r9tj|tj t   fd}|Sfd}|S)z$Returns a decoder for a bytes field.cZ|}|| |}  ||\}}||z}||krtd||||| z}||| ks||kr|Str)r/r0rr1r$ rrr2rr3r4rr=r8r9r:r&r>s rr?z)BytesDecoder..DecodeRepeatedField_snnS!!e %%c;;w+?+?@@ ((55 s* S==011 1 VCK(0022333 '#+ ) + +w#~~. rc ||\}}||z}||krtdr|s|dn||||<|Sr)rrBr$) rrr2rr3rr=rDr8r9s rrEz!BytesDecoder..DecodeFieldps&&vs33ktSd g 3./// 8$8sD!!!! W-5577 3 nrr) rIrJrKr8r:rDr?rEr9r&r>s ``` @@@r BytesDecoderrTs%  !,!FHHI)nnG         rc tj|tjt |rJ|r:tj|tj t   fd}|Sfd}|S)z$Returns a decoder for a group field.c| }||  |} | }||  |}||||}|z}|||ks||krt d| z}||| ks||kr|S)Nr Missing group end tag.)r/r0add_InternalParser) rrr2rr3r4r= end_tag_bytes end_tag_lenr8r:r&r>s rr?z)GroupDecoder..DecodeRepeatedFieldsnnS!!e %%c;;w+?+?@@s## =''[[-A-ABB%iikk((c::k/ #g+ - / /7S==566 6 '#+ ) + +w#~~.rc| }||  |}||||}|z}|||ks||krtd|S)Nr)r/r0rr) rrr2rr3r4r=rrr8r:s rrEz!GroupDecoder..DecodeFieldsnnS!!e %%c;;w+?+?@@  c 2 2cKg G  - -33444 nr)rrGrWIRETYPE_END_GROUPrHWIRETYPE_START_GROUP) rIrJrKr8r:r?rErrr&r>s `` @@@@r GroupDecoderr}s"<#.#ACC-M""+ $ !,!ACCI)nnG&          rc t|rJ|r9tj|tjt   fd}|Sfd}|S)z&Returns a decoder for a message field.ct|}|| |}  ||\}}||z}||krtd|||||krtd| z}||| ks||kr|SNr r+Unexpected end-group tag.)r/r0rrrrs rr?z+MessageDecoder..DecodeRepeatedFieldsnnS!!e %%c;;w+?+?@@((55 s* S==122 2 99;; % %fc7 ; ;w F F899 9 '#+ ) + +w#~~.rc|}|| |} ||\}}||z}||krtd|||||krtd|S)Nr+r)r/r0rr) rrr2rr3r4rr=r8r9r:s rrEz#MessageDecoder..DecodeFieldsnnS!!e %%c;;w+?+?@@&&vs33ktSd g 3/000   fc7 3 3w > >6777 nrr) rIrJrKr8r:r?rEr9r&r>s `` @@@rMessageDecoderrs% ) !,!FHHI)nnG(  rr ctjdtjtjdtjtjdtjt tt}fd}|S)aReturns a decoder for a MessageSet item. The parameter is the message Descriptor. The message set message looks like this: message MessageSet { repeated group Item = 1 { required int32 type_id = 2; required string message = 3; } } rdrbr c8|}d}d}d} ||\} }| kr||\}}nK| kr||\} }|| zx}}n.| krn(t|||| }|dkrtdq||krtd|dkrtd|dkrtd|j|} | || } | Y| j} t | dst| | | | } | ||||krtd n|j sg|_ |j t|||f|jt#j|_|j|t(j||||S) aDecode serialized message set to its value and new position. Args: buffer: memoryview of the serialized bytes. pos: int, position in the memory view to start at. end: int, end position of serialized data message: Message object to store unknown fields in field_dict: Map[Descriptor, Any] to store decoded values in. Returns: int, new position in serialized data. r,r rr+ MessageSet item missing type_id. MessageSet item missing message.N_concrete_classr) SkipFieldr Extensions_FindExtensionByNumberr/ message_typehasattrmessage_factoryGetMessageClassr0rrrzr1MESSAGE_SET_ITEM_TAGr$r|rr}r~rr)rrr2rr3message_set_item_starttype_id message_start message_endr&r extensionr4ritem_end_tag_bytesr9 local_ReadTagmessage_tag_bytestype_id_tag_bytess r DecodeItemz)MessageSetItemDecoder..DecodeItems!GMK 7&vs33y# ' ' '++FC88## ) ) ) 2 263 ? ?})D00kk * * * S)44 "99566 6 7 Syy - . .."}} ; < << ; < <<"99'BBInnY''e  - |%677 8  ) ), 7 7 7%% |335577   fmK @ @K O O6777 P  $%"$ $$ (>s(B!C!K!K!M!M NPPP  # +%/%?%A%A"  %%   / {* + 3 3 5 5777 Jr) rrGrr{rrr'rFr) descriptorlocal_SkipFieldrrr9rrrs @@@@@rMessageSetItemDecoderrs&q+*EFF&q+*OPP';+IJJ-$/EEEEEEEEEN rctjdtjtjdtjtjdtjfd}|S)z0Returns a decoder for a Unknown MessageSet item.rdrbr cd}t|}d}d} t||\}}| krt||\}}nO| krt||\}}||zx}}n.|krn(t||||}|dkrt d}||krt d|dkrt d|dkrt d||||fS)Nrr,r rr+rr)rHr'rFrrr$) rrr2rrr&rrrrrs rDecodeUnknownItemz7UnknownMessageSetItemDecoder..DecodeUnknownItemIs4 C f++CMK 7 --y# ' ' '&vs33## ) ) ) -fc : :})D00kk * * * S)44 "99566 6 7 Syy - . .."}} ; < << ; < << VM+56>>@@ AAr)rrGrr{rr)rrrrs @@@rUnknownMessageSetItemDecoderrBs{&q+*EFF&q+*OPP';+IJJBBBBBBB: rc|tj|jtjt t |jfd}|S)z"Returns a decoder for a map field.c }| }||  |}  ||\}}||z}||krtd||||||krtd r&||j|jn|j||j<|z}|||ks||kr|Sr) rr/r0rClearrr8CopyFromr4)rrr2rr3submsgr4rr=is_message_mapr8r9rr:r&r>s r DecodeMapzMapDecoder..DecodeMapus(  ) ) + +F NN3  E }##CW)=)=>>e&&vs33ktSd g 3/000 llnnn   vsG 4 4 ? ?6777 ) fj""6<0000"Lfj g c   ) )W^^-r)rrGnumberrrrHrFr) field_descriptorr:rrr8r9rr&r>s `` @@@@@r MapDecoderrjs #/6*DFF)  NN'$!.,: rct|||dzdzr4|dz }t|||dzdz4|dz }||krtd|S)z/Skip a varint value. Returns the new position.r r r+)ordr$rrrr2s r _SkipVarintrs F3s1u9  % % ' '((4/ 1HC F3s1u9  % % ' '((4/ (#3YY + , ,, *rc:|dz }||krtd|S)z0Skip a fixed64 value. Returns the new position.rpr+rrs r _SkipFixed64r*(#3YY + , ,, *rcV|dz}tjd|||d|fS)zDecode a fixed64.rprrr[r]rrr=s r_DecodeFixed64rs0 !G' -fS[1 2 21 5w ??rc`t||\}}||z }||krtd|S)z9Skip a length-delimited value. Returns the new position.r+)rFr)rrr2rs r_SkipLengthDelimitedrs=fc**+4+#3YY + , ,, *rcd t||\}}t||||}|dkr|S|}0)z*Skip sub-group. Returns the new position.r r,)r'r)rrr2r&r=s r _SkipGrouprsFvs++YS)44G"}} j C rcBtj}|||krt||\}}t|d\}}t j|\}}|tjkrn3t|||\} }|||| |{||k||fS)zFDecode UnknownFieldSet. Returns the UnknownFieldSet and new position.Nr) rr}r'rFr UnpackTagr_DecodeUnknownFieldr~) rrend_posunknown_field_setr&tag_rIrLdatas r_DecodeUnknownFieldSetrs!0223==vs++YY**HS!)3C88L)K222 %fc9==KT3<D999 3== S !!rc|tjkrt||\}}n|tjkrt ||\}}n|tjkrt ||\}}n|tjkr8t||\}}||||z}||z }nE|tj krt||\}}n!|tj krdStd||fS)zCDecode a unknown field. Returns the UnknownField and new position.)rr,zWrong wire type in tag.) rr{rFrtrrk_DecodeFixed32rr$rrrr)rrrLrrs rrrs+---,,KT33K000 --KT33K000 --KT33K999,,KT3 #c$h,  ' ' ) )D4KCCK444(55KT33K222 7 0 1 11 rcdS)zFSkipping an END_GROUP tag returns -1 to tell the parent loop to break.r,rrs r _EndGrouprs  rc:|dz }||krtd|S)z0Skip a fixed32 value. Returns the new position.rar+rrs r _SkipFixed32rrrcV|dz}tjd|||d|fS)zDecode a fixed32.rarrrrs rrrs2 !G' -fS[1 2 21 5w ??rc td)z;Skip function for unknown wire types. Raises an exception.zTag had invalid wire type.rrs r_RaiseInvalidWireTypers 1222rctttttt t t gtjfd}|S)z"Constructs the SkipField function.c^t|ddz}||||S)aSkips a field with the specified tag. |pos| should point to the byte immediately after the tag. Returns: The new position (after the tag value), or -1 if the tag is an end-group tag (in which case the calling loop should break). rr )r)rrr2r&rLWIRETYPE_TO_SKIPPER wiretype_masks rrz _FieldSkipper..SkipFields9IacN##m3I ) y )&#s ; ;;r) rrrrrrrr TAG_TYPE_MASK)rrrs @@r _FieldSkipperr sV +- < < < < < < rrNrR)C__doc__ __author__rgr[google.protobuf.internalrrrgoogle.protobufr DecodeErrorrrr!intrF_DecodeSignedVarint_DecodeVarint32rxr'rOrUr^rmrurr{ Int32Decoder Int64Decoder UInt32Decoder UInt64Decoder ZigZagDecode SInt32Decoder SInt64DecoderrkFixed32DecoderrtFixed64DecoderSFixed32DecoderSFixed64Decoder FloatDecoder DoubleDecoderbool BoolDecoderrrrrrGrrrrrrrrrrrrrrrrrrrrrrs>00d0 //////,,,,,,000000###### " 60}c22 **2s33!.44,,R55:<<<~ 0 0 00002*C*C*CZ%C%C%CR"'HHHH\~!688 ~!466 {:OLL {:MJJ   +2JLL    0HJJ %$[%A4HH$$[%A4HH$$[%A4HH$$[%A4HH}   66 $)2222l#(&&&&R,,,^///h(w';+KLL]]]@$$$P(((\       @@@    """"".      @@@333 @ MOO r