o
    g                     @   s0   d dl mZ d dlmZmZ dd Zdd ZdS )    )defaultdict)is_arn_matchexpand_actionc                 C   s    t | d }d|d |d S )Nr   z{}:{}serviceaction)r   format)	operationdata r
   l/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/parliament/community_auditors/sensitive_access.py_expand_action   s   r   c                 C   s   |   }z	| jd d }W n ty   i }Y nw tt}|D ]}t| d }t|}t| d }|| | qi }|D ]}t|}|	d\}	}
| 
|	|
||< qA|D ] }|| D ]}|| D ]}td||rw| jd||dd qeq_qYd S )NSENSITIVE_ACCESS	resourcesr   :object)resourceactions)location)get_allowed_actionsconfigKeyErrorr   listkeysr   valuesextendsplitget_allowed_resourcesr   add_finding)policyallowed_actionsconfig_resourcessensitive_resourcesitemr   expanded_actionr   action_resourcesr   r   action_resourcesensitive_resourcer
   r
   r   audit   s>   
r'   N)collectionsr   
parliamentr   r   r   r'   r
   r
   r
   r   <module>   s    