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: //lib/python3/dist-packages/apparmor/rule/__pycache__/ptrace.cpython-310.pyc
o

%`b��@s�ddlZddlmZmZmZddlmZmZddlm	Z	m
Z
mZmZm
Z
mZddlmZe�Zgd�Zdd�e�d	Zedd
edded
dZe�deddeddd�ZGdd�de	�ZGdd�de
�ZdS)�N)�RE_PROFILE_PTRACE�RE_PROFILE_NAME�strip_quotes)�AppArmorBug�AppArmorException)�BaseRule�BaseRuleset�check_and_split_list�logprof_value_or_all�parse_modifiers�quote_if_needed)�init_translation)	�r�w�rw�wr�read�write�readby�trace�tracedbyz\s*(�|z)\s*z\(�(z(\s|,)+z)*z\)z^(\s+(?P<access>z))?z
(\s+(peer=�peerz\s*$csxeZdZdZGdd�de�ZeZdZ		d�fdd	�	Ze	d
d��Z
e	dd
��Zddd�Zdd�Z
dd�Zdd�Z�ZS)�
PtraceRulez.Class to handle and store a single ptrace rulec@seZdZdS)zPtraceRule.__PtraceAllN)�__name__�
__module__�__qualname__�rr�6/usr/lib/python3/dist-packages/apparmor/rule/ptrace.py�__PtraceAll0sr �ptraceF�Nc	sntt|�j|||||d�t|ttjdd�\|_|_}|r(tt	d�d�
|���|j|dd|d�\|_|_
dS)	N)�audit�deny�
allow_keyword�comment�	log_eventr�accessz/Passed unknown access keyword to PtraceRule: %s� rF)�is_pathr')�superr�__init__r	�access_keywords�ALLr(�
all_accessr�_�join�_aare_or_allr�	all_peers)	�selfr(rr#r$r%r&r'�
unknown_items��	__class__rrr,7s�zPtraceRule.__init__cCs
t�|�S)N)r�search)�cls�raw_rulerrr�_matchEs
zPtraceRule._matchcCs�|�|�}|sttd�|��t|�\}}}}d}|�d�r#|�d�}|rkt�|�}|s4ttd|���|�d�rW|�d�}	|	�d�rN|	�d�rN|	dd	�}	|	�	d
d��
�}	ntj}	|�d�rgt
|�d��}
n
tj}
ntj}	tj}
t|	|
||||d
�S)z$parse raw_rule and return PtraceRulezInvalid ptrace rule '%s'r"�detailsz)Invalid or unknown keywords in 'ptrace %sr(r�)�����,r)r)r#r$r%r&)r;rr0r�group�RE_PTRACE_DETAILSr8�
startswith�endswith�replace�splitrr.r)r9r:�matchesr#r$r%r&�rule_detailsr<r(rrrr�_parseIs2






�zPtraceRule._parsercCs�d|}|jr
d}n"t|j�dkrdd�|j�}n|jr(dd�t|j��}ntd��|jr2d}n|jr>dt|jj	�}ntd	��d
||�
�|||jfS)z)return rule (in clean/default formatting)z  r"r>z %sr)z (%s)zEmpty access in ptrace rulez peer=%szEmpty peer in ptrace rulez%s%sptrace%s%s,%s)r/�lenr(r1�sortedrr3rr�regex�
modifiers_strr&)r4�depth�spacer(rrrr�	get_cleanpszPtraceRule.get_cleancCs@|�|j|j|j|jd�sdS|�|j|j|j|jd�sdSdS)z2check if other_rule is covered by this rule objectr(FrT)�_is_covered_listr(r/�_is_covered_aarerr3)r4�
other_rulerrr�is_covered_localvars�s
zPtraceRule.is_covered_localvarscCsZt|�tkstdt|���|j|jks|j|jkrdS|�|j|j|j|jd�s+dSdS)z,compare if rule-specific variables are equalzPassed non-ptrace rule: %sFrT)	�typerr�strr(r/�_is_equal_aarerr3)r4�rule_obj�strictrrr�is_equal_localvars�szPtraceRule.is_equal_localvarscCs0t|j|j�}t|j|j�}td�|td�|gS)NzAccess mode�Peer)r
r(r/rr3r0)r4r(rrrr�logprof_header_localvars�s
�z#PtraceRule.logprof_header_localvars)FFFr"N)r)rrr�__doc__�object�_PtraceRule__PtraceAllr.�	rule_namer,�classmethodr;rIrPrTrZr\�
__classcell__rrr6rr+s �


&rc@seZdZdZdd�ZdS)�
PtraceRulesetz6Class to handle and store a collection of ptrace rulescCsdS)zeReturn the next possible glob. For ptrace rules, that means removing access or removing/globbing peerzptrace,r)r4�path_or_rulerrr�get_glob�szPtraceRuleset.get_globN)rrrr]rerrrrrc�src)�re�apparmor.regexrrr�apparmor.commonrr�
apparmor.rulerrr	r
rr�apparmor.translationsr
r0r-r1�joint_access_keyword�RE_ACCESS_KEYWORDS�compilerBrrcrrrr�<module>sV ���������������