7flddlZddlmZmZmZmZmZmZmZddl m Z m Z m Z ddl mZerddlmZdZgdZGdd ZGd d eZdS) N) TYPE_CHECKINGBinaryIODictIterableListNoReturnOptional) HashMismatch HashMissingInstallationError) read_chunks)_Hashsha256)rsha384sha512c(eZdZdZddeeeeefddfdZddZ e de fdZ d ed ede fd Zd eeddfd ZdeedfddfdZdeddfdZdeddfdZdeeefde fdZde fdZdede fdZde fdZdS)HasheszaA wrapper that builds multiple hashes at once and checks them against known-good values Nhashesreturnci}|6|D]!\}}dt|D||<"||_dS)zo :param hashes: A dict of algorithm names pointing to lists of allowed hex digests Nc6g|]}|S)lower).0ks z/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/utils/hashes.py z#Hashes.__init__..$s @@@a @@@)itemssorted_allowed)selfrallowedalgkeyss r__init__zHashes.__init__sV   #\\^^ A A T@@6$<<@@@  rotherct|tstS|sSs|Si}|jD]!\}jvrfd|D|<"t|S)Nc2g|]}|jv|Sr)r!)rvr$r"s rrz"Hashes.__and__..7s*EEEaQ$-2D-D-D-D-D-Dr) isinstancerNotImplementedr!r)r"r'newvaluesr$s` @r__and__zHashes.__and__'s%(( "! ! K L >//11 F FKC$-''EEEEE6EEECHHc{{rcbtd|jDS)Nc34K|]}t|VdSN)len)rdigestss r z&Hashes.digest_count..<s(FFG3w<<FFFFFFr)sumr!r.r"s r digest_countzHashes.digest_count:s-FFt}/C/C/E/EFFFFFFr hash_name hex_digestc<||j|gvS)z/Return whether the given hex digest is allowed.)r!get)r"r9r:s ris_hash_allowedzHashes.is_hash_allowed>sT]..y"====rchunksci}|jD]A} tj|||<#tt f$rt d|wxYw|D].}|D]}||/| D])\}}| |j|vrdS*| |dS)zCheck good hashes against ones built from iterable of chunks of data. Raise HashMismatch if none match. zUnknown hash name: N) r!r%hashlibr- ValueError TypeErrorr r.updater hexdigest_raise)r"r>gotsr9chunkhashgots rcheck_against_chunkszHashes.check_against_chunksBs++-- K KI K")+i"8"8Y * K K K'(Ii(I(IJJJ K # #E  # # E"""" ##jjll  NIs}}$- ":::; Ds 7$ArFrrc,t|j|r2)r r!r"rFs rrEz Hashes._raiseYs4=$///rfilecF|t|S)zaCheck good hashes against a file-like object Raise HashMismatch if none match. )rJr )r"rMs rcheck_against_filezHashes.check_against_file\s ((T):):;;;rpathct|d5}||cdddS#1swxYwYdS)Nrb)openrO)r"rPrMs rcheck_against_pathzHashes.check_against_pathds $   1**400 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s 377cl|D]\}}|||rdSdS)z3Return whether any of the given hashes are allowed.TF)rr=)r"rr9r:s r has_one_ofzHashes.has_one_ofhsG%+\\^^   !Iz##Iz:: tt urc*t|jS)z,Return whether I know any known-good hashes.)boolr!r7s r__bool__zHashes.__bool__osDM"""rcZt|tstS|j|jkSr2)r+rr,r!)r"r's r__eq__z Hashes.__eq__ss)%(( "! !}..rc tdtd|jDS)N,c3TK|]#\}}|D]}d||fV$dS):N)join)rr$ digest_listdigests rr5z"Hashes.__hash__..{sa(["-HHc6]++r)rHr`r r!rr7s r__hash__zHashes.__hash__xs\ HH,0M,?,?,A,A     rr2)r'rrr)__name__ __module__ __qualname____doc__r rstrrr&r/propertyintr8rXr=rbytesrJrErrOrTrVrYobjectr[rcrrrrrs   xS$s)^(<=       &GcGGGXG>>#>$>>>>8E?t.04W -0*0000rysTTTTTTTTTTTTTTTTTTQQQQQQQQQQ000000  /.. l l l l l l l l ^;;;;;F;;;;;r