Created
March 25, 2020 14:42
-
-
Save angstwad/7d3a7883839ac7f27dee22fd331f5874 to your computer and use it in GitHub Desktop.
Snippets for Blog: Solving a Set Cover Problem in Cloud IAM on GCP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import collections | |
| roles_to_perms = collections.defaultdict(set) | |
| perms_to_roles = collections.defaultdict(set) | |
| perms_counts = collections.defaultdict(int) | |
| unique_perms = set() | |
| for role_name, role_data in raw_role_data.items(): | |
| for perm in role_data.get('includedPermissions', tuple()): | |
| roles_to_perms[role_name].add(perm) | |
| perms_to_roles[perm].add(role_name) | |
| perms_counts[role_name] += 1 | |
| unique_perms.add(perm) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment