ok
Direktori : /opt/imunify360/venv/lib/python3.11/site-packages/im360/plugins/__pycache__/ |
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/im360/plugins/__pycache__/lfd.cpython-311.pyc |
� �cg� � � � d dl Z d dlZd dlmZ d dlmZ d dlmZm Z d dl mZmZm Z d dlmZ d dlmZ d dlmZ e j e� � Z G d� d ee� � ZdS ) � N)�utils)�config)�MessageType�Reject)�MessageSink� MessageSource�expect)�strategy)�csfc � � e Zd Zej j Zej j Z dZej � ej j dd� � Zej � ej j dd� � Zed� � � Zd� Zd� Zd� Z eej � � d � � � Z eej � � d � � � Z ej � � d� � � Z!d� Z"d � Z#dS )�LFDF�scriptszlfd_block.py�block_report_userc � � t j d� � � � � }t j � |� � t j � | j � � k S # t t f$ r Y dS w xY w)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_installed s� � � � �Z��7�7�;�;�=�=�N� �7�#�#�N�3�3�r�w�7G�7G��(�8� 8� � �� "�#5�6� � � ��5�5� ���s �&A- �-B�Bc � � K � || _ d S �N)�_loop)r �loops r �create_sinkzLFD.create_sink* � � � � ��� � � � c � � K � || _ d S r )�_sink)r r! �sinks r � create_sourcezLFD.create_source- r# r$ c � � K � d S r � )r s r �shutdownzLFD.shutdown0 s � � � � �r$ c � �v K � | � |j t j j | j � � � d {V �� d S r )� _switch_stater r �CSFIntegration�ENABLEDr )r �messages r �on_strategy_changezLFD.on_strategy_change5 s[ � � � �� � ����!�)��"� � � � � � � � � � � r$ c � � K � | � t j j t j j | j � � � d {V �� d S r )r- r �Strategy�currentr r. r/ r )r �_s r �on_config_changezLFD.on_config_change= s^ � � � �� � ���%��!�)��"� � � � � � � � � � � r$ c � � K � |o || j k }|r |s| � � � � d {V �� d S d S |r| � � � � d {V �� d S d S r )�STRATEGY�_revert_script� _setup_script)r �current_strategy� is_enabled�is_script_installed�should_script_be_installeds r r- zLFD._switch_stateE s� � � � � &0� & ��� �-� #� � '�-� ,��)�)�+�+�+�+�+�+�+�+�+�+�+� ,� ,� '� '��$�$�&�&�&�&�&�&�&�&�&�&�&� '� 'r$ c � � K � t � d� � t j � t j d� � � | j � � � � }|rF|| j k r;t � d| j |� � t j || j � � t j � � � d {V �� d S )Nz+Setup lfd BLOCK_REPORT to Imunify360 scriptr zCreating a symlink %s to %s)�logger�infor r r r r �setr �USER_SCRIPT_LINK�symlink�lfd_restart)r � old_scripts r r: zLFD._setup_scriptR s� � � � ����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� � t j � | j � � r3t j | j � � }t j | j � � nd} t j d� � � |� � t j � � � d {V ��rt j � � � d {V �� d S d S # t $ r&}t � d|� � Y d }~d S d }~ww xY w)NzReverting lfd BLOCK_REPORT� r z'Failed to revert BLOCK_REPORT value: %s)r@ rA r r �islinkrC �readlink�remover r rB � is_runningrE r �warning)r �user_script�es r r9 zLFD._revert_scripta s" � � � ����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_FREEMIUMr r �join� common_config� Packaging�DATADIRr rC �propertyr r"