PATH:
opt
/
imunify360
/
venv
/
lib
/
python3.11
/
site-packages
/
defence360agent
/
simple_rpc
/
__pycache__
/
Editing: wordpress_security_plugin.cpython-311.opt-1.pyc
� ���i � � � d dl Z d dlZd dlZd dlmZ d dlmZmZmZ d dl m Z mZ d dlm Z d dlmZ d dlmZ d dlmZ e j e� � Z dd edz d edz deedz edz f fd�Z G d � de� � Z G d� de� � ZdS )� N)�ValidationError)�CommonEndpoints� RootEndpoints�bind)�Scope�is_root_user)�MessageType)�get_wordpress_incidents)�get_installed_sites_paginated)�get_domain_paths�user�site_search�returnc �x � t j � � }t � � r�t � d| � � d}| �s t j | � � j }t � d| |� � n<# t $ r/ t � d| � � t d| � d�� � �w xY w||fS ||fS )a� Determine the user_id and site_path for filtering WordPress incidents. Three calling contexts: 1. Root user: Can query all incidents or filter by specific user 2. Non-root user: Can only query their own incidents (user/site_search ignored) 3. Proxy service: Both user and site_search must be set, restricted to that site Args: user: Username to filter by site_search: Site path to filter by Returns: Tuple of (user_id, site_path) to filter by, or (None, None) for all Raises: KeyError: If the specified user doesn't exist ValueError: If proxy service call is missing required parameters z-Root user querying incidents, user filter: %sNz(Filtering incidents for user %s (uid=%d)zUser not found: %szUser 'z' not found) �os�getuidr �logger�debug�pwd�getpwnam�pw_uid�KeyError�warning)r r �current_uid�user_ids �i/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/simple_rpc/wordpress_security_plugin.py�get_user_id_and_site_for_queryr s� � �, �)�+�+�K��~�~� $����D�d�K�K�K����� ;��,�t�,�,�3�����>��g�� � � �� � ;� ;� ;����3�T�:�:�:��9��9�9�9�:�:�:� ;���� ��#�#���#�#s �5A8 �89B1c �� � e Zd Zej Z edd� � d� � � Z edd� � d� � � Z edd� � d� � � Z edd� � d � � � Z d S )�WordpressEndpoints�wordpress-pluginzinstall-on-new-sitesc � �p K � | j � t j d�� � � � � d {V �� d S )N�install_on_new_sites��action��_sink�process_messager �WordpressPluginAction��selfs r �wordpress_plugin_installz+WordpressEndpoints.wordpress_plugin_installD sZ � � � ��j�(�(��-�5K�L�L�L� � � � � � � � � � � � ztidy-upc � �p K � | j � t j d�� � � � � d {V �� d S )N�tidy_upr# r% r) s r �wordpress_plugin_tidy_upz+WordpressEndpoints.wordpress_plugin_tidy_upJ sY � � � ��j�(�(��-�Y�?�?�?� � � � � � � � � � � r, �updatec � �p K � | j � t j d�� � � � � d {V �� d S )N�update_existingr# r% r) s r �wordpress_plugin_updatez*WordpressEndpoints.wordpress_plugin_updateP sZ � � � ��j�(�(��-�5F�G�G�G� � � � � � � � � � � r, zinstall-and-updatec � �p K � | j � t j d�� � � � � d {V �� d S )N�install_and_updater# r% r) s r �#wordpress_plugin_install_and_updatez6WordpressEndpoints.wordpress_plugin_install_and_updateV sZ � � � ��j�(�(��-�5I�J�J�J� � � � � � � � � � � r, N)�__name__� __module__�__qualname__r �AV_IM360�SCOPEr r+ r/ r3 r6 � r, r r r A s� � � � � � ��N�E� �T� �4�5�5� � � 6�5� � �T� �i�(�(� � � )�(� � �T� �h�'�'� � � (�'� � �T� �2�3�3� � � 4�3� � � r, r c � � e Zd Zej Z edd� � ddedz dedz ded ed edz dedz dedz d edz dedz dedz de dz de e fd�� � Z edd� � dd�� � ZdS )�WordpressCommonEndpointsr zlist-incidentsN�2 r r r �limit�offset�by_abuser_ip�by_country_code� by_domain�search�since�to�order_byr c � �@ K � t ||� � \ }} n/# t $ r"}t t |� � � � |�d}~ww xY wt |||||||| | | |�� � }|D ]:}|� d� � |d<