gq" dZddlmZmZmZddlmZmZmZm Z m Z m Z m Z m Z mZmZddlmZmZddlmZmZGdde ZGdd e ZGd d e ZGd d e ZGddee e ZGddee e eZGddee ZGdde ZGdde ZGddeZGddeZ GddeZ!GddeZ"Gd d!eZ#Gd"d#e e Z$Gd$d%e e Z%Gd&d'e e Z&Gd(d)e Z'Gd*d+ee e Z(Gd,d-eZ)Gd.d/e Z*Gd0d1e Z+Gd2d3e Z,Gd4d5e Z-Gd6d7e Z.Gd8d9e Z/Gd:d;e Z0Gd<d=ee e Z1Gd>d?eZ2Gd@dAe Z3dBee3eeeeeee%e ef DZ4dCS)Du  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 )ListOptionalSet) AccumulatableAck FilesUpdatedLockableMessageNoopReceived ReportableShortenReprListMixin Splittable)MalwareScanTypeQueuedScanState)MalwareDatabaseHitInfoMalwareDatabaseScanReportceZdZdZdZdS)MalwareScanTaskz/ Creates task to scan file for malware MALWARE_SCAN_TASKN__name__ __module__ __qualname____doc__DEFAULT_METHODL/opt/imunify360/venv/lib/python3.11/site-packages/imav/contracts/messages.pyrr+s)NNNrrceZdZdZdS)MalwareScanCompleteMALWARE_SCAN_COMPLETENrrrrrrrr!r!3s,NNNrr!ceZdZdZdS)MalwareCleanCompleteMALWARE_CLEAN_COMPLETENr#rrrr%r%7s-NNNrr%ceZdZdZdS)MalwareRestoreCompleteMALWARE_RESTORE_COMPLETENr#rrrr(r(;s/NNNrr(c"eZdZdZfdZxZS)MalwareScanSummaryMALWARE_SCAN_SUMMARYcVd|D}tj|d|i|dS)Nc"g|] }d|di S)summaryr.0items r z/MalwareScanSummary.__init__..Ds!@@@$)T)_-@@@ritemssuper__init__selfr4argskwargs __class__s rr7zMalwareScanSummary.__init__Bs=@@%@@@$6e6v66666r)rrrrr7 __classcell__r<s@rr+r+?s=+N777777777rr+c.eZdZdZdZdZdZfdZxZS)MalwareScanResultMALWARE_SCAN_RESULTiresultscVd|D}tj|d|i|dS)Nchg|]/}d|dD|dd0S)c"i|] \}}|dv || S)>r:typescanidr)r1keyvalues r z9MalwareScanResult.__init__...Ts4"U888888rr/rC)r/rC)r4r0s rr3z.MalwareScanResult.__init__..Qsd    &*9o&;&;&=&=  ?      rr4r5r8s rr7zMalwareScanResult.__init__PsL        $6e6v66666r) rrrr LIST_SIZE BATCH_SIZE BATCH_FIELDr7r=r>s@rr@r@HsL*NIJK777777777rr@c*eZdZdZdZeefZdefdZ dS) MalwareScanz+ Represents results of single scan MALWARE_SCANreturnc|d}|didtjkr|duSt|S)NrCr/rG)getr BACKGROUNDbool)r9rCs r do_accumulatezMalwareScan.do_accumulateisT((9%% 88Ir " " & &v . ./2L L L$& &G}}rN) rrrrrr+r@ LIST_CLASSrVrWrrrrPrPasK$N$&78JtrrPceZdZdZdZdS)MalwareMRSUploadzk Used to isolate a possibly long running uploading to MRS from the other MalwareScan handlers. MALWARE_MRS_UPLOADNrrrrrZrZps *NNNrrZceZdZdZdS)MalwareScanQueueMALWARE_SCAN_QUEUENr#rrrr]r]y)NNNrr]ceZdZfdZxZS)MalwareScanQueuePutcNt||dS)N)paths scan_argsr5)r9rcrdr<s rr7zMalwareScanQueuePut.__init__~s& u :::::rrrrr7r=r>s@rrara}s8;;;;;;;;;rraceZdZfdZxZS)MalwareScanQueueRemovecLt|dS)N)scan_idsr5)r9rir<s rr7zMalwareScanQueueRemove.__init__s$ (+++++rrer>s@rrgrgs8,,,,,,,,,rrgceZdZfdZxZS)MalwareScanQueueRecheckcHtdSNr5r9r<s rr7z MalwareScanQueueRecheck.__init__ rrer>s@rrkrk8rrkceZdZfdZxZS)MalwareScanQueueStopBackgroundcHtdSrmr5rns rr7z'MalwareScanQueueStopBackground.__init__rorrer>s@rrrrrrprrrc<eZdZddddeedeffdZxZS)MalwareScanQueueUpdateStatusNristatusrirwcNt||dS)Nrvr5)r9rirwr<s rr7z%MalwareScanQueueUpdateStatus.__init__s( (6:::::r)rrrrstrrr7r=r>s@rrurus`'+t;;;9;5D;;;;;;;;;;rruc$eZdZdxZ\ZZZZdZdS)MalwareResponse)BLACKWHITEKNOWNUNKNOWNMALWARE_RESPONSEN) rrrTYPESr|r}r~rrrrrr{r{s&+OOE (E5%'NNNrr{ceZdZdZdS)MalwareSendFilesMALWARE_SEND_FILESNr#rrrrrr_rrceZdZdZdS)MalwareRescanFilesMALWARE_RESCAN_FILESNr#rrrrr+NNNrrc4eZdZdZdZddddddfd ZxZS)MalwareCleanupTaskz' Creates task to cleanup files MALWARE_CLEANUP_TASKN) standard_onlycause initiatorscan_id post_actioncVt||||||dS)N)hitsrrrrrr5)r9rrrrrrr<s rr7zMalwareCleanupTask.__init__sB '#      r)rrrrrr7r=r>s@rrrsd,N            rrceZdZdZdS)MalwareCleanupListMALWARE_CLEANUP_LISTNr#rrrrrrrrceZdZdZdZeZdS)MalwareCleanupz. Represents results of single cleanup MALWARE_CLEANUPN)rrrrrrrXrrrrrs$'N#JJJrrceZdZdZdS)MalwareIgnorePathUpdatedzESignal through a message bus that MalwareIgnorePath has been updated.NrrrrrrrrrsOODrrcteZdZUdZeeeed<eed<eed<eed<eeed<eed<eed<eed <eed <e e ed <eeed <d d d d dddddeeedeededededed ed ed e e deed eeffdZ de fdZ dZdZdZxZS)MalwareDatabaseScanz1 Represents results of a single MDS scan r:pathrrGerrorstarted completedtotal_resourcestotal_maliciousrrrN)rrrrrrrc `t||||||||| | |  dS)N) r:rrrGrrrrrrrr5) r9r:rrrGrrrrrrrr<s rr7zMalwareDatabaseScan.__init__sQ ++  rreportcl||j|j|j|j|jdS)N)rrrrr)updaterrrrr)r9rs rupdate_with_reportz&MalwareDatabaseScan.update_with_reportsC N&"2"2      rc.||SN)r)r)r9messages rupdate_with_errorz%MalwareDatabaseScan.update_with_error s{{{)))rctrmNotImplementedError)r9rIrJs r __setitem__zMalwareDatabaseScan.__setitem__ !!rctrmr)r9rIs r __delitem__zMalwareDatabaseScan.__delitem__rr)rrrrrrry__annotations__intrrr7rrrrrr=r>s@rrrs 49  III LLL III C= LLLNNN $ %%%%}  ,0##'   tCy! sm          () } C=      : )B    ***""""""""""rrceZdZdZdS)MalwareDatabaseRestorez4 Represents results of a single MDS restore NrrrrrrsrrcBeZdZUdZeed<eed<dedeffd ZxZS)MalwareDatabaseRestoreTaskz. Represents a single MDS restore task rapp_namecNt||dS)N)rrr5)r9rrr<s rr7z#MalwareDatabaseRestoreTask.__init__"s& dX66666rrrrrryrr7r=r>s@rrrsk IIIMMM7S7C7777777777rrcreZdZUdZeeed<eeed<deedeeffd ZxZS)MalwareDatabaseCleanupz4 Represents results of a single mds cleanup succeededfailedcNt||dS)N)rrr5)r9rrr<s rr7zMalwareDatabaseCleanup.__init__.s6       r) rrrrrrrr7r=r>s@rrr&s)**** & '''' -. *+          rrc4eZdZUdZeed<deffd ZxZS)MalwareDatabaseCleanupFailedz* Signifies an MDS cleanup failure rcLt|dSrr5r9rr<s rr7z%MalwareDatabaseCleanupFailed.__init__@$ u%%%%%rrr>s@rrr9[ JJJ&&&&&&&&&&&rrc4eZdZUdZeed<deffd ZxZS)MalwareDatabaseRestoreFailedz* Signifies an MDS restore failure rcLt|dSrr5rs rr7z%MalwareDatabaseRestoreFailed.__init__Krrrr>s@rrrDrrrceZdZdZdS)MalwareCleanupRevertListMALWARE_CLEANUP_REVERT_LISTNr#rrrrrOs2NNNrrceZdZeZdS)MalwareCleanupRevertN)rrrrrXrrrrrSs)JJJrrceZdZdZdS)CheckDetachedScansMALWARE_CHECK_DETACHED_SCANSNr#rrrrrWs3NNNrrcg|] }|j Sr)r)r1msgs rr3r3[s+ rN)5rtypingrrr"defence360agent.contracts.messagesrrrr r r r r rrimav.malwarelib.configrrimav.malwarelib.scan.mds.reportrrrr!r%r(r+r@rPrZr]rargrkrrrur{rrrrrrrrrrrrrrrMSGS_WITHOUT_IPrrrrsA*'&&&&&&&&&                        DCCCCCCC )))))g)))-----'---.....7...00000W00077777-w 77777777,gz:7772     -   *****w********w***;;;;;*;;; ,,,,,-,,, . %5 ;;;;;#3;;;(((((gx((( *****w***,,,,,(,,,        6,,,,,-w ,,,$$$$$]$$$     w   >">">">">"'>">">"BW 7 7 7 7 7 7 7 7     W   &&&&&&7&&&&&&&&7&&&333333Wj333*****=***44444444   r