ok

Mini Shell

Direktori : /opt/imunify360/venv/lib64/python3.11/site-packages/im360/plugins/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/im360/plugins/__pycache__/lfd.cpython-311.pyc

�

�cg�
���ddlZddlZddlmZddlmZddlmZm	Z	ddl
mZmZm
Z
ddlmZddlmZddlmZeje��ZGd�d	ee��ZdS)
�N)�utils)�config)�MessageType�Reject)�MessageSink�
MessageSource�expect)�strategy)�csfc��eZdZejjZejj	Z
dZej
�ejjdd��Zej
�ejjdd��Zed���Zd�Zd�Zd�Zeej��d	���Zeej��d
���Zej ��d���Z!d�Z"d
�Z#dS)�LFDF�scriptszlfd_block.py�block_report_userc�
�	tjd�����}tj�|��tj�|j��kS#ttf$rYdSwxYw)N�BLOCK_REPORTF)	r�Config�get�os�path�realpath�BLOCK_REPORT_SCRIPT�FileNotFoundError�NotADirectoryError)�self�current_scripts  �F/opt/imunify360/venv/lib/python3.11/site-packages/im360/plugins/lfd.py�_script_installedzLFD._script_installeds���	� �Z��7�7�;�;�=�=�N��7�#�#�N�3�3�r�w�7G�7G��(�8�8��
��"�#5�6�	�	�	��5�5�	���s�&A-�-B�Bc��K�||_dS�N)�_loop)r�loops  r�create_sinkzLFD.create_sink*�������
�
�
�c��K�||_dSr)�_sink)rr!�sinks   r�
create_sourcezLFD.create_source-r#r$c��
K�dSr�)rs r�shutdownzLFD.shutdown0s
����	
�r$c��vK�|�|jtjj|j���d{V��dSr)�
_switch_stater
r�CSFIntegration�ENABLEDr)r�messages  r�on_strategy_changezLFD.on_strategy_change5s[����� � ����!�)��"�
�
�	
�	
�	
�	
�	
�	
�	
�	
�	
r$c��K�|�tjjtjj|j���d{V��dSr)r-r
�Strategy�currentrr.r/r)r�_s  r�on_config_changezLFD.on_config_change=s^����� � ���%��!�)��"�
�
�	
�	
�	
�	
�	
�	
�	
�	
�	
r$c��K�|o
||jk}|r |s|����d{V��dSdS|r|����d{V��dSdSr)�STRATEGY�_revert_script�
_setup_script)r�current_strategy�
is_enabled�is_script_installed�should_script_be_installeds     rr-zLFD._switch_stateEs�����&0�&
���
�-�	#��	'�-�
,��)�)�+�+�+�+�+�+�+�+�+�+�+�
,�
,�
'�	'��$�$�&�&�&�&�&�&�&�&�&�&�&�	'�	'r$c��K�t�d��tj�tjd���|j����}|rF||jkr;t�d|j	|��tj
||j	��tj���d{V��dS)Nz+Setup lfd BLOCK_REPORT to Imunify360 scriptrzCreating a symlink %s to %s)�logger�inforrrrr�setr�USER_SCRIPT_LINK�symlink�lfd_restart)r�
old_scripts  rr:zLFD._setup_scriptRs��������A�B�B�B��W�%�%��J�~�&�&�*�*�4�+C�D�D�
�
�
��	:�:��)A�A�A��K�K�-��%��
�
�
�

�J�z�4�#8�9�9�9��o�����������r$c��K�t�d��tj�|j��r3tj|j��}tj|j��nd}	tj	d���
|��tj���d{V��rtj���d{V��dSdS#t$r&}t�d|��Yd}~dSd}~wwxYw)NzReverting lfd BLOCK_REPORT�rz'Failed to revert BLOCK_REPORT value: %s)r@rArr�islinkrC�readlink�removerrrB�
is_runningrEr�warning)r�user_script�es   rr9zLFD._revert_scriptas"�������0�1�1�1�
�7�>�>�$�/�0�0�	��+�d�&;�<�<�K��I�d�+�,�,�,�,��K�	(��J�~�&�&�*�*�;�7�7�7��^�%�%�%�%�%�%�%�%�
(��o�'�'�'�'�'�'�'�'�'�'�'�
(�
(��!�	I�	I�	I��N�N�D�a�H�H�H�H�H�H�H�H�H�����	I���s�7'C�
D�C?�?DN)$�__name__�
__module__�__qualname__r�ProcessingOrderr
�PROCESSING_ORDERr
r3�CSF_COOP_STRATEGYr8�AVAILABLE_ON_FREEMIUMrr�join�
common_config�	Packaging�DATADIRrrC�propertyrr"r(r+r	r�StrategyChanger1�ConfigUpdater6r�log_error_and_ignorer-r:r9r*r$rr
r
sY������"�2�6��� �2�H�!���'�,�,���'��N�����w�|�|���'��4G��������X��������
�
�
�
�V�K�&�'�'�
�
�(�'�
��V�K�$�%�%�
�
�&�%�
� �U��!�!�
'�
'�"�!�
'�
 �
 �
 �(�(�(�(�(r$r
)�loggingr�defence360agentr�defence360agent.contractsrrX�"defence360agent.contracts.messagesrr�!defence360agent.contracts.pluginsrrr	�im360.contracts�im360.internalsr
�im360.subsysr�	getLoggerrPr@r
r*r$r�<module>rhs������	�	�	�	�!�!�!�!�!�!�=�=�=�=�=�=�B�B�B�B�B�B�B�B�����������
#�"�"�"�"�"�$�$�$�$�$�$�������	��	�8�	$�	$��\(�\(�\(�\(�\(�+�}�\(�\(�\(�\(�\(r$

Zerion Mini Shell 1.0