Skip to content

Commit

Permalink
policy_api: handle non-conforming group ids (e.g., actual group name) (
Browse files Browse the repository at this point in the history
  • Loading branch information
rlxdev authored and buidav committed Feb 13, 2025
1 parent 842dcf9 commit 35be7f0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scubagoggles/policy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,14 @@ def _reduce(self, policies: Iterable):
if 'group' in policy['policyQuery']:
group_id = policy['policyQuery']['group']
group_id = group_id.removeprefix('groups/')
group_name = self._group_id_map[group_id]
# NOTE: the get() handles the case where Google returns
# something that doesn't conform to their documented format
# (i.e., 'groups/<group-id>'). For example, Google will
# return "WORKSPACE_ALL_ADMIN_GROUP" as a value in some
# cases. If the group id value doesn't conform to the
# expected format, the value is kept as received as the
# group name.
group_name = self._group_id_map.get(group_id, group_id)
orgunit_name += f' (group "{group_name}")'

# The setting has two layers in the policies dictionary. Depending
Expand Down

0 comments on commit 35be7f0

Please sign in to comment.