yiSގ d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m
Z
mZ ddlm
Z
ddlmZ ddlmZmZ dd lmZ dd
lmZmZ ddlmZ ddlmZmZ dd
lmZ ddlm Z ej! e" Z#de$de%e$ fdZ&de$de%e$ dz de%e$ fdZ'de%e( de(dz de%e( fdZ) dde%e$ dedz ddfdZ* G d de Z+dS )z6RPC endpoints for WordPress disabled protection rules. N)MessageType)MessageSink)IndexWP_RULES)WPDisabledRule)ValidationError)CommonEndpointsbind)
hosting_panel)Scopelog_future_errors)ChangelogProcessor)redeploy_wp_rulesupdate_disabled_rules_on_sites)get_installed_sites_by_domains)get_wp_rules_datauserreturnc K t j }| d{V }| | g S # t $ r(}t
d| | g cY d}~S d}~ww xY w)z
Get domains for a user from the hosting panel.
Returns:
List of domains the user owns, or empty list on error.
Nz%Failed to get domains for user %s: %s)r HostingPanelget_domains_per_userget Exceptionloggerwarning)r hpdomains_per_useres a/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/simple_rpc/wp_disabled_rules.py_get_user_domainsr s
'
)
)!#!8!8!:!:::::::##D"--- >aHHH s AA
A9A4.A94A9domainsc K t | d{V |sst d S fd|D }|st d |S )a
Validate and filter domains for a non-root user.
If no domains specified, returns all user's domains.
If domains specified, filters to only those the user owns.
Args:
user: Username to validate domains for
domains: Requested domains, or None for all user's domains
Returns:
List of validated domains the user can access
Raises:
ValidationError: If user has no domains or no access to requested domains
NzNo domains found for userc g | ]}|v | S r$ .0duser_domainss r