🔐 Sid Gifari File Manager Pro
v8.0.5 | 2026-06-15 07:40:14 | PHP 8.1.34
📂
/ (Root)
/
opt
/
imunify360
/
venv
/
lib
/
python3.11
/
site-packages
/
defence360agent
/
hooks
/
__pycache__
📍 /opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/hooks/__pycache__
🔄 Refresh
✏️
Editing: execute.cpython-311.pyc
Read Only
� L��c��v� � � d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl mZ d dlm Z d dlmZ d dlmZmZ e� � Zd� Zd d �Zd d�Zej fd�ZdS )� N)�Core��native)�EventHookLogger)� EventHook)�db)�run� snake_casec � � t j rg S t j � � � t j | k � � }t |� � S )N)r �deferredr �select�where�event�list)r �hookss �R/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/hooks/execute.py� get_hooksr sB � � �{� �� �����$�$�Y�_��%=�>�>�E���;�;�� Fc �X � t j � | � � s"t d� | � � � � �|rBt j | t j � � s"t d� | � � � � �nAt j | t j � � s"t d� | � � � � �t j � | � � } t j |� � }n5# t $ r(}t d� | |� � � � �d}~ww xY w|j t j z r"t d� | � � � � �t j � |� � }|r�|dk r� t j |� � }n5# t $ r(}t d� ||� � � � �d}~ww xY w|j t j z r;|j t j z s)t d � || � � � � �dS dS dS dS ) a' Raise ValueError if path is not a safe hook file. The original check rejected any path under /tmp, /var/tmp, /dev/shm on the grounds that those dirs are world-writable. That blanket- by-prefix rule was too coarse: pytest's tmp_path lives under /tmp/pytest-of-<user>/... and the agent's own integration fixtures legitimately put hook files there. The real threats are (a) an attacker-owned file (DB row points at a path the attacker controls) and (b) a hook whose immediate parent is world-writable so the file can be swapped between this check and the exec. The required permission bit differs between branches: subprocess hooks are exec'd by the kernel (needs X_OK), but native hooks are loaded via importlib's open()+exec_module path which only needs R_OK. A standard Python file in mode 0o644 is loadable but not executable, so requiring +x for native hooks would silently break the typical native-hook deployment (the `hook add-native` RPC has never required or documented an executable bit). z-Hook path does not exist or is not a file: {}zHook path is not readable: {}zHook path is not executable: {}zHook path stat failed: {}: {}NzHook path is world-writable: {}�/zHook parent stat failed: {}: {}z=Hook path has world-writable parent without sticky bit {}: {})�os�path�isfile� ValueError�format�access�R_OK�X_OK�realpath�stat�OSError�st_mode�S_IWOTH�dirname�S_ISVTX)r r �real�st�exc�parent�psts r �_validate_hook_pathr+ s; � �( �7�>�>�$��� ��;�B�B�4�H�H� � � � � M��y��r�w�'�'� K��<�C�C�D�I�I�J�J�J� K� �y��r�w�'�'� M��>�E�E�d�K�K�L�L�L� �7���D�!�!�D�L� �W�T�]�]����� L� L� L��8�?�?��c�J�J�K�K�K�����L���� �z�D�L� � I��:�A�A�$�G�G�H�H�H� �W�_�_�T� "� "�F� � �&�C�-�-� ��'�&�/�/�C�C��� � � ��1�8�8���E�E�� � ����� ���� �K�$�,�&� ���t�|�1K� ��� �&���.�.�� � �� �-�-� � � � s0 �'C<