Hacked By AnonymousFox

Current Path : /opt/imunify360/venv/lib/python3.11/site-packages/imav/malwarelib/plugins/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/imav/malwarelib/plugins/__pycache__/scanner.cpython-311.pyc

�

��go����dZddlZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
mZddlmZdd	lmZdd
lmZddlmZddlmZee��ZGd
�de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 <https://www.gnu.org/licenses/>.

Copyright © 2019 Cloud Linux Software Inc.

This software is also available under ImunifyAV commercial license,
see <https://www.imunify360.com/legal/eula>
�N)�defaultdict)�	getLogger)�Malware)�MessageType)�MessageSink�
MessageSource�expect)�MalwareScanType)�MalwareIgnorePath)�DetachedScanPlugin)�MalwareScanner)�recurring_checkc���eZdZd\ZZdZdZd�Zd�Zd�Z	d�Z
eej
��d���Zeej��d���Zed	���Zd
�Zd�Zeej��d���ZdS)
�Scanner)NNNc��K�||_||_|j�|�����|_dS�N)�_loop�_sink�create_task�_recurring_scan�
_scan_task)�self�loop�sinks   �T/opt/imunify360/venv/lib/python3.11/site-packages/imav/malwarelib/plugins/scanner.py�
create_sourcezScanner.create_source/s;������
���
��*�0�0��1E�1E�1G�1G�H�H�����c��<K�tt��|_dSr)r�set�_targets)rrs  r�create_sinkzScanner.create_sink5s����#�C�(�(��
�
�
rc��VK�|j���|j�d{V��dSr)r�cancel�rs r�shutdownzScanner.shutdown8s:�������� � � ��o���������rc	�l�|dD]�}t|t��sSt|��}tj|��}t
�d||tt��|��|�dtj	��}|j
|�|����dS)N�filelistz1Received path %s as %s instead of %s. Message: %s�	scan_type)�
isinstance�str�type�os�fsdecode�logger�error�getr
�REALTIMEr �add)r�message�path�tr(s     r�_process_scan_taskzScanner._process_scan_task<s����J�'�	/�	/�D��d�C�(�(�	
���J�J���{�4�(�(�����G�����I�I����� ���K��1I�J�J�I��M�)�$�(�(��.�.�.�.�	/�	/rc��4K�|�|��dSr)r6)rr3s  r�process_scan_taskzScanner.process_scan_taskKs ��������(�(�(�(�(rc��K�|d}tj||�dd�����}|�|��dS)N�filesr+�rescan)r'r()r�MalwareScanTaskr0r6)rr3r'�msgs    r�rescan_fileszScanner.rescan_filesOsV�����7�#���)�����V�X�)F�)F�
�
�
��	
����$�$�$�$�$rc���K�t��}|D]P}tj�|��r/t	j|���d{V��s|�|���Q|Sr)�listr,r4�existsr�is_path_ignored�append)�targets�result�filenames   r�_filter_outzScanner._filter_outWsx���������	(�	(�H��w�~�~����
(�-�=�h�G�G�G�G�G�G�G�G�
(��
�
�h�'�'�'���
rc��K�|r-t�d�|����|�|���d{V��}|sdSt�d|��t|jd���}|�||���|����d{V��}|�Ktj
|���d{V��}|j�tj
di|�����d{V��dSdS)Nz#Checking files to scan with type={}zScanning files: %sT)r�hooks)r(�)r.�info�formatrG�debugr
r�start�
async_waitr�aggregate_result�process_messager�MalwareScan)rrDr(�	file_list�scannerrEr3s       r�
_scan_targetszScanner._scan_targetsasQ�����	��K�K�5�<�<�Y�G�G�
�
�
��*�*�7�3�3�3�3�3�3�3�3�	��	��F����)�9�5�5�5� �d�j��=�=�=���
�
�i�9�
�5�5�5��)�)�+�+�+�+�+�+�+�+����.�?��G�G�G�G�G�G�G�G�G��*�,�,��'�2�2�'�2�2���
�
�
�
�
�
�
�
�
��rc��K�|jtt��c}|_|���D]!\}}|�||���d{V���"dSr)r rr�itemsrU)rrDr(r:s    r�_scanz
Scanner._scanvso����!%���C�0@�0@����� '�
�
���	7�	7��I�u��$�$�U�I�6�6�6�6�6�6�6�6�6�6�	7�	7rc��>K�|����d{V��dSr)rXr$s rrzScanner._recurring_scan|s,�����j�j�l�l���������r)�__name__�
__module__�__qualname__rrr rrr!r%r6r	rr<r8�MalwareRescanFilesr>�staticmethodrGrUrXr�Config�INOTIFY_SCAN_PERIODrrJrrrr*s�������L�E�5��H��J�I�I�I�)�)�)����
/�
/�
/��V�K�'�(�(�)�)�)�(�)��V�K�*�+�+�%�%�,�+�%�����\�����*7�7�7��_�V�/�0�0���1�0���rr)�__doc__r,�collectionsr�loggingr� defence360agent.contracts.configrr_�"defence360agent.contracts.messagesr�!defence360agent.contracts.pluginsrrr	�imav.malwarelib.configr
�imav.malwarelib.modelr�%imav.malwarelib.plugins.detached_scanr�imav.malwarelib.scan.scannerr
�defence360agent.utilsrrZr.rrJrr�<module>rls?����*
�	�	�	�#�#�#�#�#�#�������>�>�>�>�>�>�:�:�:�:�:�:�����������
3�2�2�2�2�2�3�3�3�3�3�3�D�D�D�D�D�D�7�7�7�7�7�7�1�1�1�1�1�1�	��8�	�	��T�T�T�T�T�k�=�T�T�T�T�Tr

Hacked By AnonymousFox1.0, Coded By AnonymousFox