403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.142.201.222
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/cloudlinux/venv/lib/python3.11/site-packages/ssa/modules/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/cloudlinux/venv/lib/python3.11/site-packages/ssa/modules/__pycache__/processor.cpython-311.pyc
�

ve�g���dZddlZddlZddlZddlZddlmZmZmZddlm	Z	m
Z
mZddlm
Z
mZddlmZddlmZdd	lmZdd
lmZddlmZmZmZmZmZmZdd
lmZddl m!Z!m"Z"m#Z#e!Gd�de����Z$dS)z-
This module contains RequestProcessor class
�N)�datetime�	timedelta�timezone)�Thread�RLock�current_thread)�Callable�Any�)�
AutoTracer)�Common)�
DecisionMaker)�StatisticsSender�)�
session_scope�setup_database�
RequestResult�cleanup_old_data�restore_database�is_malformed_database)�SSAError)�	singleton�	url_split�switch_schedstatsc����eZdZdZdZd�fd�	Zed���Zdefd�Z	dd	�Z
dd
�Zdede
fd�Zddefd�Zd�Zd�Zededefd���Zd�Zdd�Zdeddfd�Z�xZS)�RequestProcessorz^
    SSA Request processor implementation.
    Only one instance is allowed to be created
    �dNc����t�����tjd��|_|j�dt��td���|r|n
t��|_	t��|_t|���|_
t��|_t!|���|_|���g|_dS)N�
req_processorzProcessor enabled: %sT��enabled)�engine)�super�__init__�logging�	getLogger�logger�info�__package__rrr"r�_lockr�decision_makerr�senderr�auto_tracer�start_background_routine�_buffer)�selfr"�	__class__s  ��L/opt/cloudlinux/venv/lib64/python3.11/site-packages/ssa/modules/processor.pyr$zRequestProcessor.__init__)s����
���������'��8�8�������0�+�>�>�>��$�'�'�'�'� &�<�f�f�N�,<�,<����W�W��
�+�6�:�:�:���&�(�(���%�V�4�4�4����%�%�'�'�'������c��|jdzS)zp
        Return config file value multiplied by 1000000,
        as we receive duration in microseconds
        i@B)�requests_duration)r0s r2�configured_durationz$RequestProcessor.configured_duration=s���%��/�/r3�reportc��	|j�|��dS#t$r3}|j�dt|����Yd}~dSd}~wwxYw)z(
        Call Statistics Sender
        zStatisticsSender failed: %sN)r,�sendrr'�error�str)r0r7�es   r2�
send_statszRequestProcessor.send_statsEsx��	E��K���V�$�$�$�$�$���	E�	E�	E��K���;�S��V�V�D�D�D�D�D�D�D�D�D�����	E���s��
A�(A�A�returnc��t|jd���}|���|j�d|j��dS)zA
        Start dumper|DecisionMaker thread in background
        T)�target�daemonz[%s] Routine startedN)r�background_routine�startr'r(�name)r0�ts  r2r.z)RequestProcessor.start_background_routineNsG��
�$�1�$�?�?�?��	���	�	�	�����/���8�8�8�8�8r3c�2�	tjtj��}|jdk�r�|jdk�r�t
|j��rZ|�|�	|j����|j
�dt��j
|��|j
�dt��j
|��|�|j��|j
�dt��j
|��|�|j��|j
�dt��j
|��|�|j��}|j
�dt��j
|��t%|j��|�|j|��t)d���|�d	��n|�|j����)
z�
        Dumps collected stats to file once an hour.
        Runs DecisionMaker once a day
        Cleanup storage after DecisionMaker run
        TrzP[%s] Routine thread found Database disk image is malformed and now restored (%s)z2[%s] Routine thread launching buffer flushing (%s)z-[%s] Routine thread launching AutoTracer (%s)z0[%s] Routine thread launching DecisionMaker (%s)z*[%s] Routine thread launching cleanup (%s)r �<)r�nowr�utc�minute�hourrr"�
_save_exec�restore_db_with_lockr'r(rrD�
_safe_exec�flush_with_lockr-r+rr=r�
_simple_sleep�_sleep_till_next_hour)r0�tickr7s   r2rBz#RequestProcessor.background_routineVs��� 	8��<���-�-�D��{�a����9��>�>�,�T�[�9�9�9�����(A�(A�$�+�(N�(N�O�O�O���(�(�n�*�,�,�1�4�9�9�9��K�$�$�L�&�(�(�-�t�5�5�5��O�O�D�$8�9�9�9��K�$�$�G�&�(�(�-�t�5�5�5��O�O�D�$4�5�5�5��K�$�$�J�&�(�(�-�t�5�5�5�"�_�_�T�-@�A�A�F��K�$�$�D�&�(�(�-�t�5�5�5�%�T�[�1�1�1��O�O�D�O�V�<�<�<�&�d�3�3�3�3��"�"�2�&�&�&�&��*�*�4�;�7�7�7�A 	8r3�actionc
���	||�S#t$rZtj��\}}}|j�dt|��||dt
j��i���YdSwxYw)zACall requested Callable with given args and capture any exceptionz%s failed with exception %s, %s�orig_traceback)�extraN)�	Exception�sys�exc_infor'�	exceptionr;�	traceback�
format_exc)r0rS�args�et�ev�_s      r2rNzRequestProcessor._safe_exec~s���	T��6�4�=� ���	T�	T�	T�����I�B��A��K�!�!�"C�"%�f�+�+�r�2�)9�9�;O�;Q�;Q�(R�
"�
T�
T�
T�
T�
T�
T�	T���s��A A+�*A+��to_sleepc��|j�dt��j|��t	j|��dS)zP
        Log and sleep given number of seconds or 15 minutes by default
        z%[%s] Routine thread sleeping for (%s)N)r'r(rrD�time�sleep)r0rbs  r2rPzRequestProcessor._simple_sleep�sE��	
����@�'�)�)�.��	:�	:�	:��
�8�����r3c��td���t|���z
���}|�t|����dS)zF
        Sleep the number of minutes remaining till next hour
        r)�hours)�minutesN)r�
total_secondsrP�int)r0�start_minute�	sleep_fors   r2rQz&RequestProcessor._sleep_till_next_hour�sY���Q�'�'�'�)� �+"�+"�+"�"�#0�=�?�?�	����3�y�>�>�*�*�*�*�*r3c�d�|j5t|��ddd��dS#1swxYwYdS�N)r*r)r0r"s  r2rMz%RequestProcessor.restore_db_with_lock�s|��
�Z�	%�	%��V�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�	%�	%s�%�)�)�	timestampc�J�tj|tj��jS)zN
        Takes an hour of a day, to which the given timestamp belongs
        )r�
fromtimestamprrIrK)ros r2�get_interval_forz!RequestProcessor.get_interval_for�s��
�%�i���>�>�C�Cr3c��|j5|jdd�}g|_ddd��n#1swxYwY|�|��dSrn)r*r/�flush_buffer)r0�objectss  r2rOz RequestProcessor.flush_with_lock�s���
�Z�	�	��l�1�1�1�o�G��D�L�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
���'�"�"�"�"�"s�+�/�/c��|�|j}|sdSt|j��5}|�|��ddd��dS#1swxYwYdS)z6
        Save in-memory buffer into database.
        N)r/rr"�bulk_save_objects)r0ru�dbs   r2rtzRequestProcessor.flush_buffer�s����?��l�G��	��F�
�4�;�
'�
'�	*�2�� � ��)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*s�A�A	�A	�datac�`�|s.|j�dt��j��dS|�d��}|�|��r|j�d|��dSt|��\}}|j�dt��j��g}|j5|j	�
t|||d|d|d|jk|d|d	|d
|d��	�	��t|j	��|jkr|j	dd�}g|_	|�|��ddd��n#1swxYwY|j�d
t��j��dS)z,
        Process given request data
        z [%s] has empty request, skippingN�urlz
%s ignoredz-[%s] Acquires lock to handle request countersro�duration�hitting_limits�throttled_time�io_throttled_time�	wordpress)	�domain�pathror|�is_slow_requestr}r~rr�z-[%s] Released lock to handle request counters)r'r(rrD�get�
is_ignored�debugrr*r/�appendrr6�len�BUFFER_SIZErt)r0ryr{r��uri�objects_per_threads      r2�handlezRequestProcessor.handle�s����	��K���?��AQ�AQ�AV�W�W�W��F��h�h�u�o�o���?�?�3���	��K���l�C�0�0�0��F���n�n��������I�(�*�*�/�	1�	1�	1���
�Z�	2�	2��L����!��"�;�/�!�*�-�$(��$4�t�7O�$O�#'�(8�#9�#'�(8�#9�&*�+>�&?�"�;�/����

�

�

� �4�<� � �D�$4�4�4�%)�\�!�!�!�_�"�!������0�1�1�1�+	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�.	
����I�(�*�*�/�	1�	1�	1�	1�	1s�?B,E7�7E;�>E;rn)r>N)ra)�__name__�
__module__�__qualname__�__doc__r�r$�propertyr6�dictr=r.rBr	r
rNrjrPrQrM�staticmethodrrrOrtr��
__classcell__)r1s@r2rr s����������
�K�������(�0�0��X�0�E��E�E�E�E�9�9�9�9�&8�&8�&8�&8�PT��T�S�T�T�T�T���c�����+�+�+�%�%�%��D�C�D�C�D�D�D��\�D�#�#�#�*�*�*�*�)1�4�)1�D�)1�)1�)1�)1�)1�)1�)1�)1r3r)%r�r%rXrdr[rrr�	threadingrrr�typingr	r
�
autotracerr�commonr
r+r�stat_senderrrxrrrrrr�internal.exceptionsr�internal.utilsrrrr�r3r2�<module>r�s���������
�
�
�
���������2�2�2�2�2�2�2�2�2�2�3�3�3�3�3�3�3�3�3�3� � � � � � � � �"�"�"�"�"�"�������)�)�)�)�)�)�)�)�)�)�)�)�x�x�x�x�x�x�x�x�x�x�x�x�x�x�x�x�*�*�*�*�*�*������������~1�~1�~1�~1�~1�v�~1�~1���~1�~1�~1r3

Youez - 2016 - github.com/yon3zu
LinuXploit