Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def categories_for_actions(actions):
"""
Given an iterable of actions, return a mapping of action groups.
actions: {'ec2:authorizesecuritygroupingress', 'iam:putrolepolicy', 'iam:listroles'}
Returns:
{
'ec2': {'Write'},
'iam': {'Permissions', 'List'})
}
"""
groups = defaultdict(set)
for action in actions:
service = action.split(":")[0]
groups[service].add(_action_categories.get(action))
return groups