g dZddlmZddlmZddlmZddlmZddl m Z m Z m Z ddl mZddlmZdd lmZdd lmZdd lmZeejd ZGdde 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 )partial)Dict) inactivity) MessageType) MessageSink MessageSourceexpect)MalwareHitStatus) MalwareHit) MalwareAction)Scope)MalwareActionIm360status) attributecjeZdZdZejZdZdZdZ e e j de fdZdS)RestoreFromBackupPluginz5A plugin that handles RestoreFromBackupTask messages.c$d\|_|_dS)N)NN)_loop_sink)selfs U/opt/imunify360/venv/lib/python3.11/site-packages/imav/plugins/restore_from_backup.py__init__z RestoreFromBackupPlugin.__init__.s!+ DJJJcK||_dSN)r)rloops r create_sinkz#RestoreFromBackupPlugin.create_sink1 rcK||_dSr)r)rrsinks r create_sourcez%RestoreFromBackupPlugin.create_source4rrmessagecTK|d}|sdS|d}tj|tjt jd5i}||g |gg}}| D]\}}tj |||j d{V}| d| D| d| Dtj|t|} | D]\} } tj| |  ddddS#1swxYwYdS)aRestores hits in RestoreFromBackupTask message from backup. - sets restore_from_backup_started status for received hits in the database. - successfully restored files are removed from the database. - statuses in the database are reverted from restore_from_backup_started to its original value for files that failed to restore. hitsN initiatorrestore_from_backup)r$r%r c&g|]\}}|j |S successful.0hitevents r z?RestoreFromBackupPlugin.restore_from_backup..Ys$OOOZS%e>NOSOOOrc&g|]\}}|j |Sr(r)r+s rr/z?RestoreFromBackupPlugin.restore_from_backup..]s5&C$/r)getr set_statusr RESTORE_FROM_BACKUP_STARTEDrtracktask setdefaultextenditemsr r&rdelete_instances_group_by_status) rr"r$r% to_restorerestoredfailed init_hitsresultsoriginal_statusr failed_hitss rr&z+RestoreFromBackupPlugin.restore_from_backup7s2{{6""  FKK ,,  ">     " "#8 9 9 ; ;J  ! !)R 0 0 7 7 = = =!2fH(2(8(8(:(:  $ 9 - A"'!!! OO7==??OOO *1--//  ' 1 1 1.v66O'6'<'<'>'> ; ;# %k6:::: ;7 ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s/D FF!$F!N)__name__ __module__ __qualname____doc__r IM360SCOPErrr!r rRestoreFromBackupTaskrr&r(rrrr)s?? KE,,, VK -..0;0;0;0;/.0;0;0;rrN)rE functoolsrtypingrdefence360agent.apir"defence360agent.contracts.messagesr!defence360agent.contracts.pluginsrrr imav.malwarelib.configr imav.malwarelib.modelr imav.malwarelib.subsys.malwarer defence360agent.utilsr rgroup_by_attributer:rr(rrrSs5*******:::::: 433333,,,,,,888888''''''======7:8HMMM?;?;?;?;?;k=?;?;?;?;?;r