Skip to content

Commit

Permalink
Incorporate Roy's hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
adhilto committed Feb 14, 2025
1 parent 7ca614b commit 17c9f46
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions scubagoggles/policy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,16 +604,22 @@ def _reduce(self, policies: Iterable):
policies.sort(key = self._sort_order, reverse = True)

for policy in policies:
if 'orgUnit' not in policy['policyQuery']:
log.debug('Org unit data missing for %s, skipping.', policy['setting']['type'])
continue

# For the current policy setting, use the returned org unit id
# to get the org unit name, which is used as the key for the
# result dictionary.
orgunit_id = policy['policyQuery']['orgUnit']
orgunit_id = orgunit_id.removeprefix('orgUnits/')
orgunit_name = self._orgunit_id_map[orgunit_id]['name']

if 'orgUnit' in policy['policyQuery']:
orgunit_id = policy['policyQuery']['orgUnit']
orgunit_id = orgunit_id.removeprefix('orgUnits/')
orgunit_name = self._orgunit_id_map[orgunit_id]['name']
else:
# NOTE: a policy setting should always be associated with
# an org unit. In rare cases, an org unit is not provided,
# and in this case the policy is associated with the top-level
# org unit.
log.debug('Org unit data missing for %s, assuming top-level OU.', policy['setting']['type'])
orgunit_name = self._top_orgunit

if 'group' in policy['policyQuery']:
group_id = policy['policyQuery']['group']
Expand Down

0 comments on commit 17c9f46

Please sign in to comment.