hdZddlZddlmZddlmZddlmZmZddl m Z ddl m Z ddl mZejeZd Zd Zgd ZGd d e 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) lru_cache)Path) hosting_panelplesk) MessageSink) HooksConfig)notifierzK/usr/local/psa/admin/plib/modules/imunify360/scripts/send-notifications.phpz@/opt/imunify360/venv/share/imunify360/scripts/send-notifications)CUSTOM_SCAN_MALWARE_FOUNDUSER_SCAN_MALWARE_FOUNDREALTIME_MALWARE_FOUNDc\eZdZdZeddefdZdefdZdZdZ d S) PleskNotificationsHooksc$KtjjtjjkrdS|r2|s|d{VdSdS|d{VdS)zMessageSink methodN) r HostingPanelNAMErPlesk is_supported is_applied add_hooks remove_hooks)selfloops U/opt/imunify360/venv/lib/python3.11/site-packages/imav/plugins/plesk_notifications.py create_sinkz#PleskNotificationsHooks.create_sink+s  % ' ' , 0@ @ @ F      &??$$ 'nn&&&&&&&&&&& ' '##%% % % % % % % % % %)maxsizereturnctto%ttSN)r SCRIPT_PATHexists HOOK_PATH)rs rrz$PleskNotificationsHooks.is_supported5s3K  ''))Fd9oo.D.D.F.FFrct}|ditfdtDsdStfdtDS)Nrulesc3 K|]}|vV dSr .0event config_ruless r z5PleskNotificationsHooks.is_applied..=s(==U5L(======rFc3K|];}t|didgvV.@sg   E"&&x4488BGG H      r)rr0allEVENTS)rconfigr+s @rrz"PleskNotificationsHooks.is_applied9s""$$zz'2.. ====f===== 5           rcHKt}dd|diDi}tD]}||dvr i|d|<d}tD]}|d|}t|didgvr]d|vri|d<g|dd<nd|dvr g|dd<d|dd<|ddtd}|rt| tjd{Vt ddS#t$rt d YdSwxYwdS) Nr%c,i|]\}}|tv||Sr'r2r)r*rules r z5PleskNotificationsHooks.add_hooks..I/E4F??t"??rFr.r/Tenabledz%Hooks added and configuration updated9Notifier is not running, cannot send CONFIG_UPDATED event) rr0itemsr2r#appendupdater config_updatedloggerinfoConnectionRefusedErrorwarning)rr3datar*updatedr8s rrz!PleskNotificationsHooks.add_hooksFs""$$ #)::gr#:#:#@#@#B#B  * *EDM))')W e$  E='D2 6 6 : :9b I III4''%'DN02DN9--d8n4402DN9-,0Xy)Xy)00;;;  E MM  & & & E-/////////  CDDDDD *   O  E EsE77$FFcKt}dd|diDi}d}|dD]\}}t|didgvrP|ddtt |dddk|dd<d}|rt| tjd{Vt d dS#t$rt d YdSwxYwdS) Nr%c,i|]\}}|tv||Sr'r6r7s rr9z8PleskNotificationsHooks.remove_hooks..or:rFr.r/rr;Tz'Hooks removed and configuration updatedr<) rr0r=r#removelenr?r r@rArBrCrD)rr3rErFr*r8s rrz$PleskNotificationsHooks.remove_hooksls""$$ #)::gr#:#:#@#@#B#B =..00  KE4DHHXr2266y"EEEEXy)00;;;,/Xy0I,J,Ja,OXy)  G MM  & & & G-/////////  EFFFFF *   O  G GsE$E;:E;N) __name__ __module__ __qualname__rrboolrrrrr'rrrr*s&&&YqGdGGGG  D     $E$E$ELGGGGGrr)__doc__logging functoolsrpathlibrdefence360agent.subsys.panelsrr!defence360agent.contracts.pluginsrdefence360agent.contracts.hooksrdefence360agent.subsysr getLoggerrKrAr!r#r2rr'rrrXs*>>>>>>>>999999777777++++++  8 $ $[ N    ZGZGZGZGZGkZGZGZGZGZGr