3 �^� � @ s� d dl mZmZ ddlmZ ddlmZ ddlmZm Z ddl mZ ddlm Z dd lmZ ed ddd g�ZG dd� de�ZG dd� de �ZG dd� de �ZdS )� )�defaultdict� namedtuple� )�RBACRuletype� )�DiffResultDescriptor)� Difference�Wrapper)�class_wrapper_factory)�role_wrapper_factory)�type_or_attr_wrapper_factoryZmodified_rbacrule�ruleZ added_defaultZremoved_defaultc @ sh e Zd ZdZed�Zed�Zed�Zed�Zed�Z e e�Ze e�Z dd� Zdd� Zdd � Zd d� ZdS ) �RBACRulesDifferencez<Determine the difference in RBAC rules between two policies.�diff_role_allows�diff_role_transitionsc C sd | j jdj| �� | j s"| j r*| j� | j| j| jtj t �| j| jtj t ��\| _| _}dS )zAGenerate the difference in role allow rules between the policies.zJGenerating role allow differences from {0.left_policy} to {0.right_policy}N) �log�info�format�_left_rbac_rules�_right_rbac_rules�_create_rbac_rule_lists� _set_diff�_expand_generatorr Zallow�RoleAllowWrapper�added_role_allows�removed_role_allows)�self�_� r �!/usr/lib64/python3.6/rbacrules.pyr 3 s z$RBACRulesDifference.diff_role_allowsc C s� | j jdj| �� | j s"| j r*| j� | j| j| jtj t �| j| jtj t ��\}}}g }x:|D ]2\}}t|j�t|j�krf|j t||j|j�� qfW || _|| _|| _dS )zFGenerate the difference in role_transition rules between the policies.zOGenerating role_transition differences from {0.left_policy} to {0.right_policy}N)r r r r r r r r r Zrole_transition�RoleTransitionWrapperr �default�append�modified_rbacrule_record�added_role_transitions�removed_role_transitions�modified_role_transitions)r ZaddedZremovedZmatchedZmodifiedZ left_ruleZ right_ruler r r r A s&