관리-도구
편집 파일: assertrbac.cpython-39.opt-1.pyc
a q�qe� � @ s� d dl Z d dlmZmZ ddlmZ ddlmZ ddlm Z ddl mZ dd lm Z mZ d ZdZdZd ZdZdZG dd� de�ZdS )� N)�List�Union� )�InvalidCheckValue)�AnyRBACRule)� RBACRuleQuery� )� CheckerModule)�ConfigDescriptor�ConfigSetDescriptor�source�target� exempt_source� exempt_target� expect_source� expect_targetc s� e Zd ZdZdZeeeee e ef�Ze d�Ze d�Zedddd�Zedddd�Zedddd�Zedddd�Zdd�� fd d �Zed�dd�Z� ZS ) � AssertRBACz?Checker module for asserting a RBAC allow rule exists (or not).Zassert_rbacZlookup_roleFT)�strict�expandN)�returnc s� t � �|||� t�t�| _|�t�| _|�t �| _ |�t�| _|�t �| _|�t�| _|�t�| _t| j| j f�s|td��| j| j@ }|r�| j�d�d�dd� |D ���� | j| j@ }|r�| j�d�d�dd� |D ���� d S )Nz5At least one of source or target options must be set.z.Overlap in expect_source and exempt_source: {}z, c s s | ]}|j V qd S �N��name��.0�i� r �@/usr/lib64/python3.9/site-packages/setools/checker/assertrbac.py� <genexpr>; � z&AssertRBAC.__init__.<locals>.<genexpr>z.Overlap in expect_target and exempt_target: {}c s s | ]}|j V qd S r r r r r r r @ r )�super�__init__�loggingZ getLogger�__name__�log�get� SOURCE_OPTr � TARGET_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__r r r! ( s, � � �zAssertRBAC.__init__c C s& | j �d� t| j| j| jdd�}t| j�}t| j�}g }t |� � �D ]x}t|j�� �}t|j�� �}||8 }||8 }|| j | j r�|| j | j r�| �t|�� |�|� qF| �t|�� qF|D ]"}d�|�} | �| � |�| � q�|D ]"}d�|�} | �| � |�| � q�| j �d�|�� |S )Nz#Checking RBAC allow rule assertion.)Zallow)r r Zruletypez)Expected rule with source "{}" not found.z)Expected rule with target "{}" not found.z {} failure(s))r$ r- r r1 r r �setr r �sorted�resultsr r r Zlog_fail�str�appendZlog_okr. �debug) r0 �queryZunseen_sourcesZunseen_targetsZfailuresZruleZsrcsZtgts�itemZfailurer r r �runB s<