VULN_CHECK_I913V6 ;E~ pddlmZddlZddlZddlZddlZddlZddlmZddl m Z m Z m Z ddl mZddlmZddlmZddlmZmZdd lmZmZmZdd lmZdd lmZmZm Z dd l!m"Z"dd l#m$Z$ddl%m&Z&ddl'm(Z(m)Z)ddl*m+Z+m,Z,m-Z-ddl.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6ee7Z8eGddZ9de:de"fdZ;de:de:dede:de e"fdZ?ddde:de:d e:de e:e9ffd!Z@d"ejAd#e:fd$ZBde:deeZdZUeed<eed<dZeeed<dS)WordpressErrormessagecontextNcode) __name__ __module__ __qualname__str__annotations__dictr(rintpy/clwpos/wp_utils.pyr%r%4s8 LLL MMMD(3-r1r% abs_wp_pathreturncttjd}|rt |pt |}nt |}|S)z Return php_version that will be used for calling wp-cli commands. If 'CLWPOS_USE_SAVED_PHP_VERSION' envar is defined, try to get this version from a previously saved file. CLWPOS_USE_SAVED_PHP_VERSION)boolosenvironget_get_saved_php_version_get_php_version)r3use_saved_php_version php_versions r2get_php_versionr?;sY !0N!O!OPP4,[99Z=Mk=Z=Z &{33 r1 documentrootctj|}tj|} tj||g|kS#t$rYdSwxYw)a  Return True if abs_wp_path is the documentroot or a path contained within it, using canonical containment rather than a raw string prefix so that a path containing ``..`` cannot escape the documentroot while still textually matching its prefix. F)r8pathrealpath commonpath ValueError)r3r@resolved_docrootresolved_wp_paths r2_path_within_docrootrHIs|w'' 55w'' 44w!!#35E"FGGK[[[ uus$A%% A32A3)maxsizect}g}|D];}t||dr#||d|df<|d|ddS)zReturn PHP version.r@versionT)reverser)rrHappendsort)r3resultitemsitems r2r<r<^s~ZZF EBB  T.-A B B B LL$~.Y@ A A A JJtJ 8A;r1c tstdtjd}t t j|}tj |sdS t|5}tj |}dddn #1swxYwYnD#ttjjf$r&}t"d|Yd}~dSd}~wwxYwg}|D];}t'||dr#||d|df<|sdSt+d it-|dd d d S)z@ Get domain's php version from a previously saved file. z*Internal Error. Contact CloudLinux supportCLWPOS_PHP_FILE_ID)file_idNz,Error during reading of ".php_info" file: %sr@rLc|ddS)NrN identifierr0)rSs r2z(_get_saved_php_version..sa.r1T)keyrMrrNr0)rr r8r9r:rr rformatrBexistsopenjsonloadOSErrordecoderJSONDecodeError_logger exceptionrHrOrsorted)r3 php_file_id php_info_filef _php_infoe php_versions vhost_infos r2r;r;ks   FDEEE*..!566KY[[))299+9NNM 7>>- ( (t -  %A ! I % % % % % % % % % % % % % % % T\1 2JANNNtttttLUU  Z-G H H U   N!;Z =R S T T T t    . .       s<C"C7 CCC C CD*D  DenvrBcommand subcommandcTt|}t|j}tj|s plugin install redis-cache wp --path= plugin activate redis-cache wp --path= redis enable wp --path= plugin deactivate redis-cache wp --path= plugin uninstall redis-cache @return: stderr if error was happened. zLError during wp-cli command execution "%s": invalid path to binary file "%s"zQError during resolving path to php binary file: got non-existent path "%(path)s".rBr&r'zExecuting command=%s T)checkrnzPost-check failedz7Error during command execution: %s stdout=%s stderr=%s)homedirzUnexpected error happened during command execution: '%(command)s'. Event is logged to file: '%(logger_path)s' with stdout and stderr recorded.ro logger_path error_desc)r&r'r(NzCommand=%s returned output=%s)r?r,binr8rBr\rcrdr%_rrinfojoinr subprocessCalledProcessErrorstderrstdoutgetuidrrr[pwdgetpwuidpw_dir_process_post_check returncode)rBrorprnargsr> php_bin_path command_part full_command environmentoutputerrorpost_check_flagrwr&r's r2 wordpressrsz"$''K{''L 7>>, ' ' ?!< 1 1 1<==\*    {+++Z/$/L   L )K LL',)?)?@@@ (T{SSS  (   -=((<((&"5< ? ? ?13 6((ARAYL--4B6B6B6   { 3 3 3 3fggG#*#lG !         ' 0 LL0#((<2H2H#fmJ\J\]]] =sC&&G5CGGGrQlog_pathcd}||jvrtt|d}d}||jvrr||jvri|j|\}}|d}|d}tt ||d} | |jvrQ|jdd}|d}tt |td} |j||j |jzd } ttd | | d ) zx In some rare cases plugin installation (CDN) may return post-check errors which we should handle properly. zCDN url not found on pagezURL z#returned unexpected response statusrNu( )’'z+CDN url returned unexpected response status(zWordPress plugin failed to activate correctly. Changes were reverted and caching module is now disabled. Error reported from plugin: %(error_desc)s. Event is logged to file: '%(logger_path)s' with stdout and stderr recorded.rvzPost check failed)header descriptionr'fix_tip) rrrsplitstriprrrzcmdrr) rQrcnd_not_active_msg url_matchunexpected_error_matchurl_part code_parturlr(unexpected_error_static_contentr&r's r2rrs5V]** 3H = =>>>IBFM!!&< &M&M$m112HII)nnq!y)) #C . .   'T#&&-77M'',,Q/ y)) !$ ' '   ^__G :mfm3G -"   r1cHd}d|z}td|5}|jr||jvcdddSt|d|tdi}t |t rt |j|j||_||vcdddS#1swxYwYdS) Ncl_multisite_detectedzCif ( is_multisite() ) { echo "%s"; } else { echo "not_multisite"; } is_multisiterBeval1rmrr) rdatarr isinstancer%r r&r')rBmarkerrorecordrQs r2rrs $FSV\\G d 3 3 3 v ; )V[(        47NPS6TUUU fn - - LFNFNKKK K                   sBABBBFwp_pathconstantcdd|iz}td|z|5}|jr|jcdddSt|d|tdi}t |t rF|rt |j|j t d | ddddS||_|cdddS#1swxYwYdS) zt Get: - defined constant value - None in case of error - empty string if no such constant found z-if (defined('%(const)s')) { echo %(const)s; }constzconst.rNrrrmrrz Error during get WP constant: %s) rrrrrr%r r&r'rcr)rrraise_exceptionrorrQs r2wp_get_constantrs`>(@SSG H,7 ; ; ; v ; ;        7FG:QSV9WXXX fn - -  X'WWWW MMBBDZDhDm-1333F YJ!+-C-Q-V WYYY Y 7>>& ! !4N!)6 2444 444r1cvd}d}trd}ntrd}trd}||dS)z* Returns needed envars for wp-cli Apacher LiteSpeednginxzCloudLinux MAx Webserver)SERVER_SOFTWARESERVER_SOFTWARE_EXTRA)r!r"r#)server_softwareserver_software_extras r2obtain_wp_cli_envr>sbO"%   "!  ; :+!6  r1c8eZdZUeed<eed<eed<eed<dS) PluginInforstatusupdaterLN)r)r*r+r,r-r0r1r2rrTs: III KKK KKKLLLLLr1rc|r,t|}|tdin tdi}t|ddd|}t |t rgSd} t j|}ng#ttt j f$rH}||}||}n.ttdd|it| Yd}~nd}~wwxYwt |ts ttd d|i |D]7}t |ts ttd d|i 8|S) Nrpluginlistz--jsonrmcd}d}tj||}|r; |d}tj|}n#t $rYnwxYw|S)Nz (\[{.*?}\])rN)researchgroupr^loads Exception)r_resultpatternmatches json_strings r2 _maybe_jsonz(_cached_plugin_list.._maybe_jsonrss )GV,,   %mmA.. *[11    s)A AAzQMalformed plugins information received from wp-cli. Raw response is %(response)s.response)r&r'detailszIMalformed plugin list received from wp-cli. Raw response is %(response)s.rrzPMalformed plugin information received from wp-cli. Raw response is %(response)s.)r.rrrrr%r^rrE TypeErrorrbr rzr,r)r3 wp_cli_envrQrplugin_list_rawrjmaybe_json_result plugin_infos r2_cached_plugin_listrbs4*%% 2C89999-s3 {HfhJ O O OF&.))     *V,,  4#7 8   'K//  (/OO455$V,A   OOOO  ot , , 011 (     ' +t,, 455$V,    s'A<<C >CC cttj||r!t |ndSN)rr8rBnormpathtuplerRr3rs r2 plugin_listrsK  %% ( uZ-=-=-?-?'@'@'@  r1c6dt||DS)Nc*g|]}|ddk|S)ractiver0).0rSs r2 z'list_active_plugins..s1    >X % % % % %r1)rrs r2list_active_pluginsrs-  $[*==   r1ct|}t|trt|j|jfd|DS)N)r3rrc,g|]}|dk|S)rr0rrS plugin_names r2rz#get_plugin_data..s' I I ITT&\[-H-HD-H-H-Hr1)rrr%r r&r')wordpress_abs_pathr plugins_datas ` r2get_plugin_datarsb+=>>>L,//6 4 , 4666 6 I I I I\ I I IIr1rcVtfdt||DS)Nc3HK|]}|dko |ddkVdS)rrrNr0rs r2 z&is_plugin_activated..sVAAF|{*ItH~/IAAAAAAr1anyrr3rrs ` r2is_plugin_activatedrsO AAAA&{J??AAA A AAr1cVtfdt||DS)Nc30K|]}|dkVdS)rNr0rs r2rz&is_plugin_installed..s,\\ttF|{*\\\\\\r1rrs ` r2is_plugin_installedrs1 \\\\{;PZ7[7[\\\ \ \\r1 constant_namecX|Rt|dd|dtdi}t|trd}nst|dd|ddtdi}nUt|dd||d dd d dtdi }t|trt|dd||d ddtdi }|S) Nconfighasz--type=constantrrmdeletez--quietsetz--rawz/--anchor=// End of CloudLinux generated sectionz--placement=before)rrrr%)r3rconstant_valuerQs r2update_constantrs;%HY 7=??? fn - - CFF{Hh O`bk$;S#ACCCFF ;%X_,._/AXZ]@^``` fn - - a{He]N\c0)BY[^A_aaaF Mr1cBt|tjj|Sr)rr WP_REDIS_DISABLE_BANNERSr)r3rs r2%update_redis_disable_banners_constantrs ;(>(W(\^l m mmr1)Fr)P __future__rr^r8rrr} dataclassesrtypingrrr functoolsrtyping_extensionsr clwposr rzclwpos.cl_wpos_exceptionsr r clwpos.constantsr rrclwpos.data_collector_utilsrclwpos.logsetuprrrclwpos.php.baserclwpos.scoped_cacherclwpos.user.cacherclwpos.user.website_checkrr clwpos.user.website_check.errorsrrr clwpos.utilsrrrrr r!r"r#r)rcr%r,r?r7rHr<r;rr~rrrrrrrrrrrrrrr0r1r2rs'&&&&& !!!!!!((((((((((''''''BBBBBBBBTTTTTTTTTT000000  //////------JJJJJJJJ                     - ! !        c* 3 # #           @DH;;;C;#;3;ERUWeReLf;;;;|9-99999x  s  t     SC8TW=.44c4444&,        ==S=d:>N====@Sd:6FSJZ8HJJJJAASAsAPTAAAA ]]S]s]PT]]]]SRZ[iRj0nnsnT\]kTlnnnnnnr1