U ì·€g&ã @sªddlmZmZmZddlmZerHddlmZddlmZddlm Z dddd d d d d ddddddddddddddddddd d!d"d#d$d%g Z dd&d'd(gZ Gd)d*„d*ƒZ d+S),é)Úcapture_internal_exceptionsÚAnnotatedValueÚiter_event_frames)Ú TYPE_CHECKING)ÚEvent)ÚList)ÚOptionalÚpasswordÚpasswdÚsecretZapi_keyZapikeyÚauthÚ credentialsZ mysql_pwdZ privatekeyZ private_keyÚtokenÚsessionZ csrftokenZ sessionidZ x_csrftokenZx_forwarded_forÚ set_cookieÚcookieÚ authorizationZ x_api_keyZaiohttp_sessionz connect.sidZ csrf_tokenZcsrfZ_csrfZ _csrf_tokenZ PHPSESSIDÚ_sessionZsymfonyZ user_sessionZ_xsrfz XSRF-TOKENZ x_real_ipÚ ip_addressZ remote_addrc@s^eZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Zdd„Z dd„Z dd„Z dd„Z dS)Ú EventScrubberNFcCsX|dkrt ¡n||_|s<|dkr*t ¡n|}|j|7_dd„|jDƒ|_||_dS)a  A scrubber that goes through the event payload and removes sensitive data configured through denylists. :param denylist: A security denylist that is always scrubbed, defaults to DEFAULT_DENYLIST. :param recursive: Whether to scrub the event payload recursively, default False. :param send_default_pii: Whether pii is sending is on, pii fields are not scrubbed. :param pii_denylist: The denylist to use for scrubbing when pii is not sent, defaults to DEFAULT_PII_DENYLIST. NcSsg|] }| ¡‘qS©)Úlower)Ú.0ÚxrrúA/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/scrubber.pyÚ Ssz*EventScrubber.__init__..)ÚDEFAULT_DENYLISTÚcopyÚdenylistÚDEFAULT_PII_DENYLISTÚ recursive)Úselfrr Zsend_default_piiZ pii_denylistrrrÚ__init__?s ÿzEventScrubber.__init__cCs0t|tƒsdS|D]}| |¡| |¡qdS)a* If a list is passed to this method, the method recursively searches the list and any nested lists for any dictionaries. The method calls scrub_dict on all dictionaries it finds. If the parameter passed to this method is not a list, the method does nothing. N)Ú isinstanceÚlistÚ scrub_dictÚ scrub_list)r!ÚlstÚvrrrr&Vs   zEventScrubber.scrub_listcCsdt|tƒsdS| ¡D]H\}}t|tƒrD| ¡|jkrDt ¡||<q|jr|  |¡|  |¡qdS)a[ If a dictionary is passed to this method, the method scrubs the dictionary of any sensitive data. The method calls itself recursively on any nested dictionaries ( including dictionaries nested in lists) if self.recursive is True. This method does nothing if the parameter passed to it is not a dictionary. N) r#ÚdictÚitemsÚstrrrrZ+substituted_because_contains_sensitive_datar r%r&)r!ÚdÚkr(rrrr%es  zEventScrubber.scrub_dictc Csxtƒhd|krjd|dkr.| |dd¡d|dkrL| |dd¡d|dkrj| |dd¡W5QRXdS)NÚrequestÚheadersÚcookiesÚdata©rr%©r!ÚeventrrrÚ scrub_requestys   zEventScrubber.scrub_requestc Cs,tƒd|kr| |d¡W5QRXdS)NÚextrar2r3rrrÚ scrub_extra„szEventScrubber.scrub_extrac Cs,tƒd|kr| |d¡W5QRXdS)NÚuserr2r3rrrÚ scrub_userŠszEventScrubber.scrub_userc CsRtƒBd|krDd|dkrD|ddD]}d|kr(| |d¡q(W5QRXdS)NZ breadcrumbsÚvaluesr1r2)r!r4ÚvaluerrrÚscrub_breadcrumbss  zEventScrubber.scrub_breadcrumbsc Cs:tƒ*t|ƒD]}d|kr| |d¡qW5QRXdS)NÚvars)rrr%)r!r4ÚframerrrÚ scrub_frames™s zEventScrubber.scrub_framesc CsBtƒ2d|kr4|dD]}d|kr| |d¡qW5QRXdS)NÚspansr1r2)r!r4ÚspanrrrÚ scrub_spans s  zEventScrubber.scrub_spanscCs@| |¡| |¡| |¡| |¡| |¡| |¡dS)N)r5r7r9r<r?rBr3rrrÚ scrub_event¨s      zEventScrubber.scrub_event)NFFN) Ú__name__Ú __module__Ú __qualname__r"r&r%r5r7r9r<r?rBrCrrrrr>sÿ   rN) Zsentry_sdk.utilsrrrÚtypingrZsentry_sdk._typesrrrrrrrrrrÚsX    Ü(ü