HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //proc/676643/root/lib/python3/dist-packages/apparmor/__pycache__/aare.cpython-310.pyc
o

%`bL�@s<ddlZddlmZmZmZmZGdd�de�Zdd�ZdS)�N)�convert_regexp�type_is_str�AppArmorBug�AppArmorExceptionc@sTeZdZdZddd�Zdd�Zdd�Ze�d	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dS)�AAREz0AARE (AppArmor Regular Expression) wrapper classNcCsT|r|�d�rn|�d�rntd|��|r||_t|�|_nd|_||_d|_dS)z�create an AARE instance for the given AppArmor regex
        If is_path is true, the regex is expected to be a path and therefore must start with / or a variable.�/z@{z)Path doesn't start with / or variable: %sN)�
startswithr�
orig_regex�convert_expression_to_aare�regex�_regex_compiled)�selfr�is_path�	log_event�r�//usr/lib/python3/dist-packages/apparmor/aare.py�__init__s


z
AARE.__init__cCs
d|jS)z,returns a "printable" representation of AAREz
AARE('%s'))r)r
rrr�__repr__-s
z
AARE.__repr__cCs$|jrt|jddd�St|jdd�S)NFT)rr)r)r	rr)r
�memorrr�__deepcopy__1szAARE.__deepcopy__z^[0-9a-zA-Z/._-]+$cCs~t|�tkr|jr
|j}n|j�|j�r|j}n|�|�St|�s)tdt	|���|j
dur7t�t
|j��|_
t|j
�|��S)z@check if the given expression (string or AARE) matches the regexz+AARE.match() called with unknown object: %sN)�typerr	�
plain_path�matchr�is_equalrr�strr�re�compiler�bool�r
�
expressionrrrr<s

z
AARE.matchcCs:t|�tkr|j|jkSt|�r|j|kStdt|���)z&check if the given expression is equalz.AARE.is_equal() called with unknown object: %s)rrrrrrrrrrrOs

z
AARE.is_equalcCs&|jddkrK|jdd�dks|jdd�dkr"t�dd|j�}nlt�d	|j�r2t�d	d|j�}n\t�d
|j�rBt�d
d|j�}nLt�dd|j�}nC|jdd�dks]|jd
d�dkrft�dd|j�}n(t�d|j�rvt�dd|j�}nt�d|j�r�t�dd|j�}nt�dd|j�}t|d�S)z%Glob the given file or directory path���r���Nz/**/���z/*/z/[^/]+/\*{1,2}/$z/[^/]+\*\*[^/]*/$z/\*\*[^/]+/$z/[^/]+/$�/**����/*z/[^/]+/\*{1,2}$z/[^/]*\*\*[^/]+$z/[^/]+\*\*$z/[^/]+$F)rr�sub�searchr)r
�newpathrrr�	glob_pathYs $$
zAARE.glob_pathcCs�t�d|j�}|rt�dd|��d|j�}nTt�d|j�r5t�d|j�}t�dd|��d|j�}n7t�d|j�rRt�d|j�}t�dd|��d|j�}n|j}t�d	|j�}|rlt�d
d|��d|j�}t|d�S)
zhGlob given file path with extension
           Files without extensions and directories won't be changedz/\*{1,2}(\.[^/]+)$z/[^/]+/\*{1,2}\.[^/]+$r#rz/[^/]+\*\*[^/]*\.[^/]+$z/[^/]+\*\*[^/]*(\.[^/]+)$z/\*\*[^/]+\.[^/]+$z/\*\*[^/]+(\.[^/]+)$z
(\.[^/]+)$z/[^/]+(\.[^/]+)$r%F)rr'rr&�groupsr)r
rr(rrr�glob_path_withextus
zAARE.glob_path_withext)N)�__name__�
__module__�__qualname__�__doc__rrrrrrrrr)r+rrrrrs

	
rcCs&gd�}|D]
}|�|d|�}q|S)z>convert an expression (taken from audit.log) to an AARE string)	�\�?�*�[�]�{�}�"�!r0)�replace)r�aare_escape_chars�charrrrr
�sr
)	r�apparmor.commonrrrr�objectrr
rrrr�<module>sz