?????????? ????????? - ??????????????? - /opt/imunify360/venv/lib/python3.11/site-packages/imav/wordpress/__pycache__/plugin.cpython-311.pyc
???????
� �B~z�Ox� �8 � d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddlmZ ddl mZ ddlmZ ddlmZmZmZ ddlmZ dd lmZ dd lmZ ddlmZ ddlmZ dd l m!Z!m"Z"m#Z# ddl$m%Z% ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8 ddl9m:Z: ej; e<� � Z= ed� � Z>dZ?dZ@d� ZAdeBdejC deBfd�ZDdejC defd�ZEdejF fd�ZGdBdeHfd �ZId!� ZJdeKfd"�ZLd#� ZMd$efd%�ZNd$edeOfd&�ZPd'� ZQd(� ZR dCd)eSe fd*�ZTd+eHe fd,�ZUd$ed-eBfd.�ZVd/ed0eKdedz fd1�ZWd2edeBdz fd3�ZXd/edeBdz fd4�ZYd/edeKfd5�ZZd$edejC d6eKd7eSd8eSddfd9�Z[d/ed:e\ddfd;�Z]d<� Z^d=� Z_d$ede\fd>�Z`d$ed?eOde\fd@�ZadA� ZbdS )Du This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see <https://www.imunify360.com/legal/eula> � N)�defaultdict)�LooseVersion)�Path)� inactivity)�MalwareScanScheduleInterval�SystemConfig�ANTIVIRUS_MODE)�Index)�log_message)�files)� Wordpress)�WPSite)�cli� telemetry�PLUGIN_VERSION_FILE)�get_user_schedule_config)�calculate_next_scan_timestamp�$clear_get_cagefs_enabled_users_cache�ensure_site_data_directory�format_php_with_embedded_json� get_last_scan�get_malware_history�prepare_scan_data�!write_plugin_data_file_atomically) �delete_site�get_outdated_sites�get_sites_for_user�get_sites_to_install�%get_sites_to_mark_as_manually_deleted�get_installed_sites�insert_installed_sites�mark_site_as_manually_deleted�update_site_version)�setup_site_authenticationzD/var/lib/cloudlinux-app-version-detector/components_versions.sqlite3zwp-rules.zip�VERSIONc �H � t � � t j � � dS )z#Clear all WordPress-related caches.N)r r �clear_get_content_dir_cache� � �J/opt/imunify360/venv/lib/python3.11/site-packages/imav/wordpress/plugin.py�clear_cachesr+ S s# � �(�*�*�*��#�%�%�%�%�%r) �items� user_info�returnc �� ��� t |� � }d� |D � � }| D ]D���fd�|D � � }|r1t |t �� � }|| � �� � �E|S )Nc � � i | ]}|g ��S r( r( )�.0�paths r* � <dictcomp>zsite_search.<locals>.<dictcomp>\ s � � .� .� .�4�d�B� .� .� .r) c �, �� g | ]} ��|� � �|��S r( r( )r1 r2 �item�matchers ��r* � <listcomp>zsite_search.<locals>.<listcomp>_ s* �� �M�M�M�4����t�9L�9L�M�$�M�M�Mr) )�key)r �max�len�append)r, r- r6 � user_sites�result�matching_sites�most_specific_siter5 s ` @r* �site_searchr@ Y s� ��� �#�I�.�.�J� .� .�:� .� .� .�F�� 4� 4��M�M�M�M�M�:�M�M�M��� 4�!$�^��!=�!=�!=���%�&�-�-�d�3�3�3���Mr) �admin_configc � �: K � t | |j � � � d {V ��}|� dd � � }t |j |� � \ }}}}d } |t j k rt ||||� � } t |j � � } t | |d� � � }|| |fS )N� scan_datec �P � | d dk o| d � |� � S )N� resource_type�file)� startswith)r5 r2 s r* �<lambda>z)_get_scan_data_for_user.<locals>.<lambda>� s- � �4��0�F�:� *���L�#�#�D�)�)� r) ) r �pw_name�getr �Interval�NONEr r r@ )�sinkr- rA � last_scan�last_scan_time�interval�hour�day_of_month�day_of_week�next_scan_time�malware_history�malware_by_sites r* �_get_scan_data_for_userrW i s� � � � � $�D�)�*;�<�<�<�<�<�<�<�<�I� �]�]�;��5�5�N� 1I���<�1� 1�-�H�d�L�+� �N��8�=� � �6��d�L�+� � �� *�)�*;�<�<�O� "��� *� *�� �O� �>�?�:�:r) � semaphorec � �� K � |4 �d {V �� | � d {V �� n4# t $ r'}t � d|� �� � Y d }~nd }~ww xY wd d d � � �d {V �� d S # 1 �d {V ��swxY w Y d S )NzTelemetry task failed: )� Exception�logger�error)�cororX �es r* �_send_telemetry_taskr_ � s+ � � � �� 8� 8� 8� 8� 8� 8� 8� 8� 8��J�J�J�J�J�J�J�J��� 8� 8� 8��L�L�6�1�6�6�7�7�7�7�7�7�7�7����� 8����8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8���� 8� 8� 8� 8� 8� 8s5 �A��A� A�A�A�A�A� A'�*A'� � coroutinesc � �� �K � | sdS t j |� � ��fd�| D � � } t j |� � d{V �� dS # t $ r(}t � d|� �� � Y d}~dS d}~ww xY w)zK Process a list of telemetry coroutines with a concurrency limit.s Nc �T �� g | ]$}t j t |�� � � � ��%S r( )�asyncio�create_taskr_ )r1 r] rX s �r* r7 z+process_telemetry_tasks.<locals>.<listcomp>� s? �� � � � �� ��0��y�A�A�B�B� � � r) zSome telemetry tasks failed: )rd � Semaphore�gatherrZ r[ r\ )ra �concurrency�tasksr^ rX s @r* �process_telemetry_tasksrj � s� �� � � � � ����!�+�.�.�I� � � � �� � � �E� :��n�e�$�$�$�$�$�$�$�$�$�$��� :� :� :����8�Q�8�8�9�9�9�9�9�9�9�9�9�����:���s �A � A3�A.�.A3c � �x K � t � d� � t � � }t � � }t � � }t � � }t � � }g }t j � d� � 5 t � � t � � }|s2 t |� � t |� � � d{V �� ddd� � dS t � � } t j t j d�� � } | � � � � d{V �� t | � � } n4# t $ r'}t � d|� � d} Y d}~nd}~ww xY w| st � d� � | r$t% | � � }|| d�} t'