/opt/imunify360/venv/lib/python3.11/site-packages/im360/model/__pycache__
� �}�}��^� � � d Z ddlZddlZddlmZmZ ddlmZ ej e � � Z dZ G d� d� � Z G d� d e� � Z dS ) zb Global whitelist as it was initially defined by https://cloudlinux.atlassian.net/browse/DEF-2307 � N)�Iterable�List)�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 $ r t � d� � g cY S w xY wt |� � S )N�groups�name�urlzFailed to load global whitelist)�set�strr �Index�locked� WHITELISTS�items�getr �update� _load_file� localfilepath� Exception�logger� exception�list)�cls�group�result�local_index�items 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�!"� !"�� � ��� � � � � � � � � � � � � � � � � � � � � � � ���� � � � ��� � � � ����>�?�?�?��I�I�I� ���� �F�|�|�s6 �/D �B,D�9D � D�D �D�D �&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 �error�open� enumerate� partition�strip� ipaddress� ip_network�version�removesuffix� ValueError)r"