name : assertte.cpython-39.opt-1.pyc
a

q�qe��@s�ddlZddlmZmZddlmZddlmZddlm	Z	ddl
mZdd	lm
Z
mZmZd
ZdZdZd
ZdZdZdZdZGdd�de�ZdS)�N)�List�Union�)�InvalidCheckValue)�	AnyTERule)�TERuleQuery�)�
CheckerModule)�ConfigDescriptor�ConfigSetDescriptor�ConfigPermissionSetDescriptor�source�target�tclass�perms�
exempt_source�
exempt_target�
expect_source�
expect_targetc	s�eZdZdZdZeeeee	e
eee
f�Zed�Zed�Zedddd�Ze�Zedddd�Zedddd�Zedddd�Zedddd�Zdd	��fd
d�Zed	�dd
�Z�ZS)�AssertTEzKChecker module for asserting a type enforcement allow rule exists (or not).Z	assert_teZlookup_type_or_attrZlookup_classTF)�strict�expandN)�returncst��|||�t�t�|_|�t�|_|�t	�|_
|�t�|_|�t
�|_|�t�|_|�t�|_|�t�|_|�t�|_t|j|j
|j|jf�s�td��|j|j@}|r�|j�d�d�dd�|D����|j|j@}|�r|j�d�d�dd�|D����dS)NzEAt least one of source, target, tclass, or perms options must be set.z.Overlap in expect_source and exempt_source: {}z, css|]}|jVqdS�N��name��.0�i�r�>/usr/lib64/python3.9/site-packages/setools/checker/assertte.py�	<genexpr>A�z$AssertTE.__init__.<locals>.<genexpr>z.Overlap in expect_target and exempt_target: {}css|]}|jVqdSrrrrrr r!Fr")�super�__init__�loggingZ	getLogger�__name__�log�get�
SOURCE_OPTr
�
TARGET_OPTr�	CLASS_OPTr�	PERMS_OPTr�EXEMPT_SRC_OPTr�EXEMPT_TGT_OPTr�EXPECT_SRC_OPTr�EXPECT_TGT_OPTr�anyr�info�format�join)�self�policyZ	checknameZconfigZsource_exempt_expect_overlapZtarget_exempt_expect_overlap��	__class__rr r$,s0�
�
�zAssertTE.__init__c
Cs.|j�d�t|j|j|j|j|jdd�}t|j	�}t|j
�}g}t|���D]x}t|j�
��}t|j�
��}||8}||8}||j	|jr�||j
|jr�|�t|��|�|�qN|�t|��qN|D]"}d�|�}	|�|	�|�|	�q�|D]"}d�|�}	|�|	�|�|	�q�|j�d�|��|S)Nz!Checking TE allow rule assertion.)Zallow)r
rrrZruletypez)Expected rule with source "{}" not found.z)Expected rule with target "{}" not found.z
{} failure(s))r'r2rr6r
rrr�setrr�sorted�resultsrrrZlog_fail�str�appendZlog_okr3�debug)
r5�queryZunseen_sourcesZunseen_targetsZfailuresZruleZsrcsZtgts�itemZfailurerrr �runHs@�

�



zAssertTE.run)r&�
__module__�__qualname__�__doc__Z
check_type�	frozensetr)r*r+r,r-r.r/r0Zcheck_configr
r
rrrrrrrrrr$rrA�
__classcell__rrr7r rs�r)r%�typingrr�	exceptionrZ	policyreprZterulequeryrZ
checkermoduler	Zdescriptorsr
rrr)r*r+r,r-r.r/r0rrrrr �<module>s

© 2025 Cubjrnet7