}gldZddlZddlZddlmZmZmZddlmZddl m Z m Z ddl m Z ddlmZejeZGdd 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)MalwareScanResourceTypeMalwareScanTypeQueuedScanState) DetachedState)QueuedScanBase ScanQueue)create_task_and_log_exceptions) MessageTypec~eZdZeZddZ ddefdZdZdZ ddZ d Z d Z d Z d Zd ZdefdZdZdS)QueueSupervisorSyncNc|ptj|_||_|jj}|rD|jtj tj fvrtj |_ dSdSdSN)asyncioget_event_looploopsinkqueue current_scan detached_scanget_detached_process_staterRUNNINGFINISHEDrrunningstate)selfrrrs _/opt/imunify360/venv/lib/python3.11/site-packages/imav/malwarelib/scan/queue_supervisor_sync.py__init__zQueueSupervisorSync.__init__)s4G244  z.  9*EEGG%}'=>??"1!8L     9 9??F resource_typecKtd|jd||jj}|D]:}|j||x}r|j|;|rA|j|vr8|j |kr-|j |j d|j d{V|jj|f||d|d{V|dS)NzQueuing %s scan for %s, )pathrT)rkill scan_started)r prioritize)loggerinfovaluejoinrrfindremover"rrhandle_aborted_processrstartedputrecheck)rpathsrr% scan_args running_scanr"scans rr.zQueueSupervisorSync.put5s^  $m&9499U;K;K   z.  ( (DzD NNNt ( !!$'''  !U***m;;,CCYT 8LD       djn  '!             rcX|jr"|j|j dSdSr)rr+rs rclearzQueueSupervisorSync.clearXs@j J     j     rc |jtj}|sdS|j|D)NT) scan_type)rr*r BACKGROUNDr+rr3s rclear_backgroundz$QueueSupervisorSync.clear_background\sG $:??_-G?HHD  J  d # # #  $rc@|r|j|}n|jjx}r|gng}d|D}tdd||D]}|j||dS)Ncg|] }|j S)r").0ss r z.QueueSupervisorSync.remove..is'''A'''rz$Removing scans from the queue for %sr!)rfind_allrr&r'r)r+r/)rscan_idsscansr3r0s rr+zQueueSupervisorSync.removecs  HJ''11EE'+z'>>tGTFFRE''''' :DIIe)startrprocess_messager MalwareScanr/)rr3 scan_datas rrTzQueueSupervisorSync._scan_coros**,,&&&&&&  )++'44)44          LLNNNNNrc@K|j||dSr)rupdate)rrCrNs rupdate_scan_statusz&QueueSupervisorSync.update_scan_statuss$ (F+++++r)NN)Fr)__name__ __module__ __qualname__rrrrr.r6r;r+r/rKrNrRrHrrTr\r>rrr r &s IKKE 9 9 9 9  !!/!!!!F   $$$    ))) $$$    666III ^,,,,,rr )__doc__rloggingimav.malwarelib.configrrrimav.malwarelib.scan.detachedrimav.malwarelib.scan.queuerrdefence360agent.utilsr "defence360agent.contracts.messagesr getLoggerr]r&r r>rrrhs* 877777@@@@@@@@@@@@@@::::::  8 $ $~,~,~,~,~,~,~,~,~,~,r