HEX
Server: LiteSpeed
System: Linux linux31.centraldnserver.com 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: salamatk (1501)
PHP: 8.1.33
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open
Upload Files
File: //opt/imunify360/venv/lib64/python3.11/site-packages/imav/__pycache__/server.cpython-311.pyc
�

՞iO��R�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZddlmZddlmZddlmZmZddlmZddlZdd	lmZddlZddlZddlZdd
lmZddl m!Z!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'm(Z(dd
l)m*Z*ddl+m,Z,ddl-m.Z.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7m8Z8m9Z9ddl:m;Z;m<Z<m=Z=m>Z>m?Z?ddl@mAZAmBZBddlCmDZDmEZEmFZFmGZGddlHmIZIddlJmKZKddlLmMZMddlNmOZOmPZPddlQmRZRddlSmTZTmUZUmVZVddlWmXZXmYZYddlZZZdZ[ede'j\z��Z]d Z^ej_e`��ZaePeO�!��eajb��ZcGd"�d#��Zde
d$���Zed8d&�Zfd'�Zgd(�Zhd)�Zid*�Zjd+�Zkd%ee5elelffd,�Zmd-e5fd.�Znd/�Zod0�Zpd1eld%dfd2�Zqd3�Zrd4�Zsd5�Ztd6�Zud7�ZvdS)9u

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)�ThreadPoolExecutor)�contextmanager�suppress)�partial)�Path)�CalledProcessError�check_output)�Tuple)�
AlreadyLocked)�files)�health�
inactivity)�ConfigsValidator�Core�Merger�Model�	SimpleRpc)�	HookEvent)�
LicenseCLN)�MessageSink�
MessageSource)�g)�IndependentAgentIDAPI)�TheSink)�instance�simplification�	tls_check)�NonRootRpcServer�NonRootRpcServerAV�	RpcServer�RpcServerAV�
is_running)�persistent_state�systemd_notifier)�Task�create_task_and_log_exceptions�is_root_user�is_systemd_boot)�shutdown_process_pools)�is_db_corrupted)�EXITCODE_GENERAL_ERROR)�DAY�
rate_limit)�flush_sentry)�MalwareHitStatus�MalwareScanResourceType�VulnerabilityHitStatus)�
MalwareHit�VulnerabilityHiti4z%s.is_corruptedz�Imunify360 database is corrupt. Application cannot run with corrupt database. Please, contact Imunify360 support team at https://cloudlinux.zendesk.com)�periodc��eZdZd�Zd�ZdS)�TaskFactoryc�,�t��|_dS�N)�set�pool)�selfs �@/opt/imunify360/venv/lib/python3.11/site-packages/imav/server.py�__init__zTaskFactory.__init__gs���E�E��	�	�	�c��t||���}|j�|��|�|jj��|S)N��loop)r%r:�add�add_done_callback�discard)r;rA�coro�tasks    r<�__call__zTaskFactory.__call__jsF���D�t�$�$�$���	�
�
�d�������t�y�0�1�1�1��r>N)�__name__�
__module__�__qualname__r=rG�r>r<r6r6fs2�������������r>r6c#�K�	dV�dS#t$r;}t�d||��tj|��Yd}~dSd}~wwxYw)z)Log *message* on any error & suppress it.Nzcaught error %r on %s)�	Exception�logger�error�
sentry_sdk�capture_exception)�message�es  r<�log_and_suppress_errorrTqsq����(�
��������(�(�(����,�a��9�9�9��$�Q�'�'�'�'�'�'�'�'�'�����(���s�
�
A�0A
�
A�returnc���tjd��sdStj���d�tj��D��}�fd�|D��}t
�dt|��t|����|D].}t
�d|j|j	|j
���/	tj��}|�
d���}|r�t
�d	t|����|D]j}	t
�d
|j|���|������J#tjtjf$rY�gwxYwdSt
�d��dS#t$$r&}t
�d|��Yd}~dSd}~wwxYw)
z�Log debug information about threads and child processes at shutdown.

    This helps diagnose why the process might hang during shutdown.
    �DEBUGNc�:�g|]}|����|��SrK)�is_alive��.0�ts  r<�
<listcomp>z,_log_shutdown_debug_info.<locals>.<listcomp>�s%��F�F�F�1������F�Q�F�F�Fr>c�.��g|]}|js|�k�|��SrK)�daemon)r[r\�current_threads  �r<r]z,_log_shutdown_debug_info.<locals>.<listcomp>�s4����������56�.�5H�5H��5H�5H�5Hr>z@Shutdown debug: %d threads alive (%d non-daemon, excluding main)z&  Thread: name=%r, daemon=%s, ident=%sT)�	recursivez"Shutdown debug: %d child processesz+  Child process: pid=%d, name=%r, status=%sz"Shutdown debug: no child processesz'Could not enumerate child processes: %s)r�get�	threadingr`�	enumeraterN�info�len�namer_�ident�psutil�Process�children�pid�status�
NoSuchProcess�AccessDeniedrM�warning)�
alive_threads�non_daemon_threadsr\�current_processrk�childrSr`s       @r<�_log_shutdown_debug_inforu{s���

�5��>�>�����-�/�/�N�F�F�	� 3� 5� 5�F�F�F�M����� ������K�K�J��M�����������
�
�����4�
�F�
�H�
�G�		
�	
�	
�	
�E� �.�*�*��"�+�+�d�+�;�;���
	>��K�K�<�c�(�m�m�L�L�L�!�	
�	
����K�K�E��	��
�
��������	������,�f�.A�B�����D�����	
�	
�
�K�K�<�=�=�=�=�=���E�E�E����@�!�D�D�D�D�D�D�D�D�D�����E���sD�>AF�AE�F�E;�8F�:E;�;F�F�
G�&G�Gc	��RK�td��5tj�t	j����ddd��n#1swxYwYt
�dtj����td��5tj
d��4�d{V��dtvrBtj�
��tj����d{V��ddd���d{V��n#1�d{V��swxYwYddd��n#1swxYwYt|d����D]�}td��5tj
d��4�d{V��t
�d	|jj|jj|j��|����d{V��ddd���d{V��n#1�d{V��swxYwYddd��n#1swxYwY��td
��5t
�d��tj
d��4�d{V��|����d{V��ddd���d{V��n#1�d{V��swxYwYddd��n#1swxYwYtd
��5t+j���d{V��ddd��n#1swxYwYtjd��x}�Ctd��5tj|d����d{V��ddd��n#1swxYwYtd��5|���ddd��n#1swxYwYt3��t
�dtj����dS)Nz)marking the start of the shutdown processzshutdown task starting, pid=%szclosing external sources�
�
sensor_serverc��|jSr8)�SHUTDOWN_PRIORITY)�ps r<�<lambda>z _shutdown_task.<locals>.<lambda>�s	��A�4G�r>)�keyzshutting down pluginz$Shutting down %s.%s (priority %d)...zdraining message queuezShutting down TheSink...�zshutting down IAID API�web_server_restart_taskzwaiting for web server restart�<��timeoutz
stopping loopzshutdown task finished, pid=%s)rTr
�sensor�
shutting_down�timerNre�os�getpid�asyncior�rrx�close�wait_closed�sorted�	__class__rIrHrz�shutdownrrb�wait_for�stopr.)rA�the_sink�plugin_list�plugin�restart_tasks     r<�_shutdown_taskr��s�����	� K�	L�	L�1�1��
�#�#�D�I�K�K�0�0�0�1�1�1�1�1�1�1�1�1�1�1����1�1�1�1��K�K�0�"�)�+�+�>�>�>�
 � :�	;�	;�4�4��?�2�&�&�	4�	4�	4�	4�	4�	4�	4�	4��!�#�#���%�%�'�'�'��o�1�1�3�3�3�3�3�3�3�3�3�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�4�4�4�4�4�4�4�4�4�4�4����4�4�4�4���*G�*G�H�H�H�	(�	(��
#�$:�
;�
;�	(�	(���r�*�*�
(�
(�
(�
(�
(�
(�
(�
(����:��$�/��$�-��,�	����o�o�'�'�'�'�'�'�'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(��
 � 8�	9�	9�&�&����.�/�/�/��?�2�&�&�	&�	&�	&�	&�	&�	&�	&�	&��#�#�%�%�%�%�%�%�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&�&�&�&�&�&�&�&�&�&�&�&����&�&�&�&�

 � 8�	9�	9�/�/�#�,�.�.�.�.�.�.�.�.�.�/�/�/�/�/�/�/�/�/�/�/����/�/�/�/���7�8�8�8��E�
#�$D�
E�
E�	=�	=��"�<��<�<�<�<�<�<�<�<�<�<�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=�
 ��	0�	0����	�	�����������������������N�N�N�
�K�K�0�"�)�+�+�>�>�>�>�>s��1A�A�A�D+�0AD�<D+�
D	�D+�D	�D+�+D/�2D/�G4�4AG�G4�
G!�!G4�$G!�%G4�4G8	�;G8	�5J�I1�J�1
I;	�;J�>I;	�?J�J�J�(K�K�K�>L'�'L+�.L+�M"�"M&�)M&c��t�d|��tj��}tj�|��|_d|_tj|_	t��rd|_nd|_tj
j���|_	|���nC#t"$r6t�d��t'jt*��YnwxYwt-j��tj
j���dS)NzRun as daemon [pidfile = %s]FTz*PID file already locked by another process)rNrer_�
DaemonContext�pidfile�PIDLockFile�prevent_corer�
FILE_UMASK�umaskr(�detach_process�defence360agent�	internals�get_fds�files_preserve�openrrO�sys�exitr+�gc�collect�reconfigure)�pidfilepath�dcs  r<�
_daemonizer��s
��
�K�K�.��<�<�<�	�	�	�	�B���+�+�K�8�8�B�J��B�O���B�H����!�!���� ���'�1�8�@�@�B�B�B��)�
���	�	�	�	���)�)�)����A�B�B�B���'�(�(�(�(�(�)�����J�L�L�L���$�0�0�2�2�2�2�2s�1C�=D�Dc��<K�tj���d{V��dS)zPerform update files on start.N)r�!update_all_no_fail_if_files_existrKr>r<�_initial_files_updater��s-����
�
1�
3�
3�3�3�3�3�3�3�3�3�3r>c�j�|�tj|tj����dSr8)�run_until_completer�run_in_executorr�resetr@s r<�_tls_check_resetr��s6������&�t�Y�_�=�=�����r>c� ���fd�|D��S)Nc�4��g|]}t|����|��SrK)�
isinstance)r[r{�pclasss  �r<r]z$plugin_instances.<locals>.<listcomp>s(���5�5�5�!�z�!�V�4�4�5�A�5�5�5r>rK)�objsr�s `r<�plugin_instancesr�s���5�5�5�5�t�5�5�5�5r>c���d�|D��}t|t��}|D]E}t�d|��|�|�|�����Ft
||��}t|t��}|D]F}t�d|��|�|�||�����G|�	��|||fS)Nc�"�g|]}|����
SrKrK)r[�plugin_classs  r<r]z"_start_plugins.<locals>.<listcomp>
s��A�A�A�,�|�|�~�~�A�A�Ar>zCreating sink %rzCreating source %r)
r�rrNrer��create_sinkrr�
create_source�start)rA�plugin_classes�plugins�sinks�sr��sourcess       r<�_start_pluginsr�	s���A�A�.�A�A�A�G�
�W�k�2�2�E�
�5�5�����&��*�*�*�����
�
�d� 3� 3�4�4�4�4��u�d�#�#�H��w�
�6�6�G�
�A�A�����(�!�,�,�,��������h� ?� ?�@�@�@�@��N�N�����U�G�#�#r>r�c���t�d��tjrtt
f}nttf}|D]+}|�|�	||�����,dS)NzStarting RpcServers...)
rNrer�SOCKET_ACTIVATIONr!rr rr��create)rAr��rpc_servers�rpcs    r<�
_start_rpcr�sv��
�K�K�(�)�)�)��"�4�"�$6�7��� �"2�3���<�<������
�
�4�� :� :�;�;�;�;�<�<r>c���	tddgt|��zdditj����}n_#t$r}t|j��}Yd}~n<d}~wt$rt�	d��gcYSt$rgcYSwxYw|����d��}d�|D��}tt|����S)	N�lsofz+wt�PATHz/usr/sbin:/usr/bin)�envz&There is no lsof in /usr/sbin:/usr/bin�
c�0�g|]}|�t|����SrK)�int)r[�lines  r<r]z"_get_pids_open.<locals>.<listcomp>6s#��0�0�0�$�4�0�C��I�I�0�0�0r>)r	�listr��environr�bytes�output�FileNotFoundErrorrNrp�IOError�strip�splitr9)r�outrS�lines�pidss     r<�_get_pids_openr�(s����
�U�O�d�5�k�k�)��-�<���<�
�
�
���������A�H�o�o������������������?�@�@�@��	�	�	������	�	�	������I�I�K�K���e�$�$�E�0�0�%�0�0�0�D���D�	�	�?�?�s �14�
B�A�)B�B�Bc�F�t���r�tj��}|dk�r�tj|�����}t
tjtj	��}g}|D]�}	tj|��}n#tj
$rY�)wxYw|���}|r|���}nd}|�||���dt|��zf����	t|��5}	|	���}
ddd��n#1swxYwYn#t t"f$rd}
YnwxYwt%dt&j�d|�d|�dt|���d|�d	|
�d
�
��t+jt.��t1t2j���r�t6���s9t:�t>��t6� ��nt:�!t>��t+jt.��dStEtF��5t6�$��ddd��dS#1swxYwYdS)Nr�Nonezparent process = %szInstance of z% is already running. Parent process "z" with pid "z". Sockets are in use by z. z file contents z pid)�db_path)%r"r��getppidrirjrgr�r�SOCKET_PATH�NON_ROOT_SOCKET_PATHrn�parent�append�strr��read�OSErrorr��throttled_log_errorr�SVC_NAMEr�r�r+r*rr��_DB_IS_CORRUPTED_FLAG�existsrNrO�_DB_IS_CORRUPTED_MSG�touchrprr��unlink)r��ppidr��pids_used_socket�process_used_socketrl�_pr�
_local_parent�_parent_name�file�written_pids           r<�_check_able_to_startr�:s���|�|�--��z�|�|���1�9�9��^�D�)�)�.�.�0�0�F�-��%�y�'E� � ��#%��'�
�
��� �.��-�-�C�C���+�����H����� #�
�
���
� �*�#0�#5�#5�#7�#7�L�L�#)�L�#�*�*�����
�
�-��L�0A�0A�A������
#��'�]�]�.�d�"&�)�)�+�+�K�.�.�.�.�.�.�.�.�.�.�.����.�.�.�.����W�%�
#�
#�
#�"����
#�������M�M�M��F�F��D�D��+�,�,�,�,��G�G��K�K��

�

�

�
�H�+�,�,�,��u�z�*�*�*�	+�$�+�+�-�-�	1��L�L�-�.�.�.�!�'�'�)�)�)�)��N�N�/�0�0�0���'�(�(�(�(�(�
�'�
(�
(�	+�	+�!�(�(�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�	+�	+sZ�;B�B"�!B"�E
�D>�2E
�>E�E
�E�E
�
E �E �/J�J�Jr�c
��t��s3t�d��tjt
��t
��}tjj�	|j
��|jstj
�d��rHtjj�|jptj
�d����tjt"��t%|j��|jr7t+|j��t-jt,jj��t4j�t;j����t=j��st4j� ��tCj"��}tj#��}|�$tKtMd|r|dznd�������|�'tQ����	tS|��tTj+�,tZj.��t_|��taj1��|�2|����	tfthfD]}|���
n]#tjj6$rK}t�7dtq|����tjt
��Yd}~nd}~wwxYw|�2tsj:����s�t�d	��	|�2tw����nP#trj<$r>}t�7d
|��tjt
��Yd}~nd}~wwxYwtzj>�?t�jA��t�||��\}}}	t�||��t�d��t�jEt�jGd�
��}
t�||jI|
��	t�jK��n2#t�$r%}t�7d|��Yd}~nd}~wwxYwt�|t�t�||||	z����|�P��t�d��t�d��t���d�tCjR|��D��}|r�t�dt�|����|D]}|�T���t�t���5|�2tCjV|d�����ddd��n#1swxYwYt�|dd��}
|
r1t�d��|
�Xdd���t�d��t���t�d��t���|�Z��t�d��dS#t�d��t���d�tCjR|��D��}|r�t�dt�|����|D]}|�T���t�t���5|�2tCjV|d�����ddd��n#1swxYwYt�|dd��}
|
r1t�d��|
�Xdd���t�d��t���t�d��t���|�Z��t�d��wxYw)z�Common function for agent service startup.

    plugin_classes is a list of classes implementing message processing
    plugins. init_actions is a coroutine that will be called prior to starting
    RPC and message processing.z5Imunify agent could be started by the root user only!�IMUNIFY360_LOGGING_CONFIG_FILE� ��)�max_workersz0Failed to stop pending cleanup/patch. Reason: %sNz=Essential files are missing. Performing initial files update.z*Failed to perform initial files update: %szMessage Bus startedF)�version�residentz!Failed to remove unused locks: %szloop stoppedzStarting executor cleanupc�:�g|]}|����|��SrK)�donerZs  r<r]zstart.<locals>.<listcomp>�s%��F�F�F��Q�V�V�X�X�F�1�F�F�Fr>zCancelling %d pending tasksg@r��_default_executorz Shutting down ThreadPoolExecutorT)�wait�cancel_futuresz"Shutting down ProcessPoolExecutorszExecutor cleanup completezEvent loop closed)[r'rNrer�r�r+�	parse_clir�r��setLogLevel�verbose�
log_configr�r�rb�update_logging_config_from_file�setrecursionlimit�_MAX_RECURSION_DEPTHr�r�r_r�r$�notify�
AgentState�
DAEMONIZEDr
r��startingr�r�
is_registered�unregisteredr��get_event_loop�	cpu_count�set_default_executorr�min�set_task_factoryr6r�r�db�initrr��validate_configs_on_startr�update_merged_configr��_stop_pending_cleanup�_stop_pending_patchr�PeeweeExceptionrO�reprr�essential_files_existr��UpdateErrorr�track�set_timeoutr�INACTIVITY_TIMEOUTr�r�r�AgentStartedr�VERSIONr&�process_messager#�remove_unused_locksrM�_setup_signal_handlersrr��run_foreverru�	all_tasksrf�cancelrr�getattrr�r)r�)r��init_actions�argsrA�_cpu�_stop_outdatedrSr�r�r��
agent_started�pendingrF�executors              r<r�r�vsE���>�>�)����K�L�L�L���'�(�(�(��;�;�D���$�0�0���>�>�>���
�"�*�.�.�)I�J�J�
��!�(�H�H��O�O�r�z�~�~�.N�O�O�	
�	
�	
���.�/�/�/����&�&�&��{�H��4�<� � � ��� 0� ;� F�G�G�G�
�M���4�9�;�;�'�'�'��#�%�%�%��
�"�"�$�$�$��!�#�#�D�
�<�>�>�D�	����s�2�4�/F�t�a�x�x�Q�'G�'G�H�H�H����	���+�-�-�(�(�(�\)������������$�$�$�!�$�'�'�'��#�%�%�%��������/�/�/�
	-�#8�:M�"N�
!�
!���� � � � �
!���-�	-�	-�	-�
�L�L�B�D��G�G�
�
�
�
�H�+�,�,�,�,�,�,�,�,�����	-�����&�&�u�'B�'D�'D�E�E�	1��K�K�O�
�
�
�
1��'�'�(=�(?�(?�@�@�@�@���$�
1�
1�
1����I�1�M�M�M���/�0�0�0�0�0�0�0�0�����
1����	��$�$�Y�%A�B�B�B�#1�$��#G�#G� ��%���4��"�"�"����)�*�*�*�!�.��L�5�
�
�
�
�	'��(�*�M�	
�	
�	
�	A��0�2�2�2�2���	A�	A�	A��L�L�<�a�@�@�@�@�@�@�@�@�����	A����	��'�.�$��%�'�/�J�J�	
�	
�	
�	
���������N�#�#�#�	���/�0�0�0� �"�"�"�G�F�g�/��5�5�F�F�F���	L��K�K�5�s�7�|�|�D�D�D��
�
�����
�
�
�
��)�$�$�
L�
L��'�'���W�c�(J�(J�(J�K�K�K�
L�
L�
L�
L�
L�
L�
L�
L�
L�
L�
L����
L�
L�
L�
L��4�!4�d�;�;���	?��K�K�:�;�;�;����5���>�>�>�	���8�9�9�9�� � � �	���/�0�0�0� �"�"�"�	
�
�
�������'�(�(�(�(�(��E	���/�0�0�0� �"�"�"�G�F�g�/��5�5�F�F�F���	L��K�K�5�s�7�|�|�D�D�D��
�
�����
�
�
�
��)�$�$�
L�
L��'�'���W�c�(J�(J�(J�K�K�K�
L�
L�
L�
L�
L�
L�
L�
L�
L�
L�
L����
L�
L�
L�
L��4�!4�d�;�;���	?��K�K�:�;�;�;����5���>�>�>�	���8�9�9�9�� � � �	���/�0�0�0� �"�"�"�	
�
�
�������'�(�(�(�(���s��3A7Z3�+K�Z3�L!�AL�Z3�L!�!AZ3�%!N�Z3�O�4O�
Z3�O�B Z3�5R	�Z3�	
R8�R3�.Z3�3R8�8AZ3�.*W$�$W(�+W(�3Ba�*^�;a�^�a�^�Cac�j�	tj��dS#t$r�}ddlm}tjt|�����}|�||����t�
t|����tj
t��Yd}~dSd}~wwxYw)Nr)�
execute_hooks)rO)r�validate_config_layersrM�defence360agent.hooks.executer6r�AgentMisconfigrr�rNrpr�r�r�r+)rArSr6�agent_misconfigs    r<rr�s���)��/�1�1�1�1�1���)�)�)�?�?�?�?�?�?�#�2��a���A�A�A�����
�
�o� >� >�?�?�?����s�1�v�v������'�(�(�(�(�(�(�(�(�(�����
)���s��
B2�BB-�-B2c����d���fd�}tjtjtjtjfD]}|�||||���dS)NFc����s/d�t�d|��t|����dSt�d|��dS)NTz	Caught %sz9Caught %s. Shutdown task is already running, please wait.)rNrer&)rA�sig�called�shutdowntasks  ��r<�_sighandlerz+_setup_signal_handlers.<locals>._sighandler
s]����		��F��K�K��S�)�)�)�3�D�,�G�G�F�F�F��K�K�K��
�
�
�
�
r>)�signal�SIGINT�SIGTERM�SIGUSR1�SIGUSR2�add_signal_handler)rAr?r@r=r>s `  @r<r)r)sp����
�F��������
�v�~�v�~�v�~�N�=�=������[�$��<�<�<�<�=�=r>c�<�tjd���}|�ddddd���|�d	d
d���|�d
dd���|�dd���|�tjdd���S)NzRun imunify agent)�descriptionz-vr�countrz�Level of logging. Each value corresponds to:1 - console only log level,2 - previous plus add network log,3 - all previous plus add process message log,4 - all previous plus add debug log)�dest�action�default�helpz--daemon�
store_truez
run as daemon)rKrMz	--pidfilez/var/run/imunify360.pidzuse with --daemon)rLrMz--log-configzlogging config filename)rM�)�argparse�ArgumentParser�add_argument�
parse_argsr��argv)�parsers r<rrs���
�
$�1D�
E�
E�
E�F�
����
���
2�
�������
�<�o��N�N�N�
����)�
 �����
����-F��G�G�G����S�X�a�b�b�\�*�*�*r>c��tj���tjtjktjtjj	k��}tj
|tj��dS)zP
    Get back to FOUND all malware hits which have stuck in CLEANUP_STARTED
    N)r2�select�wherermr/�CLEANUP_STARTED�
resource_typer0�FILE�value�
set_status�FOUND��hitss r<rr4sb������$�$���-�=�=�� �$;�$@�$F�F���D���$� 0� 6�7�7�7�7�7r>c��tj���tjtjk��}tj|tj��dS)zZ
    Get back to VULNERABLE all vulnerabilities which have stuck in PATCH_IN_PROGRESS
    N)r3rWrXrmr1�PATCH_IN_PROGRESSr]�
VULNERABLEr_s r<rr?sP���"�$�$�*�*���#9�#K�K���D����&<�&G�H�H�H�H�Hr>)rUN)w�__doc__rPr�r��loggingr�rAr�rcr��concurrent.futuresr�
contextlibrr�	functoolsr�pathlibr�
subprocessrr	�typingr
r_�lockfiler�daemon.pidfileri� defence360agent.internals.loggerr�r�defence360agent.apir
r� defence360agent.contracts.configrrrrr�%defence360agent.contracts.hook_eventsr�!defence360agent.contracts.licenser�!defence360agent.contracts.pluginsrr�&defence360agent.internals.global_scoper�defence360agent.internals.iaidr�"defence360agent.internals.the_sinkr�defence360agent.modelrrr�defence360agent.simple_rpcrrr r!r"�defence360agent.subsysr#r$�defence360agent.utilsr%r&r'r(�"defence360agent.utils.safe_fileopsr)�defence360agent.utils.check_dbr*�defence360agent.utils.clir+�defence360agent.utils.commonr,r-�defence360agent.sentryr.�imav.malwarelib.configr/r0r1�imav.malwarelib.modelr2r3rPrr�r�r��	getLoggerrHrNrOr�r6rTrur�r�r�r�r�r�r�r�r�r�r�rr)rrrrKr>r<�<module>r�s\����*��������	�	�	�	�����	�	�	�	�
�
�
�
�
�
�
�
���������1�1�1�1�1�1�/�/�/�/�/�/�/�/�������������7�7�7�7�7�7�7�7�������
�
�
�
�"�"�"�"�"�"�����
�
�
�
�'�'�'�'�!�!�!�!�!�!�2�2�2�2�2�2�2�2���������������<�;�;�;�;�;�8�8�8�8�8�8�H�H�H�H�H�H�H�H�4�4�4�4�4�4�@�@�@�@�@�@�6�6�6�6�6�6�E�E�E�E�E�E�E�E�E�E���������������F�E�E�E�E�E�E�E�������������F�E�E�E�E�E�:�:�:�:�:�:�<�<�<�<�<�<�8�8�8�8�8�8�8�8�/�/�/�/�/�/�����������
?�>�>�>�>�>�>�>���������.���;�<�<��%��
��	�8�	$�	$��,�j�j��,�,�,�V�\�:�:�����������(�(���(�0E�0E�0E�0E�f+?�+?�+?�\3�3�3�24�4�4�
���6�6�6�$�E�'�4��2E�,F�$�$�$�$�*<�w�<�<�<�<����$9+�9+�9+�xB)�$�B)��B)�B)�B)�B)�J	)�	)�	)�=�=�=�(+�+�+�28�8�8�I�I�I�I�Ir>