hWdZddlZddlZddlmZmZddlmZddlm Z m Z m Z ej e ZdefdZdefdZdefd Zdefd Zdefd Zdefd ZdS) u  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 . Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see N) check_run CheckRunError)WPSite) PLUGIN_PATH PLUGIN_SLUGutilssiteczKtj|jj}t j||d{V}gt j||jddttdd}t j ||}t d|t|d{VdS)zFInstall the Imunify Security WordPress plugin on given WordPress site.Nplugininstall --activate--forcezInstalling wp plugin pwdgetpwuiduidpw_namerget_php_binary_path wp_wrapperdocrootstrrbuild_command_for_userloggerinforr usernamephp_pathargscommands G/opt/imunify360/venv/lib/python3.11/site-packages/imav/wordpress/cli.pyplugin_installr!'s|DH%%-H.tX>>>>>>>>H   (DL 1 1     K        D*8T::G KK111222 G  czKtj|jj}t j||d{V}gt j||jddttdd}t j ||}t d|t|d{VdS)z Update the Imunify Security WordPress plugin on given WordPress site. Currently, this is the same as install, but in the future it may differ. Nr r r rzUpdating wp plugin rrs r plugin_updater$<s |DH%%-H.tX>>>>>>>>H   (DL 1 1     K        D*8T::G KK/g//000 G  r"c\Ktj|jj}t j||d{V}gt j||jddtd}t j ||}t d|t|d{VdS)z>>>>>>>H   (DL 1 1          D*8T::G KK3'33444 G  r"cKtj|jj}t j||d{V}gt j||jddtd}t j ||}t d| t|d{V}| d}|sdS|d d S#t $r+}td |jYd}~dSd}~wt&$r&}td |Yd}~dSd}~wwxYw) zTGet the version of the imunify-security wp plugin installed on given WordPress site.Nr getz--field=versionzGetting wp plugin version zutf-8)maxsplitrz0Failed to get wp plugin version. Return code: %sz-Failed to decode wp plugin version output: %s)rrrrrrrrrrrrrdecodestripsplitrerror returncodeUnicodeDecodeError)r rrrrresultoutputes r get_plugin_versionr6is|DH%%-H.tX>>>>>>>>H   (DL 1 1          D*8T::G KK6W66777 ))))))))w''--// 2||Q|''**  > L   ttttt  DaHHHttttts*>C4C44 E> D$$ E1EEc~Ktj|jj}t j||d{V}gt j||jddt}t j ||}t d| t|d{Vn#t$rYdSwxYwdS)zMCheck if the imunify-security wp plugin is installed on given WordPress site.Nr is-installedz#Checking if wp plugin is installed FT)rrrrrrrrrrrrrrrs r is_plugin_installedr9s|DH%%-H.tX>>>>>>>>H   (DL 1 1       D *8T::G KK?g??@@@          uu 4sB,, B:9B:cpKtj|jj}t j||d{V}gt j||jdd}t j||}t d| t|d{Vn#t$rYdSwxYwdS)zJCheck if WordPress is installed and given site is accessible using WP CLI.Ncorer8z#Checking if WordPress is installed FT) rrrrrrrrrrrrrrs r is_wordpress_installedr<s|DH%%-H.tX>>>>>>>>H   (DL 1 1    D *8T::G KK?g??@@@          uu 4sB%% B32B3)__doc__loggingrdefence360agent.utilsrrimav.model.wordpressrimav.wordpressrrr getLogger__name__rr!r$r'r6r9r<r"r rEsR* ('''''  8 $ $v*f2(6@F0vr"