JezK
Edit File: generic_sensor.cpython-311.opt-1.pyc
� ��UgD��� �( � d Z ddlZddlZddlZddlZddlZddlmZ ddlZ ddl mZmZ ddl mZ ddlmZ ddlmZ ddlmZ dd lmZ dd lmZmZmZ ddlmZ ddlmZmZ ee � � ee � � cZ!Z" G d � de� � Z# G d� de� � Z$dS )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> Generic Sensor plugin - Creates listening unix domain socket on config.GenericSensor.SOCKET_PATH - Expects alert data formatted as � N)� getLogger)� SimpleRpc�GENERIC_SENSOR_SOCKET_PATH)�MessageType)�Sensor)�UnixSocketAuthProtocol)�g)�getNetworkLogger)�ConnectionLimiter�RpcServerAV�ConnectionGuard)�Scope)� LineBuffer�LineBufferOverflowc � � � e Zd Zej ej ej ej ej ej ej ej d�Zddd�d�Z � fd�Zd� Zd� Zd� Zd � Z� xZS ) �Protocol)�NOOP�MALWARE_SCAN�MALWARE_SCAN_TASK�MALWARE_SCAN_COMPLETE�MALWARE_CLEAN_COMPLETE�MALWARE_RESTORE_COMPLETE�MALWARE_CHECK_DETACHED_SCANS�MALWARE_SEND_FILESN��limiter�read_timeoutc � � || _ || _ t � � | _ d | _ t |||d�� � | _ d S )Nzgeneric sensor)r r �name)�_loop�_sinkr �_line_buffer� transportr �_guard)�self�loop�sinkr r �_s �P/opt/imunify360/venv/lib/python3.11/site-packages/imav/plugins/generic_sensor.py�__init__zProtocol.__init__K sI � ��� ��� �&�L�L������%���%�!� � � ����� c � �� t � � � |� � nY# t t t j f$ r:}t � d|� � |� � � Y d }~d S d }~ww xY w| j dk rBt � d| j | j | j � � |� � � d S | j � |� � s|� � � d S | j � | j | j � � || _ t � d� � d S )Nz@Rejected generic_sensor connection: SO_PEERCRED unavailable (%s)r zJRejected generic_sensor connection from non-root peer uid=%d gid=%d pid=%dzConnection made)�super�connection_made�OSError�AttributeError�struct�error�network_logger�warning�close�_uid�_gid�_pidr$ � try_admit� note_peerr# �debug)r% r# �exc� __class__s �r) r. zProtocol.connection_madeW sE �� � ��G�G�#�#�I�.�.�.�.������6� � � ��"�"�/�� � � � �O�O�����F�F�F�F�F����� ���� �9��>�>��"�"�'�� �� �� � � � � �O�O�����F��{�$�$�Y�/�/� ��O�O�����F�����d�i���3�3�3�"������.�/�/�/�/�/s �!% �A;�/A6�6A;c �� � | j �d S | j � � � |� � � }|� � � st � d|� � d S | j � |� � nl# t $ r_}t � d|� � | j � � � d | _ | j � � � Y d }~d S d }~ww xY w| j D ]s}|rot � d� |� � � � | � |� � }|r+t# j � � |d<