Skip to content

Commit

Permalink
Work-around for Policy API Missing OrgUnit in Settings (0.4.1) release (
Browse files Browse the repository at this point in the history
#605)

* policy_api: default to top-level org unit if not provided with policy setting

* update version number from 0.4.0 to 0.4.1

* policy_api: include log message for no orgunit in policy setting

---------

Co-authored-by: Alden Hilton <adhilto@sandia.gov>
  • Loading branch information
rlxdev and adhilto authored Feb 19, 2025
1 parent f664410 commit 8da61d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</ul>
<ul>
<a href="https://github.com/cisagov/ScubaGoggles/releases">
<img src="https://img.shields.io/badge/ScubaGoggles-v0.4.0-%2385B065?labelColor=%23005288" alt="ScubaGoggles version #"></a>
<img src="https://img.shields.io/badge/ScubaGoggles-v0.4.1-%2385B065?labelColor=%23005288" alt="ScubaGoggles version #"></a>
<a href="https://github.com/cisagov/ScubaGoggles/tree/main/baselines">
<img src="https://img.shields.io/badge/GWS_SCB-v0.4-%2385B065?labelColor=%23005288" alt="GWS SCB version #"></a>
<a href="">
Expand Down
2 changes: 1 addition & 1 deletion scubagoggles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
All other references to the version number are derived from this value.
"""

__version__ = '0.4.0'
__version__ = '0.4.1'
17 changes: 14 additions & 3 deletions scubagoggles/policy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,20 @@ def _reduce(self, policies: Iterable):
# 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 8da61d3

Please sign in to comment.