Edit File: global_whitelist.cpython-311.pyc
� �gh+ � � � d Z ddlZddlZddlmZmZ ddlmZ ddlm Z ej e� � ZdZ G d� d� � Z G d � d e� � ZdS )zb Global whitelist as it was initially defined by https://cloudlinux.atlassian.net/browse/DEF-2307 � N)�Iterable�List)�IntegrityError)�fileszimunify360.txtc �| � e Zd Zed� � � Zeddee fd�� � Zedd�de e fd�� � Z dS )�GlobalWhitelistc � � | t k S )z�Check if file file_name should be loaded. Do not load imunify360.txt as it will be loaded separately in GlobalImunifyWhitelist. ��IM360_FILE_NAME)� file_names �Q/opt/imunify360/venv/lib/python3.11/site-packages/im360/model/global_whitelist.py�_allow_load_from_filez%GlobalWhitelist._allow_load_from_file s � � �O�+�+� N�returnc � �� K � t t � � } t j � t j � � 4 �d {V �� t j t j � � }|� � � D ]x}|�||� dg � � v r\| � |d � � rA|� | � |� |d � � � � � � �y d d d � � �d {V �� n# 1 �d {V ��swxY w Y n;# t t f$ r'}t � d|� � g cY d }~S d }~ww xY wt! |� � S )N�groups�name�urlz%s)�set�strr �Index�locked� WHITELISTS�items�getr �update� _load_file� localfilepath�FileNotFoundErrorr �logger�error�list)�cls�group�result�local_index�item�es r �loadzGlobalWhitelist.load s� � � � ��S����� ��{�)�)�%�*:�;�;� � � � � � � � �#�k�%�*:�;�;��'�-�-�/�/� � �D��}��$�(�(�8�R�2H�2H�)H�)H��4�4�T�&�\�B�B� �"�M�M� #���$/�$=�$=�d�5�k�$J�$J�!"� !"�� � ��� � � � � � � � � � � � � � � � � � � � � � � ���� � � � ��� "�>�2� � � ��L�L��q�!�!�!��I�I�I�I�I�I����� ���� �F�|�|�sB �/D �B,D�9D � D�D �D�D �E�.E� E�E)� log_errorc # �� K � |�t j }t |� � 5 }t |� � D ]�\ }}|� d� � d � � � }|s�5 t j |� � }|j dk r|� d� � }|V � �o# t $ r} |d|||dz � � Y d}~��d}~ww xY w ddd� � dS # 1 swxY w Y dS )zu :param file: file path :param log_error: what logging method to use [default: logger.error] N�#r � z/32z%s in %s line %d� )r r! �open� enumerate� partition�strip� ipaddress� ip_network�version�removesuffix� ValueError)r# �filer* �f�lnr'