Skip to content

Instantly share code, notes, and snippets.

@angstwad
Created March 25, 2020 14:42
Show Gist options
  • Select an option

  • Save angstwad/7d3a7883839ac7f27dee22fd331f5874 to your computer and use it in GitHub Desktop.

Select an option

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
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