관리-도구
편집 파일: model.cpython-311.opt-1.pyc
� IMg� � �( � d dl Z d dlZd dlZd dlmZmZ d dlmZmZ d dl m c mc mZ d dlmZ d dlmZmZ d dlmZ d dlmZ d dlmZ d d lmZ ej e� � Z G d � de� � Zd� Zd ee de!fd�Z"de!fd�Z#d ee de!fd�Z$dS )� N)�List�Optional)�BooleanField� CharField)�MessageType)�Model�instance)�run_in_executor)�execute_iterable_expression�� update_config)� MalwareHitc � � e Zd ZdZ G d� d� � Z ed�� � Z edd�� � Ze de e d efd �� � Z e dee defd �� � ZdS )� MyImunifyzSecure-site related settingsc � � e Zd Zej ZdZdS )�MyImunify.Meta� myimunifyN)�__name__� __module__�__qualname__r �db�database�db_table� � �T/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/myimunify/model.py�Metar s � � � � � ��;�����r r T)�uniqueF)�null�default�user�returnc �\ � |�|dk rdS | � |ddi�� � \ }}|j S )z%Get SecureSite protection by usernameN�rootT� protectionF)r! �defaults)� get_or_creater% )�clsr! �perm�_s r �get_protectionzMyImunify.get_protection! s? � � �<�4�6�>�>��4��#�#���u�8M�#�N�N���a���r �users�statusc � �� | � �fd�|D � � � � � | j gg | j �i�� � � � � d S )Nc � �� g | ]}|�d ���S ))r! r% r )�.0r! r- s �r � <listcomp>z5MyImunify.update_users_protection.<locals>.<listcomp>. s! �� �D�D�D�d�d�&� 1� 1�D�D�Dr )�conflict_target�preserve�update)�insert_many�on_conflictr! r% �execute)r( r, r- s `r �update_users_protectionz!MyImunify.update_users_protection+ sd �� ����D�D�D�D�e�D�D�D� � � �+� �X�J���N�F�+� � � � �'�)�)�)�)�)r N)r r r �__doc__r r r! r r% �classmethodr �str�boolr+ r r8 r r r r r s� � � � � � �&�&�� � � � � � � � �9�D�!�!�!�D� ��5�%�8�8�8�J���(�3�-� �D� � � � �[�� ��D��I� �t� � � � �[�� � r r c � � K � t j |d�� � }|r0| � t j |�� � � � � d {V �� d S d S )NT)r! �cleanup)�hits)r �malicious_select�process_messager �MalwareCleanupTask)�sinkr! r? s r �malware_cleanuprD 6 sj � � � ��&�D�$�?�?�?�D�� N��"�"�;�#A�t�#L�#L�#L�M�M�M�M�M�M�M�M�M�M�M�N� Nr r, r- c � � � ���K � t d ��fd�� � � d {V �� d ��sd��� fd��D � � }�r|� fd��D � � z }t j |� � d {V �� d S )Nc �: �� t � �� � � S �N)r r8 )r- r, s ��r �<lambda>z)update_users_protection.<locals>.<lambda>? s �� � �1�1�%��@�@� r �LOGc �: �� g | ]}t �d d�ii|� � ��S )�PROACTIVE_DEFENCE�moder )r0 r! �proactive_moderC s ��r r1 z+update_users_protection.<locals>.<listcomp>D sH �� � � � � � �� �6�>�":�;�� � � � � r c �0 �� g | ]}t �|� � ��S r )rD )r0 r! rC s �r r1 z+update_users_protection.<locals>.<listcomp>N s# �� �@�@�@�$�/�$��-�-�@�@�@r )r �asyncio�gather)rC r, r- �tasksrM s ``` @r r8 r8 <