PATH:
opt
/
imunify360
/
venv
/
lib
/
python3.11
/
site-packages
/
defence360agent
/
wordpress
/
__pycache__
/
Editing: site_repository.cpython-311.opt-1.pyc
� ���i�@ � � � d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlm Z d dl mZmZ d dl mZ ej e� � Z ed� � Zded ee fd �Zdej d ee fd�Zd ee fd �Zd ee fd�Zdee d dfd�Zded ee fd�Zdeded dfd�Z d*dee d ee fd�Zdeded dfd�Z d+de!dz de!dz de!d e"e!ee f fd�Z#d ee fd�Z$dee d ee fd �Z%d!� Z& e ed"d#d$e&�%� � ded e!fd&�� � Z'd ee fd'�Z(d ee fd(�Z)ded dfd)�Z*dS ),� N)�Path)�SqliteDatabase�OperationalError)�retry_on)�WPSite� WordpressSite)�PLUGIN_SLUGzD/var/lib/cloudlinux-app-version-detector/components_versions.sqlite3�path�returnc �< � t � � � s;t � dt t � � � � t � � S t t � � � d| � d�� � }d� |� � � D � � S )a� Get a list of WordPress sites that match the given path. Args: path: The path to search for WordPress sites. Note: The same WordPress site (real_path) can appear in multiple reports if it was scanned directly and also as part of a parent folder scan. We use only the entry from the latest report for each real_path. Returns: A list of WPSite objects that match the path. �-App detector database '%s' couldn't be found.a� WITH latest_reports AS ( SELECT id, uid, domain FROM report WHERE id IN ( SELECT MAX(id) FROM report WHERE domain IS NOT NULL AND domain != '' GROUP BY dir ) ), -- Get all WordPress sites with their report IDs all_wp_sites AS ( SELECT wp.real_path, lr.domain, lr.uid, lr.id as report_id FROM apps AS wp INNER JOIN latest_reports AS lr ON wp.report_id = lr.id WHERE wp.title = 'wp_core' AND wp.parent_id IS NULL AND wp.real_path LIKE 'aa %' ) -- For each real_path, keep only the entry from the latest report SELECT real_path, domain, uid FROM all_wp_sites WHERE (real_path, report_id) IN ( SELECT real_path, MAX(report_id) FROM all_wp_sites GROUP BY real_path ) c �p � g | ]3}t |d |d t |d � � �� � ��4S �r � � )�docroot�domain�uid�r �int��.0�rows �^/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/wordpress/site_repository.py� <listcomp>z%get_sites_by_path.<locals>.<listcomp>H �I � � � � �� �s�1�v�c�!�f�#�c�!�f�+�+�>�>�>�� � � ) �COMPONENTS_DB_PATH�exists�logger�error�str�listr �execute_sql�fetchall)r �cursors r �get_sites_by_pathr'