OwlCyberSecurity - MANAGER
Edit File: sanic.cpython-38.opt-1.pyc
U ������\�����������������������@���s����d�dl�Z�d�dlZd�dlmZ�d�dlmZmZ�d�dlmZ�d�dl m Z mZmZ�d�dl mZ�d�dlmZmZ�d�dlmZ�d�d lmZmZ�d�d lmZ�d�dlmZ�d�dlmZ�G�d d��de�Z&dd��Z'dd��Z(G�dd��de�Z)dS�)�����N)�isawaitable)�urlparse�reraise)�Hub)�capture_internal_exceptions�event_from_exception�HAS_REAL_CONTEXTVARS)�Integration)�RequestExtractor�_filter_headers)� ignore_logger)�Sanic�__version__)�SanicException)�Router)�ErrorHandlerc�������������������@���s���e�Zd�ZdZedd���ZdS�)�SanicIntegration�sanicc���������������������sj���t�std��t�d�rtd��tj��fdd�}�|�t_tj��fdd�}|t_t j ����fdd �}|t _ d�S�) NzPThe sanic integration for Sentry requires Python 3.7+ or aiocontextvars packagez0.8.�rootc�������������� �������s����t�j}|�t�d�kr&��|�|f|�|�S�t�|�}t�|��`}|����}|����|�t |���W�5�Q�R�X���|�|f|�|�}t |�r�|I�d�H�}|W��5�Q�R���S�Q�R�X�d�S��N)r����current�get_integrationr����weakref�ref�configure_scopeZclear_breadcrumbsZadd_event_processor�_make_request_processorr���)�self�request�args�kwargs�hub�weak_request�scope�response)�old_handle_request���N/opt/alt/python38/lib/python3.8/site-packages/sentry_sdk/integrations/sanic.py�sentry_handle_request=���s���� z:SanicIntegration.setup_once.<locals>.sentry_handle_requestc�������������� ������sT�����|�|�}t�j}|�t�d�k rPt���&�|����}|d�j|_W�5�Q�R�X�W�5�Q�R�X�|S��Nr���)r���r���r���r���r���r����__name__Ztransaction)r���r����rvr ���r"���)�old_router_getr%���r&����sentry_router_getT���s���� z6SanicIntegration.setup_once.<locals>.sentry_router_getc��������������������sB���t�|���|�|�����d�krd�S�tj�t�d�kr2��S���fdd�}|S�)Nc���������������������sT���z"��|�|�}t�|�r|I�d�H�}|W�S��tk rN���t���}t|��t|���Y�nX�d�S�r���)r���� Exception�sys�exc_info�_capture_exceptionr���)r���� exceptionr#���r/����Zold_error_handlerr%���r&����sentry_wrapped_error_handlerm���s���� zfSanicIntegration.setup_once.<locals>.sentry_error_handler_lookup.<locals>.sentry_wrapped_error_handler)r0���r���r���r���r���)r���r1���r3���)�old_error_handler_lookupr2���r&����sentry_error_handler_lookupb���s���� z@SanicIntegration.setup_once.<locals>.sentry_error_handler_lookup)r����RuntimeError�VERSION� startswithr���r ���Zhandle_requestr����getr����lookup)r'���r,���r5���r%���)r4���r$���r+���r&���� setup_once$���s����� zSanicIntegration.setup_onceN)r)���� __module__�__qualname__Z identifier�staticmethodr;���r%���r%���r%���r&���r���!���s���r���c�������������� ���C���s\���t�j}|�t�}|d�krd�S�t���0�t|�|jjddd�d�\}}|j||d��W�5�Q�R�X�d�S�)Nr���F)�typeZhandled)Zclient_optionsZ mechanism)�hint) r���r���r���r���r���r���Zclient�optionsZ capture_event)r1���r ���Zintegration�eventr@���r%���r%���r&���r0�������s���� � r0���c��������������������s�����fdd�}|S�)Nc�������������� ������s����zt�|d�d�t�rW�d�S�W�n�tk r0���Y�nX�����}|d�krD|�S�t���x�t|�}|�|���|�d�}t�|j�}d|j |j |jf�|d<�|j|d<�|j |d<�d|ji|d <�tt|j��|d <�W�5�Q�R�X�|�S�)Nr/���r���r���z %s://%s%s�urlZquery_string�methodZREMOTE_ADDR�env�headers)� issubclassr����KeyErrorr����SanicRequestExtractorZextract_into_eventr���ZurlsplitrC���ZschemeZnetloc�pathZqueryrD���Zremote_addrr����dictrF���)rB���r@���r���Z extractorZrequest_infoZurlparts�r!���r%���r&����sanic_processor����s.���� � z0_make_request_processor.<locals>.sanic_processorr%���)r!���rM���r%���rL���r&���r�������s����!r���c�������������������@���sL���e�Zd�Zdd��Zdd��Zdd��Zdd��Zd d ��Zdd��Zd d��Z dd��Z dS�)rI���c�����������������C���s���|�j�jd�krdS�t|�j�j�S�r(���)r����body�len�r���r%���r%���r&����content_length����s����z$SanicRequestExtractor.content_lengthc�����������������C���s���t�|�jj�S�r���)rK���r����cookiesrP���r%���r%���r&���rR�������s����zSanicRequestExtractor.cookiesc�����������������C���s���|�j�jS�r���)r���rN���rP���r%���r%���r&����raw_data����s����zSanicRequestExtractor.raw_datac�����������������C���s���|�j�jS�r���)r����formrP���r%���r%���r&���rT�������s����zSanicRequestExtractor.formc�����������������C���s ���t����d�S�r���)�NotImplementedErrorrP���r%���r%���r&����is_json����s����zSanicRequestExtractor.is_jsonc�����������������C���s���|�j�jS�r���)r����jsonrP���r%���r%���r&���rW�������s����zSanicRequestExtractor.jsonc�����������������C���s���|�j�jS�r���)r����filesrP���r%���r%���r&���rX�������s����zSanicRequestExtractor.filesc�����������������C���s���t�|jp d�S�)Nr%���)rO���rN���)r����filer%���r%���r&����size_of_file����s����z"SanicRequestExtractor.size_of_fileN)r)���r<���r=���rQ���rR���rS���rT���rV���rW���rX���rZ���r%���r%���r%���r&���rI�������s���rI���)*r.���r����inspectr���Zsentry_sdk._compatr���r���Zsentry_sdk.hubr���Zsentry_sdk.utilsr���r���r���Zsentry_sdk.integrationsr ���Z$sentry_sdk.integrations._wsgi_commonr ���r���Zsentry_sdk.integrations.loggingr���r���r ���r���r7���Zsanic.exceptionsr���Zsanic.routerr���Zsanic.handlersr���ZRequestZAny�CallableZDictZOptionalZUnionZTupleZRequestParametersr���r0���r���rI���r%���r%���r%���r&����<module>���s ���`&